Rev 3661: Stacking policy doesn't force format upgrade on branch (abentley) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Aug 28 23:05:08 BST 2008


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

------------------------------------------------------------
revno: 3661
revision-id: pqm at pqm.ubuntu.com-20080828220458-9l8imklutrsvcw5t
parent: pqm at pqm.ubuntu.com-20080828212328-q4mx5qgvrokx06c0
parent: aaron at aaronbentley.com-20080828213220-m0cmqwofh9g9cmv7
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-08-28 23:04:58 +0100
message:
  Stacking policy doesn't force format upgrade on branch (abentley)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.14
    revision-id: aaron at aaronbentley.com-20080828213220-m0cmqwofh9g9cmv7
    parent: aaron at aaronbentley.com-20080828212449-myg1t02s4zrlnj5l
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 17:32:20 -0400
    message:
      Update NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3650.3.13
    revision-id: aaron at aaronbentley.com-20080828212449-myg1t02s4zrlnj5l
    parent: aaron at aaronbentley.com-20080828163339-3zdi0ewhixwpwoqn
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 17:24:49 -0400
    message:
      Make cloning_metadir handle stacking requirements
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.12
    revision-id: aaron at aaronbentley.com-20080828163339-3zdi0ewhixwpwoqn
    parent: aaron at aaronbentley.com-20080828162941-x6m5o49fkg8sb2ez
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 12:33:39 -0400
    message:
      Update NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3650.3.11
    revision-id: aaron at aaronbentley.com-20080828162941-x6m5o49fkg8sb2ez
    parent: aaron at aaronbentley.com-20080828162037-u9hrcv4yubm7tdmi
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 12:29:41 -0400
    message:
      Update docs
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3650.3.10
    revision-id: aaron at aaronbentley.com-20080828162037-u9hrcv4yubm7tdmi
    parent: aaron at aaronbentley.com-20080828154643-avn3r5tzy8xc5qb0
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 12:20:37 -0400
    message:
      Ensure that sprout chooses a rich-root format as needed
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.9
    revision-id: aaron at aaronbentley.com-20080828154643-avn3r5tzy8xc5qb0
    parent: aaron at aaronbentley.com-20080828144243-mvaldxu6im406gm2
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 11:46:43 -0400
    message:
      Move responsibility for stackable repo format to _get_metadir
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.8
    revision-id: aaron at aaronbentley.com-20080828144243-mvaldxu6im406gm2
    parent: aaron at aaronbentley.com-20080828142447-5rdjc02r4ajze56f
    parent: aaron at aaronbentley.com-20080828144110-l4gw1l23ypqtp07q
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 10:42:43 -0400
    message:
      merge with test-kipple
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
      bzrlib/chunk_writer.py         chunk_writer.py-20080630234519-6ggn4id17nipovny-1
      bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
      bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
      bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
      bzrlib/tests/test_chunk_writer.py test_chunk_writer.py-20080630234519-6ggn4id17nipovny-2
      bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
      bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
        ------------------------------------------------------------
        revno: 3650.4.2
        revision-id: aaron at aaronbentley.com-20080828144110-l4gw1l23ypqtp07q
        parent: aaron at aaronbentley.com-20080827212252-c00jxh0p8apelzkb
        parent: aaron at aaronbentley.com-20080828144044-ezvrt8jbrgop1rdl
        committer: Aaron Bentley <aaron at aaronbentley.com>
        branch nick: test-kipple
        timestamp: Thu 2008-08-28 10:41:10 -0400
        message:
          Merge with sprout
        modified:
          NEWS                           NEWS-20050323055033-4e00b5db738777ff
          bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
          bzrlib/chunk_writer.py         chunk_writer.py-20080630234519-6ggn4id17nipovny-1
          bzrlib/log.py                  log.py-20050505065812-c40ce11702fe5fb1
          bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
          bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
          bzrlib/tests/test_chunk_writer.py test_chunk_writer.py-20080630234519-6ggn4id17nipovny-2
          bzrlib/tests/test_log.py       testlog.py-20050728115707-1a514809d7d49309
          bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
    ------------------------------------------------------------
    revno: 3650.3.7
    revision-id: aaron at aaronbentley.com-20080828142447-5rdjc02r4ajze56f
    parent: aaron at aaronbentley.com-20080827213332-4b1eo8ckkzmbz5uf
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Thu 2008-08-28 10:24:47 -0400
    message:
      Fix test
    modified:
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.6
    revision-id: aaron at aaronbentley.com-20080827213332-4b1eo8ckkzmbz5uf
    parent: aaron at aaronbentley.com-20080827204103-kjuwhyg2h74ktj79
    parent: aaron at aaronbentley.com-20080827212252-c00jxh0p8apelzkb
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Wed 2008-08-27 17:33:32 -0400
    message:
      Merge from test-kipple
    modified:
      bzrlib/_patiencediff_c.c       _patiencediff_c.c-20070721205602-q3imkipwlgagp3cy-1
      bzrlib/tests/test_diff.py      testdiff.py-20050727164403-d1a3496ebb12e339
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
        ------------------------------------------------------------
        revno: 3650.4.1
        revision-id: aaron at aaronbentley.com-20080827212252-c00jxh0p8apelzkb
        parent: aaron at aaronbentley.com-20080827204807-f2rn8vrv57uisl1b
        committer: Aaron Bentley <aaron at aaronbentley.com>
        branch nick: test-kipple
        timestamp: Wed 2008-08-27 17:22:52 -0400
        message:
          Fix test kipple in test_break_lock_breaks_physical_lock
        modified:
          bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
    ------------------------------------------------------------
    revno: 3650.3.5
    revision-id: aaron at aaronbentley.com-20080827204103-kjuwhyg2h74ktj79
    parent: aaron at aaronbentley.com-20080827190258-0ge5u00jwusd6q5i
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Wed 2008-08-27 16:41:03 -0400
    message:
      Fix parent location when copying content
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.4
    revision-id: aaron at aaronbentley.com-20080827190258-0ge5u00jwusd6q5i
    parent: aaron at aaronbentley.com-20080827182450-csvsugy94mgz6glu
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Wed 2008-08-27 15:02:58 -0400
    message:
      Update test to permit calling copy_content_into
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
    ------------------------------------------------------------
    revno: 3650.3.3
    revision-id: aaron at aaronbentley.com-20080827182450-csvsugy94mgz6glu
    parent: aaron at aaronbentley.com-20080826210605-9ie943xkqs2itq5e
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Wed 2008-08-27 14:24:50 -0400
    message:
      fix sprout
    modified:
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3650.3.2
    revision-id: aaron at aaronbentley.com-20080826210605-9ie943xkqs2itq5e
    parent: aaron at aaronbentley.com-20080826210526-vp6i7h6eeurh0gpt
    parent: aaron at aaronbentley.com-20080826205846-k4oo0yvjs2ki76fe
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Tue 2008-08-26 17:06:05 -0400
    message:
      Merge from sprout
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
    ------------------------------------------------------------
    revno: 3650.3.1
    revision-id: aaron at aaronbentley.com-20080826210526-vp6i7h6eeurh0gpt
    parent: aaron at aaronbentley.com-20080826203846-qqja1nmhybdpzizy
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: stacking-policy
    timestamp: Tue 2008-08-26 17:05:26 -0400
    message:
      Ensure stacking policy does not cause format upgrades
    modified:
      bzrlib/bzrdir.py               bzrdir.py-20060131065624-156dfea39c4387cb
      bzrlib/tests/test_bzrdir.py    test_bzrdir.py-20060131065654-deba40eef51cf220
=== modified file 'NEWS'
--- a/NEWS	2008-08-28 16:46:17 +0000
+++ b/NEWS	2008-08-28 22:04:58 +0000
@@ -23,6 +23,9 @@
 
   IMPROVEMENTS:
 
+    * ``bzr branch`` uses the default stacking policy if the branch format
+      supports it. (Aaron Bentley)
+
     * ``bzr init`` and ``bzr init-repo`` will now print out the same as
       ``bzr info`` if it completed successfully.
       (Marius Kruger)
@@ -73,6 +76,9 @@
     * The deprecated ``Branch.abspath`` and unimplemented 
       ``Branch.rename_one`` and ``Branch.move`` were removed. (Jelmer Vernooij)
 
+    * BzrDir.cloning_metadir implementations must now take a require_stacking
+      parameter.  (Aaron Bentley)
+
   TESTING:
 
     * ``addCleanup`` now takes ``*arguments`` and ``**keyword_arguments``

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2008-08-26 20:38:46 +0000
+++ b/bzrlib/branch.py	2008-08-27 18:24:50 +0000
@@ -705,7 +705,8 @@
         """
         if revision_id == _mod_revision.NULL_REVISION:
             new_history = []
-        new_history = self.revision_history()
+        else:
+            new_history = self.revision_history()
         if revision_id is not None and new_history != []:
             try:
                 new_history = new_history[:new_history.index(revision_id) + 1]

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2008-08-28 20:30:29 +0000
+++ b/bzrlib/bzrdir.py	2008-08-28 22:04:58 +0000
@@ -1017,15 +1017,17 @@
             result_format.workingtree_format = tree._format.__class__()
         return result_format, source_repository
 
-    def cloning_metadir(self):
+    def cloning_metadir(self, require_stacking=False):
         """Produce a metadir suitable for cloning or sprouting with.
 
         These operations may produce workingtrees (yes, even though they're
         "cloning" something that doesn't have a tree), so a viable workingtree
         format must be selected.
 
+        :require_stacking: If True, non-stackable formats will be upgraded
+            to similar stackable formats.
         :returns: a BzrDirFormat with all component formats either set
-            appropriately or set to None if that component should not be 
+            appropriately or set to None if that component should not be
             created.
         """
         format, repository = self._cloning_metadir()
@@ -1034,6 +1036,20 @@
                 return format
             tree_format = repository._format._matchingbzrdir.workingtree_format
             format.workingtree_format = tree_format.__class__()
+        if (require_stacking and not
+            format.get_branch_format().supports_stacking()):
+            # We need to make a stacked branch, but the default format for the
+            # target doesn't support stacking.  So force a branch that *can*
+            # support stacking.
+            from bzrlib.branch import BzrBranchFormat7
+            format._branch_format = BzrBranchFormat7()
+            mutter("using %r for stacking" % (format._branch_format,))
+            from bzrlib.repofmt import pack_repo
+            if format.repository_format.rich_root_data:
+                repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
+            else:
+                repo_format = pack_repo.RepositoryFormatKnitPack5()
+            format.repository_format = repo_format
         return format
 
     def checkout_metadir(self):
@@ -1065,7 +1081,8 @@
         """
         target_transport = get_transport(url, possible_transports)
         target_transport.ensure_base()
-        cloning_format = self.cloning_metadir()
+        cloning_format = self.cloning_metadir(stacked)
+        # Create/update the result branch
         result = cloning_format.initialize_on_transport(target_transport)
         try:
             source_branch = self.open_branch()
@@ -1087,39 +1104,27 @@
             force_new_repo, stacked_branch_url, require_stacking=stacked)
         result_repo = repository_policy.acquire_repository()
         if source_repository is not None:
-            # XXX: Isn't this redundant with the copy_content_into used below
-            # after creating the branch? -- mbp 20080724
+            # Fetch while stacked to prevent unstacked fetch from
+            # Branch.sprout.
             result_repo.fetch(source_repository, revision_id=revision_id)
 
-        # Create/update the result branch
-        format_forced = False
-        if ((stacked 
-             or repository_policy._require_stacking 
-             or repository_policy._stack_on)
-            and not result._format.get_branch_format().supports_stacking()):
-            # We need to make a stacked branch, but the default format for the
-            # target doesn't support stacking.  So force a branch that *can*
-            # support stacking. 
-            from bzrlib.branch import BzrBranchFormat7
-            format = BzrBranchFormat7()
-            result_branch = format.initialize(result)
-            mutter("using %r for stacking" % (format,))
-            format_forced = True
-        elif source_branch is None:
+        if source_branch is None:
             # this is for sprouting a bzrdir without a branch; is that
             # actually useful?
+            # Not especially, but it's part of the contract.
             result_branch = result.create_branch()
         else:
+            # Force NULL revision to avoid using repository before stacking
+            # is configured.
             result_branch = source_branch.sprout(
-                result, revision_id=revision_id)
+                result, revision_id=_mod_revision.NULL_REVISION)
+            parent_location = result_branch.get_parent()
         mutter("created new branch %r" % (result_branch,))
         repository_policy.configure_branch(result_branch)
-        if source_branch is not None and format_forced:
-            # XXX: this duplicates Branch.sprout(); it probably belongs on an
-            # InterBranch method? -- mbp 20080724
-            source_branch.copy_content_into(result_branch,
-                 revision_id=revision_id)
-            result_branch.set_parent(self.root_transport.base)
+        if source_branch is not None:
+            source_branch.copy_content_into(result_branch, revision_id)
+            # Override copy_content_into
+            result_branch.set_parent(parent_location)
 
         # Create/update the result working tree
         if isinstance(target_transport, LocalTransport) and (
@@ -1178,8 +1183,10 @@
         """Pre-splitout bzrdirs do not suffer from stale locks."""
         raise NotImplementedError(self.break_lock)
 
-    def cloning_metadir(self):
+    def cloning_metadir(self, require_stacking=False):
         """Produce a metadir suitable for cloning with."""
+        if require_stacking:
+            return format_registry.make_bzrdir('1.6')
         return self._format.__class__()
 
     def clone(self, url, revision_id=None, force_new_repo=False,
@@ -2905,29 +2912,7 @@
 
         Creates the desired repository in the bzrdir we already have.
         """
-        if self._stack_on or self._require_stacking:
-            # we may be coming from a format that doesn't support stacking,
-            # but we require it in the destination, so force creation of a new
-            # one here.
-            #
-            # TODO: perhaps this should be treated as a distinct repository
-            # acquisition policy?
-            repository_format = self._bzrdir._format.repository_format
-            if not repository_format.supports_external_lookups:
-                # should possibly be controlled by the registry rather than
-                # hardcoded here.
-                from bzrlib.repofmt import pack_repo
-                if repository_format.rich_root_data:
-                    repository_format = \
-                        pack_repo.RepositoryFormatKnitPack5RichRoot()
-                else:
-                    repository_format = pack_repo.RepositoryFormatKnitPack5()
-                note("using %r for stacking" % (repository_format,))
-            repository = repository_format.initialize(self._bzrdir,
-                shared=shared)
-        else:
-            # let bzrdir choose
-            repository = self._bzrdir.create_repository(shared=shared)
+        repository = self._bzrdir.create_repository(shared=shared)
         self._add_fallback(repository)
         if make_working_trees is not None:
             repository.set_make_working_trees(make_working_trees)

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-08-14 20:15:21 +0000
+++ b/bzrlib/remote.py	2008-08-28 21:24:49 +0000
@@ -88,9 +88,9 @@
             self._real_bzrdir = BzrDir.open_from_transport(
                 self.root_transport, _server_formats=False)
 
-    def cloning_metadir(self):
+    def cloning_metadir(self, stacked=False):
         self._ensure_real()
-        return self._real_bzrdir.cloning_metadir()
+        return self._real_bzrdir.cloning_metadir(stacked)
 
     def _translate_error(self, err, **context):
         _translate_error(err, bzrdir=self, **context)

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2008-08-20 16:14:09 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2008-08-28 21:24:49 +0000
@@ -1,5 +1,5 @@
 # Copyright (C) 2005, 2006, 2007 Canonical Ltd
-# 
+#
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
@@ -442,9 +442,9 @@
         self.assertEqual(parent_bzrdir.root_transport.base,
                          repo_policy._stack_on_pwd)
 
-    def prepare_default_stacking(self):
+    def prepare_default_stacking(self, child_format='development1'):
         parent_bzrdir = self.make_bzrdir('.')
-        child_branch = self.make_branch('child', format='development1')
+        child_branch = self.make_branch('child', format=child_format)
         parent_bzrdir.get_config().set_default_stack_on(child_branch.base)
         new_child_transport = parent_bzrdir.transport.clone('child2')
         return child_branch, new_child_transport
@@ -461,6 +461,47 @@
         self.assertEqual(child_branch.base,
                          new_child.open_branch().get_stacked_on_url())
 
+    def test_clone_ignores_policy_for_unsupported_formats(self):
+        child_branch, new_child_transport = self.prepare_default_stacking(
+            child_format='pack-0.92')
+        new_child = child_branch.bzrdir.clone_on_transport(new_child_transport)
+        self.assertRaises(errors.UnstackableBranchFormat,
+                          new_child.open_branch().get_stacked_on_url)
+
+    def test_sprout_ignores_policy_for_unsupported_formats(self):
+        child_branch, new_child_transport = self.prepare_default_stacking(
+            child_format='pack-0.92')
+        new_child = child_branch.bzrdir.sprout(new_child_transport.base)
+        self.assertRaises(errors.UnstackableBranchFormat,
+                          new_child.open_branch().get_stacked_on_url)
+
+    def test_sprout_upgrades_format_if_stacked_specified(self):
+        child_branch, new_child_transport = self.prepare_default_stacking(
+            child_format='pack-0.92')
+        new_child = child_branch.bzrdir.sprout(new_child_transport.base,
+                                               stacked=True)
+        self.assertEqual(child_branch.bzrdir.root_transport.base,
+                         new_child.open_branch().get_stacked_on_url())
+        repo = new_child.open_repository()
+        self.assertTrue(repo._format.supports_external_lookups)
+        self.assertFalse(repo.supports_rich_root())
+
+    def test_sprout_upgrades_to_rich_root_format_if_needed(self):
+        child_branch, new_child_transport = self.prepare_default_stacking(
+            child_format='rich-root-pack')
+        def do_sprout():
+            try:
+                return child_branch.bzrdir.sprout(new_child_transport.base,
+                                                  stacked=True)
+            except errors.IncompatibleRepositories:
+                raise AssertionError(
+                    'Rich root format should be sprout-compatible')
+        self.expectFailure('Rich root format should be sprout-compatible',
+                           do_sprout)
+        repo = new_child.open_repository()
+        self.assertTrue(repo._format.supports_external_lookups)
+        self.assertTrue(repo.supports_rich_root())
+
     def test_add_fallback_repo_handles_absolute_urls(self):
         stack_on = self.make_branch('stack_on', format='development1')
         repo = self.make_repository('repo', format='development1')
@@ -1139,7 +1180,7 @@
     def open_branch(self, unsupported=False):
         return self.test_branch
 
-    def cloning_metadir(self):
+    def cloning_metadir(self, require_stacking=False):
         return _TestBzrDirFormat()
 
 
@@ -1149,9 +1190,20 @@
     def __init__(self, *args, **kwargs):
         super(_TestBranch, self).__init__(*args, **kwargs)
         self.calls = []
-    
+        self._parent = None
+
     def sprout(self, *args, **kwargs):
         self.calls.append('sprout')
+        return _TestBranch()
+
+    def copy_content_into(self, destination, revision_id=None):
+        self.calls.append('copy_content_into')
+
+    def get_parent(self):
+        return self._parent
+
+    def set_parent(self, parent):
+        self._parent = parent
 
 
 class TestBzrDirSprout(TestCaseWithMemoryTransport):
@@ -1182,5 +1234,10 @@
         result = source_bzrdir.sprout(target_url, recurse='no')
 
         # The bzrdir called the branch's sprout method.
-        self.assertEqual(['sprout'], source_bzrdir.test_branch.calls)
-        
+        self.assertSubset(['sprout'], source_bzrdir.test_branch.calls)
+
+    def test_sprout_parent(self):
+        grandparent_tree = self.make_branch('grandparent')
+        parent = grandparent_tree.bzrdir.sprout('parent').open_branch()
+        branch_tree = parent.bzrdir.sprout('branch').open_branch()
+        self.assertContainsRe(branch_tree.get_parent(), '/parent/$')




More information about the bazaar-commits mailing list