Rev 2500: Add more dirstate root-id-changing tests in file:///home/mbp/bzr/Work/dirstate/
Martin Pool
mbp at sourcefrog.net
Sat Mar 3 02:21:27 GMT 2007
------------------------------------------------------------
revno: 2500
revision-id: mbp at sourcefrog.net-20070303022125-m66a0pccahokfj2k
parent: mbp at sourcefrog.net-20070303014729-27moafq7ozd00101
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: dirstate
timestamp: Sat 2007-03-03 13:21:25 +1100
message:
Add more dirstate root-id-changing tests
modified:
bzrlib/tests/test_dirstate.py test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
bzrlib/tests/test_workingtree_4.py test_workingtree_4.p-20070223025758-531n3tznl3zacv2o-1
=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py 2007-03-02 02:11:59 +0000
+++ b/bzrlib/tests/test_dirstate.py 2007-03-03 02:21:25 +0000
@@ -454,6 +454,7 @@
('a', '', 0, False, ''),
]),
]
+ state._validate()
self.assertEqual(expected_rows, list(state._iter_entries()))
# should work across save too
state.save()
@@ -463,9 +464,19 @@
state = dirstate.DirState.on_file('dirstate')
state.lock_read()
try:
+ state._validate()
self.assertEqual(expected_rows, list(state._iter_entries()))
finally:
state.unlock()
+ # now change within an existing file-backed state
+ state.lock_write()
+ try:
+ state._validate()
+ state.set_path_id('', 'tree-root-2')
+ state._validate()
+ finally:
+ state.unlock()
+
def test_set_parent_trees_no_content(self):
# set_parent_trees is a slow but important api to support.
=== modified file 'bzrlib/tests/test_workingtree_4.py'
--- a/bzrlib/tests/test_workingtree_4.py 2007-03-01 19:58:38 +0000
+++ b/bzrlib/tests/test_workingtree_4.py 2007-03-03 02:21:25 +0000
@@ -434,3 +434,23 @@
self.assertEqual('b', tree.id2path('b-id'))
self.assertEqual(None, tree.id2path('c-id'))
+ def test_set_root_id(self):
+ # similar to some code that fails in the dirstate-plus-subtree branch
+ # -- setting the root id while adding a parent seems to scramble the
+ # dirstate invariants. -- mbp 20070303
+ def validate():
+ wt.lock_read()
+ try:
+ wt.current_dirstate()._validate()
+ finally:
+ wt.unlock()
+ wt = self.make_workingtree('tree')
+ wt.set_root_id('TREE-ROOTID')
+ validate()
+ wt.commit('somenthing')
+ validate()
+ # now switch and commit again
+ wt.set_root_id('tree-rootid')
+ validate()
+ wt.commit('again')
+ validate()
More information about the bazaar-commits
mailing list