[PATCH 2 of 2 evolve-ext] evolve: add the next() revset
Laurent Charignon
lcharignon at fb.com
Thu Jun 4 19:06:08 CDT 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1433461833 25200
# Thu Jun 04 16:50:33 2015 -0700
# Node ID 5367886c7c250c623b4dd9e2ae57f915c63bf4f3
# Parent 6910cd198dd7824af651d72b224cf66966f59788
evolve: add the next() revset
The next() revset encompasses all the revisions that will be stabilized on '.'.
If a set is given to the next revset, it means all the revisions that will
be stabilized on that set.
diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -431,6 +431,55 @@
ui.setconfig('alias', 'grab',
"! $HG rebase --dest . --rev $@ && $HG up tip")
+### Next revset symbol
+ at eh.revset('next')
+def revsetnext(repo, subset, x):
+ """``next()``
+ Returns the changesets that stabilize on top of a subset
+ Consider the following graph:
+
+ O d
+ | O f
+ e O - - - X |
+ \ | X - - O g
+ \ c O /
+ \ | /
+ \ b O/
+ \ |
+ \ |
+ \O a
+
+ next(e) is d
+ next(g) if f
+ next(f) is empty
+ next(head()) is d and f
+
+ Default argument is '.'
+ """
+ args = revset.getargs(x, 0, 1, 'next takes one or no arguments')
+ troubled = set()
+ troubled.update(getrevs(repo, 'unstable'))
+ if args:
+ s = revset.getset(repo, subset, x)
+ else:
+ s = set([repo['.'].rev()])
+
+ troubled.update(s)
+
+ # Iterate through the reverse dependency graph from the current node
+ # to find all the revs that will stabilize on top
+ _ , _rorder = builddependencies(repo, troubled)
+ queue = collections.deque()
+ for r in s:
+ for dependency in _rorder[r]:
+ queue.append(dependency)
+
+ nextset = set()
+ while queue:
+ r = queue.popleft()
+ queue.extend([x for x in _rorder[r] if x not in nextset])
+ nextset.add(r)
+ return subset & revset.baseset(nextset)
### Troubled revset symbol
diff --git a/tests/test-evolve.t b/tests/test-evolve.t
--- a/tests/test-evolve.t
+++ b/tests/test-evolve.t
@@ -1212,6 +1212,17 @@
o 25:4c0bc042ef3b at default(draft) add j1
|
+Check the next() revset:
+ $ hg log -r 'next(4a34f6744d4b)'
+ 38 : add c3_ - test
+ 41 : add c2prime - test
+ $ hg log -r 'next()'
+ 46 : add b4_ - test
+ $ hg log -r 'next(head())'
+ 38 : add c3_ - test
+ 41 : add c2prime - test
+ 46 : add b4_ - test
+
Solve the full second stack and only part of the first one
$ echo "(25::) - $(shaof c3_)"
(25::) - 28172de7eb73578cf665e868a265caf2a2655c66
More information about the Mercurial-devel
mailing list