[PATCH 3 of 5] destutil: improve stackbase logic

Gregory Szorc gregory.szorc at gmail.com
Tue Jul 4 00:32:39 EDT 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1499141798 25200
#      Mon Jul 03 21:16:38 2017 -0700
# Node ID 98ad38a7e25c0fca06cac849e5f68bd3c0cc82bb
# Parent  f2c118798d8bd214679f9a6ad3f8f4f87882d9d3
destutil: improve stackbase logic

We can use repo.revs() since user-defined aliases aren't important.

revs.last() can return None if the set is empty. So be specific
about how we interpret the revset result.

diff --git a/mercurial/destutil.py b/mercurial/destutil.py
--- a/mercurial/destutil.py
+++ b/mercurial/destutil.py
@@ -357,8 +357,8 @@ def desthistedit(ui, repo):
 def stackbase(ui, repo):
     # The histedit default base stops at public changesets, branchpoints,
     # and merges, which is exactly what we want for a stack.
-    revs = scmutil.revrange(repo, [histeditdefaultrevset])
-    return revs.last() if revs else None
+    revs = repo.revs(histeditdefaultrevset)
+    return revs.last() if revs and revs.last() is not None else None
 
 def _statusotherbook(ui, repo):
     bmheads = bookmarks.headsforactive(repo)


More information about the Mercurial-devel mailing list