Patchwork [STABLE] largefiles: ensure lfutil.getstandinmatcher() only matches standins

login
register
mail settings
Submitter Matt Harbison
Date Aug. 12, 2015, 5:29 p.m.
Message ID <c4f15541404673a3debf.1439400541@waste.org>
Download mbox | patch
Permalink /patch/10195/
State Accepted
Headers show

Comments

Matt Harbison - Aug. 12, 2015, 5:29 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1439396799 14400
#      Wed Aug 12 12:26:39 2015 -0400
# Branch stable
# Node ID c4f15541404673a3debf275d9dfd1dc453129739
# Parent  d4e1e947444b81a9e0a7d5dc7bfa282b38d00b94
largefiles: ensure lfutil.getstandinmatcher() only matches standins

Previously, simply having the largefiles extension loaded without any largefiles
added would crash when amending with -I.  The problem was with no files in the
matcher, the pattern list of files joined with 'standindir' was empty, and
scmutil.match() would match everything.  In lfutil.composestandinmatcher(), the
match function is used to test if the file is a standin, and after getting a
false positive, proceeds to call lfutil.splitstandin().  This returns None
because it isn't a standin, which blows up when passed to rmatcher.matchfn().

Manually overriding _always in getstandinmatcher() probably isn't necessary
anymore, but we leave well enough alone on stable.  This regressed in
ab618e52788a.
Matt Mackall - Aug. 12, 2015, 10:24 p.m.
On Wed, 2015-08-12 at 12:29 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1439396799 14400
> #      Wed Aug 12 12:26:39 2015 -0400
> # Branch stable
> # Node ID c4f15541404673a3debf275d9dfd1dc453129739
> # Parent  d4e1e947444b81a9e0a7d5dc7bfa282b38d00b94
> largefiles: ensure lfutil.getstandinmatcher() only matches standins

Queued for stable, thanks.

Patch

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -247,6 +247,8 @@ 
 
     if rmatcher and not rmatcher.always():
         pats = [os.path.join(standindir, pat) for pat in rmatcher.files()]
+        if not pats:
+            pats = [standindir]
         match = scmutil.match(repo[None], pats, badfn=badfn)
         # if pats is empty, it would incorrectly always match, so clear _always
         match._always = False
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -505,4 +505,8 @@ 
   1:9599899f62c0 a
   0:79b99e9c8e49 b
 
+  $ echo "foo" > amended.txt
+  $ hg add amended.txt
+  $ hg ci -q --config extensions.largefiles= --amend -I amended.txt
+
   $ cd ..