Rev 4336: (igc) pull --local (Gary van der Merwe) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed May 6 08:48:17 BST 2009


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

------------------------------------------------------------
revno: 4336
revision-id: pqm at pqm.ubuntu.com-20090506074811-dtxiv8kba5sez934
parent: pqm at pqm.ubuntu.com-20090506062429-suh2qssj5ak01olt
parent: ian.clatworthy at canonical.com-20090506063603-dbpoy8otr2s4f8mb
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-05-06 08:48:11 +0100
message:
  (igc) pull --local (Gary van der Merwe)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_bound_branches.py test_bound_branches.py-20051109215527-2373188ad566c205
  bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
  bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 4335.1.1
    revision-id: ian.clatworthy at canonical.com-20090506063603-dbpoy8otr2s4f8mb
    parent: pqm at pqm.ubuntu.com-20090506062429-suh2qssj5ak01olt
    parent: garyvdm at gmail.com-20090226214224-lv6lafw95vs0r49s
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: integration
    timestamp: Wed 2009-05-06 16:36:03 +1000
    message:
      (igc) pull --local (Gary van der Merwe)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_bound_branches.py test_bound_branches.py-20051109215527-2373188ad566c205
      bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 4056.6.6
    revision-id: garyvdm at gmail.com-20090226214224-lv6lafw95vs0r49s
    parent: garyvdm at gmail.com-20090226212954-xsc02ngqwtsvk58f
    committer: Gary van der Merwe <garyvdm at gmail.com>
    branch nick: bzr.dev
    timestamp: Thu 2009-02-26 23:42:24 +0200
    message:
      When using pull --local - don't try open the master branch.
    modified:
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
    ------------------------------------------------------------
    revno: 4056.6.5
    revision-id: garyvdm at gmail.com-20090226212954-xsc02ngqwtsvk58f
    parent: garyvdm at gmail.com-20090226205625-kws76tm1oeqm77hb
    committer: Gary van der Merwe <garyvdm at gmail.com>
    branch nick: bzr.dev
    timestamp: Thu 2009-02-26 23:29:54 +0200
    message:
      Update NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 4056.6.4
    revision-id: garyvdm at gmail.com-20090226205625-kws76tm1oeqm77hb
    parent: garyvdm at gmail.com-20090226201204-vjfm86y9udbz7552
    committer: Gary van der Merwe <garyvdm at gmail.com>
    branch nick: bzr.dev
    timestamp: Thu 2009-02-26 22:56:25 +0200
    message:
      Implement pull --local.
    modified:
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 4056.6.3
    revision-id: garyvdm at gmail.com-20090226201204-vjfm86y9udbz7552
    parent: garyvdm at gmail.com-20090226193116-gjxhlnvorzr5edjh
    committer: Gary van der Merwe <garyvdm at gmail.com>
    branch nick: bzr.dev
    timestamp: Thu 2009-02-26 22:12:04 +0200
    message:
      Add local args to pull methods, and add more tests
    modified:
      bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
      bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
      bzrlib/workingtree.py          workingtree.py-20050511021032-29b6ec0a681e02e3
    ------------------------------------------------------------
    revno: 4056.6.2
    revision-id: garyvdm at gmail.com-20090226193116-gjxhlnvorzr5edjh
    parent: garyvdm at gmail.com-20090226192049-btc9w91tzj8unz5f
    committer: Gary van der Merwe <garyvdm at gmail.com>
    branch nick: bzr.dev
    timestamp: Thu 2009-02-26 21:31:16 +0200
    message:
      Implement test for pull --local
    modified:
      bzrlib/tests/blackbox/test_bound_branches.py test_bound_branches.py-20051109215527-2373188ad566c205
    ------------------------------------------------------------
    revno: 4056.6.1
    revision-id: garyvdm at gmail.com-20090226192049-btc9w91tzj8unz5f
    parent: pqm at pqm.ubuntu.com-20090226073908-1fjp24b0llwqc0l7
    committer: Gary van der Merwe <garyvdm at gmail.com>
    branch nick: bzr.dev
    timestamp: Thu 2009-02-26 21:20:49 +0200
    message:
      Add --local option to pull.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
=== modified file 'NEWS'
--- a/NEWS	2009-05-06 05:31:47 +0000
+++ b/NEWS	2009-05-06 06:36:03 +0000
@@ -35,6 +35,10 @@
 * ``--coverage`` works for code running in threads too.
   (Andrew Bennets, Vincent Ladeuil)
 
+* ``bzr pull`` now has a ``--local`` option to only make changes to the
+  local branch, and not the bound master branch.
+  (Gary van der Merwe, #194716)
+
 Bug Fixes
 *********
 

=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2009-05-05 12:55:37 +0000
+++ b/bzrlib/branch.py	2009-05-06 06:36:03 +0000
@@ -846,7 +846,8 @@
         return history[revno - 1]
 
     def pull(self, source, overwrite=False, stop_revision=None,
-             possible_transports=None, _override_hook_target=None):
+             possible_transports=None, _override_hook_target=None,
+             local=False):
         """Mirror source into this branch.
 
         This branch is considered to be 'local', having low latency.
@@ -2180,7 +2181,7 @@
     @needs_write_lock
     def pull(self, source, overwrite=False, stop_revision=None,
              _hook_master=None, run_hooks=True, possible_transports=None,
-             _override_hook_target=None):
+             _override_hook_target=None, local=False):
         """See Branch.pull.
 
         :param _hook_master: Private parameter - set the branch to
@@ -2190,7 +2191,12 @@
             so it should not run its hooks.
         :param _override_hook_target: Private parameter - set the branch to be
             supplied as the target_branch to pull hooks.
+        :param local: Only update the local branch, and not the bound branch.
         """
+        # This type of branch can't be bound.
+        if local:
+            raise errors.LocalRequiresBoundBranch()
+        
         result = PullResult()
         result.source_branch = source
         if _override_hook_target is None:
@@ -2278,7 +2284,7 @@
     @needs_write_lock
     def pull(self, source, overwrite=False, stop_revision=None,
              run_hooks=True, possible_transports=None,
-             _override_hook_target=None):
+             _override_hook_target=None, local=False):
         """Pull from source into self, updating my master if any.
 
         :param run_hooks: Private parameter - if false, this branch
@@ -2286,8 +2292,10 @@
             so it should not run its hooks.
         """
         bound_location = self.get_bound_location()
+        if local and not bound_location:
+            raise errors.LocalRequiresBoundBranch()
         master_branch = None
-        if bound_location and source.base != bound_location:
+        if not local and bound_location and source.base != bound_location:
             # not pulling from master, so we need to update master.
             master_branch = self.get_master_branch(possible_transports)
             master_branch.lock_write()

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-04-29 20:31:34 +0000
+++ b/bzrlib/builtins.py	2009-05-06 06:36:03 +0000
@@ -882,13 +882,18 @@
             short_name='d',
             type=unicode,
             ),
+        Option('local',
+            help="Perform a local pull in a bound "
+                 "branch.  Local pulls are not applied to "
+                 "the master branch."
+            ),
         ]
     takes_args = ['location?']
     encoding_type = 'replace'
 
     def run(self, location=None, remember=False, overwrite=False,
             revision=None, verbose=False,
-            directory=None):
+            directory=None, local=False):
         # FIXME: too much stuff is in the command class
         revision_id = None
         mergeable = None
@@ -900,6 +905,9 @@
         except errors.NoWorkingTree:
             tree_to = None
             branch_to = Branch.open_containing(directory)[0]
+        
+        if local and not branch_to.get_bound_location():
+            raise errors.LocalRequiresBoundBranch()
 
         possible_transports = []
         if location is not None:
@@ -948,9 +956,11 @@
                     unversioned_filter=tree_to.is_ignored, view_info=view_info)
                 result = tree_to.pull(branch_from, overwrite, revision_id,
                                       change_reporter,
-                                      possible_transports=possible_transports)
+                                      possible_transports=possible_transports,
+                                      local=local)
             else:
-                result = branch_to.pull(branch_from, overwrite, revision_id)
+                result = branch_to.pull(branch_from, overwrite, revision_id,
+                                      local=local)
 
             result.report(self.outf)
             if verbose and result.old_revid != result.new_revid:

=== modified file 'bzrlib/tests/blackbox/test_bound_branches.py'
--- a/bzrlib/tests/blackbox/test_bound_branches.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_bound_branches.py	2009-05-06 06:36:03 +0000
@@ -228,6 +228,21 @@
 
         self.check_revno(2, '../base')
 
+    def test_pull_local_updates_local(self):
+        base_tree = self.create_branches()[0]
+        newchild_tree = base_tree.bzrdir.sprout('newchild').open_workingtree()
+        self.build_tree_contents([('newchild/b', 'newchild b contents\n')])
+        newchild_tree.commit(message='newchild')
+        self.check_revno(2, 'newchild')
+
+        os.chdir('child')
+        # The pull should succeed, and update
+        # the bound parent branch
+        self.run_bzr('pull ../newchild --local')
+        self.check_revno(2)
+
+        self.check_revno(1, '../base')
+
     def test_bind_diverged(self):
         base_tree, child_tree = self.create_branches()
         base_branch = base_tree.branch

=== modified file 'bzrlib/tests/branch_implementations/test_pull.py'
--- a/bzrlib/tests/branch_implementations/test_pull.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/branch_implementations/test_pull.py	2009-05-06 06:36:03 +0000
@@ -70,6 +70,32 @@
         self.assertEqual([rev1, rev2], checkout.branch.revision_history())
         self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
 
+    def test_pull_local_updates_checkout_only(self):
+        """Pulling --local into a checkout updates the checkout and not the
+        master branch"""
+        master_tree = self.make_branch_and_tree('master')
+        rev1 = master_tree.commit('master')
+        checkout = master_tree.branch.create_checkout('checkout')
+
+        other = master_tree.branch.bzrdir.sprout('other').open_workingtree()
+        rev2 = other.commit('other commit')
+        # now pull local, which should update checkout but not master.
+        checkout.branch.pull(other.branch, local = True)
+        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
+        self.assertEqual([rev1], master_tree.branch.revision_history())
+
+    def test_pull_local_raises_LocalRequiresBoundBranch_on_unbound(self):
+        """Pulling --local into a branch that is not bound should fail."""
+        master_tree = self.make_branch_and_tree('branch')
+        rev1 = master_tree.commit('master')
+
+        other = master_tree.branch.bzrdir.sprout('other').open_workingtree()
+        rev2 = other.commit('other commit')
+        # now pull --local, which should raise LocalRequiresBoundBranch error.
+        self.assertRaises(errors.LocalRequiresBoundBranch,
+                          master_tree.branch.pull, other.branch, local = True)
+        self.assertEqual([rev1], master_tree.branch.revision_history())
+
     def test_pull_raises_specific_error_on_master_connection_error(self):
         master_tree = self.make_branch_and_tree('master')
         checkout = master_tree.branch.create_checkout('checkout')

=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py	2009-04-17 12:52:36 +0000
+++ b/bzrlib/workingtree.py	2009-05-06 06:36:03 +0000
@@ -1561,7 +1561,7 @@
 
     @needs_write_lock
     def pull(self, source, overwrite=False, stop_revision=None,
-             change_reporter=None, possible_transports=None):
+             change_reporter=None, possible_transports=None, local=False):
         top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
         source.lock_read()
         try:
@@ -1570,7 +1570,8 @@
             old_revision_info = self.branch.last_revision_info()
             basis_tree = self.basis_tree()
             count = self.branch.pull(source, overwrite, stop_revision,
-                                     possible_transports=possible_transports)
+                                     possible_transports=possible_transports,
+                                     local=local)
             new_revision_info = self.branch.last_revision_info()
             if new_revision_info != old_revision_info:
                 pp.next_phase()




More information about the bazaar-commits mailing list