24
24
import bzrlib.inventory as inventory
25
25
from bzrlib.osutils import has_symlinks, rename, pathjoin
26
26
from bzrlib.tests import TestCase, TestCaseWithTransport
27
from bzrlib.uncommit import uncommit
29
30
class TestInventory(TestCase):
339
340
self.wt.add(['file'], ['fileid'])
340
341
self.wt.commit('add file', rev_id='B')
341
342
self.inv_B = self.branch.repository.get_inventory('B')
342
self.branch.lock_write()
344
self.branch.control_files.put_utf8('revision-history', 'A\n')
343
uncommit(self.branch, tree=self.wt)
347
344
self.assertEqual(self.branch.revision_history(), ['A'])
348
345
self.wt.commit('another add of file', rev_id='C')
349
346
self.inv_C = self.branch.repository.get_inventory('C')
391
388
class TestExecutable(TestCaseWithTransport):
393
390
def test_stays_executable(self):
394
basic_inv = """<inventory format="5">
395
<file file_id="a-20051208024829-849e76f7968d7a86" name="a" executable="yes" />
396
<file file_id="b-20051208024829-849e76f7968d7a86" name="b" />
391
a_id = "a-20051208024829-849e76f7968d7a86"
392
b_id = "b-20051208024829-849e76f7968d7a86"
399
393
wt = self.make_branch_and_tree('b1')
401
395
open('b1/a', 'wb').write('a test\n')
402
396
open('b1/b', 'wb').write('b test\n')
403
397
os.chmod('b1/a', 0755)
404
398
os.chmod('b1/b', 0644)
405
# Manually writing the inventory, to ensure that
406
# the executable="yes" entry is set for 'a' and not for 'b'
407
open('b1/.bzr/inventory', 'wb').write(basic_inv)
399
wt.add(['a', 'b'], [a_id, b_id])
400
wt.inventory[a_id].executable = True
401
self.failUnless(wt.is_executable(a_id), "'a' lost the execute bit")
409
a_id = "a-20051208024829-849e76f7968d7a86"
410
b_id = "b-20051208024829-849e76f7968d7a86"
403
# reopen the tree and ensure it stuck.
411
404
wt = wt.bzrdir.open_workingtree()
412
405
self.assertEqual(['a', 'b'], [cn for cn,ie in wt.inventory.iter_entries()])