Mercurial > hg
comparison mercurial/store.py @ 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 | 72b91f905065 |
children | 8ac0c9cd4c48 |
comparison
equal
deleted
inserted
replaced
37408:dd2753729853 | 37409:4c15bee42e9c |
---|---|
317 return mode | 317 return mode |
318 | 318 |
319 _data = ('data meta 00manifest.d 00manifest.i 00changelog.d 00changelog.i' | 319 _data = ('data meta 00manifest.d 00manifest.i 00changelog.d 00changelog.i' |
320 ' phaseroots obsstore') | 320 ' phaseroots obsstore') |
321 | 321 |
322 def isrevlog(f, kind, st): | |
323 return kind == stat.S_IFREG and f[-2:] in ('.i', '.d') | |
324 | |
322 class basicstore(object): | 325 class basicstore(object): |
323 '''base class for local repository stores''' | 326 '''base class for local repository stores''' |
324 def __init__(self, path, vfstype): | 327 def __init__(self, path, vfstype): |
325 vfs = vfstype(path) | 328 vfs = vfstype(path) |
326 self.path = vfs.base | 329 self.path = vfs.base |
331 self.opener = self.vfs | 334 self.opener = self.vfs |
332 | 335 |
333 def join(self, f): | 336 def join(self, f): |
334 return self.path + '/' + encodedir(f) | 337 return self.path + '/' + encodedir(f) |
335 | 338 |
336 def _walk(self, relpath, recurse): | 339 def _walk(self, relpath, recurse, filefilter=isrevlog): |
337 '''yields (unencoded, encoded, size)''' | 340 '''yields (unencoded, encoded, size)''' |
338 path = self.path | 341 path = self.path |
339 if relpath: | 342 if relpath: |
340 path += '/' + relpath | 343 path += '/' + relpath |
341 striplen = len(self.path) + 1 | 344 striplen = len(self.path) + 1 |
345 readdir = self.rawvfs.readdir | 348 readdir = self.rawvfs.readdir |
346 while visit: | 349 while visit: |
347 p = visit.pop() | 350 p = visit.pop() |
348 for f, kind, st in readdir(p, stat=True): | 351 for f, kind, st in readdir(p, stat=True): |
349 fp = p + '/' + f | 352 fp = p + '/' + f |
350 if kind == stat.S_IFREG and f[-2:] in ('.d', '.i'): | 353 if filefilter(f, kind, st): |
351 n = util.pconvert(fp[striplen:]) | 354 n = util.pconvert(fp[striplen:]) |
352 l.append((decodedir(n), n, st.st_size)) | 355 l.append((decodedir(n), n, st.st_size)) |
353 elif kind == stat.S_IFDIR and recurse: | 356 elif kind == stat.S_IFDIR and recurse: |
354 visit.append(fp) | 357 visit.append(fp) |
355 l.sort() | 358 l.sort() |