[PATCH] cleanupnode: do not use generator for node mapping

Jun Wu quark at fb.com
Sun Jul 9 13:06:20 EDT 2017


Looks good to me. Thanks for the cleanup!

Excerpts from Boris Feld's message of 2017-07-09 18:49:04 +0200:
> # HG changeset patch
> # User Octobus <contact at octobus.net>
> # Date 1499605879 -7200
> #      Sun Jul 09 15:11:19 2017 +0200
> # Node ID a6ed7f0670010e5a6551d736b00dc0bf7367bba8
> # Parent  4672db164c986da4442bd864cd044512d975c3f2
> # EXP-Topic fix-cleanup
> cleanupnode: do not use generator for node mapping
> 
> The 'successors' part of the mappings used of be a tuple. This avoid issue from
> code consuming the generator "by mistake". For example, an extension inspecting the
> mapping content used to be able to iterate over the successors mapping without
> consequence.
> 
> Since the mapping are small we do not expect any performance impact we use tuple
> again for this.
> 
> diff -r 4672db164c98 -r a6ed7f067001 mercurial/scmutil.py
> --- a/mercurial/scmutil.py    Sat Jun 24 15:29:42 2017 -0700
> +++ b/mercurial/scmutil.py    Sun Jul 09 15:11:19 2017 +0200
> @@ -638,7 +638,7 @@
>              isobs = unfi.obsstore.successors.__contains__
>              torev = unfi.changelog.rev
>              sortfunc = lambda ns: torev(ns[0])
> -            rels = [(unfi[n], (unfi[m] for m in s))
> +            rels = [(unfi[n], tuple(unfi[m] for m in s))
>                      for n, s in sorted(mapping.items(), key=sortfunc)
>                      if s or not isobs(n)]
>              obsolete.createmarkers(repo, rels, operation=operation)


More information about the Mercurial-devel mailing list