Mercurial > public > mercurial-scm > hg
comparison mercurial/interfaces/repository.py @ 52486:c0d9fda9f5f5
interfaces: make `repository.ilocalrepositorymain` methods abstract
Same as cdd4bc69bfc1 for `imanifestrevisionstored`, but this was already a
Protocol class.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 10 Dec 2024 23:36:14 -0500 |
parents | dfb60fb155da |
children | 3daaa5195a30 |
comparison
equal
deleted
inserted
replaced
52485:dfb60fb155da | 52486:c0d9fda9f5f5 |
---|---|
1750 """A ``namespaces`` instance.""" | 1750 """A ``namespaces`` instance.""" |
1751 | 1751 |
1752 filecopiesmode: Any # TODO: add type hints | 1752 filecopiesmode: Any # TODO: add type hints |
1753 """The way files copies should be dealt with in this repo.""" | 1753 """The way files copies should be dealt with in this repo.""" |
1754 | 1754 |
1755 @abc.abstractmethod | |
1755 def close(self): | 1756 def close(self): |
1756 """Close the handle on this repository.""" | 1757 """Close the handle on this repository.""" |
1757 | 1758 |
1759 @abc.abstractmethod | |
1758 def peer(self, path=None): | 1760 def peer(self, path=None): |
1759 """Obtain an object conforming to the ``peer`` interface.""" | 1761 """Obtain an object conforming to the ``peer`` interface.""" |
1760 | 1762 |
1763 @abc.abstractmethod | |
1761 def unfiltered(self): | 1764 def unfiltered(self): |
1762 """Obtain an unfiltered/raw view of this repo.""" | 1765 """Obtain an unfiltered/raw view of this repo.""" |
1763 | 1766 |
1767 @abc.abstractmethod | |
1764 def filtered(self, name, visibilityexceptions=None): | 1768 def filtered(self, name, visibilityexceptions=None): |
1765 """Obtain a named view of this repository.""" | 1769 """Obtain a named view of this repository.""" |
1766 | 1770 |
1767 obsstore: Any # TODO: add type hints | 1771 obsstore: Any # TODO: add type hints |
1768 """A store of obsolescence data.""" | 1772 """A store of obsolescence data.""" |
1780 """Working directory state.""" | 1784 """Working directory state.""" |
1781 | 1785 |
1782 narrowpats: Any # TODO: add type hints | 1786 narrowpats: Any # TODO: add type hints |
1783 """Matcher patterns for this repository's narrowspec.""" | 1787 """Matcher patterns for this repository's narrowspec.""" |
1784 | 1788 |
1789 @abc.abstractmethod | |
1785 def narrowmatch(self, match=None, includeexact=False): | 1790 def narrowmatch(self, match=None, includeexact=False): |
1786 """Obtain a matcher for the narrowspec.""" | 1791 """Obtain a matcher for the narrowspec.""" |
1787 | 1792 |
1793 @abc.abstractmethod | |
1788 def setnarrowpats(self, newincludes, newexcludes): | 1794 def setnarrowpats(self, newincludes, newexcludes): |
1789 """Define the narrowspec for this repository.""" | 1795 """Define the narrowspec for this repository.""" |
1790 | 1796 |
1797 @abc.abstractmethod | |
1791 def __getitem__(self, changeid): | 1798 def __getitem__(self, changeid): |
1792 """Try to resolve a changectx.""" | 1799 """Try to resolve a changectx.""" |
1793 | 1800 |
1801 @abc.abstractmethod | |
1794 def __contains__(self, changeid): | 1802 def __contains__(self, changeid): |
1795 """Whether a changeset exists.""" | 1803 """Whether a changeset exists.""" |
1796 | 1804 |
1805 @abc.abstractmethod | |
1797 def __nonzero__(self): | 1806 def __nonzero__(self): |
1798 """Always returns True.""" | 1807 """Always returns True.""" |
1799 return True | 1808 return True |
1800 | 1809 |
1801 __bool__ = __nonzero__ | 1810 __bool__ = __nonzero__ |
1802 | 1811 |
1812 @abc.abstractmethod | |
1803 def __len__(self): | 1813 def __len__(self): |
1804 """Returns the number of changesets in the repo.""" | 1814 """Returns the number of changesets in the repo.""" |
1805 | 1815 |
1816 @abc.abstractmethod | |
1806 def __iter__(self): | 1817 def __iter__(self): |
1807 """Iterate over revisions in the changelog.""" | 1818 """Iterate over revisions in the changelog.""" |
1808 | 1819 |
1820 @abc.abstractmethod | |
1809 def revs(self, expr, *args): | 1821 def revs(self, expr, *args): |
1810 """Evaluate a revset. | 1822 """Evaluate a revset. |
1811 | 1823 |
1812 Emits revisions. | 1824 Emits revisions. |
1813 """ | 1825 """ |
1814 | 1826 |
1827 @abc.abstractmethod | |
1815 def set(self, expr, *args): | 1828 def set(self, expr, *args): |
1816 """Evaluate a revset. | 1829 """Evaluate a revset. |
1817 | 1830 |
1818 Emits changectx instances. | 1831 Emits changectx instances. |
1819 """ | 1832 """ |
1820 | 1833 |
1834 @abc.abstractmethod | |
1821 def anyrevs(self, specs, user=False, localalias=None): | 1835 def anyrevs(self, specs, user=False, localalias=None): |
1822 """Find revisions matching one of the given revsets.""" | 1836 """Find revisions matching one of the given revsets.""" |
1823 | 1837 |
1838 @abc.abstractmethod | |
1824 def url(self): | 1839 def url(self): |
1825 """Returns a string representing the location of this repo.""" | 1840 """Returns a string representing the location of this repo.""" |
1826 | 1841 |
1842 @abc.abstractmethod | |
1827 def hook(self, name, throw=False, **args): | 1843 def hook(self, name, throw=False, **args): |
1828 """Call a hook.""" | 1844 """Call a hook.""" |
1829 | 1845 |
1846 @abc.abstractmethod | |
1830 def tags(self): | 1847 def tags(self): |
1831 """Return a mapping of tag to node.""" | 1848 """Return a mapping of tag to node.""" |
1832 | 1849 |
1850 @abc.abstractmethod | |
1833 def tagtype(self, tagname): | 1851 def tagtype(self, tagname): |
1834 """Return the type of a given tag.""" | 1852 """Return the type of a given tag.""" |
1835 | 1853 |
1854 @abc.abstractmethod | |
1836 def tagslist(self): | 1855 def tagslist(self): |
1837 """Return a list of tags ordered by revision.""" | 1856 """Return a list of tags ordered by revision.""" |
1838 | 1857 |
1858 @abc.abstractmethod | |
1839 def nodetags(self, node): | 1859 def nodetags(self, node): |
1840 """Return the tags associated with a node.""" | 1860 """Return the tags associated with a node.""" |
1841 | 1861 |
1862 @abc.abstractmethod | |
1842 def nodebookmarks(self, node): | 1863 def nodebookmarks(self, node): |
1843 """Return the list of bookmarks pointing to the specified node.""" | 1864 """Return the list of bookmarks pointing to the specified node.""" |
1844 | 1865 |
1866 @abc.abstractmethod | |
1845 def branchmap(self): | 1867 def branchmap(self): |
1846 """Return a mapping of branch to heads in that branch.""" | 1868 """Return a mapping of branch to heads in that branch.""" |
1847 | 1869 |
1870 @abc.abstractmethod | |
1848 def revbranchcache(self): | 1871 def revbranchcache(self): |
1849 pass | 1872 pass |
1850 | 1873 |
1874 @abc.abstractmethod | |
1851 def register_changeset(self, rev, changelogrevision): | 1875 def register_changeset(self, rev, changelogrevision): |
1852 """Extension point for caches for new nodes. | 1876 """Extension point for caches for new nodes. |
1853 | 1877 |
1854 Multiple consumers are expected to need parts of the changelogrevision, | 1878 Multiple consumers are expected to need parts of the changelogrevision, |
1855 so it is provided as optimization to avoid duplicate lookups. A simple | 1879 so it is provided as optimization to avoid duplicate lookups. A simple |
1856 cache would be fragile when other revisions are accessed, too.""" | 1880 cache would be fragile when other revisions are accessed, too.""" |
1857 pass | 1881 pass |
1858 | 1882 |
1883 @abc.abstractmethod | |
1859 def branchtip(self, branchtip, ignoremissing=False): | 1884 def branchtip(self, branchtip, ignoremissing=False): |
1860 """Return the tip node for a given branch.""" | 1885 """Return the tip node for a given branch.""" |
1861 | 1886 |
1887 @abc.abstractmethod | |
1862 def lookup(self, key): | 1888 def lookup(self, key): |
1863 """Resolve the node for a revision.""" | 1889 """Resolve the node for a revision.""" |
1864 | 1890 |
1891 @abc.abstractmethod | |
1865 def lookupbranch(self, key): | 1892 def lookupbranch(self, key): |
1866 """Look up the branch name of the given revision or branch name.""" | 1893 """Look up the branch name of the given revision or branch name.""" |
1867 | 1894 |
1895 @abc.abstractmethod | |
1868 def known(self, nodes): | 1896 def known(self, nodes): |
1869 """Determine whether a series of nodes is known. | 1897 """Determine whether a series of nodes is known. |
1870 | 1898 |
1871 Returns a list of bools. | 1899 Returns a list of bools. |
1872 """ | 1900 """ |
1873 | 1901 |
1902 @abc.abstractmethod | |
1874 def local(self): | 1903 def local(self): |
1875 """Whether the repository is local.""" | 1904 """Whether the repository is local.""" |
1876 return True | 1905 return True |
1877 | 1906 |
1907 @abc.abstractmethod | |
1878 def publishing(self): | 1908 def publishing(self): |
1879 """Whether the repository is a publishing repository.""" | 1909 """Whether the repository is a publishing repository.""" |
1880 | 1910 |
1911 @abc.abstractmethod | |
1881 def cancopy(self): | 1912 def cancopy(self): |
1882 pass | 1913 pass |
1883 | 1914 |
1915 @abc.abstractmethod | |
1884 def shared(self): | 1916 def shared(self): |
1885 """The type of shared repository or None.""" | 1917 """The type of shared repository or None.""" |
1886 | 1918 |
1919 @abc.abstractmethod | |
1887 def wjoin(self, f, *insidef): | 1920 def wjoin(self, f, *insidef): |
1888 """Calls self.vfs.reljoin(self.root, f, *insidef)""" | 1921 """Calls self.vfs.reljoin(self.root, f, *insidef)""" |
1889 | 1922 |
1923 @abc.abstractmethod | |
1890 def setparents(self, p1, p2): | 1924 def setparents(self, p1, p2): |
1891 """Set the parent nodes of the working directory.""" | 1925 """Set the parent nodes of the working directory.""" |
1892 | 1926 |
1927 @abc.abstractmethod | |
1893 def filectx(self, path, changeid=None, fileid=None): | 1928 def filectx(self, path, changeid=None, fileid=None): |
1894 """Obtain a filectx for the given file revision.""" | 1929 """Obtain a filectx for the given file revision.""" |
1895 | 1930 |
1931 @abc.abstractmethod | |
1896 def getcwd(self): | 1932 def getcwd(self): |
1897 """Obtain the current working directory from the dirstate.""" | 1933 """Obtain the current working directory from the dirstate.""" |
1898 | 1934 |
1935 @abc.abstractmethod | |
1899 def pathto(self, f, cwd=None): | 1936 def pathto(self, f, cwd=None): |
1900 """Obtain the relative path to a file.""" | 1937 """Obtain the relative path to a file.""" |
1901 | 1938 |
1939 @abc.abstractmethod | |
1902 def adddatafilter(self, name, fltr): | 1940 def adddatafilter(self, name, fltr): |
1903 pass | 1941 pass |
1904 | 1942 |
1943 @abc.abstractmethod | |
1905 def wread(self, filename): | 1944 def wread(self, filename): |
1906 """Read a file from wvfs, using data filters.""" | 1945 """Read a file from wvfs, using data filters.""" |
1907 | 1946 |
1947 @abc.abstractmethod | |
1908 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs): | 1948 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs): |
1909 """Write data to a file in the wvfs, using data filters.""" | 1949 """Write data to a file in the wvfs, using data filters.""" |
1910 | 1950 |
1951 @abc.abstractmethod | |
1911 def wwritedata(self, filename, data): | 1952 def wwritedata(self, filename, data): |
1912 """Resolve data for writing to the wvfs, using data filters.""" | 1953 """Resolve data for writing to the wvfs, using data filters.""" |
1913 | 1954 |
1955 @abc.abstractmethod | |
1914 def currenttransaction(self): | 1956 def currenttransaction(self): |
1915 """Obtain the current transaction instance or None.""" | 1957 """Obtain the current transaction instance or None.""" |
1916 | 1958 |
1959 @abc.abstractmethod | |
1917 def transaction(self, desc, report=None): | 1960 def transaction(self, desc, report=None): |
1918 """Open a new transaction to write to the repository.""" | 1961 """Open a new transaction to write to the repository.""" |
1919 | 1962 |
1963 @abc.abstractmethod | |
1920 def undofiles(self): | 1964 def undofiles(self): |
1921 """Returns a list of (vfs, path) for files to undo transactions.""" | 1965 """Returns a list of (vfs, path) for files to undo transactions.""" |
1922 | 1966 |
1967 @abc.abstractmethod | |
1923 def recover(self): | 1968 def recover(self): |
1924 """Roll back an interrupted transaction.""" | 1969 """Roll back an interrupted transaction.""" |
1925 | 1970 |
1971 @abc.abstractmethod | |
1926 def rollback(self, dryrun=False, force=False): | 1972 def rollback(self, dryrun=False, force=False): |
1927 """Undo the last transaction. | 1973 """Undo the last transaction. |
1928 | 1974 |
1929 DANGEROUS. | 1975 DANGEROUS. |
1930 """ | 1976 """ |
1931 | 1977 |
1978 @abc.abstractmethod | |
1932 def updatecaches(self, tr=None, full=False, caches=None): | 1979 def updatecaches(self, tr=None, full=False, caches=None): |
1933 """Warm repo caches.""" | 1980 """Warm repo caches.""" |
1934 | 1981 |
1982 @abc.abstractmethod | |
1935 def invalidatecaches(self): | 1983 def invalidatecaches(self): |
1936 """Invalidate cached data due to the repository mutating.""" | 1984 """Invalidate cached data due to the repository mutating.""" |
1937 | 1985 |
1986 @abc.abstractmethod | |
1938 def invalidatevolatilesets(self): | 1987 def invalidatevolatilesets(self): |
1939 pass | 1988 pass |
1940 | 1989 |
1990 @abc.abstractmethod | |
1941 def invalidatedirstate(self): | 1991 def invalidatedirstate(self): |
1942 """Invalidate the dirstate.""" | 1992 """Invalidate the dirstate.""" |
1943 | 1993 |
1994 @abc.abstractmethod | |
1944 def invalidate(self, clearfilecache=False): | 1995 def invalidate(self, clearfilecache=False): |
1945 pass | 1996 pass |
1946 | 1997 |
1998 @abc.abstractmethod | |
1947 def invalidateall(self): | 1999 def invalidateall(self): |
1948 pass | 2000 pass |
1949 | 2001 |
2002 @abc.abstractmethod | |
1950 def lock(self, wait=True): | 2003 def lock(self, wait=True): |
1951 """Lock the repository store and return a lock instance.""" | 2004 """Lock the repository store and return a lock instance.""" |
1952 | 2005 |
2006 @abc.abstractmethod | |
1953 def currentlock(self): | 2007 def currentlock(self): |
1954 """Return the lock if it's held or None.""" | 2008 """Return the lock if it's held or None.""" |
1955 | 2009 |
2010 @abc.abstractmethod | |
1956 def wlock(self, wait=True): | 2011 def wlock(self, wait=True): |
1957 """Lock the non-store parts of the repository.""" | 2012 """Lock the non-store parts of the repository.""" |
1958 | 2013 |
2014 @abc.abstractmethod | |
1959 def currentwlock(self): | 2015 def currentwlock(self): |
1960 """Return the wlock if it's held or None.""" | 2016 """Return the wlock if it's held or None.""" |
1961 | 2017 |
2018 @abc.abstractmethod | |
1962 def checkcommitpatterns(self, wctx, match, status, fail): | 2019 def checkcommitpatterns(self, wctx, match, status, fail): |
1963 pass | 2020 pass |
1964 | 2021 |
2022 @abc.abstractmethod | |
1965 def commit( | 2023 def commit( |
1966 self, | 2024 self, |
1967 text=b'', | 2025 text=b'', |
1968 user=None, | 2026 user=None, |
1969 date=None, | 2027 date=None, |
1972 editor=False, | 2030 editor=False, |
1973 extra=None, | 2031 extra=None, |
1974 ): | 2032 ): |
1975 """Add a new revision to the repository.""" | 2033 """Add a new revision to the repository.""" |
1976 | 2034 |
2035 @abc.abstractmethod | |
1977 def commitctx(self, ctx, error=False, origctx=None): | 2036 def commitctx(self, ctx, error=False, origctx=None): |
1978 """Commit a commitctx instance to the repository.""" | 2037 """Commit a commitctx instance to the repository.""" |
1979 | 2038 |
2039 @abc.abstractmethod | |
1980 def destroying(self): | 2040 def destroying(self): |
1981 """Inform the repository that nodes are about to be destroyed.""" | 2041 """Inform the repository that nodes are about to be destroyed.""" |
1982 | 2042 |
2043 @abc.abstractmethod | |
1983 def destroyed(self): | 2044 def destroyed(self): |
1984 """Inform the repository that nodes have been destroyed.""" | 2045 """Inform the repository that nodes have been destroyed.""" |
1985 | 2046 |
2047 @abc.abstractmethod | |
1986 def status( | 2048 def status( |
1987 self, | 2049 self, |
1988 node1=b'.', | 2050 node1=b'.', |
1989 node2=None, | 2051 node2=None, |
1990 match=None, | 2052 match=None, |
1993 unknown=False, | 2055 unknown=False, |
1994 listsubrepos=False, | 2056 listsubrepos=False, |
1995 ): | 2057 ): |
1996 """Convenience method to call repo[x].status().""" | 2058 """Convenience method to call repo[x].status().""" |
1997 | 2059 |
2060 @abc.abstractmethod | |
1998 def addpostdsstatus(self, ps): | 2061 def addpostdsstatus(self, ps): |
1999 pass | 2062 pass |
2000 | 2063 |
2064 @abc.abstractmethod | |
2001 def postdsstatus(self): | 2065 def postdsstatus(self): |
2002 pass | 2066 pass |
2003 | 2067 |
2068 @abc.abstractmethod | |
2004 def clearpostdsstatus(self): | 2069 def clearpostdsstatus(self): |
2005 pass | 2070 pass |
2006 | 2071 |
2072 @abc.abstractmethod | |
2007 def heads(self, start=None): | 2073 def heads(self, start=None): |
2008 """Obtain list of nodes that are DAG heads.""" | 2074 """Obtain list of nodes that are DAG heads.""" |
2009 | 2075 |
2076 @abc.abstractmethod | |
2010 def branchheads(self, branch=None, start=None, closed=False): | 2077 def branchheads(self, branch=None, start=None, closed=False): |
2011 pass | 2078 pass |
2012 | 2079 |
2080 @abc.abstractmethod | |
2013 def branches(self, nodes): | 2081 def branches(self, nodes): |
2014 pass | 2082 pass |
2015 | 2083 |
2084 @abc.abstractmethod | |
2016 def between(self, pairs): | 2085 def between(self, pairs): |
2017 pass | 2086 pass |
2018 | 2087 |
2088 @abc.abstractmethod | |
2019 def checkpush(self, pushop): | 2089 def checkpush(self, pushop): |
2020 pass | 2090 pass |
2021 | 2091 |
2022 prepushoutgoinghooks: util.hooks | 2092 prepushoutgoinghooks: util.hooks |
2023 """util.hooks instance.""" | 2093 """util.hooks instance.""" |
2024 | 2094 |
2095 @abc.abstractmethod | |
2025 def pushkey(self, namespace, key, old, new): | 2096 def pushkey(self, namespace, key, old, new): |
2026 pass | 2097 pass |
2027 | 2098 |
2099 @abc.abstractmethod | |
2028 def listkeys(self, namespace): | 2100 def listkeys(self, namespace): |
2029 pass | 2101 pass |
2030 | 2102 |
2103 @abc.abstractmethod | |
2031 def debugwireargs(self, one, two, three=None, four=None, five=None): | 2104 def debugwireargs(self, one, two, three=None, four=None, five=None): |
2032 pass | 2105 pass |
2033 | 2106 |
2107 @abc.abstractmethod | |
2034 def savecommitmessage(self, text): | 2108 def savecommitmessage(self, text): |
2035 pass | 2109 pass |
2036 | 2110 |
2111 @abc.abstractmethod | |
2037 def register_sidedata_computer( | 2112 def register_sidedata_computer( |
2038 self, kind, category, keys, computer, flags, replace=False | 2113 self, kind, category, keys, computer, flags, replace=False |
2039 ): | 2114 ): |
2040 pass | 2115 pass |
2041 | 2116 |
2117 @abc.abstractmethod | |
2042 def register_wanted_sidedata(self, category): | 2118 def register_wanted_sidedata(self, category): |
2043 pass | 2119 pass |
2044 | 2120 |
2045 | 2121 |
2046 class completelocalrepository( | 2122 class completelocalrepository( |