Patchwork [8,of,8] largefiles: replace match.bad() monkey patching with match.badmatch()

login
register
mail settings
Submitter Matt Harbison
Date June 5, 2015, 4 a.m.
Message ID <89c9da9f2121dcba3600.1433476853@Envy>
Download mbox | patch
Permalink /patch/9508/
State Accepted
Commit 1a95c57959f6a35c95f2ba8e78cb71c26250d929
Headers show

Comments

Matt Harbison - June 5, 2015, 4 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1433470278 14400
#      Thu Jun 04 22:11:18 2015 -0400
# Node ID 89c9da9f2121dcba36002cf10a23df677026ee59
# Parent  91db1c0b272e90c500f1fe5416150a65c2c6579f
largefiles: replace match.bad() monkey patching with match.badmatch()

No known issues with the previous code since it restored the original method,
but this is cleaner.

The monkey patching in cat is harmless, because it is created locally, and
doesn't pass it anywhere (subrepo cat isn't supported with largefiles).
Martin von Zweigbergk - June 5, 2015, 4:26 a.m.
This series looks good to me, but I'll let Matt take a look at particularly
1/8, so I'll leave the queuing for him.

On Thu, Jun 4, 2015 at 9:09 PM Matt Harbison <mharbison72@gmail.com> wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1433470278 14400
> #      Thu Jun 04 22:11:18 2015 -0400
> # Node ID 89c9da9f2121dcba36002cf10a23df677026ee59
> # Parent  91db1c0b272e90c500f1fe5416150a65c2c6579f
> largefiles: replace match.bad() monkey patching with match.badmatch()
>
> No known issues with the previous code since it restored the original
> method,
> but this is cleaner.
>
> The monkey patching in cat is harmless, because it is created locally, and
> doesn't pass it anywhere (subrepo cat isn't supported with largefiles).
>
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -100,10 +100,10 @@
>              lfmatcher = match_.match(repo.root, '', list(lfpats))
>
>      lfnames = []
> -    m = copy.copy(matcher)
> -    m.bad = lambda x, y: None
> +    m = matcher
> +
>      wctx = repo[None]
> -    for f in repo.walk(m):
> +    for f in repo.walk(match_.badmatch(m, lambda x, y: None)):
>          exact = m.exact(f)
>          lfile = lfutil.standin(f) in wctx
>          nfile = f in wctx
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
Matt Mackall - June 5, 2015, 5:29 p.m.
On Fri, 2015-06-05 at 00:00 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1433470278 14400
> #      Thu Jun 04 22:11:18 2015 -0400
> # Node ID 89c9da9f2121dcba36002cf10a23df677026ee59
> # Parent  91db1c0b272e90c500f1fe5416150a65c2c6579f
> largefiles: replace match.bad() monkey patching with match.badmatch()

These are queued for default, thanks.

Maybe we should probably grow a bad= arg on the constructor since it
seems to be somewhat common to create a matcher and then immediately
wrap it.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -100,10 +100,10 @@ 
             lfmatcher = match_.match(repo.root, '', list(lfpats))
 
     lfnames = []
-    m = copy.copy(matcher)
-    m.bad = lambda x, y: None
+    m = matcher
+
     wctx = repo[None]
-    for f in repo.walk(m):
+    for f in repo.walk(match_.badmatch(m, lambda x, y: None)):
         exact = m.exact(f)
         lfile = lfutil.standin(f) in wctx
         nfile = f in wctx