hgext/histedit.py
changeset 17760 1b8e820ef19d
parent 17759 9c7497cd39fd
child 17761 c80a7a0c7d22
equal deleted inserted replaced
17759:9c7497cd39fd 17760:1b8e820ef19d
   585 
   585 
   586 def between(repo, old, new, keep):
   586 def between(repo, old, new, keep):
   587     """select and validate the set of revision to edit
   587     """select and validate the set of revision to edit
   588 
   588 
   589     When keep is false, the specified set can't have children."""
   589     When keep is false, the specified set can't have children."""
   590     revs = [old]
   590     revs = list(repo.set('%n::%n', old, new))
   591     current = old
   591     if not keep and repo.revs('(%ld::) - %ld', revs, revs):
   592     while current != new:
       
   593         ctx = repo[current]
       
   594         if not keep and len(ctx.children()) > 1:
       
   595             raise util.Abort(_('cannot edit history that would orphan nodes'))
       
   596         if len(ctx.parents()) != 1 and ctx.parents()[1] != node.nullid:
       
   597             raise util.Abort(_("can't edit history with merges"))
       
   598         if not ctx.children():
       
   599             current = new
       
   600         else:
       
   601             current = ctx.children()[0].node()
       
   602             revs.append(current)
       
   603     if len(repo[current].children()) and not keep:
       
   604         raise util.Abort(_('cannot edit history that would orphan nodes'))
   592         raise util.Abort(_('cannot edit history that would orphan nodes'))
   605     return revs
   593     return [c.node() for c in revs]
   606 
   594 
   607 
   595 
   608 def writestate(repo, parentnode, rules, keep, topmost, replacements):
   596 def writestate(repo, parentnode, rules, keep, topmost, replacements):
   609     fp = open(os.path.join(repo.path, 'histedit-state'), 'w')
   597     fp = open(os.path.join(repo.path, 'histedit-state'), 'w')
   610     pickle.dump((parentnode, rules, keep, topmost, replacements), fp)
   598     pickle.dump((parentnode, rules, keep, topmost, replacements), fp)