Rev 5004: (nmb) Better error message for bzr bind on and already bound branch in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Feb 4 10:14:17 GMT 2010


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5004 [merge]
revision-id: pqm at pqm.ubuntu.com-20100204101415-x0kx6871ji6rcp6s
parent: pqm at pqm.ubuntu.com-20100203163347-hd3o9r24qbgofg7s
parent: v.ladeuil+lp at free.fr-20100204094150-x33ump3qf7eafx1o
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2010-02-04 10:14:15 +0000
message:
  (nmb) Better error message for bzr bind on and already bound branch
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_bound_branches.py test_bound_branches.py-20051109215527-2373188ad566c205
=== modified file 'NEWS'
--- a/NEWS	2010-02-03 16:33:47 +0000
+++ b/NEWS	2010-02-04 09:41:50 +0000
@@ -49,6 +49,9 @@
 * Fix ``log`` to better check ancestors even if merged revisions are involved.
   (Vincent Ladeuil, #476293)
 
+* Give a better error message when doing ``bzr bind`` in an already bound
+  branch.  (Neil Martinsen-Burrell, #513063)
+
 * Set the mtime of files exported to a directory by ``bzr export`` all to
   the same value to avoid confusing ``make`` and other date-based build
   systems. (Robert Collins, #515631)

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-02-02 23:13:02 +0000
+++ b/bzrlib/builtins.py	2010-02-04 09:41:50 +0000
@@ -4619,8 +4619,11 @@
                     'This format does not remember old locations.')
             else:
                 if location is None:
-                    raise errors.BzrCommandError('No location supplied and no '
-                        'previous location known')
+                    if b.get_bound_location() is not None:
+                        raise errors.BzrCommandError('Branch is already bound')
+                    else:
+                        raise errors.BzrCommandError('No location supplied '
+                            'and no previous location known')
         b_other = Branch.open(location)
         try:
             b.bind(b_other)

=== modified file 'bzrlib/tests/blackbox/test_bound_branches.py'
--- a/bzrlib/tests/blackbox/test_bound_branches.py	2009-09-17 11:54:41 +0000
+++ b/bzrlib/tests/blackbox/test_bound_branches.py	2010-02-04 09:37:08 +0000
@@ -22,17 +22,18 @@
 
 from bzrlib import (
     bzrdir,
-    errors
+    errors,
+    tests,
     )
 from bzrlib.branch import Branch
 from bzrlib.bzrdir import (BzrDir, BzrDirFormat, BzrDirMetaFormat1)
 from bzrlib.osutils import getcwd
-from bzrlib.tests import TestCaseWithTransport
+from bzrlib.tests import script
 import bzrlib.urlutils as urlutils
 from bzrlib.workingtree import WorkingTree
 
 
-class TestLegacyFormats(TestCaseWithTransport):
+class TestLegacyFormats(tests.TestCaseWithTransport):
 
     def setUp(self):
         super(TestLegacyFormats, self).setUp()
@@ -61,7 +62,7 @@
                          'upgrade your branch at %s/.\n' % cwd, err)
 
 
-class TestBoundBranches(TestCaseWithTransport):
+class TestBoundBranches(tests.TestCaseWithTransport):
 
     def create_branches(self):
         base_tree = self.make_branch_and_tree('base')
@@ -420,3 +421,24 @@
         # both the local and master should have been updated.
         self.check_revno(4)
         self.check_revno(4, '../base')
+
+
+class TestBind(script.TestCaseWithTransportAndScript):
+
+    def test_bind_when_bound(self):
+        self.run_script("""
+$ bzr init trunk
+$ bzr init copy
+$ cd copy
+$ bzr bind ../trunk
+$ bzr bind
+2>bzr: ERROR: Branch is already bound
+""")
+
+    def test_bind_before_bound(self):
+        self.run_script("""
+$ bzr init trunk
+$ cd trunk
+$ bzr bind
+2>bzr: ERROR: No location supplied and no previous location known
+""")




More information about the bazaar-commits mailing list