Rev 3239: no parent branch causes an error on push --shallow. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

Robert Collins robertc at robertcollins.net
Tue Feb 26 13:03:50 GMT 2008


At http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

------------------------------------------------------------
revno: 3239
revision-id:robertc at robertcollins.net-20080226130346-g3doxza12x4l3z0h
parent: robertc at robertcollins.net-20080226034339-splbn4dr2gq00ilb
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.reference
timestamp: Wed 2008-02-27 00:03:46 +1100
message:
  no parent branch causes an error on push --shallow.
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-02-26 01:58:59 +0000
+++ b/bzrlib/builtins.py	2008-02-26 13:03:46 +0000
@@ -722,8 +722,14 @@
         if reference is not None:
             reference = urlutils.normalize_url(reference)
         if shallow:
-            parent = Branch.open(br_from.get_parent())
-            reference = parent.get_public_branch()
+            reference = None
+            parent_url = br_from.get_parent()
+            if parent_url:
+                parent = Branch.open(parent_url)
+                reference = parent.get_public_branch()
+            if not reference:
+                raise errors.BzrCommandError(
+                    "Could not determine branch to refer to.")
         # where to push logic:
         stored_loc = br_from.get_push_location()
         if location is None:

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2008-02-26 03:43:39 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2008-02-26 13:03:46 +0000
@@ -284,7 +284,7 @@
             trunk_tree.branch.base)
 
     def test_push_new_branch_shallow_uses_parent_public(self):
-        """Pushing a new branch with --reference creates a stacked branch."""
+        """Pushing a new branch with --shallow creates a stacked branch."""
         trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
         # the trunk is published on a web server
         self.transport_readonly_server = HttpServer
@@ -301,6 +301,17 @@
             trunk_public_url, err)
         self.assertPublished(branch_tree.last_revision(), trunk_public_url)
 
+    def test_push_new_branch_shallow_no_parent(self):
+        """Pushing with --shallow and no parent branch errors."""
+        branch = self.make_branch_and_tree('branch', format='development')
+        # now we do a shallow push, which should fail as the place to refer too
+        # cannot be determined.
+        out, err = self.run_bzr_error(
+            ['Could not determine branch to refer to\\.'], ['push', '--shallow',
+            self.get_url('published')], working_dir='branch')
+        self.assertEqual('', out)
+        self.assertFalse(self.get_transport('published').has('.'))
+
 
 class RedirectingMemoryTransport(MemoryTransport):
 



More information about the bazaar-commits mailing list