Rev 4493: push --strict is now the default in http://bazaar.launchpad.net/%7Evila/bzr/integration
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Jun 30 09:10:16 BST 2009
At http://bazaar.launchpad.net/%7Evila/bzr/integration
------------------------------------------------------------
revno: 4493 [merge]
revision-id: v.ladeuil+lp at free.fr-20090630081007-5zthi8fk1xkbtepb
parent: pqm at pqm.ubuntu.com-20090630063506-f7wlyoa0ldu816g0
parent: v.ladeuil+lp at free.fr-20090630080635-w9gmlrpta383usl1
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: integration
timestamp: Tue 2009-06-30 10:10:07 +0200
message:
push --strict is now the default
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-06-30 05:34:47 +0000
+++ b/NEWS 2009-06-30 08:10:07 +0000
@@ -21,9 +21,10 @@
New Features
************
-* ``bzr push`` now checks if uncommitted changes are present in the working
- tree if the ``--strict`` option is used.
- (Vincent Ladeuil, #284038)
+* ``bzr push`` now aborts if uncommitted changes (including pending merges)
+ are present in the working tree (if one is present) and no revision is
+ speified. The configuration option ``push_strict`` can be used to set the
+ default for this behavior. (Vincent Ladeuil, #284038, #322808, #65286)
Bug Fixes
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2009-06-26 03:44:30 +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 strict:
- changes = tree.changes_from(tree.basis_tree())
- if changes.has_changed():
- 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/errors.py'
--- a/bzrlib/errors.py 2009-06-19 00:33:36 +0000
+++ b/bzrlib/errors.py 2009-06-30 08:06:35 +0000
@@ -2778,7 +2778,8 @@
class UncommittedChanges(BzrError):
- _fmt = 'Working tree "%(display_url)s" has uncommitted changes.'
+ _fmt = ('Working tree "%(display_url)s" has uncommitted changes'
+ ' (See bzr status).')
def __init__(self, tree):
import bzrlib.urlutils as urlutils
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2009-06-22 08:14:24 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2009-06-29 09:02:28 +0000
@@ -35,6 +35,28 @@
from bzrlib.transport import memory
+def load_tests(standard_tests, module, loader):
+ """Multiply tests for the push command."""
+ result = loader.suiteClass()
+
+ # one for each king of change
+ changes_tests, remaining_tests = tests.split_suite_by_condition(
+ standard_tests, tests.condition_isinstance((
+ TestPushStrictWithChanges,
+ )))
+ changes_scenarios = [
+ ('uncommitted',
+ dict(_changes_type= '_uncommitted_changes')),
+ ('pending_merges',
+ dict(_changes_type= '_pending_merges')),
+ ]
+ tests.multiply_tests(changes_tests, changes_scenarios, result)
+ # No parametrization for the remaining tests
+ result.addTests(remaining_tests)
+
+ return result
+
+
class TestPush(tests.TestCaseWithTransport):
def test_push_error_on_vfs_http(self):
@@ -569,72 +591,112 @@
class TestPushStrict(tests.TestCaseWithTransport):
def make_local_branch_and_tree(self):
- tree = self.make_branch_and_tree('local')
+ self.tree = self.make_branch_and_tree('local')
self.build_tree_contents([('local/file', 'initial')])
- tree.add('file')
- tree.commit('adding file', rev_id='from-1')
- return tree
-
- def make_local_branch_and_tree_with_changes(self):
- tree = self.make_local_branch_and_tree()
- # Make some changes
+ self.tree.add('file')
+ self.tree.commit('adding file', rev_id='added')
self.build_tree_contents([('local/file', 'modified')])
- return tree
+ self.tree.commit('modify file', rev_id='modified')
- def set_config_push_strict(self, tree, value):
+ def set_config_push_strict(self, value):
# set config var (any of bazaar.conf, locations.conf, branch.conf
# should do)
- conf = tree.branch.get_config()
+ conf = self.tree.branch.get_config()
conf.set_user_option('push_strict', value)
- def assertPushFails(self, location, *args):
+ def assertPushFails(self, args):
self.run_bzr_error(['Working tree ".*/local/"'
' has uncommitted changes.$',],
- ['push', '../' + location] + list(args),
+ ['push', '../to'] + args,
working_dir='local', retcode=3)
- def assertPushSucceeds(self, location, *args):
- self.run_bzr(['push', '../' + location] + list(args),
+ def assertPushSucceeds(self, args, pushed_revid=None):
+ self.run_bzr(['push', '../to'] + args,
working_dir='local')
- tree_to = workingtree.WorkingTree.open(location)
+ 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')
-
- def test_push_default(self):
- tree = self.make_local_branch_and_tree_with_changes()
- self.assertPushSucceeds('to')
-
- def test_push_no_strict_with_changes(self):
- tree = self.make_local_branch_and_tree_with_changes()
- self.assertPushSucceeds('to', '--no-strict')
+ self.assertTrue(repo_to.has_revision(pushed_revid))
+ self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
+
+
+
+class TestPushStrictWithoutChanges(TestPushStrict):
+
+ def setUp(self):
+ super(TestPushStrictWithoutChanges, self).setUp()
+ self.make_local_branch_and_tree()
+
+ def test_push_default(self):
+ self.assertPushSucceeds([])
+
+ def test_push_strict(self):
+ self.assertPushSucceeds(['--strict'])
+
+ def test_push_no_strict(self):
+ self.assertPushSucceeds(['--no-strict'])
+
+ def test_push_config_var_strict(self):
+ self.set_config_push_strict('true')
+ self.assertPushSucceeds([])
+
+ def test_push_config_var_no_strict(self):
+ self.set_config_push_strict('false')
+ self.assertPushSucceeds([])
+
+
+class TestPushStrictWithChanges(TestPushStrict):
+
+ _changes_type = None # Set by load_tests
+
+ def setUp(self):
+ super(TestPushStrictWithChanges, self).setUp()
+ getattr(self, self._changes_type)()
+
+ def _uncommitted_changes(self):
+ self.make_local_branch_and_tree()
+ # Make a change without committing it
+ self.build_tree_contents([('local/file', 'in progress')])
+
+ def _pending_merges(self):
+ self.make_local_branch_and_tree()
+ # Create 'other' branch containing a new file
+ other_bzrdir = self.tree.bzrdir.sprout('other')
+ other_tree = other_bzrdir.open_workingtree()
+ self.build_tree_contents([('other/other-file', 'other')])
+ other_tree.add('other-file')
+ other_tree.commit('other commit', rev_id='other')
+ # Merge and revert, leaving a pending merge
+ self.tree.merge_from_branch(other_tree.branch)
+ self.tree.revert(filenames=['other-file'], backups=False)
+
+ def test_push_default(self):
+ self.assertPushFails([])
+
+ 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):
- tree = self.make_local_branch_and_tree_with_changes()
- self.assertPushFails('to', '--strict')
-
- def test_push_strict_without_changes(self):
- tree = self.make_local_branch_and_tree()
- self.assertPushSucceeds('to', '--strict')
+ self.assertPushFails(['--strict'])
def test_push_respect_config_var_strict(self):
- tree = self.make_local_branch_and_tree_with_changes()
- self.set_config_push_strict(tree, 'true')
- self.assertPushFails('to')
+ self.set_config_push_strict('true')
+ self.assertPushFails([])
def test_push_bogus_config_var_ignored(self):
- tree = self.make_local_branch_and_tree_with_changes()
- self.set_config_push_strict(tree, "I don't want you to be strict")
- self.assertPushSucceeds('to')
+ self.set_config_push_strict("I don't want you to be strict")
+ self.assertPushFails([])
def test_push_no_strict_command_line_override_config(self):
- tree = self.make_local_branch_and_tree_with_changes()
- self.set_config_push_strict(tree, 'yES')
- self.assertPushFails('to')
- self.assertPushSucceeds('to', '--no-strict')
+ self.set_config_push_strict('yES')
+ self.assertPushFails([])
+ self.assertPushSucceeds(['--no-strict'])
def test_push_strict_command_line_override_config(self):
- tree = self.make_local_branch_and_tree_with_changes()
- self.set_config_push_strict(tree, 'oFF')
- self.assertPushFails('to', '--strict')
- self.assertPushSucceeds('to')
+ self.set_config_push_strict('oFF')
+ self.assertPushFails(['--strict'])
+ self.assertPushSucceeds([])
More information about the bazaar-commits
mailing list