[PATCH 1 of 1] backout: add a --linear option to rebase the backout
Gilles Moris
gilles.moris at free.fr
Mon Sep 13 02:24:08 CDT 2010
# HG changeset patch
# User Gilles Moris <gilles.moris at free.fr>
# Date 1284107298 -7200
# Node ID 1c8397d0983aaae32b79e1bd12ccc5d74ca6464b
# Parent 1ed2dc9d4368ed9676e970d300dfb8d822ce1cab
backout: add a --linear option to rebase the backout
diff -r 1ed2dc9d4368 -r 1c8397d0983a mercurial/commands.py
--- a/mercurial/commands.py Sun Sep 12 16:10:41 2010 +0900
+++ b/mercurial/commands.py Fri Sep 10 10:28:18 2010 +0200
@@ -216,6 +216,14 @@
def backout(ui, repo, node=None, rev=None, **opts):
'''reverse effect of earlier changeset
+ If the --linear option is given, the change will be backed out
+ and ready to be committed. This will result in a linear history.
+ There will be no additional action needed but your commit message
+ should contain a reference to the backed out changeset if you
+ want to keep a trace of this operation.
+ The rest of the help content applies if the --linear option is
+ not given.
+
Commit the backed out changes as a new changeset. The new
changeset is a child of the backed out changeset.
@@ -241,6 +249,9 @@
if not rev:
raise util.Abort(_("please specify a revision to backout"))
+ if opts.get('linear') and opts.get('merge'):
+ raise util.Abort(_("cannot specify both --linear and --merge"))
+
date = opts.get('date')
if date:
opts['date'] = util.parsedate(date)
@@ -280,6 +291,9 @@
revert_opts['rev'] = hex(parent)
revert_opts['no_backup'] = None
revert(ui, repo, **revert_opts)
+ if opts.get('linear') and op1 != node:
+ return hg.update(repo, op1)
+
commit_opts = opts.copy()
commit_opts['addremove'] = False
if not commit_opts['message'] and not commit_opts['logfile']:
@@ -4050,6 +4064,8 @@
(backout,
[('', 'merge', None,
_('merge with old dirstate parent after backout')),
+ ('', 'linear', None,
+ _('rebase the backout directly on top of the current parent')),
('', 'parent', '',
_('parent to choose when backing out merge'), _('REV')),
('r', 'rev', '',
diff -r 1ed2dc9d4368 -r 1c8397d0983a tests/test-backout.t
--- a/tests/test-backout.t Sun Sep 12 16:10:41 2010 +0900
+++ b/tests/test-backout.t Fri Sep 10 10:28:18 2010 +0200
@@ -9,6 +9,8 @@
abort: please specify a revision to backout
$ hg backout -r 0 0
abort: please specify just one revision
+ $ hg backout --linear --merge 0
+ abort: cannot specify both --linear and --merge
# basic operation
@@ -252,4 +254,45 @@
C default
C file1
+ $ cd ..
+
+check for linear backout
+
+ $ hg init linear
+ $ cd linear
+ $ echo line 0 > a
+ $ echo line 1 >> a
+ $ hg add a
+ $ hg ci -d '0 0' -m 0
+change first line
+ $ echo line x > a
+ $ echo line 1 >> a
+ $ hg ci -d '1 0' -m 1
+add line 2
+ $ echo line 2 >> a
+ $ hg ci -d '2 0' -m 2
+
+backout with merge
+ $ hg backout --linear 1
+ reverting a
+ merging a
+ 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+ $ cat a
+ line 0
+ line 1
+ line 2
+ $ hg id -n
+ 2+
+
+backout the tip
+ $ hg update --quiet --clean
+ $ hg backout --linear tip
+ reverting a
+ changeset 3:cbc01815b68f backs out changeset 2:9f67d2a2d22f
+ $ cat a
+ line x
+ line 1
+ $ hg id -n
+ 3
+
$ exit 0
diff -r 1ed2dc9d4368 -r 1c8397d0983a tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t Sun Sep 12 16:10:41 2010 +0900
+++ b/tests/test-debugcomplete.t Fri Sep 10 10:28:18 2010 +0200
@@ -195,7 +195,7 @@
update: clean, check, date, rev
addremove: similarity, include, exclude, dry-run
archive: no-decode, prefix, rev, type, include, exclude
- backout: merge, parent, rev, include, exclude, message, logfile, date, user
+ backout: merge, linear, parent, rev, include, exclude, message, logfile, date, user
bisect: reset, good, bad, skip, command, noupdate
branch: force, clean
branches: active, closed
More information about the Mercurial-devel
mailing list