diff --git a/contrib/hggitperf.py b/contrib/hggitperf.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_Y29udHJpYi9oZ2dpdHBlcmYucHk=..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_Y29udHJpYi9oZ2dpdHBlcmYucHk= 100644
--- a/contrib/hggitperf.py
+++ b/contrib/hggitperf.py
@@ -33,6 +33,7 @@
     fm = ui.formatter(b'perf', opts)
     return functools.partial(_timer, fm), fm
 
+
 def _timer(fm, func, title=None):
     results = []
     begin = time.time()
@@ -45,7 +46,7 @@
         ostop = os.times()
         count += 1
         a, b = ostart, ostop
-        results.append((cstop - cstart, b[0] - a[0], b[1]-a[1]))
+        results.append((cstop - cstart, b[0] - a[0], b[1] - a[1]))
         if cstop - begin > 3 and count >= 100:
             break
         if cstop - begin > 10 and count >= 3:
@@ -62,7 +63,7 @@
     fm.write(b'wall', b' wall %f', m[0])
     fm.write(b'comb', b' comb %f', m[1] + m[2])
     fm.write(b'user', b' user %f', m[1])
-    fm.write(b'sys',  b' sys %f', m[2])
-    fm.write(b'count',  b' (best of %d)', count)
+    fm.write(b'sys', b' sys %f', m[2])
+    fm.write(b'count', b' (best of %d)', count)
     fm.plain(b'\n')
 
@@ -67,8 +68,9 @@
     fm.plain(b'\n')
 
+
 @command(b'perfgitloadmap')
 def perfgitloadmap(ui, repo):
     timer, fm = gettimer(ui)
     timer(repo.githandler.load_map)
     fm.end()
 
@@ -69,9 +71,10 @@
 @command(b'perfgitloadmap')
 def perfgitloadmap(ui, repo):
     timer, fm = gettimer(ui)
     timer(repo.githandler.load_map)
     fm.end()
 
+
 @command(b'perfgitsavemap')
 def perfgitsavemap(ui, repo):
     timer, fm = gettimer(ui)
diff --git a/hggit/__init__.py b/hggit/__init__.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvX19pbml0X18ucHk=..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvX19pbml0X18ucHk= 100644
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -162,7 +162,7 @@
     b'collections',
 }
 
-testedwith = (b'5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0')
+testedwith = b'5.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0'
 minimumhgversion = b'5.2'
 buglink = b'https://foss.heptapod.net/mercurial/hg-git/issues'
 
diff --git a/hggit/_ssh.py b/hggit/_ssh.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvX3NzaC5weQ==..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvX3NzaC5weQ== 100644
--- a/hggit/_ssh.py
+++ b/hggit/_ssh.py
@@ -23,8 +23,9 @@
             assert isinstance(command, str)
             command = command.encode(SSHGitClient.DEFAULT_ENCODING)
             sshcmd = ui.config(b"ui", b"ssh", b"ssh")
-            args = procutil.sshargs(sshcmd, pycompat.bytesurl(host),
-                                  username, port)
+            args = procutil.sshargs(
+                sshcmd, pycompat.bytesurl(host), username, port
+            )
             cmd = b'%s %s %s' % (sshcmd, args, procutil.shellquote(command))
             # consistent with mercurial
             ui.debug(b'running %s\n' % cmd)
diff --git a/hggit/commands.py b/hggit/commands.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvY29tbWFuZHMucHk=..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvY29tbWFuZHMucHk= 100644
--- a/hggit/commands.py
+++ b/hggit/commands.py
@@ -137,19 +137,23 @@
     opts = pycompat.byteskwargs(opts)
 
     # check for various unimplemented arguments
-    compat.check_incompatible_arguments(opts, b'git', [
-        # conflict
-        b'local',
-        # we currently don't convert or expose this metadata, so
-        # disallow setting it on creation
-        b'edit',
-        b'message',
-        b'date',
-        b'user',
-    ])
+    compat.check_incompatible_arguments(
+        opts,
+        b'git',
+        [
+            # conflict
+            b'local',
+            # we currently don't convert or expose this metadata, so
+            # disallow setting it on creation
+            b'edit',
+            b'message',
+            b'date',
+            b'user',
+        ],
+    )
     compat.check_at_most_one_arg(opts, b'rev', b'remove')
 
     if opts[b'remove']:
         opts[b'rev'] = b'null'
 
     if not opts.get(b'rev'):
@@ -150,11 +154,13 @@
     compat.check_at_most_one_arg(opts, b'rev', b'remove')
 
     if opts[b'remove']:
         opts[b'rev'] = b'null'
 
     if not opts.get(b'rev'):
-        raise error.Abort(_(b'git tags require an explicit revision'),
-                          hint=b'please specify -r/--rev')
+        raise error.Abort(
+            _(b'git tags require an explicit revision'),
+            hint=b'please specify -r/--rev',
+        )
 
     # the semantics of git tag editing are quite confusing, so we
     # don't bother; if you _really_ want to, use another tool to do
diff --git a/hggit/compat.py b/hggit/compat.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvY29tcGF0LnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvY29tcGF0LnB5 100644
--- a/hggit/compat.py
+++ b/hggit/compat.py
@@ -15,6 +15,7 @@
 
 # 5.9 and earlier used a future-based API
 if hasattr(wireprotov1peer, 'future'):
+
     def makebatchable(fn):
         @functools.wraps(fn)
         @wireprotov1peer.batchable
@@ -23,5 +24,7 @@
             yield fn(*args, **kwargs)
 
         return wrapper
+
+
 # 6.0 and later simplified the API
 else:
@@ -26,5 +29,6 @@
 # 6.0 and later simplified the API
 else:
+
     def makebatchable(fn):
         @functools.wraps(fn)
         @wireprotov1peer.batchable
@@ -33,6 +37,7 @@
 
         return wrapper
 
+
 def sysbytes(s):
     # 5.2 does not check this
     if isinstance(s, str):
@@ -40,6 +45,7 @@
     else:
         return s
 
+
 try:
     # moved in 5.9
     from mercurial.utils.stringutil import parselist
@@ -52,6 +58,7 @@
     # added in 5.9
     from mercurial.node import sha1nodeconstants
 except ImportError:
+
     class sha1nodeconstants(object):
         nodelen = len(node.nullid)
 
@@ -64,6 +71,7 @@
         wdirid = node.wdirid
         wdirhex = node.wdirhex
 
+
 try:
     # added in 5.8
     from mercurial.utils import urlutil
@@ -84,6 +92,7 @@
     class HTTPUnauthorized(Exception):
         pass
 
+
 try:
     from mercurial.cmdutil import check_at_most_one_arg
 except (ImportError, AttributeError):
@@ -108,6 +117,7 @@
                 previous = x
         return previous
 
+
 # added in 5.3 but changed in 5.4, so always use our implementation
 def check_incompatible_arguments(opts, first, others):
     """abort if the first argument is given along with any of the others
diff --git a/hggit/config.py b/hggit/config.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvY29uZmlnLnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvY29uZmlnLnB5 100644
--- a/hggit/config.py
+++ b/hggit/config.py
@@ -8,7 +8,7 @@
     b'git': {
         b'authors': None,
         b'branch_bookmark_suffix': None,
-        b'debugextrainmessage': False,   # test only -- do not document this!
+        b'debugextrainmessage': False,  # test only -- do not document this!
         b'findcopiesharder': False,
         b'intree': None,
         b'mindate': None,
@@ -24,7 +24,7 @@
         b'usephases': False,
         b'retries': 3,
         b'invalidpaths': b'skip',
-    }
+    },
 }
 
 for section, items in CONFIG_DEFAULTS.items():
diff --git a/hggit/git2hg.py b/hggit/git2hg.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvZ2l0MmhnLnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvZ2l0MmhnLnB5 100644
--- a/hggit/git2hg.py
+++ b/hggit/git2hg.py
@@ -21,11 +21,13 @@
     to_publish = set()
 
     if remote_name is not None:
-        refs_to_publish.update([
-            ref[len(remote_name) + 1:]
-            for ref in refs_to_publish
-            if ref.startswith(remote_name + b'/')
-        ])
+        refs_to_publish.update(
+            [
+                ref[len(remote_name) + 1 :]
+                for ref in refs_to_publish
+                if ref.startswith(remote_name + b'/')
+            ]
+        )
 
     for ref_name, sha in refs.items():
         if ref_name.startswith(LOCAL_BRANCH_PREFIX):
@@ -29,9 +31,9 @@
 
     for ref_name, sha in refs.items():
         if ref_name.startswith(LOCAL_BRANCH_PREFIX):
-            branch = ref_name[len(LOCAL_BRANCH_PREFIX):]
+            branch = ref_name[len(LOCAL_BRANCH_PREFIX) :]
             if branch in refs_to_publish:
                 ui.note(b"publishing branch %s\n" % branch)
                 to_publish.add(sha)
 
         elif ref_name.startswith(LOCAL_TAG_PREFIX):
@@ -33,7 +35,7 @@
             if branch in refs_to_publish:
                 ui.note(b"publishing branch %s\n" % branch)
                 to_publish.add(sha)
 
         elif ref_name.startswith(LOCAL_TAG_PREFIX):
-            tag = ref_name[len(LOCAL_TAG_PREFIX):]
+            tag = ref_name[len(LOCAL_TAG_PREFIX) :]
             if publish_defaults or tag in refs_to_publish:
@@ -39,5 +41,7 @@
             if publish_defaults or tag in refs_to_publish:
-                ui.note(b"publishing tag %s\n" % ref_name[len(LOCAL_TAG_PREFIX):])
+                ui.note(
+                    b"publishing tag %s\n" % ref_name[len(LOCAL_TAG_PREFIX) :]
+                )
                 to_publish.add(sha)
 
         elif publish_defaults and ref_name == b'HEAD':
@@ -132,6 +136,8 @@
 
 
 '''struct to store result from find_incoming'''
+
+
 class GitIncomingCommit:
     __slots__ = 'sha', 'phase'
 
@@ -202,7 +208,9 @@
             command = field[3:]
             if command == b'rename':
                 before, after = data.split(b':', 1)
-                renames[hgutil.urlreq.unquote(after)] = hgutil.urlreq.unquote(before)
+                renames[hgutil.urlreq.unquote(after)] = hgutil.urlreq.unquote(
+                    before
+                )
             elif command == b'extra':
                 k, v = data.split(b':', 1)
                 extra[hgutil.urlreq.unquote(k)] = hgutil.urlreq.unquote(v)
diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -56,7 +56,8 @@
 # host and path with either a / or : (sepr)
 RE_GIT_URI = re.compile(
     br'^(?P<scheme>git([+]ssh)?://)(?P<host>.*?)(:(?P<port>\d+))?'
-    br'(?P<sepr>[:/])(?P<path>.*)$')
+    br'(?P<sepr>[:/])(?P<path>.*)$'
+)
 
 RE_NEWLINES = re.compile(br'[\r\n]$')
 RE_GIT_DETERMINATE_PROGRESS = re.compile(br'\((\d+)/(\d+)\)')
@@ -84,7 +85,9 @@
         # 'Counting objects: 33640, done.\n'
         # 'Compressing objects:   0% (1/9955)   \r
 
-        lines = (self.msgbuf + compat.sysbytes(message)).splitlines(keepends=True)
+        lines = (self.msgbuf + compat.sysbytes(message)).splitlines(
+            keepends=True
+        )
         self.msgbuf = b''
 
         for msg in lines:
@@ -136,6 +139,7 @@
             self._progress = None
         self.progress(b'')
 
+
 def get_repo_and_gitdir(repo):
     if repo.shared():
         repo = hg.sharedreposource(repo)
@@ -169,8 +173,9 @@
 
         self.init_author_file()
 
-        self.branch_bookmark_suffix = ui.config(b'git',
-                                                b'branch_bookmark_suffix')
+        self.branch_bookmark_suffix = ui.config(
+            b'git', b'branch_bookmark_suffix'
+        )
 
         self._map_git_real = None
         self._map_hg_real = None
@@ -222,11 +227,13 @@
         # have to cope with that. As a workaround, try decoding our
         # (bytes) path to the repo in hg's active encoding and hope
         # for the best.
-        gitpath = self.gitdir.decode(pycompat.sysstr(encoding.encoding),
-                                     pycompat.sysstr(encoding.encodingmode))
+        gitpath = self.gitdir.decode(
+            pycompat.sysstr(encoding.encoding),
+            pycompat.sysstr(encoding.encodingmode),
+        )
         # make the git data directory
         if os.path.exists(self.gitdir):
             return Repo(gitpath)
         else:
             if self._map_git:
                 self.ui.warn(
@@ -227,10 +234,11 @@
         # make the git data directory
         if os.path.exists(self.gitdir):
             return Repo(gitpath)
         else:
             if self._map_git:
                 self.ui.warn(
-                    b'warning: created new git repository at %s\n' % self.gitdir,
+                    b'warning: created new git repository at %s\n'
+                    % self.gitdir,
                 )
             os.mkdir(self.gitdir)
             return Repo.init_bare(gitpath)
@@ -276,8 +284,9 @@
                 # format is <40 hex digits> <40 hex digits>\n
                 if len(line) != 82:
                     raise ValueError(
-                        _(b'corrupt mapfile: incorrect line length %d') %
-                        len(line))
+                        _(b'corrupt mapfile: incorrect line length %d')
+                        % len(line)
+                    )
                 gitsha = line[:40]
                 hgsha = line[41:81]
                 map_git_real[gitsha] = hgsha
@@ -347,7 +356,9 @@
 
         if result.refs:
             imported = self.import_git_objects(
-                remote_names, result.refs, heads=heads,
+                remote_names,
+                result.refs,
+                heads=heads,
             )
         else:
             imported = 0
@@ -428,5 +439,7 @@
             return refs  # always return the same refs to make the send a no-op
 
         try:
-            self._call_client(remote, 'send_pack', changed, lambda have, want: [])
+            self._call_client(
+                remote, 'send_pack', changed, lambda have, want: []
+            )
 
@@ -432,6 +445,7 @@
 
-            changed_refs = [ref for ref, sha in new_refs.items()
-                            if sha != old_refs.get(ref)]
+            changed_refs = [
+                ref for ref, sha in new_refs.items() if sha != old_refs.get(ref)
+            ]
 
             new = [
                 bin(sha) for sha in map(self.map_hg_get, changed_refs) if sha
@@ -451,8 +465,9 @@
 
             return old, new
         except (HangupException, GitProtocolError) as e:
-            raise error.Abort(_(b"git remote error: ")
-                              + pycompat.sysbytes(str(e)))
+            raise error.Abort(
+                _(b"git remote error: ") + pycompat.sysbytes(str(e))
+            )
 
     def push(self, remote, revs, force):
         old_refs, new_refs = self.upload_pack(remote, revs, force)
@@ -471,8 +486,8 @@
             old_sha = old_refs.get(ref)
             if ref_status.get(ref) is not None:
                 self.ui.warn(
-                    b'warning: failed to update %s; %s\n' %
-                    (ref, pycompat.sysbytes(ref_status[ref])),
+                    b'warning: failed to update %s; %s\n'
+                    % (ref, pycompat.sysbytes(ref_status[ref])),
                 )
             elif old_sha is None:
                 if self.ui.verbose:
@@ -476,9 +491,11 @@
                 )
             elif old_sha is None:
                 if self.ui.verbose:
-                    self.ui.note(b"adding reference %s::%s => GIT:%s\n" %
-                                 (remote_desc, ref, new_sha[0:8]))
+                    self.ui.note(
+                        b"adding reference %s::%s => GIT:%s\n"
+                        % (remote_desc, ref, new_sha[0:8])
+                    )
                 else:
                     self.ui.status(b"adding reference %s\n" % ref)
             elif new_sha != old_sha:
                 if self.ui.verbose:
@@ -481,9 +498,11 @@
                 else:
                     self.ui.status(b"adding reference %s\n" % ref)
             elif new_sha != old_sha:
                 if self.ui.verbose:
-                    self.ui.note(b"updating reference %s::%s => GIT:%s\n" %
-                                 (remote_desc, ref, new_sha[0:8]))
+                    self.ui.note(
+                        b"updating reference %s::%s => GIT:%s\n"
+                        % (remote_desc, ref, new_sha[0:8])
+                    )
                 else:
                     self.ui.status(b"updating reference %s\n" % ref)
             else:
@@ -487,8 +506,10 @@
                 else:
                     self.ui.status(b"updating reference %s\n" % ref)
             else:
-                self.ui.debug(b"unchanged reference %s::%s => GIT:%s\n" %
-                              (remote_desc, ref, new_sha[0:8]))
+                self.ui.debug(
+                    b"unchanged reference %s::%s => GIT:%s\n"
+                    % (remote_desc, ref, new_sha[0:8])
+                )
 
         if new_refs and remote_names:
             # make sure that we know the remote head, for possible
@@ -516,10 +537,15 @@
                 # to pushing to Git, which doesn't have anonymous
                 # heads
                 served = self.repo.filtered(b'served')
-                exported = set(filter(None, (
-                    self.map_hg_get(sha, deref=True)
-                    for sha in old_refs.values()
-                )))
+                exported = set(
+                    filter(
+                        None,
+                        (
+                            self.map_hg_get(sha, deref=True)
+                            for sha in old_refs.values()
+                        ),
+                    )
+                )
                 unexported = served.revs(
                     b"not ancestors(%s)" % b" or ".join(exported),
                 )
@@ -581,8 +607,9 @@
         clnode = repo.changelog.node
 
         nodes = (clnode(n) for n in repo)
-        to_export = (repo[node] for node in nodes if not hex(node) in
-                     self._map_hg)
+        to_export = (
+            repo[node] for node in nodes if not hex(node) in self._map_hg
+        )
 
         todo_total = len(repo) - len(self._map_hg)
         topic = b'searching'
@@ -617,7 +644,8 @@
                 gitcommit = self.git[gitsha]
 
         exporter = hg2git.IncrementalChangesetExporter(
-            self.repo, pctx, self.git.object_store, gitcommit)
+            self.repo, pctx, self.git.object_store, gitcommit
+        )
 
         mapsavefreq = self.ui.configint(b'hggit', b'mapsavefrequency')
         with self.repo.ui.makeprogress(b'exporting', total=total) as progress:
@@ -651,7 +679,7 @@
         # manual edit that led to the unusual value. Based on that,
         # there is no reason to round one way or the other, so do the
         # simplest and round down.
-        timezone -= (timezone % 60)
+        timezone -= timezone % 60
         commit.author = self.get_git_author(ctx)
         commit.author_time = int(time)
         commit.author_timezone = -timezone
@@ -659,7 +687,9 @@
         if b'committer' in extra:
             try:
                 # fixup timezone
-                (name, timestamp, timezone) = extra[b'committer'].rsplit(b' ', 2)
+                (name, timestamp, timezone) = extra[b'committer'].rsplit(
+                    b' ', 2
+                )
                 commit.committer = name
                 commit.commit_time = int(timestamp)
 
@@ -685,8 +715,12 @@
             git_sha = self.map_git_get(hgsha)
             if git_sha:
                 if git_sha not in self.git.object_store:
-                    raise error.Abort(_(b'Parent SHA-1 not present in Git'
-                                        b'repo: %s' % git_sha))
+                    raise error.Abort(
+                        _(
+                            b'Parent SHA-1 not present in Git'
+                            b'repo: %s' % git_sha
+                        )
+                    )
 
                 commit.parents.append(git_sha)
 
@@ -705,8 +739,9 @@
         tree_sha = exporter.root_tree_sha
 
         if tree_sha not in self.git.object_store:
-            raise error.Abort(_(b'Tree SHA-1 not present in Git repo: %s' %
-                                tree_sha))
+            raise error.Abort(
+                _(b'Tree SHA-1 not present in Git repo: %s' % tree_sha)
+            )
 
         commit.tree = tree_sha
 
@@ -761,7 +796,9 @@
         >>> g(b'Typo in hgrc >but.hg-git@handles.it.gracefully>')
         'Typo in hgrc ?but.hg-git@handles.it.gracefully'
         """
-        return RE_GIT_SANITIZE_AUTHOR.sub(b'?', name.lstrip(b'< ').rstrip(b'> '))
+        return RE_GIT_SANITIZE_AUTHOR.sub(
+            b'?', name.lstrip(b'< ').rstrip(b'> ')
+        )
 
     def get_git_author(self, ctx):
         # hg authors might not have emails
@@ -778,7 +815,8 @@
             email = self.get_valid_git_username_email(a.group(2))
             if a.group(3) is not None and len(a.group(3)) != 0:
                 name += b' ext:(' + hgutil.urlreq.quote(a.group(3)) + b')'
-            author = b'%s <%s>'\
-                     % (self.get_valid_git_username_email(name),
-                         self.get_valid_git_username_email(email))
+            author = b'%s <%s>' % (
+                self.get_valid_git_username_email(name),
+                self.get_valid_git_username_email(email),
+            )
         elif b'@' in author:
@@ -784,7 +822,8 @@
         elif b'@' in author:
-            author = b'%s <%s>'\
-                     % (self.get_valid_git_username_email(author),
-                         self.get_valid_git_username_email(author))
+            author = b'%s <%s>' % (
+                self.get_valid_git_username_email(author),
+                self.get_valid_git_username_email(author),
+            )
         else:
             author = self.get_valid_git_username_email(author) + b' <none@none>'
 
@@ -841,7 +880,9 @@
 
         git_extraitems.sort()
         for i, field, value in git_extraitems:
-            git_extra.append((hgutil.urlreq.unquote(field), hgutil.urlreq.unquote(value)))
+            git_extra.append(
+                (hgutil.urlreq.unquote(field), hgutil.urlreq.unquote(value))
+            )
 
         if extra.get(b'hg-git-rename-source', None) != b'git':
             renames = []
@@ -855,6 +896,7 @@
             if renames:
                 for oldfile, newfile in renames:
                     if extra_in_message:
-                        extra_message += (b"rename : " + oldfile + b" => " +
-                                          newfile + b"\n")
+                        extra_message += (
+                            b"rename : " + oldfile + b" => " + newfile + b"\n"
+                        )
                     else:
@@ -860,7 +902,9 @@
                     else:
-                        spec = b'%s:%s' % (hgutil.urlreq.quote(oldfile),
-                                           hgutil.urlreq.quote(newfile))
+                        spec = b'%s:%s' % (
+                            hgutil.urlreq.quote(oldfile),
+                            hgutil.urlreq.quote(newfile),
+                        )
                         git_extra.append((b'HG:rename', spec))
 
         # hg extra items always go at the end
         for key, value in sorted(extra.items()):
@@ -863,9 +907,16 @@
                         git_extra.append((b'HG:rename', spec))
 
         # hg extra items always go at the end
         for key, value in sorted(extra.items()):
-            if key in (b'author', b'committer', b'encoding', b'message', b'branch',
-                       b'hg-git', b'hg-git-rename-source'):
+            if key in (
+                b'author',
+                b'committer',
+                b'encoding',
+                b'message',
+                b'branch',
+                b'hg-git',
+                b'hg-git-rename-source',
+            ):
                 continue
             else:
                 if extra_in_message:
@@ -869,6 +920,11 @@
                 continue
             else:
                 if extra_in_message:
-                    extra_message += (b"extra : " + key + b" : " +
-                                      hgutil.urlreq.quote(value) + b"\n")
+                    extra_message += (
+                        b"extra : "
+                        + key
+                        + b" : "
+                        + hgutil.urlreq.quote(value)
+                        + b"\n"
+                    )
                 else:
@@ -874,8 +930,10 @@
                 else:
-                    spec = b'%s:%s' % (hgutil.urlreq.quote(key),
-                                       hgutil.urlreq.quote(value))
+                    spec = b'%s:%s' % (
+                        hgutil.urlreq.quote(key),
+                        hgutil.urlreq.quote(value),
+                    )
                     git_extra.append((b'HG:extra', spec))
 
         if extra_message:
             message += b"\n--HG--\n" + extra_message
 
@@ -877,10 +935,14 @@
                     git_extra.append((b'HG:extra', spec))
 
         if extra_message:
             message += b"\n--HG--\n" + extra_message
 
-        if (extra.get(b'hg-git-rename-source', None) != b'git' and not
-            extra_in_message and not git_extra and extra_message == b''):
+        if (
+            extra.get(b'hg-git-rename-source', None) != b'git'
+            and not extra_in_message
+            and not git_extra
+            and extra_message == b''
+        ):
             # We need to store this if no other metadata is stored. This
             # indicates that when reimporting the commit into Mercurial we'll
             # know not to detect renames.
@@ -913,7 +975,7 @@
         symref = result.symrefs.get(b'HEAD')
 
         if symref and symref.startswith(LOCAL_BRANCH_PREFIX):
-            rhead = symref[len(LOCAL_BRANCH_PREFIX):]
+            rhead = symref[len(LOCAL_BRANCH_PREFIX) :]
 
             if symref in result.refs:
                 rsha = result.refs.get(symref)
@@ -948,7 +1010,9 @@
             mapsavefreq = self.ui.configint(b'hggit', b'mapsavefrequency')
 
         chunksize = max(mapsavefreq or total, 1)
-        progress = self.ui.makeprogress(b'importing', unit=b'commits', total=total)
+        progress = self.ui.makeprogress(
+            b'importing', unit=b'commits', total=total
+        )
 
         self.ui.note(b"processing commits in batches of %d\n" % chunksize)
 
@@ -958,7 +1022,7 @@
             # get at least one chunk
             for offset in range(0, max(total, 1), chunksize):
                 with self.get_transaction(b"gimport"):
-                    for commit in commits[offset:offset + chunksize]:
+                    for commit in commits[offset : offset + chunksize]:
                         progress.increment(item=commit.short)
                         self.import_git_commit(
                             self.git[commit.sha],
@@ -979,9 +1043,12 @@
         unfiltered = self.repo.unfiltered()
 
         detect_renames = False
-        (strip_message, hg_renames,
-         hg_branch, extra) = git2hg.extract_hg_metadata(
-             commit.message, commit.extra)
+        (
+            strip_message,
+            hg_renames,
+            hg_branch,
+            extra,
+        ) = git2hg.extract_hg_metadata(commit.message, commit.extra)
         if hg_renames is None:
             detect_renames = True
             # We have to store this unconditionally, even if there are no
@@ -996,7 +1063,11 @@
 
         for parent in gparents:
             if parent not in unfiltered:
-                raise error.Abort(_(b'you appear to have run strip - '
-                                    b'please run hg git-cleanup'))
+                raise error.Abort(
+                    _(
+                        b'you appear to have run strip - '
+                        b'please run hg git-cleanup'
+                    )
+                )
 
         # get a list of the changed, added, removed files and gitlinks
@@ -1001,7 +1072,8 @@
 
         # get a list of the changed, added, removed files and gitlinks
-        files, gitlinks, git_renames = self.get_files_changed(commit,
-                                                              detect_renames)
+        files, gitlinks, git_renames = self.get_files_changed(
+            commit, detect_renames
+        )
         if detect_renames:
             renames = git_renames
 
@@ -1013,7 +1085,8 @@
         # - .hgsubstate from hg parent
         # - changes in gitlinks
         hgsubstate = util.parse_hgsubstate(
-            self.git_file_readlines(git_commit_tree, b'.hgsubstate'))
+            self.git_file_readlines(git_commit_tree, b'.hgsubstate')
+        )
         parentsubdata = b''
         if gparents:
             p1ctx = unfiltered[gparents[0]]
@@ -1042,8 +1115,9 @@
         hgsub = None
         gitmodules = self.parse_gitmodules(git_commit_tree)
         if gitmodules:
-            hgsub = util.parse_hgsub(self.git_file_readlines(git_commit_tree,
-                                                             b'.hgsub'))
+            hgsub = util.parse_hgsub(
+                self.git_file_readlines(git_commit_tree, b'.hgsub')
+            )
             for (sm_path, sm_url, sm_name) in gitmodules:
                 hgsub[sm_path] = b'[git]' + sm_url
             files[b'.hgsub'] = (False, 0o100644, None)
@@ -1047,8 +1121,10 @@
             for (sm_path, sm_url, sm_name) in gitmodules:
                 hgsub[sm_path] = b'[git]' + sm_url
             files[b'.hgsub'] = (False, 0o100644, None)
-        elif (commit.parents and b'.gitmodules' in
-              self.git[self.git[commit.parents[0]].tree]):
+        elif (
+            commit.parents
+            and b'.gitmodules' in self.git[self.git[commit.parents[0]].tree]
+        ):
             # no .gitmodules in this commit, however present in the parent
             # mark its hg counterpart as deleted (assuming .hgsub is there
             # due to the same import_git_commit process
@@ -1102,8 +1178,11 @@
                 return []
             manifest1 = unfiltered[p1].manifest()
             manifest2 = unfiltered[p2].manifest()
-            return [path for path, node1 in manifest1.items() if path not
-                    in files and manifest2.get(path, node1) != node1]
+            return [
+                path
+                for path, node1 in manifest1.items()
+                if path not in files and manifest2.get(path, node1) != node1
+            ]
 
         def getfilectx(repo, memctx, f):
             info = files.get(f)
@@ -1134,10 +1213,15 @@
                 if copied:
                     copied_path = copied[0]
 
-            return context.memfilectx(unfiltered, memctx, f, data,
-                                      islink=b'l' in e,
-                                      isexec=b'x' in e,
-                                      copysource=copied_path)
+            return context.memfilectx(
+                unfiltered,
+                memctx,
+                f,
+                data,
+                islink=b'l' in e,
+                isexec=b'x' in e,
+                copysource=copied_path,
+            )
 
         p1, p2 = (nullid, nullid)
         octopus = False
@@ -1145,9 +1229,16 @@
         if len(gparents) > 1:
             # merge, possibly octopus
             def commit_octopus(p1, p2):
-                ctx = context.memctx(unfiltered, (p1, p2), text, list(files) +
-                                     findconvergedfiles(p1, p2), getfilectx,
-                                     author, date, {b'hg-git': b'octopus'})
+                ctx = context.memctx(
+                    unfiltered,
+                    (p1, p2),
+                    text,
+                    list(files) + findconvergedfiles(p1, p2),
+                    getfilectx,
+                    author,
+                    date,
+                    {b'hg-git': b'octopus'},
+                )
                 # See comment below about setting substate to None.
                 ctx.substate = None
                 with util.forcedraftcommits():
@@ -1170,7 +1261,9 @@
             extra[b'branch'] = b'default'
 
         # if committer is different than author, add it to extra
-        if commit.author != commit.committer\
-           or commit.author_time != commit.commit_time\
-           or commit.author_timezone != commit.commit_timezone:
+        if (
+            commit.author != commit.committer
+            or commit.author_time != commit.commit_time
+            or commit.author_timezone != commit.commit_timezone
+        ):
             extra[b'committer'] = b"%s %d %d" % (
@@ -1176,5 +1269,8 @@
             extra[b'committer'] = b"%s %d %d" % (
-                commit.committer, commit.commit_time, -commit.commit_timezone)
+                commit.committer,
+                commit.commit_time,
+                -commit.commit_timezone,
+            )
 
         if commit.encoding:
             extra[b'encoding'] = commit.encoding
@@ -1184,9 +1280,16 @@
         if octopus:
             extra[b'hg-git'] = b'octopus-done'
 
-        ctx = context.memctx(unfiltered, (p1, p2), text,
-                             list(files) + findconvergedfiles(p1, p2),
-                             getfilectx, author, date, extra)
+        ctx = context.memctx(
+            unfiltered,
+            (p1, p2),
+            text,
+            list(files) + findconvergedfiles(p1, p2),
+            getfilectx,
+            author,
+            date,
+            extra,
+        )
         # Starting Mercurial commit d2743be1bb06, memctx imports from
         # committablectx. This means that it has a 'substate' property that
         # contains the subrepo state. Ordinarily, Mercurial expects the subrepo
@@ -1202,7 +1305,10 @@
 
         with self.repo.lock(), self.repo.transaction(b"phase") as tr:
             phases.advanceboundary(
-                self.repo, tr, phase, [node],
+                self.repo,
+                tr,
+                phase,
+                [node],
             )
 
         # save changeset to mapping file
@@ -1225,9 +1331,10 @@
                 exportable = {}
                 for rev in (hex(r) for r in revs):
                     if rev not in all_exportable:
-                        raise error.Abort(b"revision %s cannot be pushed since"
-                                          b" it doesn't have a bookmark" %
-                                          self.repo[rev])
+                        raise error.Abort(
+                            b"revision %s cannot be pushed since"
+                            b" it doesn't have a bookmark" % self.repo[rev]
+                        )
                     exportable[rev] = all_exportable[rev]
             return self.get_changed_refs(refs, exportable, force)
 
@@ -1264,7 +1371,8 @@
         progressfunc = progress.progress
 
         try:
-            new_refs = self._call_client(remote, 'send_pack', changed, genpack,
-                                         progress=progressfunc)
+            new_refs = self._call_client(
+                remote, 'send_pack', changed, genpack, progress=progressfunc
+            )
 
             if len(change_totals) > 0:
@@ -1269,9 +1377,12 @@
 
             if len(change_totals) > 0:
-                self.ui.status(_(b"added %d commits with %d trees"
-                                 b" and %d blobs\n") %
-                               (change_totals.get(Commit, 0),
-                                change_totals.get(Tree, 0),
-                                change_totals.get(Blob, 0)))
+                self.ui.status(
+                    _(b"added %d commits with %d trees" b" and %d blobs\n")
+                    % (
+                        change_totals.get(Commit, 0),
+                        change_totals.get(Tree, 0),
+                        change_totals.get(Blob, 0),
+                    )
+                )
             return old_refs, new_refs
         except (HangupException, GitProtocolError) as e:
@@ -1276,7 +1387,8 @@
             return old_refs, new_refs
         except (HangupException, GitProtocolError) as e:
-            raise error.Abort(_(b"git remote error: ")
-                              + pycompat.sysbytes(str(e)))
+            raise error.Abort(
+                _(b"git remote error: ") + pycompat.sysbytes(str(e))
+            )
         finally:
             progress.flush()
 
@@ -1294,8 +1406,10 @@
         for rev, rev_refs in exportable.items():
             ctx = self.repo[rev]
             if not rev_refs:
-                raise error.Abort(b"revision %s cannot be pushed since"
-                                  b" it doesn't have a bookmark" % ctx)
+                raise error.Abort(
+                    b"revision %s cannot be pushed since"
+                    b" it doesn't have a bookmark" % ctx
+                )
 
             # Check if the tags the server is advertising are annotated tags,
             # by attempting to retrieve it from the our git repo, and building
@@ -1332,11 +1446,12 @@
                     if rctx.ancestor(ctx) == rctx or force:
                         new_refs[ref] = self.map_git_get(ctx.hex())
                     else:
-                        raise error.Abort(b"pushing %s overwrites %s"
-                                          % (ref, ctx))
+                        raise error.Abort(
+                            b"pushing %s overwrites %s" % (ref, ctx)
+                        )
                 elif ref in uptodate_annotated_tags:
                     # we already have the annotated tag.
                     pass
                 else:
                     raise error.Abort(
                         b"branch '%s' changed on the server, "
@@ -1337,10 +1452,11 @@
                 elif ref in uptodate_annotated_tags:
                     # we already have the annotated tag.
                     pass
                 else:
                     raise error.Abort(
                         b"branch '%s' changed on the server, "
-                        b"please pull and merge before pushing" % ref)
+                        b"please pull and merge before pushing" % ref
+                    )
 
         return new_refs
 
@@ -1363,7 +1479,9 @@
         progress = GitProgress(self.ui)
 
         tempargs = dict(
-            prefix=b'hg-git-fetch-', suffix=b'.pack', dir=self.gitdir,
+            prefix=b'hg-git-fetch-',
+            suffix=b'.pack',
+            dir=self.gitdir,
         )
 
         if self.is_clone and self.gitdir.startswith(self.repo.root):
@@ -1378,6 +1496,12 @@
             f = tempfile.SpooledTemporaryFile(**tempargs, max_size=max_size)
 
         try:
-            ret = self._call_client(remote, 'fetch_pack', determine_wants,
-                                    graphwalker, f.write, progress.progress)
+            ret = self._call_client(
+                remote,
+                'fetch_pack',
+                determine_wants,
+                graphwalker,
+                f.write,
+                progress.progress,
+            )
 
@@ -1383,5 +1507,5 @@
 
-            if(f.tell() != 0):
+            if f.tell() != 0:
                 if move:
                     self.ui.debug(b'moving git pack into %s\n' % self.gitdir)
                     # windows might have issues moving an open file?
@@ -1401,8 +1525,9 @@
 
             return ret
         except (HangupException, GitProtocolError) as e:
-            raise error.Abort(_(b"git remote error: ")
-                              + pycompat.sysbytes(str(e)))
+            raise error.Abort(
+                _(b"git remote error: ") + pycompat.sysbytes(str(e))
+            )
         finally:
             progress.flush()
             f.close()
@@ -1451,8 +1576,9 @@
         if heads is not None:
             # contains pairs of ('refs/(heads|tags|...)/foo', 'foo')
             # if ref is just '<foo>', then we get ('foo', 'foo')
-            stripped_refs = [(r, r[r.find(b'/', r.find(b'/') + 1) + 1:]) for r in
-                             refs]
+            stripped_refs = [
+                (r, r[r.find(b'/', r.find(b'/') + 1) + 1 :]) for r in refs
+            ]
             for h in heads:
                 if h.endswith(b'/*'):
                     prefix = h[:-1]  # include the / but not the *
@@ -1456,8 +1582,11 @@
             for h in heads:
                 if h.endswith(b'/*'):
                     prefix = h[:-1]  # include the / but not the *
-                    r = [pair[0] for pair in stripped_refs
-                         if pair[1].startswith(prefix)]
+                    r = [
+                        pair[0]
+                        for pair in stripped_refs
+                        if pair[1].startswith(prefix)
+                    ]
                     r.sort()
                     filteredrefs.extend(r)
                 else:
@@ -1469,7 +1598,10 @@
                         filteredrefs.append(r[0])
                     else:
                         msg = _(b"ambiguous reference %s: %s")
-                        msg %= (h, b', '.join(sorted(r)),)
+                        msg %= (
+                            h,
+                            b', '.join(sorted(r)),
+                        )
                         raise error.RepoLookupError(msg)
         else:
             for ref, sha in refs.items():
@@ -1473,9 +1605,10 @@
                         raise error.RepoLookupError(msg)
         else:
             for ref, sha in refs.items():
-                if (not ref.endswith(b'^{}') and
-                    (ref.startswith(LOCAL_BRANCH_PREFIX) or
-                     ref.startswith(LOCAL_TAG_PREFIX))):
+                if not ref.endswith(b'^{}') and (
+                    ref.startswith(LOCAL_BRANCH_PREFIX)
+                    or ref.startswith(LOCAL_TAG_PREFIX)
+                ):
                     filteredrefs.append(ref)
             filteredrefs.sort()
 
@@ -1500,6 +1633,7 @@
                 return obj.tag_time >= min_timestamp
             else:
                 return obj.commit_time >= min_timestamp
+
         return collections.OrderedDict(
             (ref, sha)
             for ref, sha in refs.items()
@@ -1526,11 +1660,13 @@
                 target = self.map_git_get(hex(sha))
 
                 if target is None:
-                    self.repo.ui.warn(b"warning: not exporting tag '%s' "
-                                      b"due to missing git "
-                                      b"revision\n" % tag)
+                    self.repo.ui.warn(
+                        b"warning: not exporting tag '%s' "
+                        b"due to missing git "
+                        b"revision\n" % tag
+                    )
                     continue
 
                 tag_refname = LOCAL_TAG_PREFIX + tag
 
                 if not check_ref_format(tag_refname):
@@ -1532,10 +1668,12 @@
                     continue
 
                 tag_refname = LOCAL_TAG_PREFIX + tag
 
                 if not check_ref_format(tag_refname):
-                    self.repo.ui.warn(b"warning: not exporting tag '%s' "
-                                      b"due to invalid name\n" % tag)
+                    self.repo.ui.warn(
+                        b"warning: not exporting tag '%s' "
+                        b"due to invalid name\n" % tag
+                    )
                     continue
 
                 # check whether the tag already exists and is
@@ -1559,7 +1697,6 @@
                         # otherwise it'd happen on every pull
                         target = reftarget
 
-
                 self.git.refs[tag_refname] = target
                 self.tags[tag] = hex(sha)
 
@@ -1569,5 +1706,6 @@
         if not self.branch_bookmark_suffix:
             return [(bm, bm, n) for bm, n in bms.items()]
         else:
+
             def _filter_bm(bm):
                 if bm.endswith(self.branch_bookmark_suffix):
@@ -1572,5 +1710,5 @@
             def _filter_bm(bm):
                 if bm.endswith(self.branch_bookmark_suffix):
-                    return bm[0:-(len(self.branch_bookmark_suffix))]
+                    return bm[0 : -(len(self.branch_bookmark_suffix))]
                 else:
                     return bm
@@ -1575,5 +1713,6 @@
                 else:
                     return bm
+
             return [(_filter_bm(bm), bm, n) for bm, n in bms.items()]
 
     def get_exportable(self):
@@ -1601,8 +1740,10 @@
             elif check_ref_format(ref_name):
                 res[hex(node)].heads.add(ref_name)
             else:
-                self.repo.ui.warn(b"warning: not exporting bookmark '%s' "
-                                  b"due to invalid name\n" % bm)
+                self.repo.ui.warn(
+                    b"warning: not exporting bookmark '%s' "
+                    b"due to invalid name\n" % bm
+                )
 
         for tag, sha in self.tags.items():
             res[sha].tags.add(LOCAL_TAG_PREFIX + tag)
@@ -1643,8 +1784,9 @@
                 self.ui.debug(b'adding git tag %s\n' % tag)
                 self.tags[tag] = target
             else:
-                raise error.Abort(b"the name '%s' is not a valid git "
-                                  b"tag" % tag)
+                raise error.Abort(
+                    b"the name '%s' is not a valid git " b"tag" % tag
+                )
 
         self.export_commits()
         self.save_tags()
@@ -1666,7 +1808,7 @@
             if not ref.startswith(LOCAL_BRANCH_PREFIX):
                 continue
 
-            h = ref[len(LOCAL_BRANCH_PREFIX):]
+            h = ref[len(LOCAL_BRANCH_PREFIX) :]
             hg_sha = self.map_hg_get(git_sha)
 
             # refs contains all the refs in the server,
@@ -1679,7 +1821,7 @@
                 prefix = remote_name + b'/'
                 for remote_ref in self.remote_refs:
                     if remote_ref.startswith(prefix):
-                        h = remote_ref[len(prefix):]
+                        h = remote_ref[len(prefix) :]
                         heads.setdefault(h, None)
 
         return heads
@@ -1708,9 +1850,8 @@
                     # possibly deleted branch, check if we have a
                     # matching remote ref
                     unmoved = any(
-                        bms[bm] == self.remote_refs.get(
-                            b'%s/%s' % (remote_name, head)
-                        )
+                        bms[bm]
+                        == self.remote_refs.get(b'%s/%s' % (remote_name, head))
                         for remote_name in remote_names
                     )
 
@@ -1747,8 +1888,12 @@
                         bms.applychanges(self.repo, tr, changes)
 
         except AttributeError:
-            self.ui.warn(_(b'creating bookmarks failed, do you have'
-                         b' bookmarks enabled?\n'))
+            self.ui.warn(
+                _(
+                    b'creating bookmarks failed, do you have'
+                    b' bookmarks enabled?\n'
+                )
+            )
 
     def get_public_heads(self, remote_name, refs):
         nodeids_to_publish = set()
@@ -1771,7 +1916,10 @@
             for t in list(remote_refs):
                 if t.startswith(remote_name + b'/'):
                     del remote_refs[t]
-                    if LOCAL_BRANCH_PREFIX + t[len(remote_name) + 1:] not in refs:
+                    if (
+                        LOCAL_BRANCH_PREFIX + t[len(remote_name) + 1 :]
+                        not in refs
+                    ):
                         del self.git.refs[REMOTE_BRANCH_PREFIX + t]
 
         all_remote_nodeids = []
@@ -1780,8 +1928,9 @@
             hgsha = self.map_hg_get(sha)
 
             if (
-                ref_name.startswith(LOCAL_BRANCH_PREFIX) and
-                hgsha is not None and hgsha in self.repo
+                ref_name.startswith(LOCAL_BRANCH_PREFIX)
+                and hgsha is not None
+                and hgsha in self.repo
             ):
                 head = ref_name[11:]
                 remote_head = b'/'.join((remote_name, head))
@@ -1790,8 +1939,9 @@
                 # TODO(durin42): what is this doing?
                 new_ref = REMOTE_BRANCH_PREFIX + remote_head
                 self.git.refs[new_ref] = sha
-            elif (ref_name.startswith(LOCAL_TAG_PREFIX) and not
-                  ref_name.endswith(b'^{}')):
+            elif ref_name.startswith(
+                LOCAL_TAG_PREFIX
+            ) and not ref_name.endswith(b'^{}'):
                 self.git.refs[ref_name] = sha
 
             if hgsha:
@@ -1803,7 +1953,10 @@
                 # are at least draft; this can happen on no-op pulls
                 # where the commit already exists, but is secret
                 phases.advanceboundary(
-                    self.repo, tr, phases.draft, all_remote_nodeids,
+                    self.repo,
+                    tr,
+                    phases.draft,
+                    all_remote_nodeids,
                 )
             # ensure that we update phases on push and no-op pulls
             phases.advanceboundary(
@@ -1817,11 +1970,7 @@
 
     def convert_git_int_mode(self, mode):
         # TODO: make these into constants
-        convert = {
-            0o100644: b'',
-            0o100755: b'x',
-            0o120000: b'l'
-        }
+        convert = {0o100644: b'', 0o100755: b'x', 0o120000: b'l'}
         if mode in convert:
             return convert[mode]
         return b''
@@ -1856,8 +2005,9 @@
         # the code below simpler
         renamed_out = set()
 
-        changes = diff_tree.tree_changes(self.git.object_store, btree, tree,
-                                         rename_detector=rename_detector)
+        changes = diff_tree.tree_changes(
+            self.git.object_store, btree, tree, rename_detector=rename_detector
+        )
 
         for change in changes:
             oldfile, oldmode, oldsha = change.old
@@ -1921,8 +2071,10 @@
                     renames[newfile] = oldfile
                     renamed_out.add(oldfile)
                     # the membership check is explained in a comment above
-                    if (change.type == diff_tree.CHANGE_RENAME and
-                        oldfile not in files):
+                    if (
+                        change.type == diff_tree.CHANGE_RENAME
+                        and oldfile not in files
+                    ):
                         files[oldfile] = True, None, None
             else:
                 # old = file
@@ -1952,11 +2104,13 @@
             max_files = None
 
         find_copies_harder = self.ui.configbool(b'git', b'findcopiesharder')
-        return diff_tree.RenameDetector(self.git.object_store,
-                                        rename_threshold=similarity,
-                                        max_files=max_files,
-                                        find_copies_harder=find_copies_harder)
+        return diff_tree.RenameDetector(
+            self.git.object_store,
+            rename_threshold=similarity,
+            max_files=max_files,
+            find_copies_harder=find_copies_harder,
+        )
 
     def parse_gitmodules(self, tree_obj):
         """Parse .gitmodules from a git tree specified by tree_obj
 
@@ -1959,10 +2113,10 @@
 
     def parse_gitmodules(self, tree_obj):
         """Parse .gitmodules from a git tree specified by tree_obj
 
-           :return: list of tuples (submodule path, url, name),
-           where name is hgutil.urlreq.quoted part of the section's name, or
-           empty list if nothing found
+        :return: list of tuples (submodule path, url, name),
+        where name is hgutil.urlreq.quoted part of the section's name, or
+        empty list if nothing found
         """
         rv = []
         try:
@@ -1983,7 +2137,7 @@
     def git_file_readlines(self, tree_obj, fname):
         """Read content of a named entry from the git commit tree
 
-           :return: list of lines
+        :return: list of lines
         """
         if fname in tree_obj:
             unused_mode, sha = tree_obj[fname]
@@ -2043,6 +2197,7 @@
     def swap_out_encoding(self, new_encoding=b'UTF-8'):
         try:
             from mercurial import encoding
+
             old = encoding.encoding
             encoding.encoding = new_encoding
         except (AttributeError, ImportError):
@@ -2157,7 +2312,8 @@
                 # obtain a realm, we can do a "full" search, including
                 # a prompt
                 username, password = self._pwmgr.find_user_password(
-                    self._http_auth_realm, str_uri,
+                    self._http_auth_realm,
+                    str_uri,
                 )
                 # NB: probably bytes here
             elif auth is not None:
diff --git a/hggit/gitdirstate.py b/hggit/gitdirstate.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvZ2l0ZGlyc3RhdGUucHk=..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvZ2l0ZGlyc3RhdGUucHk= 100644
--- a/hggit/gitdirstate.py
+++ b/hggit/gitdirstate.py
@@ -62,7 +62,7 @@
                     pat = line
                     break
                 elif line.startswith(s + b':'):
-                    pat = rels + line[len(s) + 1:]
+                    pat = rels + line[len(s) + 1 :]
                     break
             patterns.append(pat)
 
@@ -116,11 +116,12 @@
         """A copy of dirstate.walk. This is called from the new _ignore method,
         which is called by dirstate.walk, which would cause infinite recursion,
         except _finddotgitignores calls the superclass _ignore directly."""
-        match = matchmod.match(self._root, self.getcwd(),
-                               [b'relglob:.gitignore'])
+        match = matchmod.match(
+            self._root, self.getcwd(), [b'relglob:.gitignore']
+        )
         # TODO: need subrepos?
         subrepos = []
         unknown = True
         ignored = False
 
         def fwarn(f, msg):
@@ -121,12 +122,16 @@
         # TODO: need subrepos?
         subrepos = []
         unknown = True
         ignored = False
 
         def fwarn(f, msg):
-            self._ui.warn(b'%s: %s\n' % (
-                self.pathto(f), pycompat.sysbytes(msg),
-            ))
+            self._ui.warn(
+                b'%s: %s\n'
+                % (
+                    self.pathto(f),
+                    pycompat.sysbytes(msg),
+                )
+            )
             return False
 
         ignore = super(gitdirstate, self)._ignore
@@ -152,7 +157,7 @@
         exact = skipstep3 = False
         if matchfn == match.exact:  # match.exact
             exact = True
-            dirignore = util.always                  # skip step 2
+            dirignore = util.always  # skip step 2
         elif match.files() and not match.anypats():  # match.match, no patterns
             skipstep3 = True
 
diff --git a/hggit/gitrepo.py b/hggit/gitrepo.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvZ2l0cmVwby5weQ==..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvZ2l0cmVwby5weQ== 100644
--- a/hggit/gitrepo.py
+++ b/hggit/gitrepo.py
@@ -65,7 +65,8 @@
                 result = handler.fetch_pack(self.path, heads=[])
                 # map any git shas that exist in hg to hg shas
                 stripped_refs = {
-                    ref[len(LOCAL_BRANCH_PREFIX):]: handler.map_hg_get(val) or val
+                    ref[len(LOCAL_BRANCH_PREFIX) :]: handler.map_hg_get(val)
+                    or val
                     for ref, val in result.refs.items()
                     if ref.startswith(LOCAL_BRANCH_PREFIX)
                 }
@@ -116,6 +117,7 @@
     def _submitone(self, op, args):
         return None
 
+
 instance = gitrepo
 
 
diff --git a/hggit/hg2git.py b/hggit/hg2git.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvaGcyZ2l0LnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvaGcyZ2l0LnB5 100644
--- a/hggit/hg2git.py
+++ b/hggit/hg2git.py
@@ -25,7 +25,8 @@
     substate = collections.OrderedDict()
     if b'.hgsubstate' in ctx:
         substate = util.parse_hgsubstate(
-            ctx[b'.hgsubstate'].data().splitlines())
+            ctx[b'.hgsubstate'].data().splitlines()
+        )
     return sub, substate
 
 
@@ -213,7 +214,8 @@
         # localrepo.status().
         status = self._hg.status(self._ctx, newctx)
         modified, added, removed = map(
-            self.filter_unsafe_paths, (status.modified, status.added, status.removed),
+            self.filter_unsafe_paths,
+            (status.modified, status.added, status.removed),
         )
 
         # We track which directories/trees have modified in this update and we
@@ -455,5 +457,7 @@
         else:
             mode = 0o100644
 
-        return (dulobjs.TreeEntry(os.path.basename(fctx.path()), mode,
-                                  blob_id), blob)
+        return (
+            dulobjs.TreeEntry(os.path.basename(fctx.path()), mode, blob_id),
+            blob,
+        )
diff --git a/hggit/hgrepo.py b/hggit/hgrepo.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvaGdyZXBvLnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvaGdyZXBvLnB5 100644
--- a/hggit/hgrepo.py
+++ b/hggit/hgrepo.py
@@ -29,7 +29,8 @@
         def findoutgoing(self, remote, base=None, heads=None, force=False):
             if isinstance(remote, gitrepo):
                 base, heads = self.githandler.get_refs(remote.path)
-                out, h = super(hgrepo, self).findoutgoing(remote, base,
-                                                          heads, force)
+                out, h = super(hgrepo, self).findoutgoing(
+                    remote, base, heads, force
+                )
                 return out
             else:  # pragma: no cover
@@ -34,7 +35,8 @@
                 return out
             else:  # pragma: no cover
-                return super(hgrepo, self).findoutgoing(remote, base,
-                                                        heads, force)
+                return super(hgrepo, self).findoutgoing(
+                    remote, base, heads, force
+                )
 
         def _findtags(self):
             (tags, tagtypes) = super(hgrepo, self)._findtags()
diff --git a/hggit/overlay.py b/hggit/overlay.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvb3ZlcmxheS5weQ==..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvb3ZlcmxheS5weQ== 100644
--- a/hggit/overlay.py
+++ b/hggit/overlay.py
@@ -45,11 +45,7 @@
 
     def withflags(self):
         self.load()
-        return {
-            path
-            for path, flag in self._flags.items()
-            if flag != b''
-        }
+        return {path for path, flag in self._flags.items() if flag != b''}
 
     def copy(self):
         return overlaymanifest(self.repo, self.tree.id)
@@ -168,9 +164,7 @@
         clean = match
         match = None
 
-    kwargs = {
-        'clean': clean
-    }
+    kwargs = {'clean': clean}
     # Older versions of mercurial don't support the match arg, so only add it
     # if it exists.
     if match is not None:
@@ -308,8 +302,9 @@
     def phase(self):
         try:
             from mercurial import phases
+
             return phases.draft
         except (AttributeError, ImportError):
             return 1
 
     def totuple(self):
@@ -311,10 +306,16 @@
             return phases.draft
         except (AttributeError, ImportError):
             return 1
 
     def totuple(self):
-        return (self.commit.tree, self.user(), self.date(), self.files(),
-                self.description(), self.extra())
+        return (
+            self.commit.tree,
+            self.user(),
+            self.date(),
+            self.files(),
+            self.description(),
+            self.extra(),
+        )
 
 
 class overlayrevlog(object):
@@ -466,8 +467,9 @@
         self.githandler = overlaygithandler(self)
 
     def _constructmanifest(self):
-        return overlaymanifestrevlog(self,
-                                     self.handler.repo._constructmanifest())
+        return overlaymanifestrevlog(
+            self, self.handler.repo._constructmanifest()
+        )
 
     def __getitem__(self, n):
         if isinstance(n, int):
@@ -532,6 +534,6 @@
         self.tagmap = {}
         for ref in refs:
             if ref.startswith(LOCAL_BRANCH_PREFIX):
-                refname = ref[len(LOCAL_BRANCH_PREFIX):]
+                refname = ref[len(LOCAL_BRANCH_PREFIX) :]
                 self.refmap.setdefault(bin(refs[ref]), []).append(refname)
             elif ref.startswith(LOCAL_TAG_PREFIX):
@@ -536,6 +538,6 @@
                 self.refmap.setdefault(bin(refs[ref]), []).append(refname)
             elif ref.startswith(LOCAL_TAG_PREFIX):
-                tagname = ref[len(LOCAL_TAG_PREFIX):]
+                tagname = ref[len(LOCAL_TAG_PREFIX) :]
                 self.tagmap.setdefault(bin(refs[ref]), []).append(tagname)
 
     def narrowmatch(self, *args, **kwargs):
diff --git a/hggit/revsets.py b/hggit/revsets.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvcmV2c2V0cy5weQ==..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvcmV2c2V0cy5weQ== 100644
--- a/hggit/revsets.py
+++ b/hggit/revsets.py
@@ -18,8 +18,9 @@
     revset.getargs(x, 0, 0, b"fromgit takes no arguments")
     git = repo.githandler
     node = repo.changelog.node
-    return revset.baseset(r for r in subset
-                          if git.map_git_get(hex(node(r))) is not None)
+    return revset.baseset(
+        r for r in subset if git.map_git_get(hex(node(r))) is not None
+    )
 
 
 @eh.revsetpredicate(b'gitnode')
@@ -30,8 +31,7 @@
     starts with `a5b`. Aborts if multiple changesets match the abbreviation.
     '''
     args = revset.getargs(x, 1, 1, b"gitnode takes one argument")
-    rev = revset.getstring(args[0],
-                           b"the argument to gitnode() must be a hash")
+    rev = revset.getstring(args[0], b"the argument to gitnode() must be a hash")
     git = repo.githandler
     node = repo.changelog.node
 
@@ -40,8 +40,9 @@
         if gitnode is None:
             return False
         return gitnode.startswith(rev)
+
     result = revset.baseset(r for r in subset if matches(r))
     if 0 <= len(result) < 2:
         return result
 
     raise error.AmbiguousPrefixLookupError(
@@ -43,9 +44,11 @@
     result = revset.baseset(r for r in subset if matches(r))
     if 0 <= len(result) < 2:
         return result
 
     raise error.AmbiguousPrefixLookupError(
-        rev, git.map_file, _(b'ambiguous identifier'),
+        rev,
+        git.map_file,
+        _(b'ambiguous identifier'),
     )
 
 
diff --git a/hggit/schemes.py b/hggit/schemes.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvc2NoZW1lcy5weQ==..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvc2NoZW1lcy5weQ== 100644
--- a/hggit/schemes.py
+++ b/hggit/schemes.py
@@ -38,9 +38,11 @@
         # is full git repo
         return True
 
-    if (os.path.exists(os.path.join(path, b'HEAD')) and
-        os.path.exists(os.path.join(path, b'objects')) and
-        os.path.exists(os.path.join(path, b'refs'))):
+    if (
+        os.path.exists(os.path.join(path, b'HEAD'))
+        and os.path.exists(os.path.join(path, b'objects'))
+        and os.path.exists(os.path.join(path, b'refs'))
+    ):
         # is bare git repo
         return True
 
diff --git a/hggit/templates.py b/hggit/templates.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvdGVtcGxhdGVzLnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvdGVtcGxhdGVzLnB5 100644
--- a/hggit/templates.py
+++ b/hggit/templates.py
@@ -25,7 +25,7 @@
 @eh.templatekeyword(b'gitnode', requires={b'ctx', b'repo'})
 def gitnodekw(context, mapping):
     """:gitnode: String. The Git changeset identification hash, as a
-        40 hexadecimal digit string."""
+    40 hexadecimal digit string."""
     node = context.resource(mapping, b'ctx')
     repo = context.resource(mapping, b'repo')
     return _gitnodekw(node, repo)
diff --git a/hggit/util.py b/hggit/util.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvdXRpbC5weQ==..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvdXRpbC5weQ== 100644
--- a/hggit/util.py
+++ b/hggit/util.py
@@ -43,9 +43,9 @@
 
     """
     with extensions.wrappedfunction(
-            phases,
-            'newcommitphase',
-            lambda orig, ui: phases.draft,
+        phases,
+        'newcommitphase',
+        lambda orig, ui: phases.draft,
     ):
         yield
 
@@ -86,8 +86,9 @@
 
 def transform_notgit(f):
     '''use as a decorator around functions that call into dulwich'''
+
     def inner(*args, **kwargs):
         try:
             return f(*args, **kwargs)
         except errors.NotGitRepository:
             raise error.Abort(b'not a git repository')
@@ -89,8 +90,9 @@
     def inner(*args, **kwargs):
         try:
             return f(*args, **kwargs)
         except errors.NotGitRepository:
             raise error.Abort(b'not a git repository')
+
     return inner
 
 
@@ -128,8 +130,10 @@
         if len(giturl) > 1 and repopath.endswith(b'.git'):
             return True
         # use a simple regex to check if it is a fqdn regex
-        fqdn_re = (br'(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}'
-                   br'(?<!-)\.)+[a-zA-Z]{2,63}$)')
+        fqdn_re = (
+            br'(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}'
+            br'(?<!-)\.)+[a-zA-Z]{2,63}$)'
+        )
         if re.match(fqdn_re, giturl):
             return True
     return False
@@ -147,5 +151,4 @@
     """
     host = hgutil.urlreq.unquote(host)
     if host.startswith(b'-'):
-        raise error.Abort(_(b"potentially unsafe hostname: '%s'") %
-                          (host,))
+        raise error.Abort(_(b"potentially unsafe hostname: '%s'") % (host,))
diff --git a/hggit/verify.py b/hggit/verify.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_aGdnaXQvdmVyaWZ5LnB5..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_aGdnaXQvdmVyaWZ5LnB5 100644
--- a/hggit/verify.py
+++ b/hggit/verify.py
@@ -29,10 +29,13 @@
     gitsha = handler.map_git_get(hgctx.hex())
     if not gitsha:
         # TODO deal better with commits in the middle of octopus merges
-        raise error.Abort(_(b'no git commit found for rev %s') % hgctx,
-                          hint=_(b'if this is an octopus merge, '
-                                 b'verify against the last rev'))
+        raise error.Abort(
+            _(b'no git commit found for rev %s') % hgctx,
+            hint=_(
+                b'if this is an octopus merge, ' b'verify against the last rev'
+            ),
+        )
 
     try:
         gitcommit = handler.git.get_object(gitsha)
     except KeyError:
@@ -35,9 +38,10 @@
 
     try:
         gitcommit = handler.git.get_object(gitsha)
     except KeyError:
-        raise error.Abort(_(b'git equivalent %s for rev %s not found!') %
-                          (gitsha, hgctx))
+        raise error.Abort(
+            _(b'git equivalent %s for rev %s not found!') % (gitsha, hgctx)
+        )
     except Exception:
         ui.traceback()
         raise error.Abort(
@@ -46,8 +50,10 @@
         )
 
     if not isinstance(gitcommit, Commit):
-        raise error.Abort(_(b'git equivalent %s for rev %s is not a commit!') %
-                          (gitsha, hgctx))
+        raise error.Abort(
+            _(b'git equivalent %s for rev %s is not a commit!')
+            % (gitsha, hgctx)
+        )
 
     ui.status(_(b'verifying rev %s against git commit %s\n') % (hgctx, gitsha))
     failed = False
@@ -63,8 +69,9 @@
     gitfiles = set()
 
     with ui.makeprogress(b'verify', total=len(hgfiles)) as progress:
-        for gitfile, dummy in diff_tree.walk_trees(handler.git.object_store,
-                                                   gitcommit.tree, None):
+        for gitfile, dummy in diff_tree.walk_trees(
+            handler.git.object_store, gitcommit.tree, None
+        ):
             if gitfile.mode == dirkind:
                 continue
             # TODO deal with submodules
@@ -68,8 +75,11 @@
             if gitfile.mode == dirkind:
                 continue
             # TODO deal with submodules
-            if (gitfile.mode == S_IFGITLINK or gitfile.path == b'.hgsubstate' or
-                gitfile.path == b'.hgsub'):
+            if (
+                gitfile.mode == S_IFGITLINK
+                or gitfile.path == b'.hgsubstate'
+                or gitfile.path == b'.hgsub'
+            ):
                 continue
             progress.increment()
             gitfiles.add(gitfile.path)
@@ -83,8 +93,10 @@
             hgflags = fctx.flags()
             gitflags = handler.convert_git_int_mode(gitfile.mode)
             if hgflags != gitflags:
-                ui.write(_(b"file has different flags: %s (hg '%s', git '%s')\n") %
-                         (gitfile.path, hgflags, gitflags))
+                ui.write(
+                    _(b"file has different flags: %s (hg '%s', git '%s')\n")
+                    % (gitfile.path, hgflags, gitflags)
+                )
                 failed = True
             if fctx.data() != handler.git[gitfile.sha].data:
                 ui.write(_(b'difference in: %s\n') % gitfile.path)
diff --git a/setup.py b/setup.py
index 4ab269795beab355a1623ef6f0ed62171eb4050c_c2V0dXAucHk=..2e825c6ee86fae227d7e2314d3e5b9eb0c5f228f_c2V0dXAucHk= 100644
--- a/setup.py
+++ b/setup.py
@@ -2,7 +2,8 @@
 
 try:
     import setuptools_scm
-    assert setuptools_scm # silence pyflakes
+
+    assert setuptools_scm  # silence pyflakes
 except ImportError:
     pass