##// END OF EJS Templates
interfaces: convert `repository.ifilestorage` to a Protocol class...
Matt Harbison -
r53385:8c89e978 default
parent child Browse files
Show More
@@ -610,12 +610,15 class ifileindex(Protocol):
610 nullid: bytes
610 nullid: bytes
611 """node for the null revision for use as delta base."""
611 """node for the null revision for use as delta base."""
612
612
613 @abc.abstractmethod
613 def __len__(self) -> int:
614 def __len__(self) -> int:
614 """Obtain the number of revisions stored for this file."""
615 """Obtain the number of revisions stored for this file."""
615
616
617 @abc.abstractmethod
616 def __iter__(self) -> Iterator[int]:
618 def __iter__(self) -> Iterator[int]:
617 """Iterate over revision numbers for this file."""
619 """Iterate over revision numbers for this file."""
618
620
621 @abc.abstractmethod
619 def hasnode(self, node):
622 def hasnode(self, node):
620 """Returns a bool indicating if a node is known to this store.
623 """Returns a bool indicating if a node is known to this store.
621
624
@@ -626,30 +629,36 class ifileindex(Protocol):
626 The null node is never present.
629 The null node is never present.
627 """
630 """
628
631
632 @abc.abstractmethod
629 def revs(self, start=0, stop=None):
633 def revs(self, start=0, stop=None):
630 """Iterate over revision numbers for this file, with control."""
634 """Iterate over revision numbers for this file, with control."""
631
635
636 @abc.abstractmethod
632 def parents(self, node):
637 def parents(self, node):
633 """Returns a 2-tuple of parent nodes for a revision.
638 """Returns a 2-tuple of parent nodes for a revision.
634
639
635 Values will be ``nullid`` if the parent is empty.
640 Values will be ``nullid`` if the parent is empty.
636 """
641 """
637
642
643 @abc.abstractmethod
638 def parentrevs(self, rev):
644 def parentrevs(self, rev):
639 """Like parents() but operates on revision numbers."""
645 """Like parents() but operates on revision numbers."""
640
646
647 @abc.abstractmethod
641 def rev(self, node):
648 def rev(self, node):
642 """Obtain the revision number given a node.
649 """Obtain the revision number given a node.
643
650
644 Raises ``error.LookupError`` if the node is not known.
651 Raises ``error.LookupError`` if the node is not known.
645 """
652 """
646
653
654 @abc.abstractmethod
647 def node(self, rev):
655 def node(self, rev):
648 """Obtain the node value given a revision number.
656 """Obtain the node value given a revision number.
649
657
650 Raises ``IndexError`` if the node is not known.
658 Raises ``IndexError`` if the node is not known.
651 """
659 """
652
660
661 @abc.abstractmethod
653 def lookup(self, node):
662 def lookup(self, node):
654 """Attempt to resolve a value to a node.
663 """Attempt to resolve a value to a node.
655
664
@@ -659,24 +668,29 class ifileindex(Protocol):
659 Raises ``error.LookupError`` if a node could not be resolved.
668 Raises ``error.LookupError`` if a node could not be resolved.
660 """
669 """
661
670
671 @abc.abstractmethod
662 def linkrev(self, rev):
672 def linkrev(self, rev):
663 """Obtain the changeset revision number a revision is linked to."""
673 """Obtain the changeset revision number a revision is linked to."""
664
674
675 @abc.abstractmethod
665 def iscensored(self, rev):
676 def iscensored(self, rev):
666 """Return whether a revision's content has been censored."""
677 """Return whether a revision's content has been censored."""
667
678
679 @abc.abstractmethod
668 def commonancestorsheads(self, node1, node2):
680 def commonancestorsheads(self, node1, node2):
669 """Obtain an iterable of nodes containing heads of common ancestors.
681 """Obtain an iterable of nodes containing heads of common ancestors.
670
682
671 See ``ancestor.commonancestorsheads()``.
683 See ``ancestor.commonancestorsheads()``.
672 """
684 """
673
685
686 @abc.abstractmethod
674 def descendants(self, revs):
687 def descendants(self, revs):
675 """Obtain descendant revision numbers for a set of revision numbers.
688 """Obtain descendant revision numbers for a set of revision numbers.
676
689
677 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
690 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
678 """
691 """
679
692
693 @abc.abstractmethod
680 def heads(self, start=None, stop=None):
694 def heads(self, start=None, stop=None):
681 """Obtain a list of nodes that are DAG heads, with control.
695 """Obtain a list of nodes that are DAG heads, with control.
682
696
@@ -687,6 +701,7 class ifileindex(Protocol):
687 encountered.
701 encountered.
688 """
702 """
689
703
704 @abc.abstractmethod
690 def children(self, node):
705 def children(self, node):
691 """Obtain nodes that are children of a node.
706 """Obtain nodes that are children of a node.
692
707
@@ -701,12 +716,14 class ifiledata(Protocol):
701 data for a tracked file.
716 data for a tracked file.
702 """
717 """
703
718
719 @abc.abstractmethod
704 def size(self, rev):
720 def size(self, rev):
705 """Obtain the fulltext size of file data.
721 """Obtain the fulltext size of file data.
706
722
707 Any metadata is excluded from size measurements.
723 Any metadata is excluded from size measurements.
708 """
724 """
709
725
726 @abc.abstractmethod
710 def revision(self, node):
727 def revision(self, node):
711 """Obtain fulltext data for a node.
728 """Obtain fulltext data for a node.
712
729
@@ -718,9 +735,11 class ifiledata(Protocol):
718 consumers should use ``read()`` to obtain the actual file data.
735 consumers should use ``read()`` to obtain the actual file data.
719 """
736 """
720
737
738 @abc.abstractmethod
721 def rawdata(self, node):
739 def rawdata(self, node):
722 """Obtain raw data for a node."""
740 """Obtain raw data for a node."""
723
741
742 @abc.abstractmethod
724 def read(self, node):
743 def read(self, node):
725 """Resolve file fulltext data.
744 """Resolve file fulltext data.
726
745
@@ -728,6 +747,7 class ifiledata(Protocol):
728 headers is stripped.
747 headers is stripped.
729 """
748 """
730
749
750 @abc.abstractmethod
731 def renamed(self, node):
751 def renamed(self, node):
732 """Obtain copy metadata for a node.
752 """Obtain copy metadata for a node.
733
753
@@ -735,6 +755,7 class ifiledata(Protocol):
735 (path, node) from which this revision was copied.
755 (path, node) from which this revision was copied.
736 """
756 """
737
757
758 @abc.abstractmethod
738 def cmp(self, node, fulltext):
759 def cmp(self, node, fulltext):
739 """Compare fulltext to another revision.
760 """Compare fulltext to another revision.
740
761
@@ -745,6 +766,7 class ifiledata(Protocol):
745 TODO better document the copy metadata and censoring logic.
766 TODO better document the copy metadata and censoring logic.
746 """
767 """
747
768
769 @abc.abstractmethod
748 def emitrevisions(
770 def emitrevisions(
749 self,
771 self,
750 nodes,
772 nodes,
@@ -805,6 +827,7 class ifiledata(Protocol):
805 class ifilemutation(Protocol):
827 class ifilemutation(Protocol):
806 """Storage interface for mutation events of a tracked file."""
828 """Storage interface for mutation events of a tracked file."""
807
829
830 @abc.abstractmethod
808 def add(self, filedata, meta, transaction, linkrev, p1, p2):
831 def add(self, filedata, meta, transaction, linkrev, p1, p2):
809 """Add a new revision to the store.
832 """Add a new revision to the store.
810
833
@@ -816,6 +839,7 class ifilemutation(Protocol):
816 May no-op if a revision matching the supplied data is already stored.
839 May no-op if a revision matching the supplied data is already stored.
817 """
840 """
818
841
842 @abc.abstractmethod
819 def addrevision(
843 def addrevision(
820 self,
844 self,
821 revisiondata,
845 revisiondata,
@@ -843,6 +867,7 class ifilemutation(Protocol):
843 applying raw data from a peer repo.
867 applying raw data from a peer repo.
844 """
868 """
845
869
870 @abc.abstractmethod
846 def addgroup(
871 def addgroup(
847 self,
872 self,
848 deltas,
873 deltas,
@@ -881,6 +906,7 class ifilemutation(Protocol):
881 even if it existed in the store previously.
906 even if it existed in the store previously.
882 """
907 """
883
908
909 @abc.abstractmethod
884 def censorrevision(self, tr, node, tombstone=b''):
910 def censorrevision(self, tr, node, tombstone=b''):
885 """Remove the content of a single revision.
911 """Remove the content of a single revision.
886
912
@@ -898,6 +924,7 class ifilemutation(Protocol):
898 that they no longer reference the deleted content.
924 that they no longer reference the deleted content.
899 """
925 """
900
926
927 @abc.abstractmethod
901 def getstrippoint(self, minlink):
928 def getstrippoint(self, minlink):
902 """Find the minimum revision that must be stripped to strip a linkrev.
929 """Find the minimum revision that must be stripped to strip a linkrev.
903
930
@@ -908,6 +935,7 class ifilemutation(Protocol):
908 a higher-level deletion API. ``repair.strip()`` relies on this.
935 a higher-level deletion API. ``repair.strip()`` relies on this.
909 """
936 """
910
937
938 @abc.abstractmethod
911 def strip(self, minlink, transaction):
939 def strip(self, minlink, transaction):
912 """Remove storage of items starting at a linkrev.
940 """Remove storage of items starting at a linkrev.
913
941
@@ -919,9 +947,10 class ifilemutation(Protocol):
919 """
947 """
920
948
921
949
922 class ifilestorage(ifileindex, ifiledata, ifilemutation):
950 class ifilestorage(ifileindex, ifiledata, ifilemutation, Protocol):
923 """Complete storage interface for a single tracked file."""
951 """Complete storage interface for a single tracked file."""
924
952
953 @abc.abstractmethod
925 def files(self):
954 def files(self):
926 """Obtain paths that are backing storage for this file.
955 """Obtain paths that are backing storage for this file.
927
956
@@ -929,6 +958,7 class ifilestorage(ifileindex, ifiledata
929 be a better API for that.
958 be a better API for that.
930 """
959 """
931
960
961 @abc.abstractmethod
932 def storageinfo(
962 def storageinfo(
933 self,
963 self,
934 exclusivefiles=False,
964 exclusivefiles=False,
@@ -969,6 +999,7 class ifilestorage(ifileindex, ifiledata
969 callers are expected to handle this special value.
999 callers are expected to handle this special value.
970 """
1000 """
971
1001
1002 @abc.abstractmethod
972 def verifyintegrity(self, state) -> Iterable[iverifyproblem]:
1003 def verifyintegrity(self, state) -> Iterable[iverifyproblem]:
973 """Verifies the integrity of file storage.
1004 """Verifies the integrity of file storage.
974
1005
General Comments 0
You need to be logged in to leave comments. Login now