mercurial/store.py
changeset 40544 9aeb9e2d28a7
parent 40340 2d45b549392f
child 40631 a694a7159125
equal deleted inserted replaced
40543:a2c4502e409b 40544:9aeb9e2d28a7
    21     util,
    21     util,
    22     vfs as vfsmod,
    22     vfs as vfsmod,
    23 )
    23 )
    24 
    24 
    25 parsers = policy.importmod(r'parsers')
    25 parsers = policy.importmod(r'parsers')
       
    26 
       
    27 def _matchtrackedpath(path, matcher):
       
    28     """parses a fncache entry and returns whether the entry is tracking a path
       
    29     matched by matcher or not.
       
    30 
       
    31     If matcher is None, returns True"""
       
    32 
       
    33     if matcher is None:
       
    34         return True
       
    35     path = decodedir(path)
       
    36     if path.startswith('data/'):
       
    37         return matcher(path[len('data/'):-len('.i')])
       
    38     elif path.startswith('meta/'):
       
    39         return matcher.visitdir(path[len('meta/'):-len('/00manifest.i')] or '.')
    26 
    40 
    27 # This avoids a collision between a file named foo and a dir named
    41 # This avoids a collision between a file named foo and a dir named
    28 # foo.i or foo.d
    42 # foo.i or foo.d
    29 def _encodedir(path):
    43 def _encodedir(path):
    30     '''
    44     '''
   411         self.vfs = vfsmod.filtervfs(vfs, encodefilename)
   425         self.vfs = vfsmod.filtervfs(vfs, encodefilename)
   412         self.opener = self.vfs
   426         self.opener = self.vfs
   413 
   427 
   414     def datafiles(self, matcher=None):
   428     def datafiles(self, matcher=None):
   415         for a, b, size in super(encodedstore, self).datafiles():
   429         for a, b, size in super(encodedstore, self).datafiles():
       
   430             if not _matchtrackedpath(a, matcher):
       
   431                 continue
   416             try:
   432             try:
   417                 a = decodefilename(a)
   433                 a = decodefilename(a)
   418             except KeyError:
   434             except KeyError:
   419                 a = None
   435                 a = None
   420             yield a, b, size
   436             yield a, b, size
   540     def getsize(self, path):
   556     def getsize(self, path):
   541         return self.rawvfs.stat(path).st_size
   557         return self.rawvfs.stat(path).st_size
   542 
   558 
   543     def datafiles(self, matcher=None):
   559     def datafiles(self, matcher=None):
   544         for f in sorted(self.fncache):
   560         for f in sorted(self.fncache):
       
   561             if not _matchtrackedpath(f, matcher):
       
   562                 continue
   545             ef = self.encode(f)
   563             ef = self.encode(f)
   546             try:
   564             try:
   547                 yield f, ef, self.getsize(ef)
   565                 yield f, ef, self.getsize(ef)
   548             except OSError as err:
   566             except OSError as err:
   549                 if err.errno != errno.ENOENT:
   567                 if err.errno != errno.ENOENT: