mercurial/localrepo.py
changeset 45942 89a2afe31e82
parent 45846 96ca817ec192
child 46003 c6a1fa42e325
--- a/mercurial/localrepo.py	Fri Nov 27 17:00:00 2020 -0500
+++ b/mercurial/localrepo.py	Fri Nov 27 17:03:29 2020 -0500
@@ -96,8 +96,7 @@
 
 
 class _basefilecache(scmutil.filecache):
-    """All filecache usage on repo are done for logic that should be unfiltered
-    """
+    """All filecache usage on repo are done for logic that should be unfiltered"""
 
     def __get__(self, repo, type=None):
         if repo is None:
@@ -400,8 +399,8 @@
 
 @interfaceutil.implementer(repository.ipeerlegacycommands)
 class locallegacypeer(localpeer):
-    '''peer extension which implements legacy methods too; used for tests with
-    restricted capabilities'''
+    """peer extension which implements legacy methods too; used for tests with
+    restricted capabilities"""
 
     def __init__(self, repo):
         super(locallegacypeer, self).__init__(repo, caps=legacycaps)
@@ -440,7 +439,7 @@
 
 
 def _getsharedvfs(hgvfs, requirements):
-    """ returns the vfs object pointing to root of shared source
+    """returns the vfs object pointing to root of shared source
     repo for a shared repository
 
     hgvfs is vfs pointing at .hg/ of current repo (shared one)
@@ -465,7 +464,7 @@
 
 
 def _readrequires(vfs, allowmissing):
-    """ reads the require file present at root of this vfs
+    """reads the require file present at root of this vfs
     and return a set of requirements
 
     If allowmissing is True, we suppress ENOENT if raised"""
@@ -1756,7 +1755,7 @@
         return iter(self.changelog)
 
     def revs(self, expr, *args):
-        '''Find revisions matching a revset.
+        """Find revisions matching a revset.
 
         The revset is specified as a string ``expr`` that may contain
         %-formatting to escape certain types. See ``revsetlang.formatspec``.
@@ -1767,30 +1766,30 @@
 
         Returns a smartset.abstractsmartset, which is a list-like interface
         that contains integer revisions.
-        '''
+        """
         tree = revsetlang.spectree(expr, *args)
         return revset.makematcher(tree)(self)
 
     def set(self, expr, *args):
-        '''Find revisions matching a revset and emit changectx instances.
+        """Find revisions matching a revset and emit changectx instances.
 
         This is a convenience wrapper around ``revs()`` that iterates the
         result and is a generator of changectx instances.
 
         Revset aliases from the configuration are not expanded. To expand
         user aliases, consider calling ``scmutil.revrange()``.
-        '''
+        """
         for r in self.revs(expr, *args):
             yield self[r]
 
     def anyrevs(self, specs, user=False, localalias=None):
-        '''Find revisions matching one of the given revsets.
+        """Find revisions matching one of the given revsets.
 
         Revset aliases from the configuration are not expanded by default. To
         expand user aliases, specify ``user=True``. To provide some local
         definitions overriding user aliases, set ``localalias`` to
         ``{name: definitionstring}``.
-        '''
+        """
         if specs == [b'null']:
             return revset.baseset([nullrev])
         if specs == [b'.']:
@@ -1822,8 +1821,8 @@
 
     @filteredpropertycache
     def _tagscache(self):
-        '''Returns a tagscache object that contains various tags related
-        caches.'''
+        """Returns a tagscache object that contains various tags related
+        caches."""
 
         # This simplifies its cache management by having one decorated
         # function (this one) and the rest simply fetch things from it.
@@ -1861,12 +1860,12 @@
         return t
 
     def _findtags(self):
-        '''Do the hard work of finding tags.  Return a pair of dicts
+        """Do the hard work of finding tags.  Return a pair of dicts
         (tags, tagtypes) where tags maps tag name to node, and tagtypes
         maps tag name to a string like \'global\' or \'local\'.
         Subclasses or extensions are free to add their own tags, but
         should be aware that the returned dicts will be retained for the
-        duration of the localrepo object.'''
+        duration of the localrepo object."""
 
         # XXX what tagtype should subclasses/extensions use?  Currently
         # mq and bookmarks add tags, but do not set the tagtype at all.
@@ -1897,13 +1896,13 @@
         return (tags, tagtypes)
 
     def tagtype(self, tagname):
-        '''
+        """
         return the type of the given tag. result can be:
 
         'local'  : a local tag
         'global' : a global tag
         None     : tag does not exist
-        '''
+        """
 
         return self._tagscache.tagtypes.get(tagname)
 
@@ -1933,8 +1932,8 @@
         return self._bookmarks.names(node)
 
     def branchmap(self):
-        '''returns a dictionary {branch: [branchheads]} with branchheads
-        ordered by increasing revision number'''
+        """returns a dictionary {branch: [branchheads]} with branchheads
+        ordered by increasing revision number"""
         return self._branchcaches[self]
 
     @unfilteredmethod
@@ -1944,13 +1943,13 @@
         return self._revbranchcache
 
     def branchtip(self, branch, ignoremissing=False):
-        '''return the tip node for a given branch
+        """return the tip node for a given branch
 
         If ignoremissing is True, then this method will not raise an error.
         This is helpful for callers that only expect None for a missing branch
         (e.g. namespace).
 
-        '''
+        """
         try:
             return self.branchmap().branchtip(branch)
         except KeyError:
@@ -2014,7 +2013,7 @@
 
     def filectx(self, path, changeid=None, fileid=None, changectx=None):
         """changeid must be a changeset revision, if specified.
-           fileid can be a file revision or node."""
+        fileid can be a file revision or node."""
         return context.filectx(
             self, path, changeid, fileid, changectx=changectx
         )
@@ -2311,8 +2310,7 @@
         tr.addfinalize(b'flush-fncache', self.store.write)
 
         def txnclosehook(tr2):
-            """To be run if transaction is successful, will schedule a hook run
-            """
+            """To be run if transaction is successful, will schedule a hook run"""
             # Don't reference tr2 in hook() so we don't hold a reference.
             # This reduces memory consumption when there are multiple
             # transactions per lock. This can likely go away if issue5045
@@ -2362,8 +2360,7 @@
         tr.addpostclose(b'-warm-cache', self._buildcacheupdater(tr))
 
         def txnaborthook(tr2):
-            """To be run if transaction is aborted
-            """
+            """To be run if transaction is aborted"""
             reporef().hook(
                 b'txnabort', throw=False, **pycompat.strkwargs(tr2.hookargs)
             )
@@ -2620,14 +2617,14 @@
         self._quick_access_changeid_invalidate()
 
     def invalidatedirstate(self):
-        '''Invalidates the dirstate, causing the next call to dirstate
+        """Invalidates the dirstate, causing the next call to dirstate
         to check if it was modified since the last time it was read,
         rereading it if it has.
 
         This is different to dirstate.invalidate() that it doesn't always
         rereads the dirstate. Use dirstate.invalidate() if you want to
         explicitly read the dirstate again (i.e. restoring it to a previous
-        known good state).'''
+        known good state)."""
         if hasunfilteredcache(self, 'dirstate'):
             for k in self.dirstate._filecache:
                 try:
@@ -2637,13 +2634,13 @@
             delattr(self.unfiltered(), 'dirstate')
 
     def invalidate(self, clearfilecache=False):
-        '''Invalidates both store and non-store parts other than dirstate
+        """Invalidates both store and non-store parts other than dirstate
 
         If a transaction is running, invalidation of store is omitted,
         because discarding in-memory changes might cause inconsistency
         (e.g. incomplete fncache causes unintentional failure, but
         redundant one doesn't).
-        '''
+        """
         unfiltered = self.unfiltered()  # all file caches are stored unfiltered
         for k in list(self._filecache.keys()):
             # dirstate is invalidated separately in invalidatedirstate()
@@ -2673,8 +2670,8 @@
             self.store.invalidatecaches()
 
     def invalidateall(self):
-        '''Fully invalidates both store and non-store parts, causing the
-        subsequent operation to reread any outside changes.'''
+        """Fully invalidates both store and non-store parts, causing the
+        subsequent operation to reread any outside changes."""
         # extension should hook this to invalidate its caches
         self.invalidate()
         self.invalidatedirstate()
@@ -2689,7 +2686,13 @@
             ce.refresh()
 
     def _lock(
-        self, vfs, lockname, wait, releasefn, acquirefn, desc,
+        self,
+        vfs,
+        lockname,
+        wait,
+        releasefn,
+        acquirefn,
+        desc,
     ):
         timeout = 0
         warntimeout = 0
@@ -2726,12 +2729,12 @@
             callback(True)
 
     def lock(self, wait=True):
-        '''Lock the repository store (.hg/store) and return a weak reference
+        """Lock the repository store (.hg/store) and return a weak reference
         to the lock. Use this before modifying the store (e.g. committing or
         stripping). If you are opening a transaction, get a lock as well.)
 
         If both 'lock' and 'wlock' must be acquired, ensure you always acquires
-        'wlock' first to avoid a dead-lock hazard.'''
+        'wlock' first to avoid a dead-lock hazard."""
         l = self._currentlock(self._lockref)
         if l is not None:
             l.lock()
@@ -2749,13 +2752,13 @@
         return l
 
     def wlock(self, wait=True):
-        '''Lock the non-store parts of the repository (everything under
+        """Lock the non-store parts of the repository (everything under
         .hg except .hg/store) and return a weak reference to the lock.
 
         Use this before modifying files in .hg.
 
         If both 'lock' and 'wlock' must be acquired, ensure you always acquires
-        'wlock' first to avoid a dead-lock hazard.'''
+        'wlock' first to avoid a dead-lock hazard."""
         l = self._wlockref and self._wlockref()
         if l is not None and l.held:
             l.lock()
@@ -2963,7 +2966,7 @@
 
     @unfilteredmethod
     def destroying(self):
-        '''Inform the repository that nodes are about to be destroyed.
+        """Inform the repository that nodes are about to be destroyed.
         Intended for use by strip and rollback, so there's a common
         place for anything that has to be done before destroying history.
 
@@ -2972,7 +2975,7 @@
         destroyed is imminent, the repo will be invalidated causing those
         changes to stay in memory (waiting for the next unlock), or vanish
         completely.
-        '''
+        """
         # When using the same lock to commit and strip, the phasecache is left
         # dirty after committing. Then when we strip, the repo is invalidated,
         # causing those changes to disappear.
@@ -2981,10 +2984,10 @@
 
     @unfilteredmethod
     def destroyed(self):
-        '''Inform the repository that nodes have been destroyed.
+        """Inform the repository that nodes have been destroyed.
         Intended for use by strip and rollback, so there's a common
         place for anything that has to be done after destroying history.
-        '''
+        """
         # When one tries to:
         # 1) destroy nodes thus calling this method (e.g. strip)
         # 2) use phasecache somewhere (e.g. commit)
@@ -3067,13 +3070,13 @@
         return sorted(heads, key=self.changelog.rev, reverse=True)
 
     def branchheads(self, branch=None, start=None, closed=False):
-        '''return a (possibly filtered) list of heads for the given branch
+        """return a (possibly filtered) list of heads for the given branch
 
         Heads are returned in topological order, from newest to oldest.
         If branch is None, use the dirstate branch.
         If start is not None, return only heads reachable from start.
         If closed is True, return heads that are marked as closed as well.
-        '''
+        """
         if branch is None:
             branch = self[None].branch()
         branches = self.branchmap()
@@ -3352,10 +3355,10 @@
 
 
 def checkrequirementscompat(ui, requirements):
-    """ Checks compatibility of repository requirements enabled and disabled.
+    """Checks compatibility of repository requirements enabled and disabled.
 
     Returns a set of requirements which needs to be dropped because dependend
-    requirements are not enabled. Also warns users about it """
+    requirements are not enabled. Also warns users about it"""
 
     dropped = set()