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