Rev 3808: Fix 'bzr branch --stacked' from a smart server to a standalone in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Oct 29 23:28:49 GMT 2008


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

------------------------------------------------------------
revno: 3808
revision-id: pqm at pqm.ubuntu.com-20081029232846-uni2g702k01jmgvh
parent: pqm at pqm.ubuntu.com-20081029215135-qbnx14rn0gagdvik
parent: andrew.bennetts at canonical.com-20081029223355-xaqfypm2wjyt1f50
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-10-29 23:28:46 +0000
message:
  Fix 'bzr branch --stacked' from a smart server to a standalone
  	branch. (Andrew Bennetts)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
  bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3793.1.4
    revision-id: andrew.bennetts at canonical.com-20081029223355-xaqfypm2wjyt1f50
    parent: andrew.bennetts at canonical.com-20081029221308-m9yfj9bbvsklh3ar
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: bug-270397
    timestamp: Thu 2008-10-30 09:33:55 +1100
    message:
      Add NEWS entry.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3793.1.3
    revision-id: andrew.bennetts at canonical.com-20081029221308-m9yfj9bbvsklh3ar
    parent: andrew.bennetts at canonical.com-20081027002517-z0w3cm6dux5a67z8
    parent: pqm at pqm.ubuntu.com-20081029070146-p1cqjt23zctbpg51
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: bug-270397
    timestamp: Thu 2008-10-30 09:13:08 +1100
    message:
      Merge bzr.dev.
    added:
      doc/developers/btree_index_prefetch.txt btree_index_request_-20081004155340-2u6apsy53f43f0xn-1
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/help_topics/en/hooks.txt hooks.txt-20070830033044-xxu2rced13f72dka-1
      bzrlib/index.py                index.py-20070712131115-lolkarso50vjr64s-1
      bzrlib/lru_cache.py            lru_cache.py-20070119165515-tlw203kuwh0id5gv-1
      bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
      bzrlib/plugins/launchpad/account.py account.py-20071011033320-50y6vfftywf4yllw-1
      bzrlib/plugins/launchpad/test_account.py test_account.py-20071011033320-50y6vfftywf4yllw-2
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
      bzrlib/repofmt/pack_repo.py    pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
      bzrlib/repository.py           rev_storage.py-20051111201905-119e9401e46257e3
      bzrlib/revisiontree.py         revisiontree.py-20060724012533-bg8xyryhxd0o0i0h-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_missing.py test_missing.py-20051211212735-a2cf4c1840bb84c4
      bzrlib/tests/test_btree_index.py test_index.py-20080624222253-p0x5f92uyh5hw734-13
      bzrlib/tests/test_index.py     test_index.py-20070712131115-lolkarso50vjr64s-2
      bzrlib/tests/test_lru_cache.py test_lru_cache.py-20070119165535-hph6rk4h9rzy4180-1
      bzrlib/tests/test_pack_repository.py test_pack_repository-20080801043947-eaw0e6h2gu75kwmy-1
      bzrlib/tests/test_repository.py test_repository.py-20060131075918-65c555b881612f4d
      bzrlib/tests/tree_implementations/test_tree.py test_tree.py-20061215160206-usu7lwcj8aq2n3br-1
      bzrlib/transform.py            transform.py-20060105172343-dd99e54394d91687
      bzrlib/transport/__init__.py   transport.py-20050711165921-4978aa7ce1285ad5
      bzrlib/tree.py                 tree.py-20050309040759-9d5f2496be663e77
      bzrlib/win32utils.py           win32console.py-20051021033308-123c6c929d04973d
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
      bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
      doc/developers/ppa.txt         ppa.txt-20080722055539-606u7t2z32t3ae4w-1
      doc/en/user-guide/branching_a_project.txt branching_a_project.-20071122141511-0knao2lklsdsvb1q-2
      doc/en/user-guide/core_concepts.txt core_concepts.txt-20071114035000-q36a9h57ps06uvnl-2
      doc/en/user-guide/hooks.txt    hooks.txt-20070829200551-7nr6e5a1io6x78uf-1
      doc/en/user-guide/using_checkouts.txt using_checkouts.txt-20071123055134-k5x4ekduci2lbn36-4
    ------------------------------------------------------------
    revno: 3793.1.2
    revision-id: andrew.bennetts at canonical.com-20081027002517-z0w3cm6dux5a67z8
    parent: andrew.bennetts at canonical.com-20081024062622-a011tbwexeu7f634
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: bug-270397
    timestamp: Mon 2008-10-27 11:25:17 +1100
    message:
      Add test showing that stacking from the smart server works.
    modified:
      bzrlib/tests/branch_implementations/test_stacking.py test_stacking.py-20080214020755-msjlkb7urobwly0f-1
    ------------------------------------------------------------
    revno: 3793.1.1
    revision-id: andrew.bennetts at canonical.com-20081024062622-a011tbwexeu7f634
    parent: pqm at pqm.ubuntu.com-20081023190411-v80cdeda5cq1sog1
    committer: Andrew Bennetts <andrew.bennetts at canonical.com>
    branch nick: bug-270397
    timestamp: Fri 2008-10-24 17:26:22 +1100
    message:
      Make RemoteBranch.sprout use Branch.sprout when possible.
    modified:
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
=== modified file 'NEWS'
--- a/NEWS	2008-10-29 21:51:35 +0000
+++ b/NEWS	2008-10-29 23:28:46 +0000
@@ -52,6 +52,10 @@
     * API versioning support now has a multiple-version checking api
       ``require_any_api``. (Robert Collins, #279447)
 
+    * ``bzr branch --stacked`` from a smart server to a standalone branch 
+      works again.  This fixes a regression in 1.7 and 1.8.
+      (Andrew Bennetts, #270397)
+
     * ``bzr co`` uses less memory. It used to unpack the entire WT into
       memory before writing it to disk. This was a little bit faster, but
       consumed lots of memory. (John Arbash Meinel, #269456)

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-10-29 01:19:46 +0000
+++ b/bzrlib/remote.py	2008-10-29 23:28:46 +0000
@@ -1625,14 +1625,22 @@
         return self._real_branch.set_stacked_on_url(stacked_location)
 
     def sprout(self, to_bzrdir, revision_id=None):
-        # Like Branch.sprout, except that it sprouts a branch in the default
-        # format, because RemoteBranches can't be created at arbitrary URLs.
-        # XXX: if to_bzrdir is a RemoteBranch, this should perhaps do
-        # to_bzrdir.create_branch...
-        self._ensure_real()
-        result = self._real_branch._format.initialize(to_bzrdir)
-        self.copy_content_into(result, revision_id=revision_id)
-        result.set_parent(self.bzrdir.root_transport.base)
+        branch_format = to_bzrdir._format._branch_format
+        if (branch_format is None or
+            isinstance(branch_format, RemoteBranchFormat)):
+            # The to_bzrdir specifies RemoteBranchFormat (or no format, which
+            # implies the same thing), but RemoteBranches can't be created at
+            # arbitrary URLs.  So create a branch in the same format as
+            # _real_branch instead.
+            # XXX: if to_bzrdir is a RemoteBzrDir, this should perhaps do
+            # to_bzrdir.create_branch to create a RemoteBranch after all...
+            self._ensure_real()
+            result = self._real_branch._format.initialize(to_bzrdir)
+            self.copy_content_into(result, revision_id=revision_id)
+            result.set_parent(self.bzrdir.root_transport.base)
+        else:
+            result = branch.Branch.sprout(
+                self, to_bzrdir, revision_id=revision_id)
         return result
 
     @needs_write_lock

=== modified file 'bzrlib/tests/branch_implementations/test_stacking.py'
--- a/bzrlib/tests/branch_implementations/test_stacking.py	2008-10-09 00:56:15 +0000
+++ b/bzrlib/tests/branch_implementations/test_stacking.py	2008-10-27 00:25:17 +0000
@@ -22,8 +22,10 @@
     errors,
     )
 from bzrlib.revision import NULL_REVISION
+from bzrlib.smart import server
 from bzrlib.tests import TestNotApplicable, KnownFailure
 from bzrlib.tests.branch_implementations import TestCaseWithBranch
+from bzrlib.transport import get_transport
 
 
 class TestStacking(TestCaseWithBranch):
@@ -116,6 +118,38 @@
         self.assertRevisionNotInRepository('mainline', new_branch_revid)
         self.assertRevisionInRepository('newbranch', new_branch_revid)
 
+    # XXX: this helper probably belongs on TestCaseWithTransport
+    def make_smart_server(self, path):
+        smart_server = server.SmartTCPServer_for_testing()
+        smart_server.setUp(self.get_server())
+        remote_transport = get_transport(smart_server.get_url()).clone(path)
+        self.addCleanup(smart_server.tearDown)
+        return remote_transport
+
+    def test_sprout_stacked_from_smart_server(self):
+        if isinstance(self.branch_format, branch.BzrBranchFormat4):
+            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
+        # We have a mainline
+        trunk_tree = self.make_branch_and_tree('mainline')
+        trunk_revid = trunk_tree.commit('mainline')
+        # Make sure that we can make a stacked branch from it
+        try:
+            trunk_tree.bzrdir.sprout('testbranch', stacked=True)
+        except (errors.UnstackableBranchFormat,
+            errors.UnstackableRepositoryFormat), e:
+            raise TestNotApplicable(e)
+        # Now serve the original mainline from a smart server
+        remote_transport = self.make_smart_server('mainline')
+        remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport)
+        # and make branch from the smart server which is stacked
+        new_dir = remote_bzrdir.sprout('newbranch', stacked=True)
+        # stacked repository
+        self.assertRevisionNotInRepository('newbranch', trunk_revid)
+        new_tree = new_dir.open_workingtree()
+        new_branch_revid = new_tree.commit('something local')
+        self.assertRevisionNotInRepository('mainline', new_branch_revid)
+        self.assertRevisionInRepository('newbranch', new_branch_revid)
+
     def test_unstack_fetches(self):
         """Removing the stacked-on branch pulls across all data"""
         # We have a mainline




More information about the bazaar-commits mailing list