largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check stable
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Thu, 22 Mar 2012 23:58:47 +0900
branchstable
changeset 16282 50247a7a9983
parent 16281 d8cc67114dc3
child 16283 6c4dbe28dda3
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.
hgext/largefiles/reposetup.py
tests/test-largefiles.t
--- 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,
--- 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