--- a/hgext/evolve.py Thu Aug 23 12:51:34 2012 +0200
+++ b/hgext/evolve.py Thu Aug 23 12:51:06 2012 +0200
@@ -843,6 +843,57 @@
finally:
wlock.release()
+@command('^fold',
+ [('r', 'rev', [], 'revision to fold'),],
+ # allow to choose the seed ?
+ _('[-r] revs'))
+def fold(ui, repo, *revs, **opts):
+ """Fold multiple revision into a single one"""
+ revs = list(revs)
+ revs.extend(opts['rev'])
+ if not revs:
+ revs = ['.']
+ revs = scmutil.revrange(repo, revs)
+ if not revs:
+ ui.write_err('no revision to fold\n')
+ return 1
+ roots = repo.revs('roots(%ld)', revs)
+ if len(roots) > 1:
+ raise util.Abort("set have multiple roots")
+ root = repo[roots[0]]
+ if root.phase() <= phases.public:
+ raise util.Abort("can't touch public revision")
+ heads = repo.revs('heads(%ld)', revs)
+ if len(heads) > 1:
+ raise util.Abort("set have multiple heads")
+ head = repo[heads[0]]
+ obsolete = extensions.find('obsolete')
+ wlock = repo.wlock()
+ try:
+ lock = repo.lock()
+ try:
+ tr = repo.transaction('touch')
+ try:
+ allctx = [repo[r] for r in revs]
+ targetphase = max(c.phase() for c in allctx)
+ msg = '\n\n***\n\n'.join(c.description() for c in allctx)
+ newid, _ = rewrite(repo, root, allctx, head,
+ [root.p1().node(), root.p2().node()],
+ commitopts={'message': msg})
+ phases.retractboundary(repo, targetphase, [newid])
+ obsolete.createmarkers(repo, [(ctx, (repo[newid],))
+ for ctx in allctx])
+ tr.close()
+ finally:
+ tr.release()
+ finally:
+ lock.release()
+ ui.status('%i changesets folded\n' % len(revs))
+ if repo.revs('. and %ld', revs):
+ repo.dirstate.setparents(newid, node.nullid)
+ finally:
+ wlock.release()
+
def graftwrapper(orig, ui, repo, *revs, **kwargs):
kwargs = dict(kwargs)