1
# Copyright (C) 2005 by Canonical Ltd
1
# Copyright (C) 2005, 2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
200
201
self.assertIsInstance(inventory.make_entry("directory", "name", ROOT_ID),
201
202
inventory.InventoryDirectory)
204
def test_make_entry_non_normalized(self):
205
orig_normalized_filename = osutils.normalized_filename
208
osutils.normalized_filename = osutils._accessible_normalized_filename
209
entry = inventory.make_entry("file", u'a\u030a', ROOT_ID)
210
self.assertEqual(u'\xe5', entry.name)
211
self.assertIsInstance(entry, inventory.InventoryFile)
213
osutils.normalized_filename = osutils._inaccessible_normalized_filename
214
self.assertRaises(errors.InvalidNormalization,
215
inventory.make_entry, 'file', u'a\u030a', ROOT_ID)
217
osutils.normalized_filename = orig_normalized_filename
203
220
class TestEntryDiffing(TestCaseWithTransport):
516
533
self.assertEqual(expected_change, change)
519
class TestExecutable(TestCaseWithTransport):
521
def test_stays_executable(self):
522
a_id = "a-20051208024829-849e76f7968d7a86"
523
b_id = "b-20051208024829-849e76f7968d7a86"
524
wt = self.make_branch_and_tree('b1')
526
tt = TreeTransform(wt)
527
tt.new_file('a', tt.root, 'a test\n', a_id, True)
528
tt.new_file('b', tt.root, 'b test\n', b_id, False)
531
self.failUnless(wt.is_executable(a_id), "'a' lost the execute bit")
533
# reopen the tree and ensure it stuck.
534
wt = wt.bzrdir.open_workingtree()
535
self.assertEqual(['a', 'b'], [cn for cn,ie in wt.inventory.iter_entries()])
537
self.failUnless(wt.is_executable(a_id), "'a' lost the execute bit")
538
self.failIf(wt.is_executable(b_id), "'b' gained an execute bit")
540
wt.commit('adding a,b', rev_id='r1')
542
rev_tree = b.repository.revision_tree('r1')
543
self.failUnless(rev_tree.is_executable(a_id), "'a' lost the execute bit")
544
self.failIf(rev_tree.is_executable(b_id), "'b' gained an execute bit")
546
self.failUnless(rev_tree.inventory[a_id].executable)
547
self.failIf(rev_tree.inventory[b_id].executable)
549
# Make sure the entries are gone
552
self.failIf(wt.has_id(a_id))
553
self.failIf(wt.has_filename('a'))
554
self.failIf(wt.has_id(b_id))
555
self.failIf(wt.has_filename('b'))
557
# Make sure that revert is able to bring them back,
558
# and sets 'a' back to being executable
560
wt.revert(['a', 'b'], rev_tree, backups=False)
561
self.assertEqual(['a', 'b'], [cn for cn,ie in wt.inventory.iter_entries()])
563
self.failUnless(wt.is_executable(a_id), "'a' lost the execute bit")
564
self.failIf(wt.is_executable(b_id), "'b' gained an execute bit")
566
# Now remove them again, and make sure that after a
567
# commit, they are still marked correctly
570
wt.commit('removed', rev_id='r2')
572
self.assertEqual([], [cn for cn,ie in wt.inventory.iter_entries()])
573
self.failIf(wt.has_id(a_id))
574
self.failIf(wt.has_filename('a'))
575
self.failIf(wt.has_id(b_id))
576
self.failIf(wt.has_filename('b'))
578
# Now revert back to the previous commit
579
wt.revert([], rev_tree, backups=False)
580
self.assertEqual(['a', 'b'], [cn for cn,ie in wt.inventory.iter_entries()])
582
self.failUnless(wt.is_executable(a_id), "'a' lost the execute bit")
583
self.failIf(wt.is_executable(b_id), "'b' gained an execute bit")
585
# Now make sure that 'bzr branch' also preserves the
587
# TODO: Maybe this should be a blackbox test
588
d2 = b.bzrdir.clone('b2', revision_id='r1')
589
t2 = d2.open_workingtree()
591
self.assertEquals('r1', b2.last_revision())
593
self.assertEqual(['a', 'b'], [cn for cn,ie in t2.inventory.iter_entries()])
594
self.failUnless(t2.is_executable(a_id), "'a' lost the execute bit")
595
self.failIf(t2.is_executable(b_id), "'b' gained an execute bit")
597
# Make sure pull will delete the files
599
self.assertEquals('r2', b2.last_revision())
600
self.assertEqual([], [cn for cn,ie in t2.inventory.iter_entries()])
602
# Now commit the changes on the first branch
603
# so that the second branch can pull the changes
604
# and make sure that the executable bit has been copied
605
wt.commit('resurrected', rev_id='r3')
608
self.assertEquals('r3', b2.last_revision())
609
self.assertEqual(['a', 'b'], [cn for cn,ie in t2.inventory.iter_entries()])
611
self.failUnless(t2.is_executable(a_id), "'a' lost the execute bit")
612
self.failIf(t2.is_executable(b_id), "'b' gained an execute bit")
615
536
class TestRevert(TestCaseWithTransport):
617
538
def test_dangling_id(self):