hgext/remotefilelog/shallowrepo.py
changeset 43076 2372284d9457
parent 42842 2c74337e6483
child 43077 687b865b95ad
--- a/hgext/remotefilelog/shallowrepo.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/hgext/remotefilelog/shallowrepo.py	Sun Oct 06 09:45:02 2019 -0400
@@ -43,19 +43,24 @@
 
     # Instantiate local data stores
     localcontent = contentstore.remotefilelogcontentstore(
-        repo, localpath, repo.name, shared=False)
+        repo, localpath, repo.name, shared=False
+    )
     localmetadata = metadatastore.remotefilelogmetadatastore(
-        repo, localpath, repo.name, shared=False)
+        repo, localpath, repo.name, shared=False
+    )
     return localcontent, localmetadata
 
+
 def makecachestores(repo):
     """Typically machine-wide, cache of remote data; can be discarded."""
     # Instantiate shared cache stores
     cachepath = shallowutil.getcachepath(repo.ui)
     cachecontent = contentstore.remotefilelogcontentstore(
-        repo, cachepath, repo.name, shared=True)
+        repo, cachepath, repo.name, shared=True
+    )
     cachemetadata = metadatastore.remotefilelogmetadatastore(
-        repo, cachepath, repo.name, shared=True)
+        repo, cachepath, repo.name, shared=True
+    )
 
     repo.sharedstore = cachecontent
     repo.shareddatastores.append(cachecontent)
@@ -63,30 +68,35 @@
 
     return cachecontent, cachemetadata
 
+
 def makeremotestores(repo, cachecontent, cachemetadata):
     """These stores fetch data from a remote server."""
     # Instantiate remote stores
     repo.fileservice = fileserverclient.fileserverclient(repo)
     remotecontent = contentstore.remotecontentstore(
-        repo.ui, repo.fileservice, cachecontent)
+        repo.ui, repo.fileservice, cachecontent
+    )
     remotemetadata = metadatastore.remotemetadatastore(
-        repo.ui, repo.fileservice, cachemetadata)
+        repo.ui, repo.fileservice, cachemetadata
+    )
     return remotecontent, remotemetadata
 
+
 def makepackstores(repo):
     """Packs are more efficient (to read from) cache stores."""
     # Instantiate pack stores
-    packpath = shallowutil.getcachepackpath(repo,
-                                            constants.FILEPACK_CATEGORY)
+    packpath = shallowutil.getcachepackpath(repo, constants.FILEPACK_CATEGORY)
     packcontentstore = datapack.datapackstore(repo.ui, packpath)
     packmetadatastore = historypack.historypackstore(repo.ui, packpath)
 
     repo.shareddatastores.append(packcontentstore)
     repo.sharedhistorystores.append(packmetadatastore)
-    shallowutil.reportpackmetrics(repo.ui, 'filestore', packcontentstore,
-        packmetadatastore)
+    shallowutil.reportpackmetrics(
+        repo.ui, 'filestore', packcontentstore, packmetadatastore
+    )
     return packcontentstore, packmetadatastore
 
+
 def makeunionstores(repo):
     """Union stores iterate the other stores and return the first result."""
     repo.shareddatastores = []
@@ -95,23 +105,38 @@
     packcontentstore, packmetadatastore = makepackstores(repo)
     cachecontent, cachemetadata = makecachestores(repo)
     localcontent, localmetadata = makelocalstores(repo)
-    remotecontent, remotemetadata = makeremotestores(repo, cachecontent,
-                                                     cachemetadata)
+    remotecontent, remotemetadata = makeremotestores(
+        repo, cachecontent, cachemetadata
+    )
 
     # Instantiate union stores
     repo.contentstore = contentstore.unioncontentstore(
-        packcontentstore, cachecontent,
-        localcontent, remotecontent, writestore=localcontent)
+        packcontentstore,
+        cachecontent,
+        localcontent,
+        remotecontent,
+        writestore=localcontent,
+    )
     repo.metadatastore = metadatastore.unionmetadatastore(
-        packmetadatastore, cachemetadata, localmetadata, remotemetadata,
-        writestore=localmetadata)
+        packmetadatastore,
+        cachemetadata,
+        localmetadata,
+        remotemetadata,
+        writestore=localmetadata,
+    )
 
     fileservicedatawrite = cachecontent
     fileservicehistorywrite = cachemetadata
-    repo.fileservice.setstore(repo.contentstore, repo.metadatastore,
-                              fileservicedatawrite, fileservicehistorywrite)
-    shallowutil.reportpackmetrics(repo.ui, 'filestore',
-        packcontentstore, packmetadatastore)
+    repo.fileservice.setstore(
+        repo.contentstore,
+        repo.metadatastore,
+        fileservicedatawrite,
+        fileservicehistorywrite,
+    )
+    shallowutil.reportpackmetrics(
+        repo.ui, 'filestore', packcontentstore, packmetadatastore
+    )
+
 
 def wraprepo(repo):
     class shallowrepository(repo.__class__):
@@ -121,11 +146,16 @@
 
         @util.propertycache
         def fallbackpath(self):
-            path = repo.ui.config("remotefilelog", "fallbackpath",
-                                  repo.ui.config('paths', 'default'))
+            path = repo.ui.config(
+                "remotefilelog",
+                "fallbackpath",
+                repo.ui.config('paths', 'default'),
+            )
             if not path:
-                raise error.Abort("no remotefilelog server "
-                    "configured - is your .hg/hgrc trusted?")
+                raise error.Abort(
+                    "no remotefilelog server "
+                    "configured - is your .hg/hgrc trusted?"
+                )
 
             return path
 
@@ -157,8 +187,9 @@
             if self.shallowmatch(path):
                 return remotefilectx.remotefilectx(self, path, *args, **kwargs)
             else:
-                return super(shallowrepository, self).filectx(path, *args,
-                                                              **kwargs)
+                return super(shallowrepository, self).filectx(
+                    path, *args, **kwargs
+                )
 
         @localrepo.unfilteredmethod
         def commitctx(self, ctx, error=False, origctx=None):
@@ -178,12 +209,19 @@
                     if fparent1 != nullid:
                         files.append((f, hex(fparent1)))
                 self.fileservice.prefetch(files)
-            return super(shallowrepository, self).commitctx(ctx,
-                                                            error=error,
-                                                            origctx=origctx)
+            return super(shallowrepository, self).commitctx(
+                ctx, error=error, origctx=origctx
+            )
 
-        def backgroundprefetch(self, revs, base=None, repack=False, pats=None,
-                               opts=None, ensurestart=False):
+        def backgroundprefetch(
+            self,
+            revs,
+            base=None,
+            repack=False,
+            pats=None,
+            opts=None,
+            ensurestart=False,
+        ):
             """Runs prefetch in background with optional repack
             """
             cmd = [procutil.hgexecutable(), '-R', repo.origroot, 'prefetch']
@@ -193,15 +231,22 @@
                 cmd += ['-r', revs]
             # We know this command will find a binary, so don't block
             # on it starting.
-            procutil.runbgcommand(cmd, encoding.environ,
-                                  ensurestart=ensurestart)
+            procutil.runbgcommand(
+                cmd, encoding.environ, ensurestart=ensurestart
+            )
 
         def prefetch(self, revs, base=None, pats=None, opts=None):
             """Prefetches all the necessary file revisions for the given revs
             Optionally runs repack in background
             """
-            with repo._lock(repo.svfs, 'prefetchlock', True, None, None,
-                            _('prefetching in %s') % repo.origroot):
+            with repo._lock(
+                repo.svfs,
+                'prefetchlock',
+                True,
+                None,
+                None,
+                _('prefetching in %s') % repo.origroot,
+            ):
                 self._prefetch(revs, base, pats, opts)
 
         def _prefetch(self, revs, base=None, pats=None, opts=None):
@@ -212,8 +257,9 @@
                 # become obsolete if the local commits are stripped.
                 localrevs = repo.revs('outgoing(%s)', fallbackpath)
                 if base is not None and base != nullrev:
-                    serverbase = list(repo.revs('first(reverse(::%s) - %ld)',
-                                                base, localrevs))
+                    serverbase = list(
+                        repo.revs('first(reverse(::%s) - %ld)', base, localrevs)
+                    )
                     if serverbase:
                         base = serverbase[0]
             else:
@@ -290,13 +336,16 @@
 
     makeunionstores(repo)
 
-    repo.includepattern = repo.ui.configlist("remotefilelog", "includepattern",
-                                             None)
-    repo.excludepattern = repo.ui.configlist("remotefilelog", "excludepattern",
-                                             None)
+    repo.includepattern = repo.ui.configlist(
+        "remotefilelog", "includepattern", None
+    )
+    repo.excludepattern = repo.ui.configlist(
+        "remotefilelog", "excludepattern", None
+    )
     if not util.safehasattr(repo, 'connectionpool'):
         repo.connectionpool = connectionpool.connectionpool(repo)
 
     if repo.includepattern or repo.excludepattern:
-        repo.shallowmatch = match.match(repo.root, '', None,
-            repo.includepattern, repo.excludepattern)
+        repo.shallowmatch = match.match(
+            repo.root, '', None, repo.includepattern, repo.excludepattern
+        )