Rev 2991: Fix #159150, multiple connections during checkout --lightweight in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Nov 14 09:22:00 GMT 2007


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

------------------------------------------------------------
revno: 2991
revision-id: pqm at pqm.ubuntu.com-20071114092157-du5ikf6q4k64nseu
parent: pqm at pqm.ubuntu.com-20071114070314-fdmaj14v4x59z1yv
parent: v.ladeuil+lp at free.fr-20071114082805-yg8b6w06rxhcr91r
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-11-14 09:21:57 +0000
message:
  Fix #159150, multiple connections during checkout --lightweight
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/commands/test_checkout.py test_checkout.py-20070525151718-vm7ligd5px5dtmda-1
  bzrlib/tests/test_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
    ------------------------------------------------------------
    revno: 2990.1.1
    merged: v.ladeuil+lp at free.fr-20071114082805-yg8b6w06rxhcr91r
    parent: pqm at pqm.ubuntu.com-20071114070314-fdmaj14v4x59z1yv
    parent: v.ladeuil+lp at free.fr-20071114082357-fykgik644sfeujjr
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: trunk
    timestamp: Wed 2007-11-14 09:28:05 +0100
    message:
      Fix multiple connections during checkout --lightweight
    ------------------------------------------------------------
    revno: 2955.5.7
    merged: v.ladeuil+lp at free.fr-20071114082357-fykgik644sfeujjr
    parent: v.ladeuil+lp at free.fr-20071114082059-bx03o3laiqfnyleb
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Wed 2007-11-14 09:23:57 +0100
    message:
      Cosmetic change.
      
      * NEWS: 
      Entry was misplaced.
    ------------------------------------------------------------
    revno: 2955.5.6
    merged: v.ladeuil+lp at free.fr-20071114082059-bx03o3laiqfnyleb
    parent: v.ladeuil+lp at free.fr-20071114082026-4d27f52n5r0t82rw
    parent: pqm at pqm.ubuntu.com-20071114070314-fdmaj14v4x59z1yv
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Wed 2007-11-14 09:20:59 +0100
    message:
      merge bzr.dev
    ------------------------------------------------------------
    revno: 2955.5.5
    merged: v.ladeuil+lp at free.fr-20071114082026-4d27f52n5r0t82rw
    parent: v.ladeuil+lp at free.fr-20071101212605-v20ryd3vd0h51hd1
    parent: pqm at pqm.ubuntu.com-20071106124804-ehlreba0lfp3kab9
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Wed 2007-11-14 09:20:26 +0100
    message:
      merge bzr.dev
    ------------------------------------------------------------
    revno: 2955.5.4
    merged: v.ladeuil+lp at free.fr-20071101212605-v20ryd3vd0h51hd1
    parent: v.ladeuil+lp at free.fr-20071101210236-iv2k87h4g2dmig3t
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Thu 2007-11-01 22:26:05 +0100
    message:
      Fix multiple connections during checkout --lightweight
    ------------------------------------------------------------
    revno: 2955.5.3
    merged: v.ladeuil+lp at free.fr-20071101210236-iv2k87h4g2dmig3t
    parent: v.ladeuil+lp at free.fr-20071101121447-o8uwn30mroh7ju9i
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Thu 2007-11-01 22:02:36 +0100
    message:
      Fix second unwanted connection by providing the right branch to create_checkout.
      
      * bzrlib/branch.py:
      (Branch.create_checkout): Keep the lightweight branch to create
      the checkout from.
      
      * bzrlib/bzrdir.py:
      (BzrDir.create_workingtree, BzrDir.open_workingtree,
      BzrDirMeta1.create_workingtree): Add a from_branch parameter for
      lightweight checkouts purposes.
      
      * bzrlib/workingtree.py:
      (WorkingTreeFormat2.initialize, WorkingTreeFormat3.initialize):
      Use from_branch if provided or default to bzrdir branch.
      
      * bzrlib/workingtree_4.py:
      (WorkingTreeFormat4.initialize): Use from_branch if provided or
      default to bzrdir branch.
      
      * bzrlib/tests/test_workingtree.py:
      (SampleTreeFormat.initialize): Update the signature.
      
      * bzrlib/remote.py:
      (RemoteBzrDir.create_workingtree): Update the signature.
    ------------------------------------------------------------
    revno: 2955.5.2
    merged: v.ladeuil+lp at free.fr-20071101121447-o8uwn30mroh7ju9i
    parent: v.ladeuil+lp at free.fr-20071031224603-omyf4if730mfwm1h
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Thu 2007-11-01 13:14:47 +0100
    message:
      Fix first unwanted connection.
      
      * bzrlib/branch.py:
      (BranchReferenceFormat.initialize): Give self.open the transport
      to be reused via possible_transports.
      (BranchReferenceFormat.open): Add a possible_transports parameter.
    ------------------------------------------------------------
    revno: 2955.5.1
    merged: v.ladeuil+lp at free.fr-20071031224603-omyf4if730mfwm1h
    parent: pqm at pqm.ubuntu.com-20071031141102-b5664t8izotfnc6h
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: 159150
    timestamp: Wed 2007-10-31 23:46:03 +0100
    message:
      Reproduce bug 159150.
      
      * tests/commands/test_checkout.py:
      (TestCheckout.test_checkout_lightweight): New test.
=== modified file 'NEWS'
--- a/NEWS	2007-11-14 06:06:41 +0000
+++ b/NEWS	2007-11-14 08:23:57 +0000
@@ -55,6 +55,9 @@
    * Don't use timeout in HttpServer anymore.
      (Vincent Ladeuil, #158972).
 
+   * Fix multiple connections during checkout --lightweight.
+     (Vincent Ladeuil, #159150)
+
    * FTP server errors don't error in the error handling code.
      (Robert Collins, #161240)
 

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-10-26 19:18:48 +0000
+++ b/bzrlib/branch.py	2007-11-14 08:20:59 +0000
@@ -771,7 +771,7 @@
         if lightweight:
             format = self._get_checkout_format()
             checkout = format.initialize_on_transport(t)
-            BranchReferenceFormat().initialize(checkout, self)
+            from_branch = BranchReferenceFormat().initialize(checkout, self)
         else:
             format = self._get_checkout_format()
             checkout_branch = bzrdir.BzrDir.create_branch_convenience(
@@ -781,7 +781,9 @@
             # pull up to the specified revision_id to set the initial 
             # branch tip correctly, and seed it with history.
             checkout_branch.pull(self, stop_revision=revision_id)
-        tree = checkout.create_workingtree(revision_id)
+            from_branch=None
+        tree = checkout.create_workingtree(revision_id,
+                                           from_branch=from_branch)
         basis_tree = tree.basis_tree()
         basis_tree.lock_read()
         try:
@@ -1191,7 +1193,7 @@
     def get_format_description(self):
         """See BranchFormat.get_format_description()."""
         return "Checkout reference format 1"
-        
+
     def get_reference(self, a_bzrdir):
         """See BranchFormat.get_reference()."""
         transport = a_bzrdir.get_branch_transport(None)
@@ -1208,7 +1210,9 @@
         branch_transport.put_bytes('location',
             target_branch.bzrdir.root_transport.base)
         branch_transport.put_bytes('format', self.get_format_string())
-        return self.open(a_bzrdir, _found=True)
+        return self.open(
+            a_bzrdir, _found=True,
+            possible_transports=[target_branch.bzrdir.root_transport])
 
     def __init__(self):
         super(BranchReferenceFormat, self).__init__()
@@ -1224,7 +1228,8 @@
             # emit some sort of warning/error to the caller ?!
         return clone
 
-    def open(self, a_bzrdir, _found=False, location=None):
+    def open(self, a_bzrdir, _found=False, location=None,
+             possible_transports=None):
         """Return the branch that the branch reference in a_bzrdir points at.
 
         _found is a private parameter, do not use it. It is used to indicate
@@ -1235,7 +1240,8 @@
             assert format.__class__ == self.__class__
         if location is None:
             location = self.get_reference(a_bzrdir)
-        real_bzrdir = bzrdir.BzrDir.open(location)
+        real_bzrdir = bzrdir.BzrDir.open(
+            location, possible_transports=possible_transports)
         result = real_bzrdir.open_branch()
         # this changes the behaviour of result.clone to create a new reference
         # rather than a copy of the content of the branch.

=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2007-10-25 06:17:57 +0000
+++ b/bzrlib/bzrdir.py	2007-11-01 21:02:36 +0000
@@ -370,10 +370,11 @@
                                                format=format).bzrdir
         return bzrdir.create_workingtree()
 
-    def create_workingtree(self, revision_id=None):
+    def create_workingtree(self, revision_id=None, from_branch=None):
         """Create a working tree at this BzrDir.
         
-        revision_id: create it as of this revision id.
+        :param revision_id: create it as of this revision id.
+        :param from_branch: override bzrdir branch (for lightweight checkouts)
         """
         raise NotImplementedError(self.create_workingtree)
 
@@ -687,13 +688,14 @@
         raise NotImplementedError(self.open_repository)
 
     def open_workingtree(self, _unsupported=False,
-            recommend_upgrade=True):
+                         recommend_upgrade=True, from_branch=None):
         """Open the workingtree object at this BzrDir if one is present.
 
         :param recommend_upgrade: Optional keyword parameter, when True (the
             default), emit through the ui module a recommendation that the user
             upgrade the working tree when the workingtree being opened is old
             (but still fully supported).
+        :param from_branch: override bzrdir branch (for lightweight checkouts)
         """
         raise NotImplementedError(self.open_workingtree)
 
@@ -922,7 +924,7 @@
             raise errors.IncompatibleFormat('shared repository', self._format)
         return self.open_repository()
 
-    def create_workingtree(self, revision_id=None):
+    def create_workingtree(self, revision_id=None, from_branch=None):
         """See BzrDir.create_workingtree."""
         # this looks buggy but is not -really-
         # because this format creates the workingtree when the bzrdir is
@@ -1100,10 +1102,10 @@
         """See BzrDir.create_repository."""
         return self._format.repository_format.initialize(self, shared)
 
-    def create_workingtree(self, revision_id=None):
+    def create_workingtree(self, revision_id=None, from_branch=None):
         """See BzrDir.create_workingtree."""
-        from bzrlib.workingtree import WorkingTreeFormat
-        return self._format.workingtree_format.initialize(self, revision_id)
+        return self._format.workingtree_format.initialize(
+            self, revision_id, from_branch=from_branch)
 
     def destroy_workingtree(self):
         """See BzrDir.destroy_workingtree."""

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2007-11-04 20:35:32 +0000
+++ b/bzrlib/remote.py	2007-11-14 08:20:26 +0000
@@ -95,7 +95,7 @@
         self._ensure_real()
         self._real_bzrdir.destroy_branch()
 
-    def create_workingtree(self, revision_id=None):
+    def create_workingtree(self, revision_id=None, from_branch=None):
         raise errors.NotLocalUrl(self.transport.base)
 
     def find_branch_format(self):

=== modified file 'bzrlib/tests/commands/test_checkout.py'
--- a/bzrlib/tests/commands/test_checkout.py	2007-09-11 14:47:02 +0000
+++ b/bzrlib/tests/commands/test_checkout.py	2007-10-31 22:46:03 +0000
@@ -30,3 +30,12 @@
         cmd.run(self.get_url('branch1'), 'local')
         self.assertEquals(1, len(self.connections))
 
+    def test_checkout_lightweight(self):
+        self.make_branch_and_tree('branch1')
+
+        self.start_logging_connections()
+
+        cmd = cmd_checkout()
+        cmd.run(self.get_url('branch1'), 'local', lightweight=True)
+        self.assertEquals(1, len(self.connections))
+

=== modified file 'bzrlib/tests/test_workingtree.py'
--- a/bzrlib/tests/test_workingtree.py	2007-10-17 17:03:06 +0000
+++ b/bzrlib/tests/test_workingtree.py	2007-11-01 21:02:36 +0000
@@ -94,7 +94,7 @@
         """See WorkingTreeFormat.get_format_string()."""
         return "Sample tree format."
 
-    def initialize(self, a_bzrdir, revision_id=None):
+    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
         """Sample branches cannot be created."""
         t = a_bzrdir.get_workingtree_transport(self)
         t.put_bytes('format', self.get_format_string())

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2007-11-13 18:39:31 +0000
+++ b/bzrlib/workingtree.py	2007-11-14 08:20:59 +0000
@@ -2718,11 +2718,14 @@
         control_files.put_bytes('pending-merges', '')
         
 
-    def initialize(self, a_bzrdir, revision_id=None):
+    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
         """See WorkingTreeFormat.initialize()."""
         if not isinstance(a_bzrdir.transport, LocalTransport):
             raise errors.NotLocalUrl(a_bzrdir.transport.base)
-        branch = a_bzrdir.open_branch()
+        if from_branch is not None:
+            branch = from_branch
+        else:
+            branch = a_bzrdir.open_branch()
         if revision_id is None:
             revision_id = _mod_revision.ensure_null(branch.last_revision())
         branch.lock_write()
@@ -2807,7 +2810,7 @@
         return LockableFiles(transport, self._lock_file_name, 
                              self._lock_class)
 
-    def initialize(self, a_bzrdir, revision_id=None):
+    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
         """See WorkingTreeFormat.initialize().
         
         revision_id allows creating a working tree at a different
@@ -2820,7 +2823,10 @@
         control_files.create_lock()
         control_files.lock_write()
         control_files.put_utf8('format', self.get_format_string())
-        branch = a_bzrdir.open_branch()
+        if from_branch is not None:
+            branch = from_branch
+        else:
+            branch = a_bzrdir.open_branch()
         if revision_id is None:
             revision_id = _mod_revision.ensure_null(branch.last_revision())
         # WorkingTree3 can handle an inventory which has a unique root id.

=== modified file 'bzrlib/workingtree_4.py'
--- a/bzrlib/workingtree_4.py	2007-11-13 02:09:03 +0000
+++ b/bzrlib/workingtree_4.py	2007-11-14 08:20:59 +0000
@@ -1255,7 +1255,7 @@
         """See WorkingTreeFormat.get_format_description()."""
         return "Working tree format 4"
 
-    def initialize(self, a_bzrdir, revision_id=None):
+    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
         """See WorkingTreeFormat.initialize().
 
         :param revision_id: allows creating a working tree at a different
@@ -1271,7 +1271,10 @@
         control_files.create_lock()
         control_files.lock_write()
         control_files.put_utf8('format', self.get_format_string())
-        branch = a_bzrdir.open_branch()
+        if from_branch is not None:
+            branch = from_branch
+        else:
+            branch = a_bzrdir.open_branch()
         if revision_id is None:
             revision_id = branch.last_revision()
         local_path = transport.local_abspath('dirstate')




More information about the bazaar-commits mailing list