From patchwork Mon Jun 22 22:42:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 4, evolve-ext] evolve: add _nextcandidate a revset to get the target for hg evolve with no arg From: Laurent Charignon X-Patchwork-Id: 9757 Message-Id: <34f4e918c71d29989e08.1435012921@lcharignon-mbp.local> To: Date: Mon, 22 Jun 2015 15:42:01 -0700 # HG changeset patch # User Laurent Charignon # 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. 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 |