changeset 37409:4c15bee42e9c

store: make file filtering during walk configurable Previously, the walking mechanism assumed the use of revlogs for storage. Making the file filter configurable will enable custom stores to override _walk() so it recognizes additional files. Differential Revision: https://phab.mercurial-scm.org/D3093
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 04 Apr 2018 10:16:08 -0700
parents dd2753729853
children a6651f5e2c78
files mercurial/store.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Wed Apr 04 09:31:19 2018 -0700
+++ b/mercurial/store.py	Wed Apr 04 10:16:08 2018 -0700
@@ -319,6 +319,9 @@
 _data = ('data meta 00manifest.d 00manifest.i 00changelog.d 00changelog.i'
          ' phaseroots obsstore')
 
+def isrevlog(f, kind, st):
+    return kind == stat.S_IFREG and f[-2:] in ('.i', '.d')
+
 class basicstore(object):
     '''base class for local repository stores'''
     def __init__(self, path, vfstype):
@@ -333,7 +336,7 @@
     def join(self, f):
         return self.path + '/' + encodedir(f)
 
-    def _walk(self, relpath, recurse):
+    def _walk(self, relpath, recurse, filefilter=isrevlog):
         '''yields (unencoded, encoded, size)'''
         path = self.path
         if relpath:
@@ -347,7 +350,7 @@
                 p = visit.pop()
                 for f, kind, st in readdir(p, stat=True):
                     fp = p + '/' + f
-                    if kind == stat.S_IFREG and f[-2:] in ('.d', '.i'):
+                    if filefilter(f, kind, st):
                         n = util.pconvert(fp[striplen:])
                         l.append((decodedir(n), n, st.st_size))
                     elif kind == stat.S_IFDIR and recurse: