diff mercurial/commands.py @ 5568:de620356064f

backout: disallow across branches (issue655)
author Matt Mackall <mpm@selenic.com>
date Sat, 01 Dec 2007 13:09:27 -0600
parents 253736bb0dc9
children e2da5b340651
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