Patchwork [3,of,5] destutil: improve stackbase logic

login
register
mail settings
Submitter Gregory Szorc
Date July 4, 2017, 4:32 a.m.
Message ID <98ad38a7e25c0fca06ca.1499142759@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/21963/
State Accepted
Headers show

Comments

Gregory Szorc - July 4, 2017, 4:32 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.
Yuya Nishihara - July 4, 2017, 1:31 p.m.
On Mon, 03 Jul 2017 21:32:39 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@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

I meant it can just return revs.last() because we want None if the set is
empty.

Patch

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)