Mercurial > hg-stable
changeset 5568:de620356064f
backout: disallow across branches (issue655)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 01 Dec 2007 13:09:27 -0600 |
parents | 56e9f7b2d8fa |
children | 9e209193f18d |
files | mercurial/commands.py tests/test-backout tests/test-backout.out |
diffstat | 3 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Dec 01 12:54:34 2007 -0600 +++ b/mercurial/commands.py Sat Dec 01 13:09:27 2007 -0600 @@ -194,6 +194,11 @@ if op2 != nullid: raise util.Abort(_('outstanding uncommitted merge')) node = repo.lookup(rev) + + a = repo.changelog.ancestor(op1, node) + if a != node: + raise util.Abort(_('cannot back out change on a different branch')) + p1, p2 = repo.changelog.parents(node) if p1 == nullid: raise util.Abort(_('cannot back out a change with no parents')) @@ -210,6 +215,7 @@ if opts['parent']: raise util.Abort(_('cannot use --parent on non-merge changeset')) parent = p1 + hg.clean(repo, node, show_stats=False) revert_opts = opts.copy() revert_opts['date'] = None
--- a/tests/test-backout Sat Dec 01 12:54:34 2007 -0600 +++ b/tests/test-backout Sat Dec 01 13:09:27 2007 -0600 @@ -37,6 +37,22 @@ hg backout -d '3 0' --merge tip cat a 2>/dev/null || echo cat: a: No such file or directory +echo '# across branch' +cd .. +hg init branch +cd branch +echo a > a +hg ci -Am0 -d '0 0' +echo b > b +hg ci -Am1 -d '0 0' +hg co -C 0 +# should fail +hg backout -d '0 0' 1 +echo c > c +hg ci -Am2 -d '0 0' +# should fail +hg backout -d '0 0' 1 + echo '# backout with merge' cd .. hg init merge
--- a/tests/test-backout.out Sat Dec 01 12:54:34 2007 -0600 +++ b/tests/test-backout.out Sat Dec 01 13:09:27 2007 -0600 @@ -15,6 +15,13 @@ removing a changeset 3:7f6d0f120113 backs out changeset 2:de31bdc76c0d cat: a: No such file or directory +# across branch +adding a +adding b +0 files updated, 0 files merged, 1 files removed, 0 files unresolved +abort: cannot back out change on a different branch +adding c +abort: cannot back out change on a different branch # backout with merge adding a reverting a