Rev 4490: --strict is meaningless when --revision is specified. in file:///home/vila/src/bzr/bugs/284038-push-strict/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Jun 29 10:02:29 BST 2009


At file:///home/vila/src/bzr/bugs/284038-push-strict/

------------------------------------------------------------
revno: 4490
revision-id: v.ladeuil+lp at free.fr-20090629090228-ie3jj7l61r9ljl9f
parent: v.ladeuil+lp at free.fr-20090629074215-20obt2o5l57cvq72
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 284038-push-strict
timestamp: Mon 2009-06-29 11:02:28 +0200
message:
  --strict is meaningless when --revision is specified.
  
  * tests/blackbox/test_push.py:
  (load_tests): Switch to name based indirection following IRC chat
  with lifeless, spiv and poolie.
  (TestPushStrictWithChanges._changes_type): Now a string
  (TestPushStrictWithChanges.setUp): Use getattr to call the right
  bound method.
  (TestPushStrict.make_local_branch_and_tree): Add one commit so we
  have meat for push --revision.
  (TestPushStrict.assertPushSucceeds): Add a pushed_revid parameter.
  (TestPushStrictWithChanges.test_push_with_revision): New test.
  
  * builtins.py:
  (cmd_push.run): Don't look at --strict' when '--revision' is
  specified.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2009-06-29 07:14:23 +0000
+++ b/NEWS	2009-06-29 09:02:28 +0000
@@ -22,9 +22,9 @@
 ************
 
 * ``bzr push`` now aborts if uncommitted changes (including pending merges)
-  are present in the working tree (if one is present). The ``push_strict``
-  option can be declared in a configuration file.  option is used.
-  (Vincent Ladeuil, #284038)
+  are present in the working tree (if one is present) and no revision is
+  speficied. The ``push_strict`` option can be declared in a configuration
+  file.  option is used.  (Vincent Ladeuil, #284038, #322808, #65286)
 
 
 Bug Fixes

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-06-29 07:14:23 +0000
+++ b/bzrlib/builtins.py	2009-06-29 09:02:28 +0000
@@ -1057,16 +1057,17 @@
                     strict = bools[strict.lower()]
                 except KeyError:
                     strict = None
-        if tree is not None and (strict is None or strict): # Default to True:
-            changes = tree.changes_from(tree.basis_tree())
-            if changes.has_changed() or len(tree.get_parent_ids()) > 1:
-                raise errors.UncommittedChanges(tree)
         # Get the tip's revision_id
         revision = _get_one_revision('push', revision)
         if revision is not None:
             revision_id = revision.in_history(br_from).rev_id
         else:
             revision_id = None
+        if (tree is not None and revision_id is None
+            and (strict is None or strict)): # Default to True:
+            changes = tree.changes_from(tree.basis_tree())
+            if changes.has_changed() or len(tree.get_parent_ids()) > 1:
+                raise errors.UncommittedChanges(tree)
 
         # Get the stacked_on branch, if any
         if stacked_on is not None:

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-06-29 07:42:15 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-06-29 09:02:28 +0000
@@ -46,9 +46,9 @@
                 )))
     changes_scenarios = [
         ('uncommitted',
-         dict(_do_changes= TestPushStrictWithChanges.do_uncommitted_changes)),
+         dict(_changes_type= '_uncommitted_changes')),
         ('pending_merges',
-         dict(_do_changes= TestPushStrictWithChanges.do_pending_merges)),
+         dict(_changes_type= '_pending_merges')),
         ]
     tests.multiply_tests(changes_tests, changes_scenarios, result)
     # No parametrization for the remaining tests
@@ -594,7 +594,9 @@
         self.tree = self.make_branch_and_tree('local')
         self.build_tree_contents([('local/file', 'initial')])
         self.tree.add('file')
-        self.tree.commit('adding file', rev_id='from-1')
+        self.tree.commit('adding file', rev_id='added')
+        self.build_tree_contents([('local/file', 'modified')])
+        self.tree.commit('modify file', rev_id='modified')
 
     def set_config_push_strict(self, value):
         # set config var (any of bazaar.conf, locations.conf, branch.conf
@@ -608,13 +610,15 @@
                            ['push', '../to'] + args,
                            working_dir='local', retcode=3)
 
-    def assertPushSucceeds(self, args):
+    def assertPushSucceeds(self, args, pushed_revid=None):
         self.run_bzr(['push', '../to'] + args,
                      working_dir='local')
+        if pushed_revid is None:
+            pushed_revid = 'modified'
         tree_to = workingtree.WorkingTree.open('to')
         repo_to = tree_to.branch.repository
-        self.assertTrue(repo_to.has_revision('from-1'))
-        self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
+        self.assertTrue(repo_to.has_revision(pushed_revid))
+        self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
 
 
 
@@ -644,21 +648,18 @@
 
 class TestPushStrictWithChanges(TestPushStrict):
 
-    _do_changes = None # Set by load_tests
+    _changes_type = None # Set by load_tests
 
     def setUp(self):
         super(TestPushStrictWithChanges, self).setUp()
-        # FIXME: The following is a bit ugly, but I don't know how to bind the
-        # method properly, yet I want to define the method to call in
-        # load_tests(). -- vila 20090626
-        self._do_changes(self)
+        getattr(self, self._changes_type)()
 
-    def do_uncommitted_changes(self):
+    def _uncommitted_changes(self):
         self.make_local_branch_and_tree()
         # Make a change without committing it
-        self.build_tree_contents([('local/file', 'modified')])
+        self.build_tree_contents([('local/file', 'in progress')])
 
-    def do_pending_merges(self):
+    def _pending_merges(self):
         self.make_local_branch_and_tree()
         # Create 'other' branch containing a new file
         other_bzrdir = self.tree.bzrdir.sprout('other')
@@ -673,7 +674,10 @@
     def test_push_default(self):
         self.assertPushFails([])
 
-    def test_push_no_strict_with_changes(self):
+    def test_push_with_revision(self):
+        self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
+
+    def test_push_no_strict(self):
         self.assertPushSucceeds(['--no-strict'])
 
     def test_push_strict_with_changes(self):



More information about the bazaar-commits mailing list