# HG changeset patch # User Pierre-Yves David # Date 1345719066 -7200 # Node ID d2531a747ff59e3e65cbc308d91e67348e3ff6d7 # Parent 4e0f1aae8d24432eec4e767e2bef76f41a2df131 evolve: fold command First crude version of a fold command diff -r 4e0f1aae8d24 -r d2531a747ff5 README --- a/README Thu Aug 23 12:51:34 2012 +0200 +++ b/README Thu Aug 23 12:51:06 2012 +0200 @@ -52,6 +52,8 @@ - merge and update ignore extinct changeset in most case. - new "troubled()" revset - summary now reports troubles changesets +- new touch command +- new fold command - rebase refuse to work on public changeset again - rebase explicitly state that there is nothing to rebase because everything is diff -r 4e0f1aae8d24 -r d2531a747ff5 hgext/evolve.py --- 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) diff -r 4e0f1aae8d24 -r d2531a747ff5 tests/test-evolve.t --- a/tests/test-evolve.t Thu Aug 23 12:51:34 2012 +0200 +++ b/tests/test-evolve.t Thu Aug 23 12:51:06 2012 +0200 @@ -526,7 +526,7 @@ $ hg touch $ glog - @ 9:7a2f49fdcf11@default(draft) conflict + @ 9:*@default(draft) conflict (glob) | o 6:acb28cd497b7@default(draft) add 1 | @@ -540,7 +540,7 @@ $ hg touch . $ glog - @ 10:ce7e3d9b3afe@default(draft) conflict + @ 10:*@default(draft) conflict (glob) | o 6:acb28cd497b7@default(draft) add 1 | @@ -552,4 +552,25 @@ |/ o 0:8685c6d34325@default(draft) add 0 - + +Test fold + + $ hg fold 6::10 + 2 changesets folded + $ glog + @ 11:*@default(draft) add 1 (glob) + | + o 5:0b9e50c35132@default(draft) add 3 + | + o 4:ce341209337f@default(draft) add 4 + | + | o 1:73d38bb17fd7@default(draft) add 1 + |/ + o 0:8685c6d34325@default(draft) add 0 + + $ hg log -r 11 --template '{desc}\n' + add 1 + + *** + + conflict