Rev 5884: (vila) Generalises the --no-remember support for send/pull/push (Vincent in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed May 18 01:02:56 UTC 2011


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

------------------------------------------------------------
revno: 5884 [merge]
revision-id: pqm at pqm.ubuntu.com-20110518010252-kt8qh7jykm18djt1
parent: pqm at pqm.ubuntu.com-20110517231845-pkd57to3k7w8gs5q
parent: v.ladeuil+lp at free.fr-20110517150158-0pub4z502vrji1ao
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-05-18 01:02:52 +0000
message:
  (vila) Generalises the --no-remember support for send/pull/push (Vincent
   Ladeuil)
added:
  bzrlib/tests/blackbox/test_remember_option.py test_remember_option-20110517132110-7uv6puheaok558uc-1
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/help_topics/en/configuration.txt configuration.txt-20060314161707-868350809502af01
  bzrlib/push.py                 push.py-20080606021927-5fe39050e8xne9un-1
  bzrlib/send.py                 send.py-20090521192735-j7cdb33ykmtmzx4w-1
  bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
  bzrlib/tests/blackbox/test_send.py test_bundle.py-20060616222707-c21c8b7ea5ef57b1
  doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2011-05-17 13:06:56 +0000
+++ b/bzrlib/builtins.py	2011-05-18 01:02:52 +0000
@@ -962,10 +962,10 @@
     match the remote one, use pull --overwrite. This will work even if the two
     branches have diverged.
 
-    If there is no default location set, the first pull will set it.  After
-    that, you can omit the location to use the default.  To change the
-    default, use --remember. The value will only be saved if the remote
-    location can be accessed.
+    If there is no default location set, the first pull will set it (use
+    --no-remember to avoid settting it). After that, you can omit the
+    location to use the default.  To change the default, use --remember. The
+    value will only be saved if the remote location can be accessed.
 
     Note: The location can be specified either in the form of a branch,
     or in the form of a path to a file containing a merge directive generated
@@ -990,7 +990,7 @@
     takes_args = ['location?']
     encoding_type = 'replace'
 
-    def run(self, location=None, remember=False, overwrite=False,
+    def run(self, location=None, remember=None, overwrite=False,
             revision=None, verbose=False,
             directory=None, local=False,
             show_base=False):
@@ -1047,8 +1047,9 @@
             branch_from = Branch.open(location,
                 possible_transports=possible_transports)
             self.add_cleanup(branch_from.lock_read().unlock)
-
-            if branch_to.get_parent() is None or remember:
+            # Remembers if asked explicitly or no previous location is set
+            if (remember
+                or (remember is None and branch_to.get_parent() is None)):
                 branch_to.set_parent(branch_from.base)
 
         if revision is not None:
@@ -1098,10 +1099,10 @@
     do a merge (see bzr help merge) from the other branch, and commit that.
     After that you will be able to do a push without '--overwrite'.
 
-    If there is no default push location set, the first push will set it.
-    After that, you can omit the location to use the default.  To change the
-    default, use --remember. The value will only be saved if the remote
-    location can be accessed.
+    If there is no default push location set, the first push will set it (use
+    --no-remember to avoid settting it).  After that, you can omit the
+    location to use the default.  To change the default, use --remember. The
+    value will only be saved if the remote location can be accessed.
     """
 
     _see_also = ['pull', 'update', 'working-trees']
@@ -1135,7 +1136,7 @@
     takes_args = ['location?']
     encoding_type = 'replace'
 
-    def run(self, location=None, remember=False, overwrite=False,
+    def run(self, location=None, remember=None, overwrite=False,
         create_prefix=False, verbose=False, revision=None,
         use_existing_dir=False, directory=None, stacked_on=None,
         stacked=False, strict=None, no_tree=False):
@@ -3860,9 +3861,9 @@
     Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
 
     If there is no default branch set, the first merge will set it (use
-    --no-remember to *not* set it). After that, you can omit the branch to use
-    the default.  To change the default, use --remember. The value will only be
-    saved if the remote location can be accessed.
+    --no-remember to avoid settting it). After that, you can omit the branch
+    to use the default.  To change the default, use --remember. The value will
+    only be saved if the remote location can be accessed.
 
     The results of the merge are placed into the destination working
     directory, where they can be reviewed (with bzr diff), tested, and then
@@ -5289,6 +5290,12 @@
     source branch defaults to that containing the working directory, but can
     be changed using --from.
 
+    Both the submit branch and the public branch follow the usual behavior with
+    respect to --remember: If there is no default location set, the first send
+    will set it (use --no-remember to avoid settting it). After that, you can
+    omit the location to use the default.  To change the default, use
+    --remember. The value will only be saved if the location can be accessed.
+
     In order to calculate those changes, bzr must analyse the submit branch.
     Therefore it is most efficient for the submit branch to be a local mirror.
     If a public location is known for the submit_branch, that location is used
@@ -5363,7 +5370,7 @@
         ]
 
     def run(self, submit_branch=None, public_branch=None, no_bundle=False,
-            no_patch=False, revision=None, remember=False, output=None,
+            no_patch=False, revision=None, remember=None, output=None,
             format=None, mail_to=None, message=None, body=None,
             strict=None, **kwargs):
         from bzrlib.send import send

=== modified file 'bzrlib/help_topics/en/configuration.txt'
--- a/bzrlib/help_topics/en/configuration.txt	2011-05-14 14:10:56 +0000
+++ b/bzrlib/help_topics/en/configuration.txt	2011-05-18 01:02:52 +0000
@@ -550,15 +550,15 @@
 parent_location
 ~~~~~~~~~~~~~~~
 
-If present, the location of the default branch for pull or merge.
-This option is normally set by ``pull --remember`` or ``merge
+If present, the location of the default branch for pull or merge.  This option
+is normally set when creating a branch, the first ``pull`` or by ``pull
 --remember``.
 
 push_location
 ~~~~~~~~~~~~~
 
 If present, the location of the default branch for push.  This option
-is normally set by ``push --remember``.
+is normally set by the first ``push`` or ``push --remember``.
 
 push_strict
 ~~~~~~~~~~~

=== modified file 'bzrlib/push.py'
--- a/bzrlib/push.py	2010-09-29 01:57:02 +0000
+++ b/bzrlib/push.py	2011-05-17 15:01:58 +0000
@@ -129,7 +129,9 @@
         push_result.target_branch = br_to
         push_result.old_revid = _mod_revision.NULL_REVISION
         push_result.old_revno = 0
-        if br_from.get_push_location() is None or remember:
+        # Remembers if asked explicitly or no previous location is set
+        if (remember
+            or (remember is None and br_from.get_push_location() is None)):
             br_from.set_push_location(br_to.base)
     else:
         if stacked_on is not None:

=== modified file 'bzrlib/send.py'
--- a/bzrlib/send.py	2010-04-22 14:18:17 +0000
+++ b/bzrlib/send.py	2011-05-17 12:12:09 +0000
@@ -63,7 +63,8 @@
             submit_branch = stored_submit_branch
             remembered_submit_branch = "submit"
         else:
-            if stored_submit_branch is None or remember:
+            # Remembers if asked explicitly or no previous location is set
+            if remember or (remember is None and stored_submit_branch is None):
                 branch.set_submit_branch(submit_branch)
         if submit_branch is None:
             submit_branch = branch.get_parent()
@@ -95,7 +96,9 @@
         stored_public_branch = branch.get_public_branch()
         if public_branch is None:
             public_branch = stored_public_branch
-        elif stored_public_branch is None or remember:
+        # Remembers if asked explicitly or no previous location is set
+        elif (remember
+              or (remember is None and stored_public_branch is None)):
             branch.set_public_branch(public_branch)
         if no_bundle and public_branch is None:
             raise errors.BzrCommandError('No public branch specified or'

=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py	2011-05-04 11:44:18 +0000
+++ b/bzrlib/tests/blackbox/__init__.py	2011-05-17 13:21:33 +0000
@@ -98,6 +98,7 @@
                      'test_remerge',
                      'test_remove',
                      'test_re_sign',
+                     'test_remember_option',
                      'test_remove_tree',
                      'test_repair_workingtree',
                      'test_resolve',

=== added file 'bzrlib/tests/blackbox/test_remember_option.py'
--- a/bzrlib/tests/blackbox/test_remember_option.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_remember_option.py	2011-05-17 15:01:58 +0000
@@ -0,0 +1,208 @@
+# Copyright (C) 2011 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
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+from bzrlib import (
+    branch,
+    urlutils,
+    )
+from bzrlib.tests import (
+    script,
+    )
+
+
+class TestRememberMixin(object):
+    """--remember and --no-remember set locations or not."""
+
+    # the command to run (expecting additional arguments from the tests
+    command = []
+    # the dir where the command should be run (it should contain a branch for
+    # which the tested locations are/will be set)
+    working_dir = None
+    # argument list for the first command invocation
+    first_use_args = []
+    # argument list for the next command invocation
+    next_uses_args = []
+
+    def do_command(self, *args):
+        # We always expect the same result here and care only about the
+        # arguments used and their consequences on the remembered locations
+        out, err = self.run_bzr(self.command + list(args),
+                                working_dir=self.working_dir)
+
+    def test_first_use_no_option(self):
+        self.do_command(*self.first_use_args)
+        self.assertLocations(self.first_use_args)
+
+    def test_first_use_remember(self):
+        self.do_command('--remember', *self.first_use_args)
+        self.assertLocations(self.first_use_args)
+
+    def test_first_use_no_remember(self):
+        self.do_command('--no-remember', *self.first_use_args)
+        self.assertLocations([])
+
+    def test_next_uses_no_option(self):
+        self.setup_next_uses()
+        self.do_command(*self.next_uses_args)
+        self.assertLocations(self.first_use_args)
+
+    def test_next_uses_remember(self):
+        self.setup_next_uses()
+        self.do_command('--remember', *self.next_uses_args)
+        self.assertLocations(self.next_uses_args)
+
+    def test_next_uses_no_remember(self):
+        self.setup_next_uses()
+        self.do_command('--no-remember', *self.next_uses_args)
+        self.assertLocations(self.first_use_args)
+
+
+class TestSendRemember(script.TestCaseWithTransportAndScript,
+                       TestRememberMixin):
+
+    working_dir = 'work'
+    command = ['send', '-o-',]
+    first_use_args = ['../parent', '../grand_parent',]
+    next_uses_args = ['../new_parent', '../new_grand_parent']
+
+    def setUp(self):
+        super(TestSendRemember, self).setUp()
+        self.run_script('''
+            $ bzr init grand_parent
+            $ cd grand_parent
+            $ echo grand_parent > file
+            $ bzr add
+            $ bzr commit -m 'initial commit'
+            $ cd ..
+            $ bzr branch grand_parent parent
+            $ cd parent
+            $ echo parent > file
+            $ bzr commit -m 'parent'
+            $ cd ..
+            $ bzr branch parent %(working_dir)s
+            $ cd %(working_dir)s
+            $ echo %(working_dir)s > file
+            $ bzr commit -m '%(working_dir)s'
+            $ cd ..
+            ''' % {'working_dir': self.working_dir},
+                        null_output_matches_anything=True)
+
+    def setup_next_uses(self):
+        # Do a first send that remembers the locations
+        self.do_command(*self.first_use_args)
+        # Now create some new targets
+        self.run_script('''
+            $ bzr branch grand_parent new_grand_parent
+            $ bzr branch parent new_parent
+            ''',
+                        null_output_matches_anything=True)
+
+    def assertLocations(self, expected_locations):
+        if not expected_locations:
+            expected_submit_branch, expected_public_branch = None, None
+        else:
+            expected_submit_branch, expected_public_branch = expected_locations
+        br, _ = branch.Branch.open_containing(self.working_dir)
+        self.assertEquals(expected_submit_branch, br.get_submit_branch())
+        self.assertEquals(expected_public_branch, br.get_public_branch())
+
+
+class TestPushRemember(script.TestCaseWithTransportAndScript,
+                       TestRememberMixin):
+
+    working_dir = 'work'
+    command = ['push',]
+    first_use_args = ['../target',]
+    next_uses_args = ['../new_target']
+
+    def setUp(self):
+        super(TestPushRemember, self).setUp()
+        self.run_script('''
+            $ bzr init %(working_dir)s
+            $ cd %(working_dir)s
+            $ echo some content > file
+            $ bzr add
+            $ bzr commit -m 'initial commit'
+            $ cd ..
+            ''' % {'working_dir': self.working_dir},
+                        null_output_matches_anything=True)
+
+    def setup_next_uses(self):
+        # Do a first push that remembers the location
+        self.do_command(*self.first_use_args)
+        # Now create some new content
+        self.run_script('''
+            $ cd %(working_dir)s
+            $ echo new content > file
+            $ bzr commit -m 'new content'
+            $ cd ..
+            ''' % {'working_dir': self.working_dir},
+                        null_output_matches_anything=True)
+
+    def assertLocations(self, expected_locations):
+        br, _ = branch.Branch.open_containing(self.working_dir)
+        if not expected_locations:
+            self.assertEquals(None, br.get_push_location())
+        else:
+            expected_push_location = expected_locations[0]
+            push_location = urlutils.relative_url(br.base,
+                                                  br.get_push_location())
+            self.assertIsSameRealPath(expected_push_location, push_location)
+
+
+class TestPullRemember(script.TestCaseWithTransportAndScript,
+                       TestRememberMixin):
+
+    working_dir = 'work'
+    command = ['pull',]
+    first_use_args = ['../parent',]
+    next_uses_args = ['../new_parent']
+
+    def setUp(self):
+        super(TestPullRemember, self).setUp()
+        self.run_script('''
+            $ bzr init parent
+            $ cd parent
+            $ echo parent > file
+            $ bzr add
+            $ bzr commit -m 'initial commit'
+            $ cd ..
+            $ bzr init %(working_dir)s
+            ''' % {'working_dir': self.working_dir},
+                        null_output_matches_anything=True)
+
+    def setup_next_uses(self):
+        # Do a first push that remembers the location
+        self.do_command(*self.first_use_args)
+        # Now create some new content
+        self.run_script('''
+            $ bzr branch parent new_parent
+            $ cd new_parent
+            $ echo new parent > file
+            $ bzr commit -m 'new parent'
+            $ cd ..
+            ''' % {'working_dir': self.working_dir},
+                        null_output_matches_anything=True)
+
+    def assertLocations(self, expected_locations):
+        br, _ = branch.Branch.open_containing(self.working_dir)
+        if not expected_locations:
+            self.assertEquals(None, br.get_parent())
+        else:
+            expected_pull_location = expected_locations[0]
+            pull_location = urlutils.relative_url(br.base, br.get_parent())
+            self.assertIsSameRealPath(expected_pull_location, pull_location)

=== modified file 'bzrlib/tests/blackbox/test_send.py'
--- a/bzrlib/tests/blackbox/test_send.py	2011-01-10 22:20:12 +0000
+++ b/bzrlib/tests/blackbox/test_send.py	2011-05-17 15:01:58 +0000
@@ -27,10 +27,13 @@
     )
 from bzrlib.bundle import serializer
 from bzrlib.transport import memory
-from bzrlib.tests.scenarios import load_tests_apply_scenarios
-
-
-load_tests = load_tests_apply_scenarios
+from bzrlib.tests import (
+    scenarios,
+    script,
+    )
+
+
+load_tests = scenarios.load_tests_apply_scenarios
 
 
 class TestSendMixin(object):
@@ -346,7 +349,7 @@
 
 
 class TestSendStrictWithChanges(tests.TestCaseWithTransport,
-                                   TestSendStrictMixin):
+                                TestSendStrictMixin):
 
     # These are textually the same as test_push.strict_push_change_scenarios,
     # but since the functions are reimplemented here, the definitions are left

=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt	2011-05-17 17:31:51 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt	2011-05-18 01:02:52 +0000
@@ -73,6 +73,12 @@
 * ``bzr merge --no-remember location`` never sets ``submit_branch``.
   (Vincent Ladeuil, #782169)
 
+* ``bzr pull --no-remember location`` never sets
+  ``parent_location``.  ``bzr push --no-remember location`` never
+  sets ``push_location``.  ``bzr send --no-remember
+  submit_location public_location`` never sets ``submit_branch``
+  nor ``public_branch``.  (Vincent Ladeuil)
+
 * Correct parent is now set when using 'switch -b' with bound branches.
   (A. S. Budden, #513709)
 




More information about the bazaar-commits mailing list