prune: add biject option
This option allows two ranges to be given for successors and precursors such
that there is a one-to-one match between each range.
Test coverage has been added.
--- a/hgext/evolve.py Fri Feb 07 09:36:42 2014 +0100
+++ b/hgext/evolve.py Tue Feb 11 00:02:18 2014 -0600
@@ -1387,6 +1387,7 @@
[('n', 'new', [], _("successor changeset (DEPRECATED)")),
('s', 'succ', [], _("successor changeset")),
('r', 'rev', [], _("revisions to prune")),
+ ('', 'biject', False, _("do a 1-1 map between rev and successor ranges")),
('B', 'bookmark', '', _("remove revs only reachable from given"
" bookmark"))] + metadataopts,
_('[OPTION] [-r] REV...'))
@@ -1402,13 +1403,19 @@
When the working directory parent is pruned the repository is updated to a
non obsolete parents.
- you can use the ``--succ`` option to informs mercurial that a newer version
+ You can use the ``--succ`` option to informs mercurial that a newer version
of the pruned changeset exists.
+
+ You can use the ``--biject`` option to specify a 1-1 (bijection) between
+ revisions to prune and successor changesets. This option may be removed in
+ a future release (with the functionality absored automatically).
+
"""
revs = set(scmutil.revrange(repo, list(revs) + opts.get('rev')))
succs = opts['new'] + opts['succ']
bookmark = opts.get('bookmark')
metadata = _getmetadata(**opts)
+ biject = opts.get('biject')
if bookmark:
marks,revs = _reachablefrombookmark(repo, revs, bookmark)
@@ -1438,11 +1445,20 @@
# defines successors changesets
sucs = tuple(repo[n] for n in sortedrevs(succs))
- if len(sucs) > 1 and len(precs) > 1:
+ 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):
+ 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:
+ relations = [(p, (s,)) for p, s in zip(precs, sucs)]
+
# create markers
- createmarkers(repo, [(p, sucs) for p in precs], metadata=metadata)
+ createmarkers(repo, relations, metadata=metadata)
# informs that changeset have been pruned
ui.status(_('%i changesets pruned\n') % len(precs))
--- a/tests/test-prune.t Fri Feb 07 09:36:42 2014 +0100
+++ b/tests/test-prune.t Tue Feb 11 00:02:18 2014 -0600
@@ -195,6 +195,30 @@
814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 {'date': '*', 'user': 'test'} (glob)
354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 {'date': '*', 'user': 'test'} (glob)
+two old, two new with --biject
+
+ $ hg up 0
+ 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+ $ mkcommit n1
+ created new head
+ $ mkcommit n2
+
+ $ hg prune 'desc("add n1")::desc("add n2")' -s 'desc("add nD")::desc("add nE")' --biject
+ 2 changesets pruned
+ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+ working directory now at 1f0dee641bb7
+ $ hg debugobsolete
+ 9d206ffc875e1bc304590549be293be36821e66c 0 {'date': '314064000 0', 'user': 'blah'} (glob)
+ 7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {'date': '*', 'user': 'test'} (glob)
+ 4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {'date': '*', 'user': 'test'} (glob)
+ 47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {'date': '*', 'user': 'test'} (glob)
+ bb5e90a7ea1f3b4b38b23150a4a597b6146d70ef 6e8148413dd541855b72a920a90c06fca127c7e7 0 {'date': '*', 'user': 'test'} (glob)
+ 00ded550b1e28bba454bd34cec1269d22cf3ef25 aa96dc3f04c2c2341fe6880aeb6dc9fbffff9ef9 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 {'date': '**', 'user': 'test'} (glob)
+ 814c38b95e72dfe2cbf675b1649ea9d780c89a80 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 {'date': '* *', 'user': 'test'} (glob)
+ 354011cd103f58bbbd9091a3cee6d6a6bd0dddf7 6f6f25e4f748d8f7571777e6e168aedf50350ce8 0 {'date': '* *', 'user': 'test'} (glob)
+ cb7f8f706a6532967b98cf8583a81baab79a0fa7 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 {'date': '* *', 'user': 'test'} (glob)
+ 21b6f2f1cece8c10326e575dd38239189d467190 6e8148413dd541855b72a920a90c06fca127c7e7 0 {'date': '* *', 'user': 'test'} (glob)
+
test hg prune -B bookmark
yoinked from test-mq-strip.t