[PATCH] cmdutil: extract duplicate definitions of matchessubrepo in files() and remove()

Zergling zerstroyer at gmail.com
Mon Jul 18 15:56:54 EDT 2016


Hm sorry, that was the the wrong patch version. I'm gonna send again with
whitespace fixed if it's worth it and i guess i should patch against
default for this.

On Sun, Jul 17, 2016 at 7:56 AM, Hannes Oldenburg <
hannes.christian.oldenburg at gmail.com> wrote:

> # HG changeset patch
> # User Hannes Oldenburg zerstroyer at gmail.com
> # Date 1468660399 0
> #      Sat Jul 16 09:13:19 2016 +0000
> # Branch stable
> # Node ID eb4a974d3a18826632600dabe82c8fe453b65e20
> # Parent  a7d1532b26a17bbaace43124cd415dcb709b08e2
> cmdutil: extract duplicate definitions of matchessubrepo in files() and
> remove()
>
> diff -r a7d1532b26a1 -r eb4a974d3a18 mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py      Sat Jul 02 09:41:40 2016 -0700
> +++ b/mercurial/cmdutil.py      Sat Jul 16 09:13:19 2016 +0000
> @@ -2396,6 +2396,10 @@
>      forgot.extend(f for f in forget if f not in rejected)
>      return bad, forgot
>
> +def matchessubrepo(m,subpath):
> +    return (m.exact(subpath)
> +            or any(f.startswith(subpath + '/') for f in m.files()))
> +
>  def files(ui, ctx, m, fm, fmt, subrepos):
>      rev = ctx.rev()
>      ret = 1
> @@ -2413,11 +2417,7 @@
>          ret = 0
>
>      for subpath in sorted(ctx.substate):
> -        def matchessubrepo(subpath):
> -            return (m.exact(subpath)
> -                    or any(f.startswith(subpath + '/') for f in
> m.files()))
> -
> -        if subrepos or matchessubrepo(subpath):
> +        if subrepos or matchessubrepo(m,subpath):
>              sub = ctx.sub(subpath)
>              try:
>                  submatch = matchmod.subdirmatcher(subpath, m)
> @@ -2448,14 +2448,6 @@
>      total = len(subs)
>      count = 0
>      for subpath in subs:
> -        def matchessubrepo(matcher, subpath):
> -            if matcher.exact(subpath):
> -                return True
> -            for f in matcher.files():
> -                if f.startswith(subpath):
> -                    return True
> -            return False
> -
>          count += 1
>          if subrepos or matchessubrepo(m, subpath):
>              ui.progress(_('searching'), count, total=total,
> unit=_('subrepos'))
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160718/e61e997f/attachment.html>


More information about the Mercurial-devel mailing list