# HG changeset patch # User Matt Mackall # Date 1196536167 21600 # Node ID de620356064ff9dcebcb77b8595c34b40368c332 # Parent 56e9f7b2d8fa73294bd9cf0d3826ce23e4b3c65c backout: disallow across branches (issue655) diff -r 56e9f7b2d8fa -r de620356064f mercurial/commands.py --- 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 diff -r 56e9f7b2d8fa -r de620356064f tests/test-backout --- 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 diff -r 56e9f7b2d8fa -r de620356064f tests/test-backout.out --- 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