Rev 3594: Give a more specific error when target branch unreachable (James in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jul 30 06:06:18 BST 2008


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

------------------------------------------------------------
revno: 3594
revision-id:pqm at pqm.ubuntu.com-20080730050605-5hhtw13vhgailydn
parent: pqm at pqm.ubuntu.com-20080730012945-o1jetsqxklmxzgt2
parent: ian.clatworthy at canonical.com-20080730043459-fpeor9jlisylif0b
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-07-30 06:06:05 +0100
message:
  Give a more specific error when target branch unreachable (James
  	Westby)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
  bzrlib/merge_directive.py      merge_directive.py-20070228184838-ja62280spt1g7f4x-1
  bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
  bzrlib/tests/test_merge_directive.py test_merge_directive-20070228184838-ja62280spt1g7f4x-2
    ------------------------------------------------------------
    revno: 3592.1.1
    revision-id:ian.clatworthy at canonical.com-20080730043459-fpeor9jlisylif0b
    parent: pqm at pqm.ubuntu.com-20080730010050-yt2pf2kmm4x4c033
    parent: jw+debian at jameswestby.net-20080729211726-g3a8uy9qkiy91euo
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: ianc-integration
    timestamp: Wed 2008-07-30 14:34:59 +1000
    message:
      Give a more specific error when target branch unreachable (James Westby)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/merge_directive.py      merge_directive.py-20070228184838-ja62280spt1g7f4x-1
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
      bzrlib/tests/test_merge_directive.py test_merge_directive-20070228184838-ja62280spt1g7f4x-2
    ------------------------------------------------------------
    revno: 3535.8.4
    revision-id:jw+debian at jameswestby.net-20080729211726-g3a8uy9qkiy91euo
    parent: jw+debian at jameswestby.net-20080729102323-6uokwxf7utu8pz4f
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: bzr.dev.send
    timestamp: Tue 2008-07-29 22:17:26 +0100
    message:
      Replace "however" with "and" at John's request.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
    ------------------------------------------------------------
    revno: 3535.8.3
    revision-id:jw+debian at jameswestby.net-20080729102323-6uokwxf7utu8pz4f
    parent: jw+debian at jameswestby.net-20080728124059-rjc33cmq3f5og0v6
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: bzr.dev.send
    timestamp: Tue 2008-07-29 11:23:23 +0100
    message:
      Use location instead of branch as suggested by Robert.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
    ------------------------------------------------------------
    revno: 3535.8.2
    revision-id:jw+debian at jameswestby.net-20080728124059-rjc33cmq3f5og0v6
    parent: jw+debian at jameswestby.net-20080712005242-evds1umvhyshu7er
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: bzr.dev.send
    timestamp: Mon 2008-07-28 13:40:59 +0100
    message:
      Incorporate spiv's feedback.
    modified:
      bzrlib/tests/test_errors.py    test_errors.py-20060210110251-41aba2deddf936a8
      bzrlib/tests/test_merge_directive.py test_merge_directive-20070228184838-ja62280spt1g7f4x-2
    ------------------------------------------------------------
    revno: 3535.8.1
    revision-id:jw+debian at jameswestby.net-20080712005242-evds1umvhyshu7er
    parent: pqm at pqm.ubuntu.com-20080709135859-wq3r1d1fjcafelgw
    committer: James Westby <jw+debian at jameswestby.net>
    branch nick: bzr.dev.send
    timestamp: Sat 2008-07-12 01:52:42 +0100
    message:
      Handle something that isn't a branch being specified in target_branch.
      
      It's possible to create a merge directive where the target_branch isn't
      a branch by the time that it gets to be merged, either because it uses
      a local path not on the system where it is being merged, or the branch
      has been deleted.
      
      If this is the case and the target_branch needs to be consulted to
      retrieve missing revisions then a NotBranchError was raised, which
      was quite confusing. This provides a more precise error in that case.
    modified:
      bzrlib/errors.py               errors.py-20050309040759-20512168c4e14fbd
      bzrlib/merge_directive.py      merge_directive.py-20070228184838-ja62280spt1g7f4x-1
      bzrlib/tests/test_merge_directive.py test_merge_directive-20070228184838-ja62280spt1g7f4x-2
=== modified file 'NEWS'
--- a/NEWS	2008-07-30 00:26:38 +0000
+++ b/NEWS	2008-07-30 04:34:59 +0000
@@ -23,6 +23,9 @@
     * ``bzr check`` can now be told which elements at a location it should
       check.  (Daniel Watkins)
 
+    * Give a more specific error when target branch is not reachable.
+      (James Westby)
+
     * Implemented a custom ``walkdirs_utf8`` implementation for win32.
       This uses a pyrex extension to get direct access to the
       ``FindFirstFileW`` style apis, rather than using ``listdir`` +

=== modified file 'bzrlib/errors.py'
--- a/bzrlib/errors.py	2008-07-29 17:03:43 +0000
+++ b/bzrlib/errors.py	2008-07-30 04:34:59 +0000
@@ -2385,6 +2385,19 @@
         self.patch_type = patch_type
 
 
+class TargetNotBranch(BzrError):
+    """A merge directive's target branch is required, but isn't a branch"""
+
+    _fmt = ("Your branch does not have all of the revisions required in "
+            "order to merge this merge directive and the target "
+            "location specified in the merge directive is not a branch: "
+            "%(location)s.")
+
+    def __init__(self, location):
+        BzrError.__init__(self)
+        self.location = location
+
+
 class UnsupportedInventoryKind(BzrError):
     
     _fmt = """Unsupported entry kind %(kind)s"""

=== modified file 'bzrlib/merge_directive.py'
--- a/bzrlib/merge_directive.py	2008-05-23 10:39:44 +0000
+++ b/bzrlib/merge_directive.py	2008-07-12 00:52:42 +0000
@@ -210,7 +210,11 @@
                 except errors.RevisionNotPresent:
                     # At least one dependency isn't present.  Try installing
                     # missing revisions from the submit branch
-                    submit_branch = _mod_branch.Branch.open(self.target_branch)
+                    try:
+                        submit_branch = \
+                            _mod_branch.Branch.open(self.target_branch)
+                    except errors.NotBranchError:
+                        raise errors.TargetNotBranch(self.target_branch)
                     missing_revisions = []
                     bundle_revisions = set(r.revision_id for r in
                                            info.real_revisions)

=== modified file 'bzrlib/tests/test_errors.py'
--- a/bzrlib/tests/test_errors.py	2008-07-29 17:03:43 +0000
+++ b/bzrlib/tests/test_errors.py	2008-07-30 04:34:59 +0000
@@ -384,6 +384,15 @@
             host='ahost', port=444, msg='Unable to connect to ssh host',
             orig_error='my_error')
 
+    def test_target_not_branch(self):
+        """Test the formatting of TargetNotBranch."""
+        error = errors.TargetNotBranch('foo')
+        self.assertEqual(
+            "Your branch does not have all of the revisions required in "
+            "order to merge this merge directive and the target "
+            "location specified in the merge directive is not a branch: "
+            "foo.", str(error))
+
     def test_malformed_bug_identifier(self):
         """Test the formatting of MalformedBugIdentifier."""
         error = errors.MalformedBugIdentifier('bogus', 'reason for bogosity')

=== modified file 'bzrlib/tests/test_merge_directive.py'
--- a/bzrlib/tests/test_merge_directive.py	2008-05-23 10:39:44 +0000
+++ b/bzrlib/tests/test_merge_directive.py	2008-07-28 12:40:59 +0000
@@ -576,6 +576,17 @@
             branch_c.base, base_revision_id='rev2a')
         revision = md.install_revisions(tree_b.branch.repository)
 
+    def test_handle_target_not_a_branch(self):
+        tree_a, tree_b, branch_c = self.make_trees()
+        branch_c.pull(tree_a.branch)
+        self.build_tree_contents([('tree_a/file', 'content_q\ncontent_r\n')])
+        tree_a.commit('rev3a', rev_id='rev3a')
+        md = self.from_objects(tree_a.branch.repository, 'rev3a', 500, 36,
+            branch_c.base, base_revision_id='rev2a')
+        md.target_branch = self.get_url('not-a-branch')
+        self.assertRaises(errors.TargetNotBranch, md.install_revisions,
+                tree_b.branch.repository)
+
 
 class TestMergeDirective1Branch(tests.TestCaseWithTransport,
     TestMergeDirectiveBranch):




More information about the bazaar-commits mailing list