[PATCH 2 of 6 STABLE V2] largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Mar 22 10:06:32 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1332428327 -32400
# Branch stable
# Node ID d09da50da3b2a89eb2addc4deaea23b8b1683076
# Parent  447a62ee6b761f083fb839a2f65df9b1d9579cc2
largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check

original implementation queries whether specified pattern is related
or not to largefiles in target context by 'dirstate.__contains__()'.

but this can't recognize 'directory pattern' correctly, so this patch
uses 'dirstate.dirs()' for it.

this patch uses dirstate instead of lfdirstate in 'working' route
(second patch hunk for 'hgext/largefiles/reposetup.py'), because
'dirs()' information may be already built for dirstate but not yet for
lfdirstate at this point. this prevents lfdirstate from building up
and having 'dirs()' information.

diff -r 447a62ee6b76 -r d09da50da3b2 hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py	Thu Mar 22 23:58:47 2012 +0900
+++ b/hgext/largefiles/reposetup.py	Thu Mar 22 23:58:47 2012 +0900
@@ -137,8 +137,11 @@
                 # Create a copy of match that matches standins instead
                 # of largefiles.
                 def tostandin(file):
-                    if working and lfutil.standin(file) in repo.dirstate:
-                        return lfutil.standin(file)
+                    if working:
+                        sf = lfutil.standin(file)
+                        dirstate = repo.dirstate
+                        if sf in dirstate or sf in dirstate.dirs():
+                            return sf
                     return file
 
                 # Create a function that we can use to override what is
@@ -167,8 +170,12 @@
                         orig_ignore = lfdirstate._ignore
                         lfdirstate._ignore = _ignoreoverride
 
-                        match._files = [f for f in match._files if f in
-                            lfdirstate]
+                        def sfindirstate(f):
+                            sf = lfutil.standin(f)
+                            dirstate = repo.dirstate
+                            return sf in dirstate or sf in dirstate.dirs()
+                        match._files = [f for f in match._files
+                                        if sfindirstate(f)]
                         # Don't waste time getting the ignored and unknown
                         # files again; we already have them
                         s = lfdirstate.status(match, [], False,
diff -r 447a62ee6b76 -r d09da50da3b2 tests/test-largefiles.t
--- a/tests/test-largefiles.t	Thu Mar 22 23:58:47 2012 +0900
+++ b/tests/test-largefiles.t	Thu Mar 22 23:58:47 2012 +0900
@@ -251,6 +251,13 @@
   A sub2/large6
   A sub2/large7
 
+Test "hg status" with combination of 'file pattern' and 'directory
+pattern' for largefiles:
+
+  $ hg status sub2/large6 sub2
+  A sub2/large6
+  A sub2/large7
+
 Config settings (pattern **.dat, minsize 2 MB) are respected.
 
   $ echo testdata > test.dat


More information about the Mercurial-devel mailing list