[PATCH 16 of 19 STABLE] largefiles: show unknown files matching against 'directory pattern' correctly

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


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1330335216 -32400
# Branch stable
# Node ID 65d6e452e239d195df6c14f5191ac7d802fdc51f
# Parent  0e26a7e35a1ec4cfde13987fd15e977336e570ce
largefiles: show unknown files matching against 'directory pattern' correctly

current implementation can't show status for unknown files correctly
in 'working' route, if specified pattern is:

    - 'directory pattern', and
    - related to largefiles

there are some examination ways for listing specified (non-STANDIN)
'directory pattern' in 'match.files()':

    1. always:

       this causes unexpected warning message ('No such file or
       directory'), if:

           a. specified directory doesn't exist, and
           b. there is no normal file matching against specified
              pattern in source context

    2. only if it is related to normal files in current/target context:

       this works right, only if already tracked normal file happens
       to exist under specified directory, because dirstate has no
       entry in 'dirs()' for unknown files

    3. (2) or specified directory exists:

       this works right, but increases cost by stat system call

this patch chooses (3) for correct behavior.

diff -r 0e26a7e35a1e -r 65d6e452e239 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
@@ -170,7 +170,10 @@
                             continue
                         if dinctx(sf):
                             yield sf # directory pattern for large file
-                            continue
+                            # file existence check is needed to
+                            # show unknown files correctly
+                            if not (dinctx(f) or os.path.lexists(f)):
+                                continue
                         yield f
                 def matchfn(orgmatchfn, f):
                     wf = lfutil.splitstandin(f)
diff -r 0e26a7e35a1e -r 65d6e452e239 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
@@ -1111,6 +1111,40 @@
   $ hg status -A --rev . --rev 4 another1
   A another1/e.large
 
+add unknown file under same directory:
+
+  $ echo f > sub/sub/f.normal
+
+  $ hg status -A sub/sub
+  ? sub/sub/f.normal
+  C sub/sub/d.large
+  $ hg status -A --rev 2 sub/sub
+  A sub/sub/d.large
+  ? sub/sub/f.normal
+  $ hg status -A --rev . --rev 2 sub/sub
+  R sub/sub/d.large
+  $ hg status -A --rev 0 --rev 3 sub/sub
+  A sub/sub/d.large
+
+add normal file under same directory:
+
+  $ hg add sub/sub/f.normal
+  $ hg commit -m '#5'
+  Invoking status precommit hook
+  A sub/sub/f.normal
+
+  $ hg status -A sub/sub
+  C sub/sub/d.large
+  C sub/sub/f.normal
+  $ hg status -A --rev 2 sub/sub
+  A sub/sub/d.large
+  A sub/sub/f.normal
+  $ hg status -A --rev . --rev 2 sub/sub
+  R sub/sub/d.large
+  R sub/sub/f.normal
+  $ hg status -A --rev 0 --rev 3 sub/sub
+  A sub/sub/d.large
+
   $ cd ..
 
 tests for pattern matching for removed files in working context:


More information about the Mercurial-devel mailing list