Rev 2958: Fix second unwanted connection by providing the right branch to create_checkout. in file:///v/home/vila/src/bzr/bugs/159150/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Nov 1 21:02:44 GMT 2007


At file:///v/home/vila/src/bzr/bugs/159150/

------------------------------------------------------------
revno: 2958
revision-id: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.
modified:
  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_workingtree.py testworkingtree.py-20051004024258-b88d0fe8f101d468
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
  bzrlib/workingtree_4.py        workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-11-01 12:14:47 +0000
+++ b/bzrlib/branch.py	2007-11-01 21:02:36 +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:

=== 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-10-25 01:24:51 +0000
+++ b/bzrlib/remote.py	2007-11-01 21:02:36 +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/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-10-30 21:06:01 +0000
+++ b/bzrlib/workingtree.py	2007-11-01 21:02:36 +0000
@@ -2709,11 +2709,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()
@@ -2798,7 +2801,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
@@ -2811,7 +2814,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-10-24 07:28:00 +0000
+++ b/bzrlib/workingtree_4.py	2007-11-01 21:02:36 +0000
@@ -1250,7 +1250,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
@@ -1266,7 +1266,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