[PATCH 3 of 5] destutil: improve stackbase logic

Yuya Nishihara yuya at tcha.org
Tue Jul 4 09:31:41 EDT 2017


On Mon, 03 Jul 2017 21:32:39 -0700, Gregory Szorc wrote:
> # 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

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


More information about the Mercurial-devel mailing list