Show More
@@ -162,11 +162,8 b' def onetimesetup(ui):' | |||||
162 | ): |
|
162 | ): | |
163 | n = util.pconvert(fp[striplen:]) |
|
163 | n = util.pconvert(fp[striplen:]) | |
164 | d = store.decodedir(n) |
|
164 | d = store.decodedir(n) | |
165 | yield store.StoreEntry( |
|
165 | yield store.SimpleStoreEntry( | |
166 | unencoded_path=d, |
|
166 | unencoded_path=d, | |
167 | is_revlog=True, |
|
|||
168 | revlog_type=None, |
|
|||
169 | is_revlog_main=False, |
|
|||
170 | is_volatile=False, |
|
167 | is_volatile=False, | |
171 | file_size=st.st_size, |
|
168 | file_size=st.st_size, | |
172 | ) |
|
169 | ) |
@@ -454,15 +454,12 b' FILETYPE_OTHER = FILEFLAGS_OTHER' | |||||
454 |
|
454 | |||
455 |
|
455 | |||
456 | @attr.s(slots=True) |
|
456 | @attr.s(slots=True) | |
457 | class StoreEntry: |
|
457 | class BaseStoreEntry: | |
458 | """An entry in the store |
|
458 | """An entry in the store | |
459 |
|
459 | |||
460 | This is returned by `store.walk` and represent some data in the store.""" |
|
460 | This is returned by `store.walk` and represent some data in the store.""" | |
461 |
|
461 | |||
462 | unencoded_path = attr.ib() |
|
462 | unencoded_path = attr.ib() | |
463 | is_revlog = attr.ib(default=False) |
|
|||
464 | revlog_type = attr.ib(default=None) |
|
|||
465 | is_revlog_main = attr.ib(default=None) |
|
|||
466 | is_volatile = attr.ib(default=False) |
|
463 | is_volatile = attr.ib(default=False) | |
467 | file_size = attr.ib(default=None) |
|
464 | file_size = attr.ib(default=None) | |
468 |
|
465 | |||
@@ -477,6 +474,22 b' class StoreEntry:' | |||||
477 |
|
474 | |||
478 |
|
475 | |||
479 | @attr.s(slots=True) |
|
476 | @attr.s(slots=True) | |
|
477 | class SimpleStoreEntry(BaseStoreEntry): | |||
|
478 | """A generic entry in the store""" | |||
|
479 | ||||
|
480 | is_revlog = False | |||
|
481 | ||||
|
482 | ||||
|
483 | @attr.s(slots=True) | |||
|
484 | class RevlogStoreEntry(BaseStoreEntry): | |||
|
485 | """A revlog entry in the store""" | |||
|
486 | ||||
|
487 | is_revlog = True | |||
|
488 | revlog_type = attr.ib(default=None) | |||
|
489 | is_revlog_main = attr.ib(default=None) | |||
|
490 | ||||
|
491 | ||||
|
492 | @attr.s(slots=True) | |||
480 | class StoreFile: |
|
493 | class StoreFile: | |
481 | """a file matching an entry""" |
|
494 | """a file matching an entry""" | |
482 |
|
495 | |||
@@ -536,7 +549,7 b' class basicstore:' | |||||
536 |
|
549 | |||
537 | def datafiles( |
|
550 | def datafiles( | |
538 | self, matcher=None, undecodable=None |
|
551 | self, matcher=None, undecodable=None | |
539 | ) -> Generator[StoreEntry, None, None]: |
|
552 | ) -> Generator[BaseStoreEntry, None, None]: | |
540 | """Like walk, but excluding the changelog and root manifest. |
|
553 | """Like walk, but excluding the changelog and root manifest. | |
541 |
|
554 | |||
542 | When [undecodable] is None, revlogs names that can't be |
|
555 | When [undecodable] is None, revlogs names that can't be | |
@@ -546,35 +559,42 b' class basicstore:' | |||||
546 | files = self._walk(b'data', True) + self._walk(b'meta', True) |
|
559 | files = self._walk(b'data', True) + self._walk(b'meta', True) | |
547 | for (t, u, s) in files: |
|
560 | for (t, u, s) in files: | |
548 | if t is not None: |
|
561 | if t is not None: | |
549 | yield StoreEntry( |
|
562 | yield RevlogStoreEntry( | |
550 | unencoded_path=u, |
|
563 | unencoded_path=u, | |
551 | is_revlog=True, |
|
|||
552 | revlog_type=FILEFLAGS_FILELOG, |
|
564 | revlog_type=FILEFLAGS_FILELOG, | |
553 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), |
|
565 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), | |
554 | is_volatile=bool(t & FILEFLAGS_VOLATILE), |
|
566 | is_volatile=bool(t & FILEFLAGS_VOLATILE), | |
555 | file_size=s, |
|
567 | file_size=s, | |
556 | ) |
|
568 | ) | |
557 |
|
569 | |||
558 | def topfiles(self) -> Generator[StoreEntry, None, None]: |
|
570 | def topfiles(self) -> Generator[BaseStoreEntry, None, None]: | |
559 | # yield manifest before changelog |
|
571 | # yield manifest before changelog | |
560 | files = reversed(self._walk(b'', False)) |
|
572 | files = reversed(self._walk(b'', False)) | |
561 | for (t, u, s) in files: |
|
573 | for (t, u, s) in files: | |
562 | if u.startswith(b'00changelog'): |
|
574 | if u.startswith(b'00changelog'): | |
563 | revlog_type = FILEFLAGS_CHANGELOG |
|
575 | yield RevlogStoreEntry( | |
564 | elif u.startswith(b'00manifest'): |
|
|||
565 | revlog_type = FILEFLAGS_MANIFESTLOG |
|
|||
566 | else: |
|
|||
567 | revlog_type = None |
|
|||
568 | yield StoreEntry( |
|
|||
569 | unencoded_path=u, |
|
576 | unencoded_path=u, | |
570 | is_revlog=revlog_type is not None, |
|
577 | revlog_type=FILEFLAGS_CHANGELOG, | |
571 | revlog_type=revlog_type, |
|
|||
572 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), |
|
578 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), | |
573 | is_volatile=bool(t & FILEFLAGS_VOLATILE), |
|
579 | is_volatile=bool(t & FILEFLAGS_VOLATILE), | |
574 | file_size=s, |
|
580 | file_size=s, | |
575 | ) |
|
581 | ) | |
|
582 | elif u.startswith(b'00manifest'): | |||
|
583 | yield RevlogStoreEntry( | |||
|
584 | unencoded_path=u, | |||
|
585 | revlog_type=FILEFLAGS_MANIFESTLOG, | |||
|
586 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), | |||
|
587 | is_volatile=bool(t & FILEFLAGS_VOLATILE), | |||
|
588 | file_size=s, | |||
|
589 | ) | |||
|
590 | else: | |||
|
591 | yield SimpleStoreEntry( | |||
|
592 | unencoded_path=u, | |||
|
593 | is_volatile=bool(t & FILEFLAGS_VOLATILE), | |||
|
594 | file_size=s, | |||
|
595 | ) | |||
576 |
|
596 | |||
577 | def walk(self, matcher=None) -> Generator[StoreEntry, None, None]: |
|
597 | def walk(self, matcher=None) -> Generator[BaseStoreEntry, None, None]: | |
578 | """return files related to data storage (ie: revlogs) |
|
598 | """return files related to data storage (ie: revlogs) | |
579 |
|
599 | |||
580 | yields (file_type, unencoded, size) |
|
600 | yields (file_type, unencoded, size) | |
@@ -629,7 +649,7 b' class encodedstore(basicstore):' | |||||
629 |
|
649 | |||
630 | def datafiles( |
|
650 | def datafiles( | |
631 | self, matcher=None, undecodable=None |
|
651 | self, matcher=None, undecodable=None | |
632 | ) -> Generator[StoreEntry, None, None]: |
|
652 | ) -> Generator[BaseStoreEntry, None, None]: | |
633 | for entry in super(encodedstore, self).datafiles(): |
|
653 | for entry in super(encodedstore, self).datafiles(): | |
634 | try: |
|
654 | try: | |
635 | f1 = entry.unencoded_path |
|
655 | f1 = entry.unencoded_path | |
@@ -842,7 +862,7 b' class fncachestore(basicstore):' | |||||
842 |
|
862 | |||
843 | def datafiles( |
|
863 | def datafiles( | |
844 | self, matcher=None, undecodable=None |
|
864 | self, matcher=None, undecodable=None | |
845 | ) -> Generator[StoreEntry, None, None]: |
|
865 | ) -> Generator[BaseStoreEntry, None, None]: | |
846 | for f in sorted(self.fncache): |
|
866 | for f in sorted(self.fncache): | |
847 | if not _matchtrackedpath(f, matcher): |
|
867 | if not _matchtrackedpath(f, matcher): | |
848 | continue |
|
868 | continue | |
@@ -854,11 +874,9 b' class fncachestore(basicstore):' | |||||
854 | # However the fncache might contains such file added by |
|
874 | # However the fncache might contains such file added by | |
855 | # previous version of Mercurial. |
|
875 | # previous version of Mercurial. | |
856 | continue |
|
876 | continue | |
857 | t |= FILEFLAGS_FILELOG |
|
|||
858 | try: |
|
877 | try: | |
859 | yield StoreEntry( |
|
878 | yield RevlogStoreEntry( | |
860 | unencoded_path=f, |
|
879 | unencoded_path=f, | |
861 | is_revlog=True, |
|
|||
862 | revlog_type=FILEFLAGS_FILELOG, |
|
880 | revlog_type=FILEFLAGS_FILELOG, | |
863 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), |
|
881 | is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), | |
864 | is_volatile=bool(t & FILEFLAGS_VOLATILE), |
|
882 | is_volatile=bool(t & FILEFLAGS_VOLATILE), |
General Comments 0
You need to be logged in to leave comments.
Login now