Rev 2474: Add a test for setting the root id in a dirstate with parent trees in http://sourcefrog.net/bzr/dirstate-robert
Martin Pool
mbp at sourcefrog.net
Thu Mar 1 08:34:12 GMT 2007
At http://sourcefrog.net/bzr/dirstate-robert
------------------------------------------------------------
revno: 2474
revision-id: mbp at sourcefrog.net-20070301083325-e87nhnnpx3i18nea
parent: robertc at robertcollins.net-20070301080114-dt6xpp7v0envbati
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: dirstate-robert
timestamp: Thu 2007-03-01 19:33:25 +1100
message:
Add a test for setting the root id in a dirstate with parent trees
modified:
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2007-02-27 21:32:16 +0000
+++ b/bzrlib/tests/test_dirstate.py 2007-03-01 08:33:25 +0000
@@ -424,6 +424,41 @@
finally:
state.unlock()
+ def test_set_path_id_with_parents(self):
+ """Set the root file id in a dirstate with parents"""
+ mt = self.make_branch_and_tree('mt')
+ # may need to set the root when the default format is one where it's
+ # not TREE_ROOT
+ mt.commit('foo', rev_id='parent-revid')
+ rt = mt.branch.repository.revision_tree('parent-revid')
+ state = dirstate.DirState.initialize('dirstate')
+ try:
+ state.set_parent_trees([('parent-revid', rt)], ghosts=[])
+ state.set_path_id('', 'foobarbaz')
+ # now see that it is what we expected
+ expected_rows = [
+ (('', '', 'TREE_ROOT'),
+ [('a', '', 0, False, ''),
+ ('d', '', 0, False, 'parent-revid'),
+ ]),
+ (('', '', 'foobarbaz'),
+ [('d', '', 0, False, ''),
+ ('a', '', 0, False, ''),
+ ]),
+ ]
+ self.assertEqual(expected_rows, list(state._iter_entries()))
+ # should work across save too
+ state.save()
+ finally:
+ state.unlock()
+ # now flush & check we get the same
+ state = dirstate.DirState.on_file('dirstate')
+ state.lock_read()
+ try:
+ self.assertEqual(expected_rows, list(state._iter_entries()))
+ finally:
+ state.unlock()
+
def test_set_parent_trees_no_content(self):
# set_parent_trees is a slow but important api to support.
tree1 = self.make_branch_and_memory_tree('tree1')
More information about the bazaar-commits
mailing list