[PATCH 1 of 2 evolve-ext] evolve: remove --biject for prune
Laurent Charignon
lcharignon at fb.com
Fri Jun 26 00:17:14 UTC 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1435262280 25200
# Thu Jun 25 12:58:00 2015 -0700
# Node ID 0a1bf08ebdd93bfb199c18db4ea4e23c071e73cc
# Parent d3328e6775b1f23c6ab41ccd8712e02abb6eea72
evolve: remove --biject for prune
Before this patch, the prune function was expecting a --biject option to build
a bijection between precursor and successor. This is the only thing that makes
sense to do when we have more than 1 precusor and successor.
This patch removes the --biject option, making bijection the default behavior
when prune is given more than 1 precursor and more than 1 successor.
diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2092,7 +2092,6 @@ def _getmetadata(**opts):
('s', 'succ', [], _("successor changeset")),
('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")),
('B', 'bookmark', '', _("remove revs only reachable from given"
" bookmark"))] + metadataopts,
_('[OPTION] [-r] REV...'))
@@ -2111,16 +2110,16 @@ def cmdprune(ui, repo, *revs, **opts):
You can use the ``--succ`` option to inform 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 absorbed automatically).
-
+ If you precise one revision to prune and multiple successor, it is a split.
+ If you precise several commits and a single successor, it is a fold.
+ If you precise more than one revision to prune and more than one successor
+ there has to be one successor per revision to prune and a 1-1 bijection
+ is done.
"""
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')
if bookmark:
marks,revs = _reachablefrombookmark(repo, revs, bookmark)
@@ -2157,18 +2156,16 @@ def cmdprune(ui, repo, *revs, **opts):
sucs = scmutil.revrange(repo, succs)
sucs.sort()
sucs = tuple(repo[n] for n in sucs)
- 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:
+
+ if len(sucs) > 1 and len(precs) > 1:
+ # Bijection
+ if len(sucs) != len(precs):
+ msg = "Can't use %d successors for %d precursors" \
+ % (len(sucs), len(precs))
+ raise util.Abort(msg)
relations = [(p, (s,)) for p, s in zip(precs, sucs)]
+ else:
+ relations = [(p, sucs) for p in precs]
wdp = repo['.']
@@ -2515,7 +2512,6 @@ def stripwrapper(orig, ui, repo, *revs,
kwargs['rev'] = []
kwargs['new'] = []
kwargs['succ'] = []
- kwargs['biject'] = False
return cmdprune(ui, repo, *revs, **kwargs)
@command('^touch',
diff --git a/tests/test-prune.t b/tests/test-prune.t
--- a/tests/test-prune.t
+++ b/tests/test-prune.t
@@ -174,19 +174,6 @@ one old, two new
o 0:1f0dee641bb7[BABAR] (stable/public) add a
-two old, two new (should be denied)
-
- $ hg prune 'desc("add cc")' 'desc("add bb")' -s 'desc("add nD")' -s 'desc("add nC")'
- abort: Can't use multiple successors for multiple precursors
- [255]
- $ hg debugobsolete
- 9d206ffc875e1bc304590549be293be36821e66c 0 {47d2a3944de8b013de3be9578e8e344ea2e6c097} (Sat Dec 15 00:00:00 1979 +0000) {'user': 'blah'}
- 7c3bad9141dcb46ff89abf5f61856facd56e476c 0 {1f0dee641bb7258c56bd60e93edfa2405381c41e} (*) {'user': 'test'} (glob)
- 4538525df7e2b9f09423636c61ef63a4cb872a2d 0 {7c3bad9141dcb46ff89abf5f61856facd56e476c} (*) {'user': 'test'} (glob)
- 47d2a3944de8b013de3be9578e8e344ea2e6c097 0 {4538525df7e2b9f09423636c61ef63a4cb872a2d} (*) {'user': 'test'} (glob)
- bb5e90a7ea1f3b4b38b23150a4a597b6146d70ef 6e8148413dd541855b72a920a90c06fca127c7e7 0 (*) {'user': 'test'} (glob)
- 00ded550b1e28bba454bd34cec1269d22cf3ef25 aa96dc3f04c2c2341fe6880aeb6dc9fbffff9ef9 8ee176ff1d4b2034ce51e3efc579c2de346b631d 0 (*) {'user': 'test'} (glob)
-
two old, one new:
$ hg prune 'desc("add cc")' 'desc("add bb")' -s 'desc("add nB")'
@@ -209,7 +196,7 @@ two old, two new with --biject
created new head
$ mkcommit n2
- $ hg prune 'desc("add n1")::desc("add n2")' -s 'desc("add nD")::desc("add nE")' --biject
+ $ hg prune 'desc("add n1")::desc("add n2")' -s 'desc("add nD")::desc("add nE")'
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
working directory now at 1f0dee641bb7
2 changesets pruned
More information about the Mercurial-devel
mailing list