[PATCH 1 of 4] histedit: add a method to cleanup nodes safely

Yuya Nishihara yuya at tcha.org
Fri Mar 17 09:32:45 EDT 2017


On Mon, 13 Mar 2017 22:36:16 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1489464645 25200
> #      Mon Mar 13 21:10:45 2017 -0700
> # Node ID b4cf155f7a41ebf314407000f6948716ae0a64e2
> # Parent  3d3109339b57341b333c1112beb41dd281fa944a
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r b4cf155f7a41
> histedit: add a method to cleanup nodes safely

The series looks good to me, but one nit.

> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -1582,4 +1582,29 @@ def cleanupnode(ui, repo, name, nodes):
>              repair.strip(ui, repo, c)
>  
> +def safecleanupnode(ui, repo, name, nodes):
> +    """strip or obsolete nodes
> +
> +    nodes could be either a set or dict which maps to replacements.
> +    nodes could be unknown (outside the repo).
> +    """
> +    supportsmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt)
> +    if supportsmarkers:
> +        if util.safehasattr(nodes, 'get'):
> +            # nodes is a dict-like mapping
> +            # use unfiltered repo for successors in case they are hidden
> +            urepo = repo.unfiltered()
> +            marker = lambda x: (repo[x], (urepo[n] for n in nodes.get(x, ())))
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This isn't a tuple but a generator. Is that by intention?


More information about the Mercurial-devel mailing list