diff hgext/largefiles/remotestore.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 f0b6fbea00cf
children 687b865b95ad
line wrap: on
line diff
--- a/hgext/largefiles/remotestore.py	Sat Oct 05 10:29:34 2019 -0400
+++ b/hgext/largefiles/remotestore.py	Sun Oct 06 09:45:02 2019 -0400
@@ -14,9 +14,7 @@
     util,
 )
 
-from mercurial.utils import (
-    stringutil,
-)
+from mercurial.utils import stringutil
 
 from . import (
     basestore,
@@ -27,8 +25,10 @@
 urlerr = util.urlerr
 urlreq = util.urlreq
 
+
 class remotestore(basestore.basestore):
     '''a largefile store accessed over a network'''
+
     def __init__(self, ui, repo, url):
         super(remotestore, self).__init__(ui, repo, url)
         self._lstore = None
@@ -39,14 +39,18 @@
         if self.sendfile(source, hash):
             raise error.Abort(
                 _('remotestore: could not put %s to remote store %s')
-                % (source, util.hidepassword(self.url)))
+                % (source, util.hidepassword(self.url))
+            )
         self.ui.debug(
             _('remotestore: put %s to remote store %s\n')
-            % (source, util.hidepassword(self.url)))
+            % (source, util.hidepassword(self.url))
+        )
 
     def exists(self, hashes):
-        return dict((h, s == 0) for (h, s) in # dict-from-generator
-                    self._stat(hashes).iteritems())
+        return dict(
+            (h, s == 0)
+            for (h, s) in self._stat(hashes).iteritems()  # dict-from-generator
+        )
 
     def sendfile(self, filename, hash):
         self.ui.debug('remotestore: sendfile(%s, %s)\n' % (filename, hash))
@@ -56,7 +60,8 @@
         except IOError as e:
             raise error.Abort(
                 _('remotestore: could not open file %s: %s')
-                % (filename, stringutil.forcebytestr(e)))
+                % (filename, stringutil.forcebytestr(e))
+            )
 
     def _getfile(self, tmpfile, filename, hash):
         try:
@@ -64,17 +69,20 @@
         except urlerr.httperror as e:
             # 401s get converted to error.Aborts; everything else is fine being
             # turned into a StoreError
-            raise basestore.StoreError(filename, hash, self.url,
-                                       stringutil.forcebytestr(e))
+            raise basestore.StoreError(
+                filename, hash, self.url, stringutil.forcebytestr(e)
+            )
         except urlerr.urlerror as e:
             # This usually indicates a connection problem, so don't
             # keep trying with the other files... they will probably
             # all fail too.
-            raise error.Abort('%s: %s' %
-                             (util.hidepassword(self.url), e.reason))
+            raise error.Abort(
+                '%s: %s' % (util.hidepassword(self.url), e.reason)
+            )
         except IOError as e:
-            raise basestore.StoreError(filename, hash, self.url,
-                                       stringutil.forcebytestr(e))
+            raise basestore.StoreError(
+                filename, hash, self.url, stringutil.forcebytestr(e)
+            )
 
         return lfutil.copyandhash(chunks, tmpfile)
 
@@ -85,17 +93,24 @@
 
     def _verifyfiles(self, contents, filestocheck):
         failed = False
-        expectedhashes = [expectedhash
-                          for cset, filename, expectedhash in filestocheck]
+        expectedhashes = [
+            expectedhash for cset, filename, expectedhash in filestocheck
+        ]
         localhashes = self._hashesavailablelocally(expectedhashes)
-        stats = self._stat([expectedhash for expectedhash in expectedhashes
-                            if expectedhash not in localhashes])
+        stats = self._stat(
+            [
+                expectedhash
+                for expectedhash in expectedhashes
+                if expectedhash not in localhashes
+            ]
+        )
 
         for cset, filename, expectedhash in filestocheck:
             if expectedhash in localhashes:
                 filetocheck = (cset, filename, expectedhash)
-                verifyresult = self._lstore._verifyfiles(contents,
-                                                         [filetocheck])
+                verifyresult = self._lstore._verifyfiles(
+                    contents, [filetocheck]
+                )
                 if verifyresult:
                     failed = True
             else:
@@ -104,16 +119,19 @@
                     if stat == 1:
                         self.ui.warn(
                             _('changeset %s: %s: contents differ\n')
-                            % (cset, filename))
+                            % (cset, filename)
+                        )
                         failed = True
                     elif stat == 2:
                         self.ui.warn(
-                            _('changeset %s: %s missing\n')
-                            % (cset, filename))
+                            _('changeset %s: %s missing\n') % (cset, filename)
+                        )
                         failed = True
                     else:
-                        raise RuntimeError('verify failed: unexpected response '
-                                           'from statlfile (%r)' % stat)
+                        raise RuntimeError(
+                            'verify failed: unexpected response '
+                            'from statlfile (%r)' % stat
+                        )
         return failed
 
     def _put(self, hash, fd):