Rev 3299: (jam) Add --local to bzr uncommit, bug #93412 in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Thu Mar 20 18:06:26 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3299
revision-id:pqm at pqm.ubuntu.com-20080320180614-grrzhydka050ap3a
parent: pqm at pqm.ubuntu.com-20080320074642-46bf1vcpyubnaptz
parent: john at arbash-meinel.com-20080320162432-whjl8nhp3b5q0dj0
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2008-03-20 18:06:14 +0000
message:
(jam) Add --local to bzr uncommit, bug #93412
added:
bzrlib/tests/test_uncommit.py test_uncommit.py-20080316104338-y3gxu67g5m2qih10-1
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
bzrlib/uncommit.py uncommit.py-20050626215513-5ec509fa425b305c
------------------------------------------------------------
revno: 3280.3.5
revision-id:john at arbash-meinel.com-20080320162432-whjl8nhp3b5q0dj0
parent: john at arbash-meinel.com-20080320151005-z9lajjy69m20of17
parent: pqm at pqm.ubuntu.com-20080320074642-46bf1vcpyubnaptz
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: uncommit_local
timestamp: Thu 2008-03-20 11:24:32 -0500
message:
[merge] bzr.dev 3298, clean up NEWS conflicts.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/errors.py errors.py-20050309040759-20512168c4e14fbd
bzrlib/merge.py merge.py-20050513021216-953b65a438527106
bzrlib/plugin.py plugin.py-20050622060424-829b654519533d69
bzrlib/symbol_versioning.py symbol_versioning.py-20060105104851-9ecf8af605d15a80
bzrlib/tests/blackbox/test_mv.py test_mv.py-20060705114902-33tkxz0o9cdshemo-1
bzrlib/tests/bzrdir_implementations/test_bzrdir.py test_bzrdir.py-20060131065642-0ebeca5e30e30866
bzrlib/tests/test_commit.py test_commit.py-20050914060732-279f057f8c295434
bzrlib/tests/test_plugins.py plugins.py-20050622075746-32002b55e5e943e9
bzrlib/tests/test_smart.py test_smart.py-20061122024551-ol0l0o0oofsu9b3t-2
bzrlib/tests/workingtree_implementations/test_locking.py test_locking.py-20060707151933-tav3o2hpibwi53u4-3
bzrlib/trace.py trace.py-20050309040759-c8ed824bdcd4748a
bzrlib/transport/http/_urllib2_wrappers.py _urllib2_wrappers.py-20060913231729-ha9ugi48ktx481ao-1
bzrlib/ui/__init__.py ui.py-20050824083933-8cf663c763ba53a9
bzrlib/version.py version.py-20060816024207-ves6ult9a11taj9t-1
bzrlib/workingtree_4.py workingtree_4.py-20070208044105-5fgpc5j3ljlh5q6c-1
------------------------------------------------------------
revno: 3280.3.4
revision-id:john at arbash-meinel.com-20080320151005-z9lajjy69m20of17
parent: john at arbash-meinel.com-20080316104737-e7ffkpet97tkd9js
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: uncommit_local
timestamp: Thu 2008-03-20 10:10:05 -0500
message:
uncommit --local in an unbound branch raises the same exception as commit --local
modified:
bzrlib/tests/test_uncommit.py test_uncommit.py-20080316104338-y3gxu67g5m2qih10-1
bzrlib/uncommit.py uncommit.py-20050626215513-5ec509fa425b305c
------------------------------------------------------------
revno: 3280.3.3
revision-id:john at arbash-meinel.com-20080316104737-e7ffkpet97tkd9js
parent: john at arbash-meinel.com-20080316104553-hdwcnrpgav03o7i5
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: uncommit_local
timestamp: Sun 2008-03-16 10:47:37 +0000
message:
Update NEWS for fixing bug #93412
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
------------------------------------------------------------
revno: 3280.3.2
revision-id:john at arbash-meinel.com-20080316104553-hdwcnrpgav03o7i5
parent: john at arbash-meinel.com-20080316104411-t3lmcw0blmnoe0qo
parent: pqm at pqm.ubuntu.com-20080316140120-i3yq8yr1l66m11h7
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: uncommit_local
timestamp: Sun 2008-03-16 10:45:53 +0000
message:
[merge] bzr.dev 3286
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
README README-20050309040720-8f368abf9f346b9d
bzr bzr.py-20050313053754-5485f144c7006fa6
bzrlib/__init__.py __init__.py-20050309040759-33e65acf91bbcd5d
bzrlib/graph.py graph_walker.py-20070525030359-y852guab65d4wtn0-1
bzrlib/remote.py remote.py-20060720103555-yeeg2x51vn0rbtdp-1
bzrlib/repofmt/knitrepo.py knitrepo.py-20070206081537-pyy4a00xdas0j4pf-1
bzrlib/repofmt/pack_repo.py pack_repo.py-20070813041115-gjv5ma7ktfqwsjgn-1
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/revision.py revision.py-20050309040759-e77802c08f3999d5
bzrlib/revisionspec.py revisionspec.py-20050907152633-17567659fd5c0ddb
bzrlib/smart/repository.py repository.py-20061128022038-vr5wy5bubyb8xttk-1
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_upgrade.py test_upgrade.py-20060120060132-b41e5ed2f886ad28
bzrlib/tests/repository_implementations/test_repository.py test_repository.py-20060131092128-ad07f494f5c9d26c
bzrlib/tests/test_graph.py test_graph_walker.py-20070525030405-enq4r60hhi9xrujc-1
bzrlib/tests/test_merge.py testmerge.py-20050905070950-c1b5aa49ff911024
bzrlib/tests/test_revision.py testrevision.py-20050804210559-46f5e1eb67b01289
bzrlib/tests/test_upgrade.py test_upgrade.py-20051004040251-555fe1d2bae1bc71
bzrlib/upgrade.py history2weaves.py-20050818063535-e7d319791c19a8b2
setup.py setup.py-20050314065409-02f8a0a6e3f9bc70
------------------------------------------------------------
revno: 3280.3.1
revision-id:john at arbash-meinel.com-20080316104411-t3lmcw0blmnoe0qo
parent: pqm at pqm.ubuntu.com-20080315174441-l8xpw6femn0syal1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: uncommit_local
timestamp: Sun 2008-03-16 10:44:11 +0000
message:
Add uncommit --local.
Add some genuine whitebox testing of bzrlib.uncommit.uncommit
Add a local=??? flag to uncommit() and allow it being set by
uncommit --local.
added:
bzrlib/tests/test_uncommit.py test_uncommit.py-20080316104338-y3gxu67g5m2qih10-1
modified:
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/tests/__init__.py selftest.py-20050531073622-8d0e3c8845c97a64
bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
bzrlib/uncommit.py uncommit.py-20050626215513-5ec509fa425b305c
=== added file 'bzrlib/tests/test_uncommit.py'
--- a/bzrlib/tests/test_uncommit.py 1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/test_uncommit.py 2008-03-20 15:10:05 +0000
@@ -0,0 +1,98 @@
+# Copyright (C) 2008 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Test uncommit."""
+
+
+from bzrlib import (
+ errors,
+ tests,
+ uncommit,
+ )
+
+
+class TestUncommit(tests.TestCaseWithTransport):
+
+ def make_linear_tree(self):
+ tree = self.make_branch_and_tree('tree')
+ tree.lock_write()
+ try:
+ self.build_tree(['tree/one'])
+ tree.add('one')
+ rev_id1 = tree.commit('one')
+ self.build_tree(['tree/two'])
+ tree.add('two')
+ rev_id2 = tree.commit('two')
+ finally:
+ tree.unlock()
+ return tree, [rev_id1, rev_id2]
+
+ def test_uncommit(self):
+ tree, history = self.make_linear_tree()
+ self.assertEqual(history[1], tree.last_revision())
+ self.assertEqual((2, history[1]), tree.branch.last_revision_info())
+ uncommit.uncommit(tree.branch, tree=tree)
+ self.assertEqual(history[0], tree.last_revision())
+ self.assertEqual((1, history[0]), tree.branch.last_revision_info())
+
+ # The file should not be removed
+ self.failUnlessExists('tree/two')
+ # And it should still be listed as added
+ self.assertIsNot(None, tree.path2id('two'))
+
+ def test_uncommit_bound(self):
+ tree, history = self.make_linear_tree()
+ child = tree.bzrdir.sprout('child').open_workingtree()
+ child.branch.bind(tree.branch)
+
+ self.assertEqual(history[1], tree.last_revision())
+ self.assertEqual((2, history[1]), tree.branch.last_revision_info())
+ self.assertEqual(history[1], child.last_revision())
+ self.assertEqual((2, history[1]), child.branch.last_revision_info())
+
+ # Uncommit in a bound branch should uncommit the master branch, but not
+ # touch the other working tree.
+ uncommit.uncommit(child.branch, tree=child)
+
+ self.assertEqual(history[1], tree.last_revision())
+ self.assertEqual((1, history[0]), tree.branch.last_revision_info())
+ self.assertEqual(history[0], child.last_revision())
+ self.assertEqual((1, history[0]), child.branch.last_revision_info())
+
+ def test_uncommit_bound_local(self):
+ tree, history = self.make_linear_tree()
+ child = tree.bzrdir.sprout('child').open_workingtree()
+ child.branch.bind(tree.branch)
+
+ self.assertEqual(history[1], tree.last_revision())
+ self.assertEqual((2, history[1]), tree.branch.last_revision_info())
+ self.assertEqual(history[1], child.last_revision())
+ self.assertEqual((2, history[1]), child.branch.last_revision_info())
+
+ # Uncommit local=True should only affect the local branch
+ uncommit.uncommit(child.branch, tree=child, local=True)
+
+ self.assertEqual(history[1], tree.last_revision())
+ self.assertEqual((2, history[1]), tree.branch.last_revision_info())
+ self.assertEqual(history[0], child.last_revision())
+ self.assertEqual((1, history[0]), child.branch.last_revision_info())
+
+ def test_uncommit_unbound_local(self):
+ tree, history = self.make_linear_tree()
+
+ # If this tree isn't bound, local=True raises an exception
+ self.assertRaises(errors.LocalRequiresBoundBranch,
+ uncommit.uncommit, tree.branch, tree=tree, local=True)
=== modified file 'NEWS'
--- a/NEWS 2008-03-19 19:39:35 +0000
+++ b/NEWS 2008-03-20 16:24:32 +0000
@@ -36,6 +36,10 @@
* ``bzr mv a b`` can be now used also to rename previously renamed
directories, not only files. (Lukáš Lalinský, #107967)
+ * ``bzr uncommit --local`` can now remove revisions from the local
+ branch to be symmetric with ``bzr commit --local``.
+ (John Arbash Meinel, #93412)
+
* Don't ask for a password if there is no real terminal.
(Alexander Belchenko, #69851)
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2008-03-19 01:43:43 +0000
+++ b/bzrlib/builtins.py 2008-03-20 16:24:32 +0000
@@ -3657,14 +3657,19 @@
_see_also = ['commit']
takes_options = ['verbose', 'revision',
Option('dry-run', help='Don\'t actually make changes.'),
- Option('force', help='Say yes to all questions.')]
+ Option('force', help='Say yes to all questions.'),
+ Option('local',
+ help="Only remove the commits from the local branch"
+ " when in a checkout."
+ ),
+ ]
takes_args = ['location?']
aliases = []
encoding_type = 'replace'
def run(self, location=None,
dry_run=False, verbose=False,
- revision=None, force=False):
+ revision=None, force=False, local=False):
if location is None:
location = u'.'
control, relpath = bzrdir.BzrDir.open_containing(location)
@@ -3680,14 +3685,15 @@
else:
b.lock_write()
try:
- return self._run(b, tree, dry_run, verbose, revision, force)
+ return self._run(b, tree, dry_run, verbose, revision, force,
+ local=local)
finally:
if tree is not None:
tree.unlock()
else:
b.unlock()
- def _run(self, b, tree, dry_run, verbose, revision, force):
+ def _run(self, b, tree, dry_run, verbose, revision, force, local=False):
from bzrlib.log import log_formatter, show_log
from bzrlib.uncommit import uncommit
@@ -3735,7 +3741,7 @@
return 0
uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
- revno=revno)
+ revno=revno, local=local)
class cmd_break_lock(Command):
=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py 2008-03-16 00:28:48 +0000
+++ b/bzrlib/tests/__init__.py 2008-03-16 10:45:53 +0000
@@ -2743,6 +2743,7 @@
'bzrlib.tests.test_tsort',
'bzrlib.tests.test_tuned_gzip',
'bzrlib.tests.test_ui',
+ 'bzrlib.tests.test_uncommit',
'bzrlib.tests.test_upgrade',
'bzrlib.tests.test_urlutils',
'bzrlib.tests.test_versionedfile',
=== modified file 'bzrlib/tests/blackbox/test_uncommit.py'
--- a/bzrlib/tests/blackbox/test_uncommit.py 2007-12-11 14:36:31 +0000
+++ b/bzrlib/tests/blackbox/test_uncommit.py 2008-03-16 10:44:11 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006 Canonical Ltd
+# Copyright (C) 2005, 2006, 2008 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
@@ -110,6 +110,18 @@
b.pull(t_a.branch)
uncommit.uncommit(b)
+ def test_uncommit_bound_local(self):
+ t_a = self.make_branch_and_tree('a')
+ rev_id1 = t_a.commit('commit 1')
+ rev_id2 = t_a.commit('commit 2')
+ rev_id3 = t_a.commit('commit 3')
+ b = t_a.branch.create_checkout('b').branch
+
+ out, err = self.run_bzr(['uncommit', '--local', 'b', '--force'])
+ self.assertEqual(rev_id3, t_a.last_revision())
+ self.assertEqual((3, rev_id3), t_a.branch.last_revision_info())
+ self.assertEqual((2, rev_id2), b.last_revision_info())
+
def test_uncommit_revision(self):
wt = self.create_simple_tree()
=== modified file 'bzrlib/uncommit.py'
--- a/bzrlib/uncommit.py 2007-07-11 19:44:51 +0000
+++ b/bzrlib/uncommit.py 2008-03-20 15:10:05 +0000
@@ -20,12 +20,16 @@
import os
-from bzrlib import revision as _mod_revision
+from bzrlib import (
+ errors,
+ revision as _mod_revision,
+ )
from bzrlib.branch import Branch
from bzrlib.errors import BoundBranchOutOfDate
-def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None):
+def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None,
+ local=False):
"""Remove the last revision from the supplied branch.
:param dry_run: Don't actually change anything
@@ -45,10 +49,15 @@
if tree is not None:
pending_merges = tree.get_parent_ids()[1:]
- master = branch.get_master_branch()
- if master is not None:
- master.lock_write()
- unlockable.append(master)
+ if local:
+ master = None
+ if branch.get_bound_location() is None:
+ raise errors.LocalRequiresBoundBranch()
+ else:
+ master = branch.get_master_branch()
+ if master is not None:
+ master.lock_write()
+ unlockable.append(master)
rh = branch.revision_history()
if master is not None and rh[-1] != master.last_revision():
raise BoundBranchOutOfDate(branch, master)
More information about the bazaar-commits
mailing list