Patchwork [2,of,4,evolve-ext] evolve: add _nextcandidate a revset to get the target for hg evolve with no arg

login
register
mail settings
Submitter Laurent Charignon
Date June 22, 2015, 10:42 p.m.
Message ID <34f4e918c71d29989e08.1435012921@lcharignon-mbp.local>
Download mbox | patch
Permalink /patch/9757/
State Changes Requested
Delegated to: Pierre-Yves David
Headers show

Comments

Laurent Charignon - June 22, 2015, 10:42 p.m.
# HG changeset patch
# User Laurent Charignon <lcharignon@fb.com>
# Date 1435010365 25200
#      Mon Jun 22 14:59:25 2015 -0700
# Node ID 34f4e918c71d29989e08a053bf3a4bac7ee371f5
# Parent  79e0d7418fa3a9dd71e39b4865542838e63f40eb
evolve: add _nextcandidate a revset to get the target for hg evolve with no arg

This patch introduces the _nextcandidate revset. It is used to pick the next
candidate for evolution when running hg evolve with no argument.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -508,6 +508,20 @@  def _nextcandidates(repo):
                 yield successor
             tovisit.append(successor)
 
+### Next revset symbol
+
+@eh.revset('_nextcandidate')
+def _nextcandidate(repo, subset, x):
+    """Private revset that computes the next changeset that evolves on a non
+       obsolete descendant of ."""
+    revset.getargs(x, 0, 0, '_nextcandidate takes no arguments')
+    try:
+        # Pick only the first next candidate
+        u = _nextcandidates(repo).next()
+        return subset & set([u])
+    except StopIteration:
+        return revset.baseset(set())
+
 ### Troubled revset symbol
 
 @eh.revset('troubled')
diff --git a/tests/test-stabilize-order.t b/tests/test-stabilize-order.t
--- a/tests/test-stabilize-order.t
+++ b/tests/test-stabilize-order.t
@@ -139,6 +139,12 @@  Test behaviour with --any
   $ echo b >> b
   $ hg amend
   1 new unstable changesets
+  $ hg log -r "_nextcandidate()"
+  changeset:   9:65095d7d0dd5
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     addc
+  
   $ glog
   @  11:036cf654e942@default(draft) addb
   |