Rev 3100: Fix bug #175337, bzr bind shouldn't check the ancestry in http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/bind_no_ancestry_175337

John Arbash Meinel john at arbash-meinel.com
Mon Dec 10 19:21:08 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.93-dev/bind_no_ancestry_175337

------------------------------------------------------------
revno: 3100
revision-id:john at arbash-meinel.com-20071210192041-p9ukten4vt7vg8lz
parent: pqm at pqm.ubuntu.com-20071210120611-a3j02d26cbzvlyju
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: bind_no_ancestry_175337
timestamp: Mon 2007-12-10 13:20:41 -0600
message:
  Fix bug #175337, bzr bind shouldn't check the ancestry
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/tests/blackbox/test_bound_branches.py test_bound_branches.py-20051109215527-2373188ad566c205
  bzrlib/tests/branch_implementations/test_branch.py testbranch.py-20050711070244-121d632bc37d7253
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-12-07 05:46:51 +0000
+++ b/bzrlib/branch.py	2007-12-10 19:20:41 +0000
@@ -1794,22 +1794,6 @@
         # last_rev is not in the other_last_rev history, AND
         # other_last_rev is not in our history, and do it without pulling
         # history around
-        last_rev = _mod_revision.ensure_null(self.last_revision())
-        if last_rev != _mod_revision.NULL_REVISION:
-            other.lock_read()
-            try:
-                other_last_rev = other.last_revision()
-                if not _mod_revision.is_null(other_last_rev):
-                    # neither branch is new, we have to do some work to
-                    # ascertain diversion.
-                    remote_graph = other.repository.get_revision_graph(
-                        other_last_rev)
-                    local_graph = self.repository.get_revision_graph(last_rev)
-                    if (last_rev not in remote_graph and
-                        other_last_rev not in local_graph):
-                        raise errors.DivergedBranches(self, other)
-            finally:
-                other.unlock()
         self.set_bound_location(other.base)
 
     @needs_write_lock

=== modified file 'bzrlib/tests/blackbox/test_bound_branches.py'
--- a/bzrlib/tests/blackbox/test_bound_branches.py	2007-08-03 12:50:48 +0000
+++ b/bzrlib/tests/blackbox/test_bound_branches.py	2007-12-10 19:20:41 +0000
@@ -198,8 +198,6 @@
         child_tree.commit(message='child')
         self.check_revno(2)
 
-        self.run_bzr('bind', retcode=3)
-
     def test_commit_remote_bound(self):
         # It is not possible to commit to a branch
         # which is bound to a branch which is bound
@@ -247,12 +245,11 @@
         self.check_revno(2, 'base')
 
         os.chdir('child')
-        # These branches have diverged
-        self.run_bzr('bind ../base', retcode=3)
+        # These branches have diverged, but bind should succeed anyway
+        self.run_bzr('bind ../base')
 
-        # TODO: In the future, this might require actual changes
-        # to have occurred, rather than just a new revision entry
-        child_tree.merge_from_branch(base_branch)
+        # This should turn the local commit into a merge
+        child_tree.update()
         child_tree.commit(message='merged')
         self.check_revno(3)
 
@@ -261,16 +258,6 @@
         base_history = base_branch.revision_history()
         child_history = child_branch.revision_history()
 
-        # After a merge, trying to bind again should succeed
-        # keeping the new change as a local commit.
-        self.run_bzr('bind ../base')
-        self.check_revno(3)
-        self.check_revno(2, '../base')
-
-        # and compare the revision history now
-        self.assertEqual(base_history, base_branch.revision_history())
-        self.assertEqual(child_history, child_branch.revision_history())
-
     def test_bind_parent_ahead(self):
         base_tree = self.create_branches()[0]
 
@@ -322,6 +309,14 @@
         self.run_bzr('bind ../base')
         self.check_revno(1, '../base')
 
+    def test_bind_fail_if_missing(self):
+        """We should not be able to bind to a missing branch."""
+        tree = self.make_branch_and_tree('tree_1')
+        tree.commit('dummy commit')
+        self.run_bzr_error(['Not a branch.*no-such-branch/'], ['bind', '../no-such-branch'],
+                            working_dir='tree_1')
+        self.assertIs(None, tree.branch.get_bound_location())
+
     def test_commit_after_merge(self):
         base_tree, child_tree = self.create_branches()
 

=== modified file 'bzrlib/tests/branch_implementations/test_branch.py'
--- a/bzrlib/tests/branch_implementations/test_branch.py	2007-12-07 05:46:51 +0000
+++ b/bzrlib/tests/branch_implementations/test_branch.py	2007-12-10 19:20:41 +0000
@@ -28,6 +28,7 @@
     transactions,
     remote,
     repository,
+    tests,
     )
 from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
 from bzrlib.delta import TreeDelta
@@ -638,7 +639,7 @@
         try:
             branch.bind(branch2)
         except errors.UpgradeRequired:
-            raise TestSkipped('Format does not support binding')
+            raise tests.TestNotApplicable('Format does not support binding')
         self.assertTrue(branch.unbind())
         self.assertFalse(branch.unbind())
         self.assertIs(None, branch.get_bound_location())
@@ -648,13 +649,25 @@
         try:
             self.assertIs(None, branch.get_old_bound_location())
         except errors.UpgradeRequired:
-            raise TestSkipped('Format does not store old bound locations')
+            raise tests.TestNotApplicable(
+                    'Format does not store old bound locations')
         branch2 = self.make_branch('branch2')
         branch.bind(branch2)
         self.assertIs(None, branch.get_old_bound_location())
         branch.unbind()
         self.assertContainsRe(branch.get_old_bound_location(), '\/branch2\/$')
 
+    def test_bind_diverged(self):
+        tree_a = self.make_branch_and_tree('tree_a')
+        tree_a.commit('rev1a')
+        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
+        tree_a.commit('rev2a')
+        tree_b.commit('rev2b')
+        try:
+            tree_b.branch.bind(tree_a.branch)
+        except errors.UpgradeRequired:
+            raise tests.TestNotApplicable('Format does not support binding')
+
 
 class TestStrict(TestCaseWithBranch):
 



More information about the bazaar-commits mailing list