Rev 3241: no public location causes the parent to be used directly with push --shallow. in http://people.ubuntu.com/~robertc/baz2.0/shallow-branch

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


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

------------------------------------------------------------
revno: 3241
revision-id:robertc at robertcollins.net-20080226131333-4a11d181p3ly91ug
parent: robertc at robertcollins.net-20080226130956-im328z4m7jdwod57
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.reference
timestamp: Wed 2008-02-27 00:13:33 +1100
message:
  no public location causes the parent to be used directly with 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 13:03:46 +0000
+++ b/bzrlib/builtins.py	2008-02-26 13:13:33 +0000
@@ -727,6 +727,12 @@
             if parent_url:
                 parent = Branch.open(parent_url)
                 reference = parent.get_public_branch()
+                if not reference:
+                    # I considered excluding non-http url's here, thus forcing
+                    # 'public' branches only, but that only works for some
+                    # users, so its best to just depend on the user spotting an
+                    # error by the feedback given to them. RBC 20080227.
+                    reference = parent_url
             if not reference:
                 raise errors.BzrCommandError(
                     "Could not determine branch to refer to.")

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2008-02-26 13:09:56 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2008-02-26 13:13:33 +0000
@@ -283,6 +283,18 @@
         self.assertPublished(branch_tree.last_revision(),
             trunk_tree.branch.base)
 
+    def test_push_new_branch_shallow_uses_parent_when_no_public_url(self):
+        """When the parent has no public url the parent is used as-is."""
+        trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
+        # now we do a shallow push, which should determine the public location
+        # for us.
+        out, err = self.run_bzr(['push', '--shallow',
+            self.get_url('published')], working_dir='branch')
+        self.assertEqual('', out)
+        self.assertEqual('Created new shallow branch referring to %s.\n' %
+            trunk_tree.branch.base, err)
+        self.assertPublished(branch_tree.last_revision(), trunk_public_url)
+
     def test_push_new_branch_shallow_uses_parent_public(self):
         """Pushing a new branch with --shallow creates a stacked branch."""
         trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
@@ -312,17 +324,6 @@
         self.assertEqual('', out)
         self.assertFalse(self.get_transport('published').has('.'))
 
-    def test_push_new_branch_shallow_no_public_location(self):
-        """Pushing with --shallow and the parent having no public url errors."""
-        trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
-        # 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