Commits

Augie Fackler committed 73e85cd

--keep: never abort because of orphaning nodes

Since we're not destroying the original revisions, we stand no chance of
orphaning any revisions.

Comments (0)

Files changed (1)

 #
 """
 
-def between(repo, old, new):
+def between(repo, old, new, keep):
     revs = [old, ]
     current = old
     while current != new:
         ctx = repo[current]
-        if len(ctx.children()) > 1:
+        if not keep and len(ctx.children()) > 1:
             raise util.Abort('cannot edit history that would orphan nodes')
         if len(ctx.parents()) != 1 and ctx.parents()[1] != node.nullid:
             raise util.Abort("can't edit history with merges")
         else:
             current = ctx.children()[0].node()
             revs.append(current)
-    if len(repo[current].children()):
+    if len(repo[current].children()) and not keep:
         raise util.Abort('cannot edit history that would orphan nodes')
     return revs
 
 
         if len(parent) != 1:
             raise util.Abort('requires exactly one parent revision')
-        parent = parent[0]
+        parent = cmdutil.revsingle(repo, parent[0])
         # ensure that parent is stored as an unhexlified node
-        parent = repo[parent].node()
+        parent = parent.node()
 
-        revs = between(repo, parent, tip)
+        keep = opts.get('keep', False)
+        revs = between(repo, parent, tip, keep)
 
         ctxs = [repo[r] for r in revs]
         existing = [r.node() for r in ctxs]