Mercurial > hg
comparison mercurial/store.py @ 40340:2d45b549392f
store: pass matcher to store.datafiles()
To get narrow stream clones working, we need a way to filter the storage files
using a matcher. This patch adds matcher as an argument to store.walk() and
store.datafiles() so that we can filter the files returned according to the
matcher.
Differential Revision: https://phab.mercurial-scm.org/D4850
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Wed, 03 Oct 2018 16:45:24 +0300 |
parents | f44187605315 |
children | 9aeb9e2d28a7 |
comparison
equal
deleted
inserted
replaced
40339:f0e8f27768eb | 40340:2d45b549392f |
---|---|
357 elif kind == stat.S_IFDIR and recurse: | 357 elif kind == stat.S_IFDIR and recurse: |
358 visit.append(fp) | 358 visit.append(fp) |
359 l.sort() | 359 l.sort() |
360 return l | 360 return l |
361 | 361 |
362 def datafiles(self): | 362 def datafiles(self, matcher=None): |
363 return self._walk('data', True) + self._walk('meta', True) | 363 return self._walk('data', True) + self._walk('meta', True) |
364 | 364 |
365 def topfiles(self): | 365 def topfiles(self): |
366 # yield manifest before changelog | 366 # yield manifest before changelog |
367 return reversed(self._walk('', False)) | 367 return reversed(self._walk('', False)) |
368 | 368 |
369 def walk(self): | 369 def walk(self, matcher=None): |
370 '''yields (unencoded, encoded, size)''' | 370 '''yields (unencoded, encoded, size) |
371 | |
372 if a matcher is passed, storage files of only those tracked paths | |
373 are passed with matches the matcher | |
374 ''' | |
371 # yield data files first | 375 # yield data files first |
372 for x in self.datafiles(): | 376 for x in self.datafiles(matcher): |
373 yield x | 377 yield x |
374 for x in self.topfiles(): | 378 for x in self.topfiles(): |
375 yield x | 379 yield x |
376 | 380 |
377 def copylist(self): | 381 def copylist(self): |
405 vfs.createmode = self.createmode | 409 vfs.createmode = self.createmode |
406 self.rawvfs = vfs | 410 self.rawvfs = vfs |
407 self.vfs = vfsmod.filtervfs(vfs, encodefilename) | 411 self.vfs = vfsmod.filtervfs(vfs, encodefilename) |
408 self.opener = self.vfs | 412 self.opener = self.vfs |
409 | 413 |
410 def datafiles(self): | 414 def datafiles(self, matcher=None): |
411 for a, b, size in super(encodedstore, self).datafiles(): | 415 for a, b, size in super(encodedstore, self).datafiles(): |
412 try: | 416 try: |
413 a = decodefilename(a) | 417 a = decodefilename(a) |
414 except KeyError: | 418 except KeyError: |
415 a = None | 419 a = None |
534 return self.pathsep + self.encode(f) | 538 return self.pathsep + self.encode(f) |
535 | 539 |
536 def getsize(self, path): | 540 def getsize(self, path): |
537 return self.rawvfs.stat(path).st_size | 541 return self.rawvfs.stat(path).st_size |
538 | 542 |
539 def datafiles(self): | 543 def datafiles(self, matcher=None): |
540 for f in sorted(self.fncache): | 544 for f in sorted(self.fncache): |
541 ef = self.encode(f) | 545 ef = self.encode(f) |
542 try: | 546 try: |
543 yield f, ef, self.getsize(ef) | 547 yield f, ef, self.getsize(ef) |
544 except OSError as err: | 548 except OSError as err: |