[PATCH] merge: use any() instead of for loop when checking for dirty subrepos

Augie Fackler raf at durin42.com
Wed Feb 24 16:59:24 EST 2016


On Tue, Feb 23, 2016 at 11:49:19AM -0800, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz at google.com>
> # Date 1456253965 28800
> #      Tue Feb 23 10:59:25 2016 -0800
> # Node ID 3617eb5184a28329cc0ff728041bd88f91452c6d
> # Parent  19775bc34da34f28451c2b27a4e06433da058f74
> merge: use any() instead of for loop when checking for dirty subrepos

queued this, thanks

>
> I think it's both simpler and clearer to use any() than the current
> for loop.
>
> While at it, also drop the call to sorted(), since it doesn't matter
> which order we iterate over subrepos.
>
> diff -r 19775bc34da3 -r 3617eb5184a2 mercurial/merge.py
> --- a/mercurial/merge.py	Mon Feb 22 23:18:19 2016 -0800
> +++ b/mercurial/merge.py	Tue Feb 23 10:59:25 2016 -0800
> @@ -801,10 +801,8 @@
>
>      if '.hgsubstate' in m1:
>          # check whether sub state is modified
> -        for s in sorted(wctx.substate):
> -            if wctx.sub(s).dirty():
> -                m1['.hgsubstate'] += '+'
> -                break
> +        if any(wctx.sub(s).dirty() for s in wctx.substate):
> +            m1['.hgsubstate'] += '+'
>
>      # Compare manifests
>      if matcher is not None:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list