diff mercurial/interfaces/repository.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents a12a9af7536c
children 687b865b95ad
line wrap: on
line diff
--- a/mercurial/interfaces/repository.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/mercurial/interfaces/repository.py	Sun Oct 06 09:45:02 2019 -0400
@@ -8,12 +8,8 @@
 from __future__ import absolute_import
 
 from ..i18n import _
-from .. import (
-    error,
-)
-from . import (
-    util as interfaceutil,
-)
+from .. import error
+from . import util as interfaceutil
 
 # When narrowing is finalized and no longer subject to format changes,
 # we should move this to just "narrow" or similar.
@@ -38,7 +34,9 @@
 REVISION_FLAG_SIDEDATA = 1 << 12
 
 REVISION_FLAGS_KNOWN = (
-    REVISION_FLAG_CENSORED | REVISION_FLAG_ELLIPSIS | REVISION_FLAG_EXTSTORED
+    REVISION_FLAG_CENSORED
+    | REVISION_FLAG_ELLIPSIS
+    | REVISION_FLAG_EXTSTORED
     | REVISION_FLAG_SIDEDATA
 )
 
@@ -47,6 +45,7 @@
 CG_DELTAMODE_FULL = b'fulltext'
 CG_DELTAMODE_P1 = b'p1'
 
+
 class ipeerconnection(interfaceutil.Interface):
     """Represents a "connection" to a repository.
 
@@ -56,6 +55,7 @@
     This is not a complete interface definition and should not be used
     outside of this module.
     """
+
     ui = interfaceutil.Attribute("""ui.ui instance""")
 
     def url():
@@ -93,6 +93,7 @@
         associated with the peer should be cleaned up.
         """
 
+
 class ipeercapabilities(interfaceutil.Interface):
     """Peer sub-interface related to capabilities."""
 
@@ -113,6 +114,7 @@
         Raises a ``CapabilityError`` if the capability isn't present.
         """
 
+
 class ipeercommands(interfaceutil.Interface):
     """Client-side interface for communicating over the wire protocol.
 
@@ -202,6 +204,7 @@
         Returns the integer number of heads added to the peer.
         """
 
+
 class ipeerlegacycommands(interfaceutil.Interface):
     """Interface for implementing support for legacy wire protocol commands.
 
@@ -234,6 +237,7 @@
     def changegroupsubset(bases, heads, source):
         pass
 
+
 class ipeercommandexecutor(interfaceutil.Interface):
     """Represents a mechanism to execute remote commands.
 
@@ -291,6 +295,7 @@
         This method may call ``sendcommands()`` if there are buffered commands.
         """
 
+
 class ipeerrequests(interfaceutil.Interface):
     """Interface for executing commands on a peer."""
 
@@ -320,17 +325,21 @@
         being issued.
         """
 
+
 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
     """Unified interface for peer repositories.
 
     All peer instances must conform to this interface.
     """
 
+
 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests):
     """Unified peer interface for wire protocol version 2 peers."""
 
     apidescriptor = interfaceutil.Attribute(
-        """Data structure holding description of server API.""")
+        """Data structure holding description of server API."""
+    )
+
 
 @interfaceutil.implementer(ipeerbase)
 class peer(object):
@@ -346,7 +355,7 @@
         name = '%s=' % name
         for cap in caps:
             if cap.startswith(name):
-                return cap[len(name):]
+                return cap[len(name) :]
 
         return False
 
@@ -355,8 +364,13 @@
             return
 
         raise error.CapabilityError(
-            _('cannot %s; remote repository does not support the '
-              '\'%s\' capability') % (purpose, name))
+            _(
+                'cannot %s; remote repository does not support the '
+                '\'%s\' capability'
+            )
+            % (purpose, name)
+        )
+
 
 class iverifyproblem(interfaceutil.Interface):
     """Represents a problem with the integrity of the repository.
@@ -366,17 +380,20 @@
 
     Instances are essentially messages associated with severity.
     """
+
     warning = interfaceutil.Attribute(
-        """Message indicating a non-fatal problem.""")
-
-    error = interfaceutil.Attribute(
-        """Message indicating a fatal problem.""")
+        """Message indicating a non-fatal problem."""
+    )
+
+    error = interfaceutil.Attribute("""Message indicating a fatal problem.""")
 
     node = interfaceutil.Attribute(
         """Revision encountering the problem.
 
         ``None`` means the problem doesn't apply to a single revision.
-        """)
+        """
+    )
+
 
 class irevisiondelta(interfaceutil.Interface):
     """Represents a delta between one revision and another.
@@ -391,45 +408,53 @@
     Typically used for changegroup generation.
     """
 
-    node = interfaceutil.Attribute(
-        """20 byte node of this revision.""")
+    node = interfaceutil.Attribute("""20 byte node of this revision.""")
 
     p1node = interfaceutil.Attribute(
-        """20 byte node of 1st parent of this revision.""")
+        """20 byte node of 1st parent of this revision."""
+    )
 
     p2node = interfaceutil.Attribute(
-        """20 byte node of 2nd parent of this revision.""")
+        """20 byte node of 2nd parent of this revision."""
+    )
 
     linknode = interfaceutil.Attribute(
-        """20 byte node of the changelog revision this node is linked to.""")
+        """20 byte node of the changelog revision this node is linked to."""
+    )
 
     flags = interfaceutil.Attribute(
         """2 bytes of integer flags that apply to this revision.
 
         This is a bitwise composition of the ``REVISION_FLAG_*`` constants.
-        """)
+        """
+    )
 
     basenode = interfaceutil.Attribute(
         """20 byte node of the revision this data is a delta against.
 
         ``nullid`` indicates that the revision is a full revision and not
         a delta.
-        """)
+        """
+    )
 
     baserevisionsize = interfaceutil.Attribute(
         """Size of base revision this delta is against.
 
         May be ``None`` if ``basenode`` is ``nullid``.
-        """)
+        """
+    )
 
     revision = interfaceutil.Attribute(
-        """Raw fulltext of revision data for this node.""")
+        """Raw fulltext of revision data for this node."""
+    )
 
     delta = interfaceutil.Attribute(
         """Delta between ``basenode`` and ``node``.
 
         Stored in the bdiff delta format.
-        """)
+        """
+    )
+
 
 class ifilerevisionssequence(interfaceutil.Interface):
     """Contains index data for all revisions of a file.
@@ -482,6 +507,7 @@
     def insert(self, i, entry):
         """Add an item to the index at specific revision."""
 
+
 class ifileindex(interfaceutil.Interface):
     """Storage interface for index data of a single file.
 
@@ -494,6 +520,7 @@
     * DAG data (storing and querying the relationship between nodes).
     * Metadata to facilitate storage.
     """
+
     def __len__():
         """Obtain the number of revisions stored for this file."""
 
@@ -577,12 +604,14 @@
         Returns a list of nodes.
         """
 
+
 class ifiledata(interfaceutil.Interface):
     """Storage interface for data storage of a specific file.
 
     This complements ``ifileindex`` and provides an interface for accessing
     data for a tracked file.
     """
+
     def size(rev):
         """Obtain the fulltext size of file data.
 
@@ -628,11 +657,13 @@
         TODO better document the copy metadata and censoring logic.
         """
 
-    def emitrevisions(nodes,
-                      nodesorder=None,
-                      revisiondata=False,
-                      assumehaveparentrevisions=False,
-                      deltamode=CG_DELTAMODE_STD):
+    def emitrevisions(
+        nodes,
+        nodesorder=None,
+        revisiondata=False,
+        assumehaveparentrevisions=False,
+        deltamode=CG_DELTAMODE_STD,
+    ):
         """Produce ``irevisiondelta`` for revisions.
 
         Given an iterable of nodes, emits objects conforming to the
@@ -681,6 +712,7 @@
         1st parent.
         """
 
+
 class ifilemutation(interfaceutil.Interface):
     """Storage interface for mutation events of a tracked file."""
 
@@ -695,8 +727,16 @@
         May no-op if a revision matching the supplied data is already stored.
         """
 
-    def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
-                    flags=0, cachedelta=None):
+    def addrevision(
+        revisiondata,
+        transaction,
+        linkrev,
+        p1,
+        p2,
+        node=None,
+        flags=0,
+        cachedelta=None,
+    ):
         """Add a new revision to the store.
 
         This is similar to ``add()`` except it operates at a lower level.
@@ -713,8 +753,13 @@
         applying raw data from a peer repo.
         """
 
-    def addgroup(deltas, linkmapper, transaction, addrevisioncb=None,
-                 maybemissingparents=False):
+    def addgroup(
+        deltas,
+        linkmapper,
+        transaction,
+        addrevisioncb=None,
+        maybemissingparents=False,
+    ):
         """Process a series of deltas for storage.
 
         ``deltas`` is an iterable of 7-tuples of
@@ -774,6 +819,7 @@
         higher-level deletion API.
         """
 
+
 class ifilestorage(ifileindex, ifiledata, ifilemutation):
     """Complete storage interface for a single tracked file."""
 
@@ -784,9 +830,13 @@
         be a better API for that.
         """
 
-    def storageinfo(exclusivefiles=False, sharedfiles=False,
-                    revisionscount=False, trackedsize=False,
-                    storedsize=False):
+    def storageinfo(
+        exclusivefiles=False,
+        sharedfiles=False,
+        revisionscount=False,
+        trackedsize=False,
+        storedsize=False,
+    ):
         """Obtain information about storage for this file's data.
 
         Returns a dict describing storage for this tracked path. The keys
@@ -834,6 +884,7 @@
         interface.
         """
 
+
 class idirs(interfaceutil.Interface):
     """Interface representing a collection of directories from paths.
 
@@ -860,6 +911,7 @@
     def __contains__(path):
         """Whether a specific directory is in this collection."""
 
+
 class imanifestdict(interfaceutil.Interface):
     """Interface representing a manifest data structure.
 
@@ -1009,6 +1061,7 @@
         delta between ``base`` and this manifest.
         """
 
+
 class imanifestrevisionbase(interfaceutil.Interface):
     """Base interface representing a single revision of a manifest.
 
@@ -1038,6 +1091,7 @@
         The returned object conforms to the ``imanifestdict`` interface.
         """
 
+
 class imanifestrevisionstored(imanifestrevisionbase):
     """Interface representing a manifest revision committed to storage."""
 
@@ -1069,6 +1123,7 @@
         Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
         """
 
+
 class imanifestrevisionwritable(imanifestrevisionbase):
     """Interface representing a manifest revision that can be committed."""
 
@@ -1087,6 +1142,7 @@
         Returns the binary node of the created revision.
         """
 
+
 class imanifeststorage(interfaceutil.Interface):
     """Storage interface for manifest data."""
 
@@ -1094,40 +1150,47 @@
         """The path to the directory this manifest tracks.
 
         The empty bytestring represents the root manifest.
-        """)
+        """
+    )
 
     index = interfaceutil.Attribute(
-        """An ``ifilerevisionssequence`` instance.""")
+        """An ``ifilerevisionssequence`` instance."""
+    )
 
     indexfile = interfaceutil.Attribute(
         """Path of revlog index file.
 
         TODO this is revlog specific and should not be exposed.
-        """)
+        """
+    )
 
     opener = interfaceutil.Attribute(
         """VFS opener to use to access underlying files used for storage.
 
         TODO this is revlog specific and should not be exposed.
-        """)
+        """
+    )
 
     version = interfaceutil.Attribute(
         """Revlog version number.
 
         TODO this is revlog specific and should not be exposed.
-        """)
+        """
+    )
 
     _generaldelta = interfaceutil.Attribute(
         """Whether generaldelta storage is being used.
 
         TODO this is revlog specific and should not be exposed.
-        """)
+        """
+    )
 
     fulltextcache = interfaceutil.Attribute(
         """Dict with cache of fulltexts.
 
         TODO this doesn't feel appropriate for the storage interface.
-        """)
+        """
+    )
 
     def __len__():
         """Obtain the number of revisions stored for this manifest."""
@@ -1187,10 +1250,12 @@
         Returns True if the fulltext is different from what is stored.
         """
 
-    def emitrevisions(nodes,
-                      nodesorder=None,
-                      revisiondata=False,
-                      assumehaveparentrevisions=False):
+    def emitrevisions(
+        nodes,
+        nodesorder=None,
+        revisiondata=False,
+        assumehaveparentrevisions=False,
+    ):
         """Produce ``irevisiondelta`` describing revisions.
 
         See the documentation for ``ifiledata`` for more.
@@ -1251,8 +1316,9 @@
     def dirlog(d):
         """Obtain a manifest storage instance for a tree."""
 
-    def add(m, transaction, link, p1, p2, added, removed, readtree=None,
-            match=None):
+    def add(
+        m, transaction, link, p1, p2, added, removed, readtree=None, match=None
+    ):
         """Add a revision to storage.
 
         ``m`` is an object conforming to ``imanifestdict``.
@@ -1274,15 +1340,20 @@
         manifest including files that did not match.
         """
 
-    def storageinfo(exclusivefiles=False, sharedfiles=False,
-                    revisionscount=False, trackedsize=False,
-                    storedsize=False):
+    def storageinfo(
+        exclusivefiles=False,
+        sharedfiles=False,
+        revisionscount=False,
+        trackedsize=False,
+        storedsize=False,
+    ):
         """Obtain information about storage for this manifest's data.
 
         See ``ifilestorage.storageinfo()`` for a description of this method.
         This one behaves the same way, except for manifest data.
         """
 
+
 class imanifestlog(interfaceutil.Interface):
     """Interface representing a collection of manifest snapshots.
 
@@ -1336,6 +1407,7 @@
         Raises ``error.LookupError`` if the node is not known.
         """
 
+
 class ilocalrepositoryfilestorage(interfaceutil.Interface):
     """Local repository sub-interface providing access to tracked file storage.
 
@@ -1349,6 +1421,7 @@
         The returned type conforms to the ``ifilestorage`` interface.
         """
 
+
 class ilocalrepositorymain(interfaceutil.Interface):
     """Main interface for local repositories.
 
@@ -1359,13 +1432,16 @@
         """Set of requirements that apply to stream clone.
 
         This is actually a class attribute and is shared among all instances.
-        """)
+        """
+    )
 
     supported = interfaceutil.Attribute(
-        """Set of requirements that this repo is capable of opening.""")
+        """Set of requirements that this repo is capable of opening."""
+    )
 
     requirements = interfaceutil.Attribute(
-        """Set of requirements this repo uses.""")
+        """Set of requirements this repo uses."""
+    )
 
     features = interfaceutil.Attribute(
         """Set of "features" this repository supports.
@@ -1383,35 +1459,41 @@
         requirements are stored on-disk and represent requirements to open the
         repository. Features are more run-time capabilities of the repository
         and more granular capabilities (which may be derived from requirements).
-        """)
+        """
+    )
 
     filtername = interfaceutil.Attribute(
-        """Name of the repoview that is active on this repo.""")
+        """Name of the repoview that is active on this repo."""
+    )
 
     wvfs = interfaceutil.Attribute(
-        """VFS used to access the working directory.""")
+        """VFS used to access the working directory."""
+    )
 
     vfs = interfaceutil.Attribute(
         """VFS rooted at the .hg directory.
 
         Used to access repository data not in the store.
-        """)
+        """
+    )
 
     svfs = interfaceutil.Attribute(
         """VFS rooted at the store.
 
         Used to access repository data in the store. Typically .hg/store.
         But can point elsewhere if the store is shared.
-        """)
+        """
+    )
 
     root = interfaceutil.Attribute(
-        """Path to the root of the working directory.""")
-
-    path = interfaceutil.Attribute(
-        """Path to the .hg directory.""")
+        """Path to the root of the working directory."""
+    )
+
+    path = interfaceutil.Attribute("""Path to the .hg directory.""")
 
     origroot = interfaceutil.Attribute(
-        """The filesystem path that was used to construct the repo.""")
+        """The filesystem path that was used to construct the repo."""
+    )
 
     auditor = interfaceutil.Attribute(
         """A pathauditor for the working directory.
@@ -1419,49 +1501,51 @@
         This checks if a path refers to a nested repository.
 
         Operates on the filesystem.
-        """)
+        """
+    )
 
     nofsauditor = interfaceutil.Attribute(
         """A pathauditor for the working directory.
 
         This is like ``auditor`` except it doesn't do filesystem checks.
-        """)
+        """
+    )
 
     baseui = interfaceutil.Attribute(
-        """Original ui instance passed into constructor.""")
-
-    ui = interfaceutil.Attribute(
-        """Main ui instance for this instance.""")
+        """Original ui instance passed into constructor."""
+    )
+
+    ui = interfaceutil.Attribute("""Main ui instance for this instance.""")
 
     sharedpath = interfaceutil.Attribute(
-        """Path to the .hg directory of the repo this repo was shared from.""")
-
-    store = interfaceutil.Attribute(
-        """A store instance.""")
-
-    spath = interfaceutil.Attribute(
-        """Path to the store.""")
-
-    sjoin = interfaceutil.Attribute(
-        """Alias to self.store.join.""")
+        """Path to the .hg directory of the repo this repo was shared from."""
+    )
+
+    store = interfaceutil.Attribute("""A store instance.""")
+
+    spath = interfaceutil.Attribute("""Path to the store.""")
+
+    sjoin = interfaceutil.Attribute("""Alias to self.store.join.""")
 
     cachevfs = interfaceutil.Attribute(
         """A VFS used to access the cache directory.
 
         Typically .hg/cache.
-        """)
+        """
+    )
 
     wcachevfs = interfaceutil.Attribute(
         """A VFS used to access the cache directory dedicated to working copy
 
         Typically .hg/wcache.
-        """)
+        """
+    )
 
     filteredrevcache = interfaceutil.Attribute(
-        """Holds sets of revisions to be filtered.""")
-
-    names = interfaceutil.Attribute(
-        """A ``namespaces`` instance.""")
+        """Holds sets of revisions to be filtered."""
+    )
+
+    names = interfaceutil.Attribute("""A ``namespaces`` instance.""")
 
     def close():
         """Close the handle on this repository."""
@@ -1475,23 +1559,22 @@
     def filtered(name, visibilityexceptions=None):
         """Obtain a named view of this repository."""
 
-    obsstore = interfaceutil.Attribute(
-        """A store of obsolescence data.""")
-
-    changelog = interfaceutil.Attribute(
-        """A handle on the changelog revlog.""")
+    obsstore = interfaceutil.Attribute("""A store of obsolescence data.""")
+
+    changelog = interfaceutil.Attribute("""A handle on the changelog revlog.""")
 
     manifestlog = interfaceutil.Attribute(
         """An instance conforming to the ``imanifestlog`` interface.
 
         Provides access to manifests for the repository.
-        """)
-
-    dirstate = interfaceutil.Attribute(
-        """Working directory state.""")
+        """
+    )
+
+    dirstate = interfaceutil.Attribute("""Working directory state.""")
 
     narrowpats = interfaceutil.Attribute(
-        """Matcher patterns for this repository's narrowspec.""")
+        """Matcher patterns for this repository's narrowspec."""
+    )
 
     def narrowmatch(match=None, includeexact=False):
         """Obtain a matcher for the narrowspec."""
@@ -1662,8 +1745,15 @@
     def checkcommitpatterns(wctx, vdirs, match, status, fail):
         pass
 
-    def commit(text='', user=None, date=None, match=None, force=False,
-               editor=False, extra=None):
+    def commit(
+        text='',
+        user=None,
+        date=None,
+        match=None,
+        force=False,
+        editor=False,
+        extra=None,
+    ):
         """Add a new revision to the repository."""
 
     def commitctx(ctx, error=False, origctx=None):
@@ -1675,8 +1765,15 @@
     def destroyed():
         """Inform the repository that nodes have been destroyed."""
 
-    def status(node1='.', node2=None, match=None, ignored=False,
-               clean=False, unknown=False, listsubrepos=False):
+    def status(
+        node1='.',
+        node2=None,
+        match=None,
+        ignored=False,
+        clean=False,
+        unknown=False,
+        listsubrepos=False,
+    ):
         """Convenience method to call repo[x].status()."""
 
     def addpostdsstatus(ps):
@@ -1703,8 +1800,7 @@
     def checkpush(pushop):
         pass
 
-    prepushoutgoinghooks = interfaceutil.Attribute(
-        """util.hooks instance.""")
+    prepushoutgoinghooks = interfaceutil.Attribute("""util.hooks instance.""")
 
     def pushkey(namespace, key, old, new):
         pass
@@ -1718,10 +1814,13 @@
     def savecommitmessage(text):
         pass
 
-class completelocalrepository(ilocalrepositorymain,
-                              ilocalrepositoryfilestorage):
+
+class completelocalrepository(
+    ilocalrepositorymain, ilocalrepositoryfilestorage
+):
     """Complete interface for a local repository."""
 
+
 class iwireprotocolcommandcacher(interfaceutil.Interface):
     """Represents a caching backend for wire protocol commands.
 
@@ -1804,6 +1903,7 @@
     could wrap the encoded object data in ``wireprototypes.encodedresponse``
     instances to avoid this overhead.
     """
+
     def __enter__():
         """Marks the instance as active.