[PATCH 10 of 19 STABLE] largefiles: adjust matching function to match appropriate files

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Mon Feb 27 04:46:35 CST 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1330335216 -32400
# Branch stable
# Node ID 0317d98735a65b478976579bd10e75315ead234d
# Parent  d9217e9e3d58f84a077305fff6468d47d284ca03
largefiles: adjust matching function to match appropriate files

original implementation can't show correct statuses, if 'hg status' is
invoked with:

    - two target revisions, and
    - 'directory pattern' for largefiles (not for STANDIN)

this problem occurs in steps shown below:

    1. specified 'match' is used to pick files up from manifest of
       each contexts in 'localrepository.status()'

    2. 'match.matchfn' only accepts non-STANDIN files, so

    3. any STANDIN files corresponded to specified patterns are not
       chosen from target manifest

this patch adjusts matching function to match against corresponded
STANDIN files.

diff -r d9217e9e3d58 -r 0317d98735a6 hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py	Mon Feb 27 18:33:36 2012 +0900
+++ b/hgext/largefiles/reposetup.py	Mon Feb 27 18:33:36 2012 +0900
@@ -152,7 +152,15 @@
                                 continue
                         # not 'known largefile', or 'STANDIN direct' pattern
                         yield f
-                m = match.convert(filefn)
+                def matchfn(orgmatchfn, f):
+                    wf = lfutil.splitstandin(f)
+                    if wf:
+                        return (orgmatchfn(wf) or
+                                # for 'STANDIN direct' pattern
+                                orgmatchfn(f))
+                    else:
+                        return orgmatchfn(f)
+                m = match.convert(filefn, matchfn)
 
                 # Get ignored files here even if we weren't asked for them; we
                 # must use the result here for filtering later
diff -r d9217e9e3d58 -r 0317d98735a6 tests/test-largefiles.t
--- a/tests/test-largefiles.t	Mon Feb 27 18:33:36 2012 +0900
+++ b/tests/test-largefiles.t	Mon Feb 27 18:33:36 2012 +0900
@@ -1005,3 +1005,79 @@
   
 
   $ cd ..
+
+tests for pattern matching on "hg status" (mainly) with target reivisions:
+
+  $ hg init statusrev
+  $ cd statusrev
+
+  $ mkdir -p sub/
+  $ echo a > sub/a.large
+  $ hg add --large sub/a.large
+  $ hg commit -m '#0'
+  Invoking status precommit hook
+  A sub/a.large
+  $ echo b > sub/b.large
+  $ hg add --large sub/b.large
+  $ hg commit -m '#1'
+  Invoking status precommit hook
+  A sub/b.large
+  $ echo c > sub/c.large
+  $ hg add --large sub/c.large
+  $ hg commit -m '#2'
+  Invoking status precommit hook
+  A sub/c.large
+  $ mkdir sub/sub
+  $ echo d > sub/sub/d.large
+  $ hg add --large sub/sub/d.large
+  $ hg commit -m '#3'
+  Invoking status precommit hook
+  A sub/sub/d.large
+
+for file pattern
+
+  $ hg status -A sub/b.large
+  C sub/b.large
+  $ hg status -A --rev 2 sub/b.large
+  C sub/b.large
+  $ hg status -A --rev . --rev 0 sub/b.large
+  R sub/b.large
+  $ hg status -A --rev 0 --rev 1 sub/b.large
+  A sub/b.large
+
+for directory pattern
+
+  $ hg status -A sub
+  C sub/a.large
+  C sub/b.large
+  C sub/c.large
+  C sub/sub/d.large
+  $ hg status -A --rev 2 sub
+  A sub/sub/d.large
+  C sub/a.large
+  C sub/b.large
+  C sub/c.large
+  $ hg status -A --rev . --rev 0 sub
+  R sub/b.large
+  R sub/c.large
+  R sub/sub/d.large
+  C sub/a.large
+  $ hg status -A --rev 0 --rev 1 sub
+  A sub/b.large
+  C sub/a.large
+
+for file/directory mixed patterns
+
+  $ hg status -A sub/a.large sub/sub
+  C sub/a.large
+  C sub/sub/d.large
+  $ hg status -A --rev 2 sub/a.large sub/sub
+  A sub/sub/d.large
+  C sub/a.large
+  $ hg status -A --rev . --rev 0 sub/a.large sub/sub
+  R sub/sub/d.large
+  C sub/a.large
+  $ hg status -A --rev 0 --rev 1 sub/a.large sub/sub
+  C sub/a.large
+
+  $ cd ..


More information about the Mercurial-devel mailing list