Mercurial > hg
comparison mercurial/store.py @ 45351:909dafff6a78
store: refactor space delimited list to proper data structure
There is no good reason why are having a space delimited list and then using
`.split()` to get the actual list. Let's convert this into a proper collection.
Differential Revision: https://phab.mercurial-scm.org/D8908
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 08 Aug 2020 10:13:37 -0700 |
parents | 9d2b2df2c2ba |
children | d252f51ab032 |
comparison
equal
deleted
inserted
replaced
45350:1c8e3c17c702 | 45351:909dafff6a78 |
---|---|
371 except OSError: | 371 except OSError: |
372 mode = None | 372 mode = None |
373 return mode | 373 return mode |
374 | 374 |
375 | 375 |
376 _data = ( | 376 _data = [ |
377 b'bookmarks narrowspec data meta 00manifest.d 00manifest.i' | 377 b'bookmarks', |
378 b' 00changelog.d 00changelog.i phaseroots obsstore' | 378 b'narrowspec', |
379 ) | 379 b'data', |
380 b'meta', | |
381 b'00manifest.d', | |
382 b'00manifest.i', | |
383 b'00changelog.d', | |
384 b'00changelog.i', | |
385 b'phaseroots', | |
386 b'obsstore', | |
387 ] | |
380 | 388 |
381 | 389 |
382 def isrevlog(f, kind, st): | 390 def isrevlog(f, kind, st): |
383 return kind == stat.S_IFREG and f[-2:] in (b'.i', b'.d') | 391 return kind == stat.S_IFREG and f[-2:] in (b'.i', b'.d') |
384 | 392 |
445 yield x | 453 yield x |
446 for x in self.topfiles(): | 454 for x in self.topfiles(): |
447 yield x | 455 yield x |
448 | 456 |
449 def copylist(self): | 457 def copylist(self): |
450 return [b'requires'] + _data.split() | 458 return [b'requires'] + _data |
451 | 459 |
452 def write(self, tr): | 460 def write(self, tr): |
453 pass | 461 pass |
454 | 462 |
455 def invalidatecaches(self): | 463 def invalidatecaches(self): |
492 | 500 |
493 def join(self, f): | 501 def join(self, f): |
494 return self.path + b'/' + encodefilename(f) | 502 return self.path + b'/' + encodefilename(f) |
495 | 503 |
496 def copylist(self): | 504 def copylist(self): |
497 return [b'requires', b'00changelog.i'] + [ | 505 return [b'requires', b'00changelog.i'] + [b'store/' + f for f in _data] |
498 b'store/' + f for f in _data.split() | |
499 ] | |
500 | 506 |
501 | 507 |
502 class fncache(object): | 508 class fncache(object): |
503 # the filename used to be partially encoded | 509 # the filename used to be partially encoded |
504 # hence the encodedir/decodedir dance | 510 # hence the encodedir/decodedir dance |
684 if err.errno != errno.ENOENT: | 690 if err.errno != errno.ENOENT: |
685 raise | 691 raise |
686 | 692 |
687 def copylist(self): | 693 def copylist(self): |
688 d = ( | 694 d = ( |
689 b'bookmarks narrowspec data meta dh fncache phaseroots obsstore' | 695 b'bookmarks', |
690 b' 00manifest.d 00manifest.i 00changelog.d 00changelog.i' | 696 b'narrowspec', |
697 b'data', | |
698 b'meta', | |
699 b'dh', | |
700 b'fncache', | |
701 b'phaseroots', | |
702 b'obsstore', | |
703 b'00manifest.d', | |
704 b'00manifest.i', | |
705 b'00changelog.d', | |
706 b'00changelog.i', | |
691 ) | 707 ) |
692 return [b'requires', b'00changelog.i'] + [ | 708 return [b'requires', b'00changelog.i'] + [b'store/' + f for f in d] |
693 b'store/' + f for f in d.split() | |
694 ] | |
695 | 709 |
696 def write(self, tr): | 710 def write(self, tr): |
697 self.fncache.write(tr) | 711 self.fncache.write(tr) |
698 | 712 |
699 def invalidatecaches(self): | 713 def invalidatecaches(self): |