[MERGE] branch --stacked support

Martin Pool mbp at canonical.com
Wed Jul 2 05:59:39 BST 2008


Martin Pool has voted tweak.
Status is now: Conditionally approved
Comment:
-            note('Branched %d revision(s).' % branch.revno())
+            # If the source branch is stacked, the new branch may
+            # be stacked whether we asked for that explicitly or not.
+            # We therefore need a try/except here and not just 'if 
stacked:'
+            try:
+                note('Created new stacked branch referring to %s.' %
+                    branch.get_stacked_on())
+            except (errors.NotStacked, errors.UnstackableBranchFormat,
+                errors.UnstackableRepositoryFormat), e:
+                note('Branched %d revision(s).' % branch.revno())

(comment) I think it would be nice to show the 'Branched' message and 
the
new revno regardless of whether it is stacked or not, but it's not true
that we copied them so we might need a different phrasing.  It can wait.

=== modified file 'bzrlib/remote.py'
--- bzrlib/remote.py    2008-06-25 04:49:30 +0000
+++ bzrlib/remote.py    2008-06-25 05:04:14 +0000
@@ -181,6 +181,8 @@
              format.supports_tree_reference = (response[3] == 'yes')
              # No wire format to check this yet.
              format.supports_external_lookups = (response[4] == 'yes')
+            # Used to support creating a real format instance when 
needed.
+            format._creating_bzrdir = self
              return RemoteRepository(self, format)
          else:
              raise errors.NoRepositoryPresent(self)
@@ -239,7 +241,10 @@

      def initialize(self, a_bzrdir, shared=False):
          if not isinstance(a_bzrdir, RemoteBzrDir):
-            raise AssertionError('%r is not a RemoteBzrDir' % 
(a_bzrdir,))
+            prior_repo = self._creating_bzrdir.open_repository()
+            prior_repo._ensure_real()
+            return prior_repo._real_repository._format.initialize(
+                a_bzrdir, shared=shared)
          return a_bzrdir.create_repository(shared=shared)

      def open(self, a_bzrdir):

Putting a reference to a bzrdir instance into the repository format 
object
seems very odd.  Isn't the format meant to be that format in general, 
not
the particular instance?

Perhaps this means that the api should really be
bzrdir.create_repository(format) and unless it's like that there's no
clean alternative?

+    def assertShallow(self, branch_revid, stacked_on):
+        """Assert that the branch 'newbranch' has been published 
correctly."""

The docstring is a bit generic for what this actually asserts.  You 
could
add the text from the comments.

+        trunk = self.make_branch('mainline', format='development')

It may be unnecessary but I'd add an assertion that the branch you're
trying to test is actually on an hpss url.

--
Martin


For details, see: 
http://bundlebuggy.aaronbentley.com/request/%3C1214373717.1536.62.camel%40lifeless-64%3E



More information about the bazaar mailing list