Mercurial > evolve
diff hgext/evolve.py @ 1471:4140d680784e
evolve: (issue4386) cleanup, split, fold and bijection in `hg prune`
Before this patch, the prune command was splitting and folding implicitely
based on the number of successors and precursors. This patch makes the
two behavior explicit by requesting a flag to perform a split or a fold.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 25 Jun 2015 13:33:50 -0700 |
parents | fa1a27009c76 |
children | 9603aa1ecdfd |
line wrap: on
line diff
--- a/hgext/evolve.py Tue Jun 30 18:32:12 2015 -0700 +++ b/hgext/evolve.py Thu Jun 25 13:33:50 2015 -0700 @@ -2137,6 +2137,8 @@ ('r', 'rev', [], _("revisions to prune")), ('k', 'keep', None, _("does not modify working copy during prune")), ('', 'biject', False, _("do a 1-1 map between rev and successor ranges")), + ('', 'fold', False, _("record a fold (multiple precursors, one successors)")), + ('', 'split', False, _("record a split (on precursor, multiple successors)")), ('B', 'bookmark', '', _("remove revs only reachable from given" " bookmark"))] + metadataopts, _('[OPTION] [-r] REV...')) @@ -2159,12 +2161,22 @@ revisions to prune and successor changesets. This option may be removed in a future release (with the functionality absorbed automatically). + If you specify multiple revisions in --succ, you are recording a "split" + and have to acknowledge it by usng --split. The same logic apply when you + prune multiple changesets with a single successors, this will record a + "fold" requires a --fold flag. """ revs = scmutil.revrange(repo, list(revs) + opts.get('rev')) succs = opts['new'] + opts['succ'] bookmark = opts.get('bookmark') metadata = _getmetadata(**opts) biject = opts.get('biject') + fold = opts.get('fold') + split = opts.get('split') + + options = [o for o in ('biject', 'fold', 'split') if opts.get(o)] + if 1 < len(options): + raise util.Abort(_("can only specify one of %s") % ', '.join(options)) if bookmark: marks,revs = _reachablefrombookmark(repo, revs, bookmark) @@ -2204,15 +2216,20 @@ if not biject and len(sucs) > 1 and len(precs) > 1: msg = "Can't use multiple successors for multiple precursors" raise util.Abort(msg) - - if biject and len(sucs) != len(precs): + elif biject and len(sucs) != len(precs): msg = "Can't use %d successors for %d precursors" \ % (len(sucs), len(precs)) raise util.Abort(msg) - - relations = [(p, sucs) for p in precs] - if biject: + elif (len(precs) == 1 and len(sucs) > 1) and not split: + msg = "please add --split if you want to do a split" + raise util.Abort(msg) + elif len(sucs) == 1 and len(precs) > 1 and not fold: + msg = "please add --fold if you want to do a fold" + raise util.Abort(msg) + elif biject: relations = [(p, (s,)) for p, s in zip(precs, sucs)] + else: + relations = [(p, sucs) for p in precs] wdp = repo['.']