Rev 2420: Make set_root_id() a no-op if the id doesn't change, in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

John Arbash Meinel john at arbash-meinel.com
Mon Feb 26 21:18:24 GMT 2007


At http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

------------------------------------------------------------
revno: 2420
revision-id: john at arbash-meinel.com-20070226211703-hqcam97hrxohk5jc
parent: john at arbash-meinel.com-20070226191858-04chtw4qy4a1p3tz
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Mon 2007-02-26 15:17:03 -0600
message:
  Make set_root_id() a no-op if the id doesn't change,
  and change the test_merge_core tests to flush the state to disk, since
  they are hanging onto a write lock.
modified:
  bzrlib/dirstate.py             dirstate.py-20060728012006-d6mvoihjb3je9peu-1
  bzrlib/tests/test_merge_core.py test_merge_core.py-20050824132511-eb99b23a0eec641b
-------------- next part --------------
=== modified file 'bzrlib/dirstate.py'
--- a/bzrlib/dirstate.py	2007-02-26 19:18:58 +0000
+++ b/bzrlib/dirstate.py	2007-02-26 21:17:03 +0000
@@ -1530,6 +1530,9 @@
             raise NotImplementedError(self.set_path_id)
         # TODO: check new id is unique
         entry = self._get_entry(0, path_utf8=path)
+        if entry[0][2] == new_id:
+            # Nothing to change.
+            return
         # mark the old path absent, and insert a new root path
         self._make_absent(entry)
         self.update_minimal(('', '', new_id), 'd',

=== modified file 'bzrlib/tests/test_merge_core.py'
--- a/bzrlib/tests/test_merge_core.py	2007-01-28 18:19:32 +0000
+++ b/bzrlib/tests/test_merge_core.py	2007-02-26 21:17:03 +0000
@@ -49,6 +49,7 @@
            # the tests perform pulls, so need a branch that is writeable.
            wt.lock_write()
            wt.set_root_id(self.tree_root)
+           wt.flush()
            tt = TreeTransform(wt)
            return wt, tt
         self.base, self.base_tt = wt('base')
@@ -77,8 +78,12 @@
             # why does this not do wt.pull() ?
             wt.branch.pull(self.base.branch)
             wt.set_parent_ids([wt.branch.last_revision()])
+            wt.flush()
+            # We maintain a write lock, so make sure changes are flushed to
+            # disk first
             tt.apply()
             wt.commit('branch commit')
+            wt.flush()
             assert len(wt.branch.revision_history()) == 2
         self.this.branch.fetch(self.other.branch)
         other_basis = self.other.branch.basis_tree()



More information about the bazaar-commits mailing list