Rev 2418: Some comments on merge code, fix merge tests that in http://bazaar.launchpad.net/%7Ebzr/bzr/dirstate

John Arbash Meinel john at arbash-meinel.com
Mon Feb 26 17:10:44 GMT 2007


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

------------------------------------------------------------
revno: 2418
revision-id: john at arbash-meinel.com-20070226170938-ik5w1cd0a1tuzsgq
parent: john at arbash-meinel.com-20070226165924-sqwmymf6drv66yjg
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate
timestamp: Mon 2007-02-26 11:09:38 -0600
message:
  Some comments on merge code, fix merge tests that
  assume basis_tree() is valid after the tree has been modified.
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/merge.py                merge.py-20050513021216-953b65a438527106
  bzrlib/tests/test_merge.py     testmerge.py-20050905070950-c1b5aa49ff911024
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2007-02-26 02:11:26 +0000
+++ b/bzrlib/builtins.py	2007-02-26 17:09:38 +0000
@@ -3234,6 +3234,14 @@
                                      " type %s." % merge_type)
     if reprocess and show_base:
         raise errors.BzrCommandError("Cannot do conflict reduction and show base.")
+    # TODO: jam 20070226 We should really lock these trees earlier. However, we
+    #       only want to take out a lock_tree_write() if we don't have to pull
+    #       any ancestry. But merge might fetch ancestry in the middle, in
+    #       which case we would need a lock_write().
+    #       Because we cannot upgrade locks, for now we live with the fact that
+    #       the tree will be locked multiple times during a merge. (Maybe
+    #       read-only some of the time, but it means things will get read
+    #       multiple times.)
     try:
         merger = _mod_merge.Merger(this_tree.branch, this_tree=this_tree,
                                    pb=pb, change_reporter=change_reporter)

=== modified file 'bzrlib/merge.py'
--- a/bzrlib/merge.py	2007-02-26 16:59:24 +0000
+++ b/bzrlib/merge.py	2007-02-26 17:09:38 +0000
@@ -170,6 +170,10 @@
         interesting_ids = set()
         for path in file_list:
             found_id = False
+            # TODO: jam 20070226 The trees are not locked at this time,
+            #       wouldn't it make merge faster if it locks everything in the
+            #       beginning? It locks at do_merge time, but this happens
+            #       before that.
             for tree in (self.this_tree, self.base_tree, self.other_tree):
                 file_id = tree.path2id(path)
                 if file_id is not None:

=== modified file 'bzrlib/tests/test_merge.py'
--- a/bzrlib/tests/test_merge.py	2007-02-07 16:05:09 +0000
+++ b/bzrlib/tests/test_merge.py	2007-02-26 17:09:38 +0000
@@ -159,7 +159,10 @@
         self.build_tree(['a/b/'])
         tree_a.add('b', 'b-id')
         tree_a.commit('added b')
-        base_tree = tree_a.basis_tree()
+        # basis_tree() is only guaranteed to be valid as long as it is actually
+        # the basis tree. This mutates the tree after grabbing basis, so go to
+        # the repository.
+        base_tree = tree_a.branch.repository.revision_tree(tree_a.last_revision())
         tree_z = tree_a.bzrdir.sprout('z').open_workingtree()
         self.build_tree(['a/b/c'])
         tree_a.add('b/c')
@@ -183,7 +186,10 @@
         self.build_tree_contents([('tree_a/file', 'content_1')])
         tree_a.add('file')
         tree_a.commit('commit base')
-        base_tree = tree_a.basis_tree()
+        # basis_tree() is only guaranteed to be valid as long as it is actually
+        # the basis tree. This mutates the tree after grabbing basis, so go to
+        # the repository.
+        base_tree = tree_a.branch.repository.revision_tree(tree_a.last_revision())
         tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
         self.build_tree_contents([('tree_a/file', 'content_2')])
         tree_a.commit('commit other')



More information about the bazaar-commits mailing list