2
0
Jelmer Vernooij 4 жил өмнө
parent
commit
c8ce22c255
48 өөрчлөгдсөн 878 нэмэгдсэн , 258 устгасан
  1. 16 4
      dulwich/cli.py
  2. 118 28
      dulwich/client.py
  3. 6 3
      dulwich/contrib/swift.py
  4. 21 10
      dulwich/contrib/test_swift.py
  5. 3 1
      dulwich/contrib/test_swift_smoke.py
  6. 2 1
      dulwich/errors.py
  7. 11 4
      dulwich/fastexport.py
  8. 9 1
      dulwich/file.py
  9. 9 2
      dulwich/ignore.py
  10. 15 2
      dulwich/index.py
  11. 11 2
      dulwich/object_store.py
  12. 15 4
      dulwich/objects.py
  13. 26 6
      dulwich/pack.py
  14. 27 7
      dulwich/porcelain.py
  15. 2 1
      dulwich/reflog.py
  16. 56 8
      dulwich/refs.py
  17. 34 9
      dulwich/repo.py
  18. 17 4
      dulwich/server.py
  19. 8 4
      dulwich/tests/compat/server_utils.py
  20. 24 7
      dulwich/tests/compat/test_client.py
  21. 15 6
      dulwich/tests/compat/test_pack.py
  22. 23 6
      dulwich/tests/test_client.py
  23. 7 1
      dulwich/tests/test_config.py
  24. 30 11
      dulwich/tests/test_diff_tree.py
  25. 15 3
      dulwich/tests/test_fastexport.py
  26. 4 2
      dulwich/tests/test_grafts.py
  27. 4 2
      dulwich/tests/test_ignore.py
  28. 14 5
      dulwich/tests/test_index.py
  29. 2 1
      dulwich/tests/test_lru_cache.py
  30. 18 6
      dulwich/tests/test_mailmap.py
  31. 2 1
      dulwich/tests/test_missing_obj_finder.py
  32. 23 7
      dulwich/tests/test_object_store.py
  33. 15 5
      dulwich/tests/test_objects.py
  34. 12 6
      dulwich/tests/test_objectspec.py
  35. 23 7
      dulwich/tests/test_pack.py
  36. 26 6
      dulwich/tests/test_patch.py
  37. 60 19
      dulwich/tests/test_porcelain.py
  38. 6 3
      dulwich/tests/test_protocol.py
  39. 31 12
      dulwich/tests/test_refs.py
  40. 22 9
      dulwich/tests/test_repository.py
  41. 27 9
      dulwich/tests/test_server.py
  42. 18 5
      dulwich/tests/test_walk.py
  43. 12 3
      dulwich/tests/test_web.py
  44. 5 1
      dulwich/tests/utils.py
  45. 4 1
      dulwich/walk.py
  46. 30 8
      dulwich/web.py
  47. 0 2
      pyproject.toml
  48. 0 3
      setup.cfg

+ 16 - 4
dulwich/cli.py

@@ -66,14 +66,19 @@ class cmd_archive(Command):
     def run(self, args):
         parser = optparse.OptionParser()
         parser.add_option(
-            "--remote", type=str, help="Retrieve archive from specified remote repo"
+            "--remote",
+            type=str,
+            help="Retrieve archive from specified remote repo",
         )
         options, args = parser.parse_args(args)
         committish = args.pop(0)
         if options.remote:
             client, path = get_transport_and_path(options.remote)
             client.archive(
-                path, committish, sys.stdout.write, write_error=sys.stderr.write
+                path,
+                committish,
+                sys.stdout.write,
+                write_error=sys.stderr.write,
             )
         else:
             porcelain.archive(
@@ -312,7 +317,10 @@ class cmd_tag(Command):
     def run(self, args):
         parser = optparse.OptionParser()
         parser.add_option(
-            "-a", "--annotated", help="Create an annotated tag.", action="store_true"
+            "-a",
+            "--annotated",
+            help="Create an annotated tag.",
+            action="store_true",
         )
         parser.add_option(
             "-s", "--sign", help="Sign the annotated tag.", action="store_true"
@@ -650,7 +658,11 @@ class cmd_help(Command):
     def run(self, args):
         parser = optparse.OptionParser()
         parser.add_option(
-            "-a", "--all", dest="all", action="store_true", help="List all commands."
+            "-a",
+            "--all",
+            dest="all",
+            action="store_true",
+            help="List all commands.",
         )
         options, args = parser.parse_args(args)
 

+ 118 - 28
dulwich/client.py

@@ -268,7 +268,9 @@ class FetchPackResult(object):
         import warnings
 
         warnings.warn(
-            "Use FetchPackResult.refs instead.", DeprecationWarning, stacklevel=3
+            "Use FetchPackResult.refs instead.",
+            DeprecationWarning,
+            stacklevel=3,
         )
 
     def __eq__(self, other):
@@ -348,7 +350,9 @@ class SendPackResult(object):
         import warnings
 
         warnings.warn(
-            "Use SendPackResult.refs instead.", DeprecationWarning, stacklevel=3
+            "Use SendPackResult.refs instead.",
+            DeprecationWarning,
+            stacklevel=3,
         )
 
     def __eq__(self, other):
@@ -404,7 +408,11 @@ class GitClient(object):
     """Git smart server client."""
 
     def __init__(
-        self, thin_packs=True, report_activity=None, quiet=False, include_tags=False
+        self,
+        thin_packs=True,
+        report_activity=None,
+        quiet=False,
+        include_tags=False,
     ):
         """Create a new GitClient instance.
 
@@ -524,7 +532,13 @@ class GitClient(object):
         return result
 
     def fetch_pack(
-        self, path, determine_wants, graph_walker, pack_data, progress=None, depth=None
+        self,
+        path,
+        determine_wants,
+        graph_walker,
+        pack_data,
+        progress=None,
+        depth=None,
     ):
         """Retrieve a pack from a git smart server.
 
@@ -794,7 +808,11 @@ class GitClient(object):
             parts = pkt.rstrip(b"\n").split(b" ")
             if parts[0] == b"ACK":
                 graph_walker.ack(parts[1])
-            if len(parts) < 3 or parts[2] not in (b"ready", b"continue", b"common"):
+            if len(parts) < 3 or parts[2] not in (
+                b"ready",
+                b"continue",
+                b"common",
+            ):
                 break
             pkt = proto.read_pkt_line()
         if CAPABILITY_SIDE_BAND_64K in capabilities:
@@ -895,9 +913,10 @@ class TraditionalGitClient(GitClient):
                 old_refs, server_capabilities = read_pkt_refs(proto)
             except HangupException:
                 raise _remote_error_from_stderr(stderr)
-            negotiated_capabilities, agent = self._negotiate_receive_pack_capabilities(
-                server_capabilities
-            )
+            (
+                negotiated_capabilities,
+                agent,
+            ) = self._negotiate_receive_pack_capabilities(server_capabilities)
             if CAPABILITY_REPORT_STATUS in negotiated_capabilities:
                 self._report_status_parser = ReportStatusParser()
             report_status_parser = self._report_status_parser
@@ -942,7 +961,9 @@ class TraditionalGitClient(GitClient):
             )
 
             pack_data_count, pack_data = generate_pack_data(
-                have, want, ofs_delta=(CAPABILITY_OFS_DELTA in negotiated_capabilities)
+                have,
+                want,
+                ofs_delta=(CAPABILITY_OFS_DELTA in negotiated_capabilities),
             )
 
             if self._should_send_pack(new_refs):
@@ -954,7 +975,13 @@ class TraditionalGitClient(GitClient):
             return SendPackResult(new_refs, agent=agent, ref_status=ref_status)
 
     def fetch_pack(
-        self, path, determine_wants, graph_walker, pack_data, progress=None, depth=None
+        self,
+        path,
+        determine_wants,
+        graph_walker,
+        pack_data,
+        progress=None,
+        depth=None,
     ):
         """Retrieve a pack from a git smart server.
 
@@ -1007,7 +1034,11 @@ class TraditionalGitClient(GitClient):
                 depth=depth,
             )
             self._handle_upload_pack_tail(
-                proto, negotiated_capabilities, graph_walker, pack_data, progress
+                proto,
+                negotiated_capabilities,
+                graph_walker,
+                pack_data,
+                progress,
             )
             return FetchPackResult(refs, symrefs, agent, new_shallow, new_unshallow)
 
@@ -1124,7 +1155,10 @@ class TCPGitClient(TraditionalGitClient):
             s.close()
 
         proto = Protocol(
-            rfile.read, wfile.write, close, report_activity=self._report_activity
+            rfile.read,
+            wfile.write,
+            close,
+            report_activity=self._report_activity,
         )
         if path.startswith(b"/~"):
             path = path[1:]
@@ -1203,7 +1237,10 @@ class SubprocessGitClient(TraditionalGitClient):
         pw = SubprocessWrapper(p)
         return (
             Protocol(
-                pw.read, pw.write, pw.close, report_activity=self._report_activity
+                pw.read,
+                pw.write,
+                pw.close,
+                report_activity=self._report_activity,
             ),
             pw.can_read,
             p.stderr,
@@ -1317,12 +1354,21 @@ class LocalGitClient(GitClient):
         """
         with self._open_repo(path) as r:
             refs = r.fetch(
-                target, determine_wants=determine_wants, progress=progress, depth=depth
+                target,
+                determine_wants=determine_wants,
+                progress=progress,
+                depth=depth,
             )
             return FetchPackResult(refs, r.refs.get_symrefs(), agent_string())
 
     def fetch_pack(
-        self, path, determine_wants, graph_walker, pack_data, progress=None, depth=None
+        self,
+        path,
+        determine_wants,
+        graph_walker,
+        pack_data,
+        progress=None,
+        depth=None,
     ):
         """Retrieve a pack from a git smart server.
 
@@ -1370,7 +1416,13 @@ class SSHVendor(object):
     """A client side SSH implementation."""
 
     def connect_ssh(
-        self, host, command, username=None, port=None, password=None, key_filename=None
+        self,
+        host,
+        command,
+        username=None,
+        port=None,
+        password=None,
+        key_filename=None,
     ):
         # This function was deprecated in 0.9.1
         import warnings
@@ -1389,7 +1441,13 @@ class SSHVendor(object):
         )
 
     def run_command(
-        self, host, command, username=None, port=None, password=None, key_filename=None
+        self,
+        host,
+        command,
+        username=None,
+        port=None,
+        password=None,
+        key_filename=None,
     ):
         """Connect to an SSH server.
 
@@ -1421,7 +1479,13 @@ class SubprocessSSHVendor(SSHVendor):
     """SSH vendor that shells out to the local 'ssh' command."""
 
     def run_command(
-        self, host, command, username=None, port=None, password=None, key_filename=None
+        self,
+        host,
+        command,
+        username=None,
+        port=None,
+        password=None,
+        key_filename=None,
     ):
 
         if password is not None:
@@ -1457,7 +1521,13 @@ class PLinkSSHVendor(SSHVendor):
     """SSH vendor that shells out to the local 'plink' command."""
 
     def run_command(
-        self, host, command, username=None, port=None, password=None, key_filename=None
+        self,
+        host,
+        command,
+        username=None,
+        port=None,
+        password=None,
+        key_filename=None,
     ):
 
         if sys.platform == "win32":
@@ -1583,7 +1653,10 @@ class SSHGitClient(TraditionalGitClient):
         )
         return (
             Protocol(
-                con.read, con.write, con.close, report_activity=self._report_activity
+                con.read,
+                con.write,
+                con.close,
+                report_activity=self._report_activity,
             ),
             con.can_read,
             getattr(con, "stderr", None),
@@ -1596,7 +1669,7 @@ def default_user_agent_string():
     return "git/dulwich/%s" % ".".join([str(x) for x in dulwich.__version__])
 
 
-def default_urllib3_manager(
+def default_urllib3_manager(   # noqa: C901
     config, pool_manager_cls=None, proxy_manager_cls=None, **override_kwargs
 ):
     """Return `urllib3` connection pool manager.
@@ -1741,7 +1814,11 @@ class HttpGitClient(GitClient):
         return cls(urlunparse(parsedurl), **kwargs)
 
     def __repr__(self):
-        return "%s(%r, dumb=%r)" % (type(self).__name__, self._base_url, self.dumb)
+        return "%s(%r, dumb=%r)" % (
+            type(self).__name__,
+            self._base_url,
+            self.dumb,
+        )
 
     def _get_url(self, path):
         if not isinstance(path, str):
@@ -1885,9 +1962,10 @@ class HttpGitClient(GitClient):
         old_refs, server_capabilities, url = self._discover_references(
             b"git-receive-pack", url
         )
-        negotiated_capabilities, agent = self._negotiate_receive_pack_capabilities(
-            server_capabilities
-        )
+        (
+            negotiated_capabilities,
+            agent,
+        ) = self._negotiate_receive_pack_capabilities(server_capabilities)
         negotiated_capabilities.add(capability_agent())
 
         if CAPABILITY_REPORT_STATUS in negotiated_capabilities:
@@ -1907,7 +1985,9 @@ class HttpGitClient(GitClient):
             req_proto, negotiated_capabilities, old_refs, new_refs
         )
         pack_data_count, pack_data = generate_pack_data(
-            have, want, ofs_delta=(CAPABILITY_OFS_DELTA in negotiated_capabilities)
+            have,
+            want,
+            ofs_delta=(CAPABILITY_OFS_DELTA in negotiated_capabilities),
         )
         if self._should_send_pack(new_refs):
             write_pack_data(req_proto.write_file(), pack_data_count, pack_data)
@@ -1924,7 +2004,13 @@ class HttpGitClient(GitClient):
             resp.close()
 
     def fetch_pack(
-        self, path, determine_wants, graph_walker, pack_data, progress=None, depth=None
+        self,
+        path,
+        determine_wants,
+        graph_walker,
+        pack_data,
+        progress=None,
+        depth=None,
     ):
         """Retrieve a pack from a git smart server.
 
@@ -1974,7 +2060,11 @@ class HttpGitClient(GitClient):
             if new_shallow is None and new_unshallow is None:
                 (new_shallow, new_unshallow) = _read_shallow_updates(resp_proto)
             self._handle_upload_pack_tail(
-                resp_proto, negotiated_capabilities, graph_walker, pack_data, progress
+                resp_proto,
+                negotiated_capabilities,
+                graph_walker,
+                pack_data,
+                progress,
             )
             return FetchPackResult(refs, symrefs, agent, new_shallow, new_unshallow)
         finally:

+ 6 - 3
dulwich/contrib/swift.py

@@ -595,7 +595,8 @@ class SwiftPackData(PackData):
         pack_reader = SwiftPackReader(self.scon, self._filename, self.pack_length)
         (version, self._num_objects) = read_pack_header(pack_reader.read)
         self._offset_cache = LRUSizeCache(
-            1024 * 1024 * self.scon.cache_length, compute_size=_compute_object_size
+            1024 * 1024 * self.scon.cache_length,
+            compute_size=_compute_object_size,
         )
         self.pack = None
 
@@ -736,7 +737,8 @@ class SwiftObjectStore(PackBasedObjectStore):
             entries = pack.sorted_entries()
             if len(entries):
                 basename = posixpath.join(
-                    self.pack_dir, "pack-%s" % iter_sha1(entry[0] for entry in entries)
+                    self.pack_dir,
+                    "pack-%s" % iter_sha1(entry[0] for entry in entries),
                 )
                 index = BytesIO()
                 write_pack_index_v2(index, entries, pack.get_stored_checksum())
@@ -816,7 +818,8 @@ class SwiftObjectStore(PackBasedObjectStore):
         # Move the pack in.
         entries.sort()
         pack_base_name = posixpath.join(
-            self.pack_dir, "pack-" + os.fsdecode(iter_sha1(e[0] for e in entries))
+            self.pack_dir,
+            "pack-" + os.fsdecode(iter_sha1(e[0] for e in entries)),
         )
         self.scon.put_object(pack_base_name + ".pack", f)
 

+ 21 - 10
dulwich/contrib/test_swift.py

@@ -260,7 +260,8 @@ class TestSwiftRepo(TestCase):
 
     def test_init_no_data(self):
         with patch(
-            "dulwich.contrib.swift.SwiftConnector", new_callable=create_swift_connector
+            "dulwich.contrib.swift.SwiftConnector",
+            new_callable=create_swift_connector,
         ):
             self.assertRaises(Exception, swift.SwiftRepo, "fakerepo", self.conf)
 
@@ -324,7 +325,9 @@ class TestSwiftInfoRefsContainer(TestCase):
         self.fsc.store = self.store
         irc = swift.SwiftInfoRefsContainer(self.fsc, self.object_store)
         irc.set_if_equals(
-            b"refs/heads/dev", b"cca703b0e1399008b53a1a236d6b4584737649e4", b"1" * 40
+            b"refs/heads/dev",
+            b"cca703b0e1399008b53a1a236d6b4584737649e4",
+            b"1" * 40,
         )
         self.assertEqual(irc[b"refs/heads/dev"], b"1" * 40)
 
@@ -378,20 +381,23 @@ class TestSwiftConnector(TestCase):
 
     def test_root_not_exists(self):
         with patch(
-            "geventhttpclient.HTTPClient.request", lambda *args: Response(status=404)
+            "geventhttpclient.HTTPClient.request",
+            lambda *args: Response(status=404),
         ):
             self.assertEqual(self.conn.test_root_exists(), None)
 
     def test_create_root(self):
         with patch(
-            "dulwich.contrib.swift.SwiftConnector.test_root_exists", lambda *args: None
+            "dulwich.contrib.swift.SwiftConnector.test_root_exists",
+            lambda *args: None,
         ):
             with patch("geventhttpclient.HTTPClient.request", lambda *args: Response()):
                 self.assertEqual(self.conn.create_root(), None)
 
     def test_create_root_fails(self):
         with patch(
-            "dulwich.contrib.swift.SwiftConnector.test_root_exists", lambda *args: None
+            "dulwich.contrib.swift.SwiftConnector.test_root_exists",
+            lambda *args: None,
         ):
             with patch(
                 "geventhttpclient.HTTPClient.request",
@@ -410,7 +416,8 @@ class TestSwiftConnector(TestCase):
 
     def test_get_container_objects_fails(self):
         with patch(
-            "geventhttpclient.HTTPClient.request", lambda *args: Response(status=404)
+            "geventhttpclient.HTTPClient.request",
+            lambda *args: Response(status=404),
         ):
             self.assertEqual(self.conn.get_container_objects(), None)
 
@@ -423,13 +430,15 @@ class TestSwiftConnector(TestCase):
 
     def test_get_object_stat_fails(self):
         with patch(
-            "geventhttpclient.HTTPClient.request", lambda *args: Response(status=404)
+            "geventhttpclient.HTTPClient.request",
+            lambda *args: Response(status=404),
         ):
             self.assertEqual(self.conn.get_object_stat("a"), None)
 
     def test_put_object(self):
         with patch(
-            "geventhttpclient.HTTPClient.request", lambda *args, **kwargs: Response()
+            "geventhttpclient.HTTPClient.request",
+            lambda *args, **kwargs: Response(),
         ):
             self.assertEqual(self.conn.put_object("a", BytesIO(b"content")), None)
 
@@ -468,14 +477,16 @@ class TestSwiftConnector(TestCase):
 
     def test_del_root(self):
         with patch(
-            "dulwich.contrib.swift.SwiftConnector.del_object", lambda *args: None
+            "dulwich.contrib.swift.SwiftConnector.del_object",
+            lambda *args: None,
         ):
             with patch(
                 "dulwich.contrib.swift.SwiftConnector." "get_container_objects",
                 lambda *args: ({"name": "a"}, {"name": "b"}),
             ):
                 with patch(
-                    "geventhttpclient.HTTPClient.request", lambda *args: Response()
+                    "geventhttpclient.HTTPClient.request",
+                    lambda *args: Response(),
                 ):
                     self.assertEqual(self.conn.del_root(), None)
 

+ 3 - 1
dulwich/contrib/test_swift_smoke.py

@@ -174,7 +174,9 @@ class SwiftRepoSmokeTest(unittest.TestCase):
         remote_shas = {}
         for branch in ("master", "mybranch", "pullr-108"):
             local_shas[branch] = local_repo.do_commit(
-                "Test commit %s" % branch, "fbo@localhost", ref="refs/heads/%s" % branch
+                "Test commit %s" % branch,
+                "fbo@localhost",
+                ref="refs/heads/%s" % branch,
             )
         swift.SwiftRepo.init_bare(self.scon, self.conf)
         tcp_client = client.TCPGitClient(self.server_address, port=self.port)

+ 2 - 1
dulwich/errors.py

@@ -37,7 +37,8 @@ class ChecksumMismatch(Exception):
         self.extra = extra
         if self.extra is None:
             Exception.__init__(
-                self, "Checksum mismatch: Expected %s, got %s" % (expected, got)
+                self,
+                "Checksum mismatch: Expected %s, got %s" % (expected, got),
             )
         else:
             Exception.__init__(

+ 11 - 4
dulwich/fastexport.py

@@ -106,7 +106,12 @@ class GitFastExporter(object):
             ref,
             marker,
             (author, author_email, commit.author_time, commit.author_timezone),
-            (committer, committer_email, commit.commit_time, commit.commit_timezone),
+            (
+                committer,
+                committer_email,
+                commit.commit_time,
+                commit.commit_timezone,
+            ),
             commit.message,
             from_,
             merges,
@@ -223,9 +228,11 @@ class GitImportProcessor(processor.ImportProcessor):
         self.last_commit = commit_id
         if commit_id != ZERO_SHA:
             tree_id = self.repo[commit_id].tree
-            for (path, mode, hexsha) in self.repo.object_store.iter_tree_contents(
-                tree_id
-            ):
+            for (
+                path,
+                mode,
+                hexsha,
+            ) in self.repo.object_store.iter_tree_contents(tree_id):
                 self._contents[path] = (mode, hexsha)
 
     def reset_handler(self, cmd):

+ 9 - 1
dulwich/file.py

@@ -111,7 +111,15 @@ class _GitFile(object):
     """
 
     PROXY_PROPERTIES = set(
-        ["closed", "encoding", "errors", "mode", "name", "newlines", "softspace"]
+        [
+            "closed",
+            "encoding",
+            "errors",
+            "mode",
+            "name",
+            "newlines",
+            "softspace",
+        ]
     )
     PROXY_METHODS = (
         "__iter__",

+ 9 - 2
dulwich/ignore.py

@@ -183,7 +183,11 @@ class Pattern(object):
         )
 
     def __repr__(self) -> str:
-        return "%s(%r, %r)" % (type(self).__name__, self.pattern, self.ignorecase)
+        return "%s(%r, %r)" % (
+            type(self).__name__,
+            self.pattern,
+            self.ignorecase,
+        )
 
     def match(self, path: bytes) -> bool:
         """Try to match a path against this ignore pattern.
@@ -290,7 +294,10 @@ class IgnoreFilterManager(object):
     """Ignore file manager."""
 
     def __init__(
-        self, top_path: str, global_filters: List[IgnoreFilter], ignorecase: bool
+        self,
+        top_path: str,
+        global_filters: List[IgnoreFilter],
+        ignorecase: bool,
     ):
         self._path_filters = {}  # type: Dict[str, Optional[IgnoreFilter]]
         self._top_path = top_path

+ 15 - 2
dulwich/index.py

@@ -58,7 +58,18 @@ from dulwich.pack import (
 
 IndexEntry = collections.namedtuple(
     "IndexEntry",
-    ["ctime", "mtime", "dev", "ino", "mode", "uid", "gid", "size", "sha", "flags"],
+    [
+        "ctime",
+        "mtime",
+        "dev",
+        "ino",
+        "mode",
+        "uid",
+        "gid",
+        "size",
+        "sha",
+        "flags",
+    ],
 )
 
 
@@ -230,7 +241,9 @@ def write_index(f: BinaryIO, entries: List[Any], version: Optional[int] = None):
 
 
 def write_index_dict(
-    f: BinaryIO, entries: Dict[bytes, IndexEntry], version: Optional[int] = None
+    f: BinaryIO,
+    entries: Dict[bytes, IndexEntry],
+    version: Optional[int] = None,
 ) -> None:
     """Write an index file based on the contents of a dictionary."""
     entries_list = []

+ 11 - 2
dulwich/object_store.py

@@ -243,7 +243,13 @@ class BaseObjectStore(object):
         Returns: Iterator over (sha, path) pairs.
         """
         finder = MissingObjectFinder(
-            self, haves, wants, shallow, progress, get_tagged, get_parents=get_parents
+            self,
+            haves,
+            wants,
+            shallow,
+            progress,
+            get_tagged,
+            get_parents=get_parents,
         )
         return iter(finder.next, None)
 
@@ -1229,7 +1235,10 @@ class MissingObjectFinder(object):
         # common - commits from all_ancestors we hit into while
         # traversing parent hierarchy of wants
         missing_commits, common_commits = object_store._collect_ancestors(
-            want_commits, all_ancestors, shallow=shallow, get_parents=self._get_parents
+            want_commits,
+            all_ancestors,
+            shallow=shallow,
+            get_parents=self._get_parents,
         )
         self.sha_done = set()
         # Now, fill sha_done with commits and revisions of

+ 15 - 4
dulwich/objects.py

@@ -1161,7 +1161,10 @@ def parse_timezone(text):
     offset = abs(offset)
     hours = int(offset / 100)
     minutes = offset % 100
-    return (signum * (hours * 3600 + minutes * 60), unnecessary_negative_timezone)
+    return (
+        signum * (hours * 3600 + minutes * 60),
+        unnecessary_negative_timezone,
+    )
 
 
 def format_timezone(offset, unnecessary_negative_timezone=False):
@@ -1349,9 +1352,15 @@ class Commit(ShaFile):
         for field, _ in _parse_message(self._chunked_text):
             if field == _TREE_HEADER and last is not None:
                 raise ObjectFormatException("unexpected tree")
-            elif field == _PARENT_HEADER and last not in (_PARENT_HEADER, _TREE_HEADER):
+            elif field == _PARENT_HEADER and last not in (
+                _PARENT_HEADER,
+                _TREE_HEADER,
+            ):
                 raise ObjectFormatException("unexpected parent")
-            elif field == _AUTHOR_HEADER and last not in (_TREE_HEADER, _PARENT_HEADER):
+            elif field == _AUTHOR_HEADER and last not in (
+                _TREE_HEADER,
+                _PARENT_HEADER,
+            ):
                 raise ObjectFormatException("unexpected author")
             elif field == _COMMITTER_HEADER and last != _AUTHOR_HEADER:
                 raise ObjectFormatException("unexpected committer")
@@ -1421,7 +1430,9 @@ class Commit(ShaFile):
         self._parents = value
 
     parents = property(
-        _get_parents, _set_parents, doc="Parents of this commit, by their SHA1."
+        _get_parents,
+        _set_parents,
+        doc="Parents of this commit, by their SHA1.",
     )
 
     def _get_extra(self):

+ 26 - 6
dulwich/pack.py

@@ -772,7 +772,10 @@ def unpack_object(
 
     unpacked = UnpackedObject(type_num, delta_base, size, crc32)
     unused = read_zlib_chunks(
-        read_some, unpacked, buffer_size=zlib_bufsize, include_comp=include_comp
+        read_some,
+        unpacked,
+        buffer_size=zlib_bufsize,
+        include_comp=include_comp,
     )
     return unpacked, unused
 
@@ -1187,7 +1190,12 @@ class PackData(object):
             )
             if progress is not None:
                 progress(i, self._num_objects)
-            yield (offset, unpacked.pack_type_num, unpacked._obj(), unpacked.crc32)
+            yield (
+                offset,
+                unpacked.pack_type_num,
+                unpacked._obj(),
+                unpacked.crc32,
+            )
             # Back up over unused data.
             self._file.seek(-len(unused), SEEK_CUR)
 
@@ -1295,7 +1303,11 @@ class PackData(object):
         assert offset >= self._header_size
         self._file.seek(offset)
         unpacked, _ = unpack_object(self._file.read, include_comp=True)
-        return (unpacked.pack_type_num, unpacked.delta_base, unpacked.comp_chunks)
+        return (
+            unpacked.pack_type_num,
+            unpacked.delta_base,
+            unpacked.comp_chunks,
+        )
 
     def get_object_at(self, offset):
         """Given an offset in to the packfile return the object that is there.
@@ -1576,7 +1588,11 @@ def write_pack_object(f, type, object, sha=None, compression_level=-1):
 
 
 def write_pack(
-    filename, objects, deltify=None, delta_window_size=None, compression_level=-1
+    filename,
+    objects,
+    deltify=None,
+    delta_window_size=None,
+    compression_level=-1,
 ):
     """Write a new pack data file.
 
@@ -1690,7 +1706,10 @@ def write_pack_objects(
         pack_contents_count, pack_contents = pack_objects_to_data(objects)
 
     return write_pack_data(
-        f, pack_contents_count, pack_contents, compression_level=compression_level
+        f,
+        pack_contents_count,
+        pack_contents,
+        compression_level=compression_level,
     )
 
 
@@ -2032,7 +2051,8 @@ class Pack(object):
         data_stored_checksum = self.data.get_stored_checksum()
         if idx_stored_checksum != data_stored_checksum:
             raise ChecksumMismatch(
-                sha_to_hex(idx_stored_checksum), sha_to_hex(data_stored_checksum)
+                sha_to_hex(idx_stored_checksum),
+                sha_to_hex(data_stored_checksum),
             )
 
     def check(self):

+ 27 - 7
dulwich/porcelain.py

@@ -327,7 +327,12 @@ def symbolic_ref(repo, ref_name, force=False):
 
 
 def commit(
-    repo=".", message=None, author=None, committer=None, encoding=None, no_verify=False
+    repo=".",
+    message=None,
+    author=None,
+    committer=None,
+    encoding=None,
+    no_verify=False,
 ):
     """Create a new commit.
 
@@ -494,7 +499,9 @@ def add(repo=".", paths=None):
         if not paths:
             paths = list(
                 get_untracked_paths(
-                    str(Path(os.getcwd()).resolve()), str(repo_path), r.open_index()
+                    str(Path(os.getcwd()).resolve()),
+                    str(repo_path),
+                    r.open_index(),
                 )
             )
         relpaths = []
@@ -815,7 +822,10 @@ def log(
 
 # TODO(jelmer): better default for encoding?
 def show(
-    repo=".", objects=None, outstream=sys.stdout, default_encoding=DEFAULT_ENCODING
+    repo=".",
+    objects=None,
+    outstream=sys.stdout,
+    default_encoding=DEFAULT_ENCODING,
 ):
     """Print the changes in a commit.
 
@@ -945,7 +955,8 @@ def list_tags(*args, **kwargs):
     import warnings
 
     warnings.warn(
-        "list_tags has been deprecated in favour of tag_list.", DeprecationWarning
+        "list_tags has been deprecated in favour of tag_list.",
+        DeprecationWarning,
     )
     return tag_list(*args, **kwargs)
 
@@ -1487,7 +1498,10 @@ def _import_remote_refs(
         if n.startswith(LOCAL_BRANCH_PREFIX)
     }
     refs_container.import_refs(
-        b"refs/remotes/" + remote_name.encode(), branches, message=message, prune=prune
+        b"refs/remotes/" + remote_name.encode(),
+        branches,
+        message=message,
+        prune=prune,
     )
     tags = {
         n[len(b"refs/tags/") :]: v
@@ -1591,7 +1605,11 @@ def pack_objects(repo, object_ids, packf, idxf, delta_window_size=None):
 
 
 def ls_tree(
-    repo, treeish=b"HEAD", outstream=sys.stdout, recursive=False, name_only=False
+    repo,
+    treeish=b"HEAD",
+    outstream=sys.stdout,
+    recursive=False,
+    name_only=False,
 ):
     """List contents of a tree.
 
@@ -1817,7 +1835,9 @@ def describe(repo):
                         return tag_name
                     else:
                         return "{}-{}-g{}".format(
-                            tag_name, commit_count, latest_commit.id.decode("ascii")[:7]
+                            tag_name,
+                            commit_count,
+                            latest_commit.id.decode("ascii")[:7],
                         )
 
             commit_count += 1

+ 2 - 1
dulwich/reflog.py

@@ -30,7 +30,8 @@ from dulwich.objects import (
 )
 
 Entry = collections.namedtuple(
-    "Entry", ["old_sha", "new_sha", "committer", "timestamp", "timezone", "message"]
+    "Entry",
+    ["old_sha", "new_sha", "committer", "timestamp", "timezone", "message"],
 )
 
 

+ 56 - 8
dulwich/refs.py

@@ -115,7 +115,13 @@ class RefsContainer(object):
         self._logger(ref, old_sha, new_sha, committer, timestamp, timezone, message)
 
     def set_symbolic_ref(
-        self, name, other, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        other,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         """Make a ref point at another ref.
 
@@ -368,7 +374,13 @@ class RefsContainer(object):
         self.set_if_equals(name, None, ref)
 
     def remove_if_equals(
-        self, name, old_ref, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        old_ref,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         """Remove a refname only if it currently equals old_ref.
 
@@ -475,7 +487,13 @@ class DictRefsContainer(RefsContainer):
         return _DictRefsWatcher(self)
 
     def set_symbolic_ref(
-        self, name, other, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        other,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         old = self.follow(name)[-1]
         new = SYMREF + other
@@ -521,7 +539,13 @@ class DictRefsContainer(RefsContainer):
         return True
 
     def add_if_new(
-        self, name, ref, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        ref,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         if name in self._refs:
             return False
@@ -539,7 +563,13 @@ class DictRefsContainer(RefsContainer):
         return True
 
     def remove_if_equals(
-        self, name, old_ref, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        old_ref,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         if old_ref is not None and self._refs.get(name, ZERO_SHA) != old_ref:
             return False
@@ -818,7 +848,13 @@ class DiskRefsContainer(RefsContainer):
             f.abort()
 
     def set_symbolic_ref(
-        self, name, other, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        other,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         """Make a ref point at another ref.
 
@@ -919,7 +955,13 @@ class DiskRefsContainer(RefsContainer):
         return True
 
     def add_if_new(
-        self, name, ref, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        ref,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         """Add a new reference only if it does not already exist.
 
@@ -964,7 +1006,13 @@ class DiskRefsContainer(RefsContainer):
         return True
 
     def remove_if_equals(
-        self, name, old_ref, committer=None, timestamp=None, timezone=None, message=None
+        self,
+        name,
+        old_ref,
+        committer=None,
+        timestamp=None,
+        timezone=None,
+        message=None,
     ):
         """Remove a refname only if it currently equals old_ref.
 

+ 34 - 9
dulwich/repo.py

@@ -221,7 +221,9 @@ def check_user_identity(identity):
         raise InvalidUserIdentity(identity)
 
 
-def parse_graftpoints(graftpoints: Iterable[bytes]) -> Dict[bytes, List[bytes]]:
+def parse_graftpoints(
+    graftpoints: Iterable[bytes],
+) -> Dict[bytes, List[bytes]]:
     """Convert a list of graftpoints into a dict
 
     Args:
@@ -414,13 +416,21 @@ class BaseRepo(object):
         if determine_wants is None:
             determine_wants = target.object_store.determine_wants_all
         count, pack_data = self.fetch_pack_data(
-            determine_wants, target.get_graph_walker(), progress=progress, depth=depth
+            determine_wants,
+            target.get_graph_walker(),
+            progress=progress,
+            depth=depth,
         )
         target.object_store.add_pack_data(count, pack_data, progress)
         return self.get_refs()
 
     def fetch_pack_data(
-        self, determine_wants, graph_walker, progress, get_tagged=None, depth=None
+        self,
+        determine_wants,
+        graph_walker,
+        progress,
+        get_tagged=None,
+        depth=None,
     ):
         """Fetch the pack data required for a set of revisions.
 
@@ -444,7 +454,12 @@ class BaseRepo(object):
         return pack_objects_to_data(objects)
 
     def fetch_objects(
-        self, determine_wants, graph_walker, progress, get_tagged=None, depth=None
+        self,
+        determine_wants,
+        graph_walker,
+        progress,
+        get_tagged=None,
+        depth=None,
     ):
         """Fetch the missing objects required for a set of revisions.
 
@@ -605,7 +620,9 @@ class BaseRepo(object):
 
     def parents_provider(self):
         return ParentsProvider(
-            self.object_store, grafts=self._graftpoints, shallows=self.get_shallow()
+            self.object_store,
+            grafts=self._graftpoints,
+            shallows=self.get_shallow(),
         )
 
     def get_parents(self, sha: bytes, commit: Commit = None) -> List[bytes]:
@@ -831,7 +848,7 @@ class BaseRepo(object):
         with f:
             return [line.strip() for line in f.readlines() if line.strip()]
 
-    def do_commit(
+    def do_commit(  # noqa: C901
         self,
         message=None,
         committer=None,
@@ -1041,7 +1058,8 @@ class Repo(BaseRepo):
         if commondir is not None:
             with commondir:
                 self._commondir = os.path.join(
-                    self.controldir(), os.fsdecode(commondir.read().rstrip(b"\r\n"))
+                    self.controldir(),
+                    os.fsdecode(commondir.read().rstrip(b"\r\n")),
                 )
         else:
             self._commondir = self._controldir
@@ -1276,7 +1294,12 @@ class Repo(BaseRepo):
         index.write()
 
     def clone(
-        self, target_path, mkdir=True, bare=False, origin=b"origin", checkout=None
+        self,
+        target_path,
+        mkdir=True,
+        bare=False,
+        origin=b"origin",
+        checkout=None,
     ):
         """Clone this repository.
 
@@ -1316,7 +1339,9 @@ class Repo(BaseRepo):
         target_config = target.get_config()
         target_config.set(("remote", "origin"), "url", encoded_path)
         target_config.set(
-            ("remote", "origin"), "fetch", "+refs/heads/*:refs/remotes/origin/*"
+            ("remote", "origin"),
+            "fetch",
+            "+refs/heads/*:refs/remotes/origin/*",
         )
         target_config.write_to_path()
 

+ 17 - 4
dulwich/server.py

@@ -317,7 +317,11 @@ class UploadPackHandler(PackHandler):
 
     @classmethod
     def required_capabilities(cls):
-        return (CAPABILITY_SIDE_BAND_64K, CAPABILITY_THIN_PACK, CAPABILITY_OFS_DELTA)
+        return (
+            CAPABILITY_SIDE_BAND_64K,
+            CAPABILITY_THIN_PACK,
+            CAPABILITY_OFS_DELTA,
+        )
 
     def progress(self, message):
         if self.has_capability(CAPABILITY_NO_PROGRESS) or self._processing_have_lines:
@@ -373,7 +377,10 @@ class UploadPackHandler(PackHandler):
             return wants
 
         objects_iter = self.repo.fetch_objects(
-            wants_wrapper, graph_walker, self.progress, get_tagged=self.get_tagged
+            wants_wrapper,
+            graph_walker,
+            self.progress,
+            get_tagged=self.get_tagged,
         )
 
         # Note the fact that client is only processing responses related
@@ -436,7 +443,12 @@ def _split_proto_line(line, allowed):
     if len(fields) == 1 and command in (COMMAND_DONE, None):
         return (command, None)
     elif len(fields) == 2:
-        if command in (COMMAND_WANT, COMMAND_HAVE, COMMAND_SHALLOW, COMMAND_UNSHALLOW):
+        if command in (
+            COMMAND_WANT,
+            COMMAND_HAVE,
+            COMMAND_SHALLOW,
+            COMMAND_UNSHALLOW,
+        ):
             if not valid_hexsha(fields[1]):
                 raise GitProtocolError("Invalid sha")
             return tuple(fields)
@@ -1166,7 +1178,8 @@ class TCPGitServer(socketserver.TCPServer):
 
     def handle_error(self, request, client_address):
         logger.exception(
-            "Exception happened during processing of request " "from %s", client_address
+            "Exception happened during processing of request " "from %s",
+            client_address,
         )
 
 

+ 8 - 4
dulwich/tests/compat/server_utils.py

@@ -100,7 +100,8 @@ class ServerTests(object):
         port = self._start_server(self._old_repo)
 
         run_git_or_fail(
-            ["push", self.url(port)] + self.branch_args(), cwd=self._new_repo.path
+            ["push", self.url(port)] + self.branch_args(),
+            cwd=self._new_repo.path,
         )
         self.assertReposEqual(self._old_repo, self._new_repo)
 
@@ -111,7 +112,8 @@ class ServerTests(object):
         port = self._start_server(self._old_repo)
 
         run_git_or_fail(
-            ["push", self.url(port)] + self.branch_args(), cwd=self._new_repo.path
+            ["push", self.url(port)] + self.branch_args(),
+            cwd=self._new_repo.path,
         )
         self.assertReposEqual(self._old_repo, self._new_repo)
 
@@ -131,7 +133,8 @@ class ServerTests(object):
         port = self._start_server(self._new_repo)
 
         run_git_or_fail(
-            ["fetch", self.url(port)] + self.branch_args(), cwd=self._old_repo.path
+            ["fetch", self.url(port)] + self.branch_args(),
+            cwd=self._old_repo.path,
         )
         # flush the pack cache so any new packs are picked up
         self._old_repo.object_store._pack_cache_time = 0
@@ -144,7 +147,8 @@ class ServerTests(object):
         port = self._start_server(self._new_repo)
 
         run_git_or_fail(
-            ["fetch", self.url(port)] + self.branch_args(), cwd=self._old_repo.path
+            ["fetch", self.url(port)] + self.branch_args(),
+            cwd=self._old_repo.path,
         )
         # flush the pack cache so any new packs are picked up
         self._old_repo.object_store._pack_cache_time = 0

+ 24 - 7
dulwich/tests/compat/test_client.py

@@ -96,7 +96,9 @@ class DulwichClientTestBase(object):
             sendrefs = dict(src.get_refs())
             del sendrefs[b"HEAD"]
             c.send_pack(
-                self._build_path("/dest"), lambda _: sendrefs, src.generate_pack_data
+                self._build_path("/dest"),
+                lambda _: sendrefs,
+                src.generate_pack_data,
             )
 
     def test_send_pack(self):
@@ -154,7 +156,9 @@ class DulwichClientTestBase(object):
             sendrefs = dict(src.get_refs())
             del sendrefs[b"HEAD"]
             c.send_pack(
-                self._build_path("/dest"), lambda _: sendrefs, src.generate_pack_data
+                self._build_path("/dest"),
+                lambda _: sendrefs,
+                src.generate_pack_data,
             )
             self.assertDestEqualsSrc()
 
@@ -196,7 +200,10 @@ class DulwichClientTestBase(object):
                 self._build_path("/dest"), lambda _: sendrefs, gen_pack
             )
             self.assertEqual(
-                {b"refs/heads/branch": None, b"refs/heads/master": "non-fast-forward"},
+                {
+                    b"refs/heads/branch": None,
+                    b"refs/heads/master": "non-fast-forward",
+                },
                 result.ref_status,
             )
 
@@ -273,7 +280,9 @@ class DulwichClientTestBase(object):
                 return list(refs.values())
 
             result = c.fetch(
-                self._build_path("/server_new.export"), dest, determine_wants=dw
+                self._build_path("/server_new.export"),
+                dest,
+                determine_wants=dw,
             )
             for r in result.refs.items():
                 dest.refs.set_if_equals(r[0], None, r[1])
@@ -380,7 +389,10 @@ class DulwichTCPClientTest(CompatTestCase, DulwichClientTestBase):
             self.gitroot,
         ]
         self.process = subprocess.Popen(
-            args, cwd=self.gitroot, stdout=subprocess.PIPE, stderr=subprocess.PIPE
+            args,
+            cwd=self.gitroot,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
         )
         if not check_for_daemon():
             raise SkipTest("git-daemon failed to start")
@@ -421,7 +433,12 @@ class DulwichTCPClientTest(CompatTestCase, DulwichClientTestBase):
 class TestSSHVendor(object):
     @staticmethod
     def run_command(
-        host, command, username=None, port=None, password=None, key_filename=None
+        host,
+        command,
+        username=None,
+        port=None,
+        password=None,
+        key_filename=None,
     ):
         cmd, path = command.split(" ")
         cmd = cmd.split("-", 1)
@@ -491,7 +508,7 @@ class GitHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
         # Let's be quiet, the test suite is noisy enough already
         pass
 
-    def run_backend(self):
+    def run_backend(self):  # noqa: C901
         """Call out to git http-backend."""
         # Based on CGIHTTPServer.CGIHTTPRequestHandler.run_cgi:
         # Copyright (c) 2001-2010 Python Software Foundation;

+ 15 - 6
dulwich/tests/compat/test_pack.py

@@ -89,14 +89,17 @@ class TestPack(PackTests):
         write_pack(pack_path, all_to_pack, deltify=True)
         output = run_git_or_fail(["verify-pack", "-v", pack_path])
         self.assertEqual(
-            set(x[0].id for x in all_to_pack), _git_verify_pack_object_list(output)
+            set(x[0].id for x in all_to_pack),
+            _git_verify_pack_object_list(output),
         )
         # We specifically made a new blob that should be a delta
         # against the blob a_sha, so make sure we really got only 3
         # non-delta objects:
         got_non_delta = int(_NON_DELTA_RE.search(output).group("non_delta"))
         self.assertEqual(
-            3, got_non_delta, "Expected 3 non-delta objects, got %d" % got_non_delta
+            3,
+            got_non_delta,
+            "Expected 3 non-delta objects, got %d" % got_non_delta,
         )
 
     def test_delta_medium_object(self):
@@ -116,14 +119,17 @@ class TestPack(PackTests):
         write_pack(pack_path, all_to_pack, deltify=True)
         output = run_git_or_fail(["verify-pack", "-v", pack_path])
         self.assertEqual(
-            set(x[0].id for x in all_to_pack), _git_verify_pack_object_list(output)
+            set(x[0].id for x in all_to_pack),
+            _git_verify_pack_object_list(output),
         )
         # We specifically made a new blob that should be a delta
         # against the blob a_sha, so make sure we really got only 3
         # non-delta objects:
         got_non_delta = int(_NON_DELTA_RE.search(output).group("non_delta"))
         self.assertEqual(
-            3, got_non_delta, "Expected 3 non-delta objects, got %d" % got_non_delta
+            3,
+            got_non_delta,
+            "Expected 3 non-delta objects, got %d" % got_non_delta,
         )
         # We expect one object to have a delta chain length of two
         # (new_blob_2), so let's verify that actually happens:
@@ -152,12 +158,15 @@ class TestPack(PackTests):
         write_pack(pack_path, all_to_pack, deltify=True)
         output = run_git_or_fail(["verify-pack", "-v", pack_path])
         self.assertEqual(
-            set(x[0].id for x in all_to_pack), _git_verify_pack_object_list(output)
+            set(x[0].id for x in all_to_pack),
+            _git_verify_pack_object_list(output),
         )
         # We specifically made a new blob that should be a delta
         # against the blob a_sha, so make sure we really got only 4
         # non-delta objects:
         got_non_delta = int(_NON_DELTA_RE.search(output).group("non_delta"))
         self.assertEqual(
-            4, got_non_delta, "Expected 4 non-delta objects, got %d" % got_non_delta
+            4,
+            got_non_delta,
+            "Expected 4 non-delta objects, got %d" % got_non_delta,
         )

+ 23 - 6
dulwich/tests/test_client.py

@@ -698,7 +698,13 @@ class TestSSHVendor(object):
         self.key_filename = None
 
     def run_command(
-        self, host, command, username=None, port=None, password=None, key_filename=None
+        self,
+        host,
+        command,
+        username=None,
+        port=None,
+        password=None,
+        key_filename=None,
     ):
         self.host = host
         self.command = command
@@ -751,7 +757,8 @@ class SSHGitClientTests(TestCase):
     def test_alternative_command_path(self):
         self.client.alternative_paths[b"upload-pack"] = b"/usr/lib/git/git-upload-pack"
         self.assertEqual(
-            b"/usr/lib/git/git-upload-pack", self.client._get_cmd_path(b"upload-pack")
+            b"/usr/lib/git/git-upload-pack",
+            self.client._get_cmd_path(b"upload-pack"),
         )
 
     def test_alternative_command_path_spaces(self):
@@ -1171,7 +1178,10 @@ class SubprocessSSHVendorTests(TestCase):
     def test_run_command_dashes(self):
         vendor = SubprocessSSHVendor()
         self.assertRaises(
-            StrangeHostname, vendor.run_command, "--weird-host", "git-clone-url"
+            StrangeHostname,
+            vendor.run_command,
+            "--weird-host",
+            "git-clone-url",
         )
 
     def test_run_command_password(self):
@@ -1233,7 +1243,10 @@ class PLinkSSHVendorTests(TestCase):
     def test_run_command_dashes(self):
         vendor = PLinkSSHVendor()
         self.assertRaises(
-            StrangeHostname, vendor.run_command, "--weird-host", "git-clone-url"
+            StrangeHostname,
+            vendor.run_command,
+            "--weird-host",
+            "git-clone-url",
         )
 
     def test_run_command_password_and_privkey(self):
@@ -1245,7 +1258,10 @@ class PLinkSSHVendorTests(TestCase):
         self.addCleanup(restore_warnings)
 
         command = vendor.run_command(
-            "host", "git-clone-url", password="12345", key_filename="/tmp/id_rsa"
+            "host",
+            "git-clone-url",
+            password="12345",
+            key_filename="/tmp/id_rsa",
         )
 
         expected_warning = UserWarning(
@@ -1451,7 +1467,8 @@ with a tail
 """
         )
         self.assertEqual(
-            _remote_error_from_stderr(b), GitProtocolError("This is the actual error")
+            _remote_error_from_stderr(b),
+            GitProtocolError("This is the actual error"),
         )
 
     def test_no_error_line(self):

+ 7 - 1
dulwich/tests/test_config.py

@@ -352,6 +352,12 @@ class SubmodulesTests(TestCase):
         )
         got = list(parse_submodules(cf))
         self.assertEqual(
-            [(b"core/lib", b"https://github.com/phhusson/QuasselC.git", b"core/lib")],
+            [
+                (
+                    b"core/lib",
+                    b"https://github.com/phhusson/QuasselC.git",
+                    b"core/lib",
+                )
+            ],
             got,
         )

+ 30 - 11
dulwich/tests/test_diff_tree.py

@@ -184,7 +184,9 @@ class TreeChangesTest(DiffTestCase):
             [
                 TreeChange(CHANGE_UNCHANGED, (b"a", F, blob.id), (b"a", F, blob.id)),
                 TreeChange(
-                    CHANGE_UNCHANGED, (b"b/c", F, blob.id), (b"b/c", F, blob.id)
+                    CHANGE_UNCHANGED,
+                    (b"b/c", F, blob.id),
+                    (b"b/c", F, blob.id),
                 ),
             ],
             tree,
@@ -318,7 +320,9 @@ class TreeChangesTest(DiffTestCase):
         self.assertChangesEqual(
             [
                 TreeChange(
-                    CHANGE_MODIFY, (b"a", F, blob_a_1.id), (b"a", F, blob_a_2.id)
+                    CHANGE_MODIFY,
+                    (b"a", F, blob_a_1.id),
+                    (b"a", F, blob_a_2.id),
                 ),
                 TreeChange.delete((b"b/x/2", F, blob_bx2_1.id)),
                 TreeChange.add((b"b/y", F, blob_by_2.id)),
@@ -386,7 +390,9 @@ class TreeChangesTest(DiffTestCase):
             [
                 TreeChange.delete((b"a", F, blob_a1.id)),
                 TreeChange(
-                    CHANGE_UNCHANGED, (b"b", F, blob_b.id), (b"b", F, blob_b.id)
+                    CHANGE_UNCHANGED,
+                    (b"b", F, blob_b.id),
+                    (b"b", F, blob_b.id),
                 ),
                 TreeChange.add((b"c", F, blob_a2.id)),
             ],
@@ -404,7 +410,9 @@ class TreeChangesTest(DiffTestCase):
             [
                 TreeChange(CHANGE_RENAME, (b"a", F, blob_a1.id), (b"c", F, blob_a2.id)),
                 TreeChange(
-                    CHANGE_UNCHANGED, (b"b", F, blob_b.id), (b"b", F, blob_b.id)
+                    CHANGE_UNCHANGED,
+                    (b"b", F, blob_b.id),
+                    (b"b", F, blob_b.id),
                 ),
             ],
             tree1,
@@ -655,7 +663,8 @@ class RenameDetectionTest(DiffTestCase):
         data = a + b"xxx\ny\n" + a + b"zzz\n"
         blob = make_object(Blob, data=data)
         self.assertBlockCountEqual(
-            {b"a" * 64: 128, b"xxx\n": 4, b"y\n": 2, b"zzz\n": 4}, _count_blocks(blob)
+            {b"a" * 64: 128, b"xxx\n": 4, b"y\n": 2, b"zzz\n": 4},
+            _count_blocks(blob),
         )
 
     test_count_blocks_long_lines = functest_builder(
@@ -705,7 +714,9 @@ class RenameDetectionTest(DiffTestCase):
         expected_entries = [
             TreeChange.add(TreeEntry(b"aaa", F, sha)),
             TreeChange(
-                CHANGE_COPY, TreeEntry(b"bbb", F, sha), TreeEntry(b"aab", F, sha)
+                CHANGE_COPY,
+                TreeEntry(b"bbb", F, sha),
+                TreeEntry(b"aab", F, sha),
             ),
             TreeChange(
                 CHANGE_MODIFY,
@@ -713,7 +724,9 @@ class RenameDetectionTest(DiffTestCase):
                 TreeEntry(b"bbb", F, b"dabc" * 10),
             ),
             TreeChange(
-                CHANGE_RENAME, TreeEntry(b"bbc", F, sha), TreeEntry(b"ddd", F, sha)
+                CHANGE_RENAME,
+                TreeEntry(b"bbc", F, sha),
+                TreeEntry(b"ddd", F, sha),
             ),
             TreeChange.delete(TreeEntry(b"ccc", F, sha)),
         ]
@@ -833,7 +846,9 @@ class RenameDetectionTest(DiffTestCase):
         self.assertEqual(
             [
                 TreeChange(
-                    CHANGE_MODIFY, (b"a", F, blob.id), (b"a", 0o100755, blob.id)
+                    CHANGE_MODIFY,
+                    (b"a", F, blob.id),
+                    (b"a", 0o100755, blob.id),
                 ),
                 TreeChange(CHANGE_COPY, (b"a", F, blob.id), (b"b", F, blob.id)),
             ],
@@ -1065,7 +1080,8 @@ class RenameDetectionTest(DiffTestCase):
         tree1 = self.commit_tree([(b"a", blob)])
         tree2 = self.commit_tree([(b"a", blob), (b"b", blob)])
         self.assertEqual(
-            [TreeChange.add((b"b", F, blob.id))], self.detect_renames(tree1, tree2)
+            [TreeChange.add((b"b", F, blob.id))],
+            self.detect_renames(tree1, tree2),
         )
         self.assertEqual(
             [TreeChange(CHANGE_COPY, (b"a", F, blob.id), (b"b", F, blob.id))],
@@ -1078,7 +1094,8 @@ class RenameDetectionTest(DiffTestCase):
         tree1 = self.commit_tree([(b"a", blob1)])
         tree2 = self.commit_tree([(b"a", blob1), (b"b", blob2)])
         self.assertEqual(
-            [TreeChange.add((b"b", F, blob2.id))], self.detect_renames(tree1, tree2)
+            [TreeChange.add((b"b", F, blob2.id))],
+            self.detect_renames(tree1, tree2),
         )
         self.assertEqual(
             [TreeChange(CHANGE_COPY, (b"a", F, blob1.id), (b"b", F, blob2.id))],
@@ -1131,7 +1148,9 @@ class RenameDetectionTest(DiffTestCase):
             [
                 TreeChange(CHANGE_RENAME, (b"a", F, blob_a1.id), (b"c", F, blob_c2.id)),
                 TreeChange(
-                    CHANGE_UNCHANGED, (b"b", F, blob_b.id), (b"b", F, blob_b.id)
+                    CHANGE_UNCHANGED,
+                    (b"b", F, blob_b.id),
+                    (b"b", F, blob_b.id),
                 ),
             ],
             self.detect_renames(tree1, tree2, want_unchanged=True),

+ 15 - 3
dulwich/tests/test_fastexport.py

@@ -270,8 +270,16 @@ M 100644 :1 a
         commit = self.make_file_commit([commands.FileCopyCommand(b"path", b"new_path")])
         self.assertEqual(
             [
-                (b"new_path", 0o100644, b"6320cd248dd8aeaab759d5871f8781b5c0505172"),
-                (b"path", 0o100644, b"6320cd248dd8aeaab759d5871f8781b5c0505172"),
+                (
+                    b"new_path",
+                    0o100644,
+                    b"6320cd248dd8aeaab759d5871f8781b5c0505172",
+                ),
+                (
+                    b"path",
+                    0o100644,
+                    b"6320cd248dd8aeaab759d5871f8781b5c0505172",
+                ),
             ],
             self.repo[commit.tree].items(),
         )
@@ -285,7 +293,11 @@ M 100644 :1 a
         )
         self.assertEqual(
             [
-                (b"new_path", 0o100644, b"6320cd248dd8aeaab759d5871f8781b5c0505172"),
+                (
+                    b"new_path",
+                    0o100644,
+                    b"6320cd248dd8aeaab759d5871f8781b5c0505172",
+                ),
             ],
             self.repo[commit.tree].items(),
         )

+ 4 - 2
dulwich/tests/test_grafts.py

@@ -128,7 +128,8 @@ class GraftsInRepositoryBase(object):
         r = self.get_repo_with_grafts({self._shas[-1]: [self._shas[0]]})
 
         self.assertEqual(
-            [e.commit.id for e in r.get_walker()], [self._shas[-1], self._shas[0]]
+            [e.commit.id for e in r.get_walker()],
+            [self._shas[-1], self._shas[0]],
         )
 
     def test_remove_graft(self):
@@ -177,7 +178,8 @@ class GraftsInRepoTests(GraftsInRepositoryBase, TestCase):
     def test_init_with_info_grafts(self):
         r = self._repo
         r._put_named_file(
-            os.path.join("info", "grafts"), self._shas[-1] + b" " + self._shas[0]
+            os.path.join("info", "grafts"),
+            self._shas[-1] + b" " + self._shas[0],
         )
 
         r = Repo(self._repo_dir)

+ 4 - 2
dulwich/tests/test_ignore.py

@@ -129,13 +129,15 @@ class MatchPatternTests(TestCase):
     def test_matches(self):
         for (path, pattern) in POSITIVE_MATCH_TESTS:
             self.assertTrue(
-                match_pattern(path, pattern), "path: %r, pattern: %r" % (path, pattern)
+                match_pattern(path, pattern),
+                "path: %r, pattern: %r" % (path, pattern),
             )
 
     def test_no_matches(self):
         for (path, pattern) in NEGATIVE_MATCH_TESTS:
             self.assertFalse(
-                match_pattern(path, pattern), "path: %r, pattern: %r" % (path, pattern)
+                match_pattern(path, pattern),
+                "path: %r, pattern: %r" % (path, pattern),
             )
 
 

+ 14 - 5
dulwich/tests/test_index.py

@@ -702,7 +702,9 @@ class GetUnstagedChangesTests(TestCase):
 
             repo.stage(["foo1", "foo2"])
             repo.do_commit(
-                b"test status", author=b"author <email>", committer=b"committer <email>"
+                b"test status",
+                author=b"author <email>",
+                committer=b"committer <email>",
             )
 
             with open(foo1_fullpath, "wb") as f:
@@ -729,7 +731,9 @@ class GetUnstagedChangesTests(TestCase):
 
             repo.stage(["foo1"])
             repo.do_commit(
-                b"test status", author=b"author <email>", committer=b"committer <email>"
+                b"test status",
+                author=b"author <email>",
+                committer=b"committer <email>",
             )
 
             os.unlink(foo1_fullpath)
@@ -752,7 +756,9 @@ class GetUnstagedChangesTests(TestCase):
 
             repo.stage(["foo1"])
             repo.do_commit(
-                b"test status", author=b"author <email>", committer=b"committer <email>"
+                b"test status",
+                author=b"author <email>",
+                committer=b"committer <email>",
             )
 
             os.remove(foo1_fullpath)
@@ -777,7 +783,9 @@ class GetUnstagedChangesTests(TestCase):
 
             repo.stage(["foo1"])
             repo.do_commit(
-                b"test status", author=b"author <email>", committer=b"committer <email>"
+                b"test status",
+                author=b"author <email>",
+                committer=b"committer <email>",
             )
 
             os.remove(foo1_fullpath)
@@ -811,7 +819,8 @@ class TestTreeFSPathConversion(TestCase):
         tree_path = u"délwíçh/foo".encode("utf8")
         fs_path = _tree_to_fs_path(b"/prefix/path", tree_path)
         self.assertEqual(
-            fs_path, os.fsencode(os.path.join(u"/prefix/path", u"délwíçh", u"foo"))
+            fs_path,
+            os.fsencode(os.path.join(u"/prefix/path", u"délwíçh", u"foo")),
         )
 
     def test_fs_to_tree_path_str(self):

+ 2 - 1
dulwich/tests/test_lru_cache.py

@@ -166,7 +166,8 @@ class TestLRUCache(TestCase):
         # We hit the max
         self.assertEqual(10, len(cache))
         self.assertEqual(
-            [11, 10, 9, 1, 8, 7, 6, 5, 4, 3], [n.key for n in cache._walk_lru()]
+            [11, 10, 9, 1, 8, 7, 6, 5, 4, 3],
+            [n.key for n in cache._walk_lru()],
         )
 
     def test_cleanup_shrinks_to_after_clean_count(self):

+ 18 - 6
dulwich/tests/test_mailmap.py

@@ -46,9 +46,18 @@ Santa Claus <santa.claus@northpole.xx> <me@company.xx>
                 ((b"Jane Doe", b"jane@desktop.(none)"), None),
                 ((b"Joe R. Developer", b"joe@example.com"), None),
                 ((None, b"cto@company.xx"), (None, b"cto@coompany.xx")),
-                ((b"Some Dude", b"some@dude.xx"), (b"nick1", b"bugs@company.xx")),
-                ((b"Other Author", b"other@author.xx"), (b"nick2", b"bugs@company.xx")),
-                ((b"Other Author", b"other@author.xx"), (None, b"nick2@company.xx")),
+                (
+                    (b"Some Dude", b"some@dude.xx"),
+                    (b"nick1", b"bugs@company.xx"),
+                ),
+                (
+                    (b"Other Author", b"other@author.xx"),
+                    (b"nick2", b"bugs@company.xx"),
+                ),
+                (
+                    (b"Other Author", b"other@author.xx"),
+                    (None, b"nick2@company.xx"),
+                ),
                 (
                     (b"Santa Claus", b"santa.claus@northpole.xx"),
                     (None, b"me@company.xx"),
@@ -66,18 +75,21 @@ class MailmapTests(TestCase):
         m.add_entry((None, b"cto@company.xx"), (None, b"cto@coompany.xx"))
         m.add_entry((b"Some Dude", b"some@dude.xx"), (b"nick1", b"bugs@company.xx"))
         m.add_entry(
-            (b"Other Author", b"other@author.xx"), (b"nick2", b"bugs@company.xx")
+            (b"Other Author", b"other@author.xx"),
+            (b"nick2", b"bugs@company.xx"),
         )
         m.add_entry((b"Other Author", b"other@author.xx"), (None, b"nick2@company.xx"))
         m.add_entry(
-            (b"Santa Claus", b"santa.claus@northpole.xx"), (None, b"me@company.xx")
+            (b"Santa Claus", b"santa.claus@northpole.xx"),
+            (None, b"me@company.xx"),
         )
         self.assertEqual(
             b"Jane Doe <jane@desktop.(none)>",
             m.lookup(b"Jane Doe <jane@desktop.(none)>"),
         )
         self.assertEqual(
-            b"Jane Doe <jane@desktop.(none)>", m.lookup(b"Jane Doe <jane@example.com>")
+            b"Jane Doe <jane@desktop.(none)>",
+            m.lookup(b"Jane Doe <jane@example.com>"),
         )
         self.assertEqual(
             b"Jane Doe <jane@desktop.(none)>",

+ 2 - 1
dulwich/tests/test_missing_obj_finder.py

@@ -44,7 +44,8 @@ class MissingObjectFinderTest(TestCase):
     def assertMissingMatch(self, haves, wants, expected):
         for sha, path in self.store.find_missing_objects(haves, wants, set()):
             self.assertTrue(
-                sha in expected, "(%s,%s) erroneously reported as missing" % (sha, path)
+                sha in expected,
+                "(%s,%s) erroneously reported as missing" % (sha, path),
             )
             expected.remove(sha)
 

+ 23 - 7
dulwich/tests/test_object_store.py

@@ -70,7 +70,8 @@ testobject = make_object(Blob, data=b"yummy data")
 class ObjectStoreTests(object):
     def test_determine_wants_all(self):
         self.assertEqual(
-            [b"1" * 40], self.store.determine_wants_all({b"refs/heads/foo": b"1" * 40})
+            [b"1" * 40],
+            self.store.determine_wants_all({b"refs/heads/foo": b"1" * 40}),
         )
 
     def test_determine_wants_all_zero(self):
@@ -135,10 +136,17 @@ class ObjectStoreTests(object):
         tree1_id = commit_tree(self.store, blobs_1)
         blobs_2 = [(b"a", blob_a2.id, 0o100644), (b"b", blob_b.id, 0o100644)]
         tree2_id = commit_tree(self.store, blobs_2)
-        change_a = ((b"a", b"a"), (0o100644, 0o100644), (blob_a1.id, blob_a2.id))
+        change_a = (
+            (b"a", b"a"),
+            (0o100644, 0o100644),
+            (blob_a1.id, blob_a2.id),
+        )
         self.assertEqual([change_a], list(self.store.tree_changes(tree1_id, tree2_id)))
         self.assertEqual(
-            [change_a, ((b"b", b"b"), (0o100644, 0o100644), (blob_b.id, blob_b.id))],
+            [
+                change_a,
+                ((b"b", b"b"), (0o100644, 0o100644), (blob_b.id, blob_b.id)),
+            ],
             list(self.store.tree_changes(tree1_id, tree2_id, want_unchanged=True)),
         )
 
@@ -483,7 +491,8 @@ class DiskObjectStoreTests(PackBasedObjectStoreTests, TestCase):
                 self.assertTrue(o.contains_packed(packed_blob_sha))
                 self.assertTrue(o.contains_packed(blob.id))
                 self.assertEqual(
-                    (Blob.type_num, b"more yummy data"), o.get_raw(packed_blob_sha)
+                    (Blob.type_num, b"more yummy data"),
+                    o.get_raw(packed_blob_sha),
                 )
         finally:
             o.close()
@@ -537,7 +546,11 @@ class TreeLookupPathTests(TestCase):
 
     def test_lookup_not_tree(self):
         self.assertRaises(
-            NotTreeError, tree_lookup_path, self.get_object, self.tree_id, b"ad/b/j"
+            NotTreeError,
+            tree_lookup_path,
+            self.get_object,
+            self.tree_id,
+            b"ad/b/j",
         )
 
 
@@ -653,13 +666,16 @@ class CommitTreeChangesTests(TestCase):
             self.store, self.store[self.tree_id], [(b"d", 0o100644, blob_d.id)]
         )
         self.assertEqual(
-            new_tree[b"d"], (33188, b"c59d9b6344f1af00e504ba698129f07a34bbed8d")
+            new_tree[b"d"],
+            (33188, b"c59d9b6344f1af00e504ba698129f07a34bbed8d"),
         )
 
     def test_add_blob_in_dir(self):
         blob_d = make_object(Blob, data=b"d")
         new_tree = commit_tree_changes(
-            self.store, self.store[self.tree_id], [(b"e/f/d", 0o100644, blob_d.id)]
+            self.store,
+            self.store[self.tree_id],
+            [(b"e/f/d", 0o100644, blob_d.id)],
         )
         self.assertEqual(
             new_tree.items(),

+ 15 - 5
dulwich/tests/test_objects.py

@@ -930,13 +930,19 @@ class TreeTests(ShaFileCheckTests):
         self.assertEqual(
             [
                 TreeEntry(
-                    b"a", stat.S_IFDIR, b"d80c186a03f423a81b39df39dc87fd269736ca86"
+                    b"a",
+                    stat.S_IFDIR,
+                    b"d80c186a03f423a81b39df39dc87fd269736ca86",
                 ),
                 TreeEntry(
-                    b"a.c", 0o100755, b"d80c186a03f423a81b39df39dc87fd269736ca86"
+                    b"a.c",
+                    0o100755,
+                    b"d80c186a03f423a81b39df39dc87fd269736ca86",
                 ),
                 TreeEntry(
-                    b"a/c", stat.S_IFDIR, b"d80c186a03f423a81b39df39dc87fd269736ca86"
+                    b"a/c",
+                    stat.S_IFDIR,
+                    b"d80c186a03f423a81b39df39dc87fd269736ca86",
                 ),
             ],
             list(sorted_tree_items(_TREE_ITEMS, True)),
@@ -1198,12 +1204,16 @@ class CheckTests(TestCase):
             ObjectFormatException, check_hexsha, b"1" * 41, "sha too long"
         )
         self.assertRaises(
-            ObjectFormatException, check_hexsha, b"x" * 40, "invalid characters"
+            ObjectFormatException,
+            check_hexsha,
+            b"x" * 40,
+            "invalid characters",
         )
 
     def test_check_identity(self):
         check_identity(
-            b"Dave Borowitz <dborowitz@google.com>", "failed to check good identity"
+            b"Dave Borowitz <dborowitz@google.com>",
+            "failed to check good identity",
         )
         check_identity(b"<dborowitz@google.com>", "failed to check good identity")
         self.assertRaises(

+ 12 - 6
dulwich/tests/test_objectspec.py

@@ -176,13 +176,16 @@ class ParseReftupleTests(TestCase):
     def test_head(self):
         r = {b"refs/heads/foo": "bla"}
         self.assertEqual(
-            (b"refs/heads/foo", b"refs/heads/foo", False), parse_reftuple(r, r, b"foo")
+            (b"refs/heads/foo", b"refs/heads/foo", False),
+            parse_reftuple(r, r, b"foo"),
         )
         self.assertEqual(
-            (b"refs/heads/foo", b"refs/heads/foo", True), parse_reftuple(r, r, b"+foo")
+            (b"refs/heads/foo", b"refs/heads/foo", True),
+            parse_reftuple(r, r, b"+foo"),
         )
         self.assertEqual(
-            (b"refs/heads/foo", b"refs/heads/foo", True), parse_reftuple(r, {}, b"+foo")
+            (b"refs/heads/foo", b"refs/heads/foo", True),
+            parse_reftuple(r, {}, b"+foo"),
         )
         self.assertEqual(
             (b"refs/heads/foo", b"refs/heads/foo", True),
@@ -199,19 +202,22 @@ class ParseReftupleTests(TestCase):
     def test_no_left_ref(self):
         r = {b"refs/heads/foo": "bla"}
         self.assertEqual(
-            (None, b"refs/heads/foo", False), parse_reftuple(r, r, b":refs/heads/foo")
+            (None, b"refs/heads/foo", False),
+            parse_reftuple(r, r, b":refs/heads/foo"),
         )
 
     def test_no_right_ref(self):
         r = {b"refs/heads/foo": "bla"}
         self.assertEqual(
-            (b"refs/heads/foo", None, False), parse_reftuple(r, r, b"refs/heads/foo:")
+            (b"refs/heads/foo", None, False),
+            parse_reftuple(r, r, b"refs/heads/foo:"),
         )
 
     def test_default_with_string(self):
         r = {b"refs/heads/foo": "bla"}
         self.assertEqual(
-            (b"refs/heads/foo", b"refs/heads/foo", False), parse_reftuple(r, r, "foo")
+            (b"refs/heads/foo", b"refs/heads/foo", False),
+            parse_reftuple(r, r, "foo"),
         )
 
 

+ 23 - 7
dulwich/tests/test_pack.py

@@ -312,9 +312,21 @@ class TestPackData(PackTests):
             self.assertEqual(
                 set(
                     [
-                        (b"6f670c0fb53f9463760b7295fbb814e965fb20c8", 178, 1373561701),
-                        (b"b2a2766a2879c209ab1176e7e778b81ae422eeaa", 138, 912998690),
-                        (b"f18faa16531ac570a3fdc8c7ca16682548dafd12", 12, 3775879613),
+                        (
+                            b"6f670c0fb53f9463760b7295fbb814e965fb20c8",
+                            178,
+                            1373561701,
+                        ),
+                        (
+                            b"b2a2766a2879c209ab1176e7e778b81ae422eeaa",
+                            138,
+                            912998690,
+                        ),
+                        (
+                            b"f18faa16531ac570a3fdc8c7ca16682548dafd12",
+                            12,
+                            3775879613,
+                        ),
                     ]
                 ),
                 entries,
@@ -346,10 +358,12 @@ class TestPackData(PackTests):
             compute_file_sha(f, buffer_size=5).hexdigest(),
         )
         self.assertEqual(
-            sha1(b"abcd1234").hexdigest(), compute_file_sha(f, end_ofs=-4).hexdigest()
+            sha1(b"abcd1234").hexdigest(),
+            compute_file_sha(f, end_ofs=-4).hexdigest(),
         )
         self.assertEqual(
-            sha1(b"1234wxyz").hexdigest(), compute_file_sha(f, start_ofs=4).hexdigest()
+            sha1(b"1234wxyz").hexdigest(),
+            compute_file_sha(f, start_ofs=4).hexdigest(),
         )
         self.assertEqual(
             sha1(b"1234").hexdigest(),
@@ -905,7 +919,8 @@ class TestPackStreamReader(TestCase):
         self.assertEqual(OFS_DELTA, unpacked_delta.pack_type_num)
         self.assertEqual(None, unpacked_delta.obj_type_num)
         self.assertEqual(
-            unpacked_delta.offset - unpacked_blob.offset, unpacked_delta.delta_base
+            unpacked_delta.offset - unpacked_blob.offset,
+            unpacked_delta.delta_base,
         )
         delta = create_delta(b"blob", b"blob1")
         self.assertEqual(delta, b"".join(unpacked_delta.decomp_chunks))
@@ -974,7 +989,8 @@ class DeltaChainIteratorTests(TestCase):
         """Wrapper around store.get_raw that doesn't allow repeat lookups."""
         hex_sha = sha_to_hex(bin_sha)
         self.assertFalse(
-            hex_sha in self.fetched, "Attempted to re-fetch object %s" % hex_sha
+            hex_sha in self.fetched,
+            "Attempted to re-fetch object %s" % hex_sha,
         )
         self.fetched.add(hex_sha)
         return self.store.get_raw(hex_sha)

+ 26 - 6
dulwich/tests/test_patch.py

@@ -298,7 +298,9 @@ class DiffTests(TestCase):
     def test_blob_add(self):
         f = BytesIO()
         write_blob_diff(
-            f, (None, None, None), (b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n"))
+            f,
+            (None, None, None),
+            (b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n")),
         )
         self.assertEqual(
             [
@@ -317,7 +319,9 @@ class DiffTests(TestCase):
     def test_blob_remove(self):
         f = BytesIO()
         write_blob_diff(
-            f, (b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n")), (None, None, None)
+            f,
+            (b"bar.txt", 0o644, Blob.from_string(b"new\nsame\n")),
+            (None, None, None),
         )
         self.assertEqual(
             [
@@ -352,7 +356,15 @@ class DiffTests(TestCase):
         store.add_objects(
             [
                 (o, None)
-                for o in [tree1, tree2, added, removed, changed1, changed2, unchanged]
+                for o in [
+                    tree1,
+                    tree2,
+                    added,
+                    removed,
+                    changed1,
+                    changed2,
+                    unchanged,
+                ]
             ]
         )
         write_tree_diff(f, store, tree1.id, tree2.id)
@@ -389,11 +401,15 @@ class DiffTests(TestCase):
         store = MemoryObjectStore()
         tree1 = Tree()
         tree1.add(
-            b"asubmodule", S_IFGITLINK, b"06d0bdd9e2e20377b3180e4986b14c8549b393e4"
+            b"asubmodule",
+            S_IFGITLINK,
+            b"06d0bdd9e2e20377b3180e4986b14c8549b393e4",
         )
         tree2 = Tree()
         tree2.add(
-            b"asubmodule", S_IFGITLINK, b"cc975646af69f279396d4d5e1379ac6af80ee637"
+            b"asubmodule",
+            S_IFGITLINK,
+            b"cc975646af69f279396d4d5e1379ac6af80ee637",
         )
         store.add_objects([(o, None) for o in [tree1, tree2]])
         write_tree_diff(f, store, tree1.id, tree2.id)
@@ -597,7 +613,11 @@ class DiffTests(TestCase):
             f,
             store,
             (b"bar.txt", 0o644, b1.id),
-            (b"bar.txt", 0o160000, b"06d0bdd9e2e20377b3180e4986b14c8549b393e4"),
+            (
+                b"bar.txt",
+                0o160000,
+                b"06d0bdd9e2e20377b3180e4986b14c8549b393e4",
+            ),
         )
         self.assertEqual(
             [

+ 60 - 19
dulwich/tests/test_porcelain.py

@@ -265,7 +265,8 @@ class CleanTests(PorcelainTestCase):
         )
 
         porcelain.clean(
-            repo=self.repo, target_dir=os.path.join(self.repo.path, "untracked_dir")
+            repo=self.repo,
+            target_dir=os.path.join(self.repo.path, "untracked_dir"),
         )
 
         self.assert_wd(
@@ -536,7 +537,10 @@ class AddTests(PorcelainTestCase):
             paths=[os.path.join(self.test_dir, "foo")],
         )
         self.assertRaises(
-            (ValueError, FileNotFoundError), porcelain.add, self.repo, paths=["../foo"]
+            (ValueError, FileNotFoundError),
+            porcelain.add,
+            self.repo,
+            paths=["../foo"],
         )
         self.assertEqual([], list(self.repo.open_index()))
 
@@ -739,7 +743,14 @@ index 0000000..ea5c7bf
         tb.add(b"somename", 0o100644, b.id)
         cb = make_commit(tree=tb.id, parents=[ca.id])
         self.repo.object_store.add_objects(
-            [(a, None), (b, None), (ta, None), (tb, None), (ca, None), (cb, None)]
+            [
+                (a, None),
+                (b, None),
+                (ta, None),
+                (tb, None),
+                (ca, None),
+                (cb, None),
+            ]
         )
         outstream = StringIO()
         porcelain.show(self.repo.path, objects=[cb.id], outstream=outstream)
@@ -799,7 +810,9 @@ class SymbolicRefTests(PorcelainTestCase):
 
     def test_set_symbolic_ref_other_than_master(self):
         c1, c2, c3 = build_commit_graph(
-            self.repo.object_store, [[1], [2, 1], [3, 1, 2]], attrs=dict(refs="develop")
+            self.repo.object_store,
+            [[1], [2, 1], [3, 1, 2]],
+            attrs=dict(refs="develop"),
         )
         self.repo.refs[b"HEAD"] = c3.id
         self.repo.refs[b"refs/heads/develop"] = c3.id
@@ -865,7 +878,11 @@ class TagCreateTests(PorcelainTestCase):
         self.repo.refs[b"HEAD"] = c3.id
 
         porcelain.tag_create(
-            self.repo.path, b"tryme", b"foo <foo@bar.com>", b"bar", annotated=True
+            self.repo.path,
+            b"tryme",
+            b"foo <foo@bar.com>",
+            b"bar",
+            annotated=True,
         )
 
         tags = self.repo.refs.as_dict(b"refs/tags")
@@ -947,7 +964,9 @@ class ResetTests(PorcelainTestCase):
         index = self.repo.open_index()
         changes = list(
             tree_changes(
-                self.repo, index.commit(self.repo.object_store), self.repo[b"HEAD"].tree
+                self.repo,
+                index.commit(self.repo.object_store),
+                self.repo[b"HEAD"].tree,
             )
         )
 
@@ -980,7 +999,9 @@ class ResetTests(PorcelainTestCase):
         index = self.repo.open_index()
         changes = list(
             tree_changes(
-                self.repo, index.commit(self.repo.object_store), self.repo[sha].tree
+                self.repo,
+                index.commit(self.repo.object_store),
+                self.repo[sha].tree,
             )
         )
 
@@ -1042,7 +1063,8 @@ class PushTests(PorcelainTestCase):
         )
 
         self.assertEqual(
-            target_repo.refs[b"refs/remotes/origin/foo"], target_repo.refs[b"HEAD"]
+            target_repo.refs[b"refs/remotes/origin/foo"],
+            target_repo.refs[b"HEAD"],
         )
 
         # Check that the target and source
@@ -1364,7 +1386,10 @@ class PullTests(PorcelainTestCase):
 
         # Pull changes into the cloned repo
         porcelain.pull(
-            self.target_path, self.repo.path, outstream=outstream, errstream=errstream
+            self.target_path,
+            self.repo.path,
+            outstream=outstream,
+            errstream=errstream,
         )
 
         # Check the target repo for pushed changes
@@ -1461,7 +1486,8 @@ class StatusTests(PorcelainTestCase):
             f.write("origstuff")
         results = porcelain.status(self.repo.path)
         self.assertDictEqual(
-            {"add": [b"baz"], "delete": [b"foo"], "modify": [b"bar"]}, results.staged
+            {"add": [b"baz"], "delete": [b"foo"], "modify": [b"bar"]},
+            results.staged,
         )
         self.assertListEqual(results.unstaged, [b"blye"])
         self.assertListEqual(results.untracked, ["blyat"])
@@ -1949,7 +1975,8 @@ class LsTreeTests(PorcelainTestCase):
         f = StringIO()
         porcelain.ls_tree(self.repo, b"HEAD", outstream=f)
         self.assertEqual(
-            f.getvalue(), "100644 blob 8b82634d7eae019850bb883f06abf428c58bc9aa\tfoo\n"
+            f.getvalue(),
+            "100644 blob 8b82634d7eae019850bb883f06abf428c58bc9aa\tfoo\n",
         )
 
     def test_recursive(self):
@@ -1969,7 +1996,8 @@ class LsTreeTests(PorcelainTestCase):
         f = StringIO()
         porcelain.ls_tree(self.repo, b"HEAD", outstream=f)
         self.assertEqual(
-            f.getvalue(), "40000 tree b145cc69a5e17693e24d8a7be0016ed8075de66d\tadir\n"
+            f.getvalue(),
+            "40000 tree b145cc69a5e17693e24d8a7be0016ed8075de66d\tadir\n",
         )
         f = StringIO()
         porcelain.ls_tree(self.repo, b"HEAD", outstream=f, recursive=True)
@@ -2018,7 +2046,8 @@ class RemoteAddTests(PorcelainTestCase):
         porcelain.remote_add(self.repo, "jelmer", "git://jelmer.uk/code/dulwich")
         c = self.repo.get_config()
         self.assertEqual(
-            c.get((b"remote", b"jelmer"), b"url"), b"git://jelmer.uk/code/dulwich"
+            c.get((b"remote", b"jelmer"), b"url"),
+            b"git://jelmer.uk/code/dulwich",
         )
 
     def test_exists(self):
@@ -2054,7 +2083,8 @@ class CheckIgnoreTests(PorcelainTestCase):
             f.write("foo\n")
         self.assertEqual([], list(porcelain.check_ignore(self.repo, [path])))
         self.assertEqual(
-            ["foo"], list(porcelain.check_ignore(self.repo, [path], no_index=True))
+            ["foo"],
+            list(porcelain.check_ignore(self.repo, [path], no_index=True)),
         )
 
     def test_check_added_rel(self):
@@ -2158,7 +2188,8 @@ class DescribeTests(PorcelainTestCase):
             committer=b"Bob <bob@example.com>",
         )
         self.assertEqual(
-            "g{}".format(sha[:7].decode("ascii")), porcelain.describe(self.repo.path)
+            "g{}".format(sha[:7].decode("ascii")),
+            porcelain.describe(self.repo.path),
         )
 
     def test_tag(self):
@@ -2173,7 +2204,11 @@ class DescribeTests(PorcelainTestCase):
             committer=b"Bob <bob@example.com>",
         )
         porcelain.tag_create(
-            self.repo.path, b"tryme", b"foo <foo@bar.com>", b"bar", annotated=True
+            self.repo.path,
+            b"tryme",
+            b"foo <foo@bar.com>",
+            b"bar",
+            annotated=True,
         )
         self.assertEqual("tryme", porcelain.describe(self.repo.path))
 
@@ -2189,7 +2224,11 @@ class DescribeTests(PorcelainTestCase):
             committer=b"Bob <bob@example.com>",
         )
         porcelain.tag_create(
-            self.repo.path, b"tryme", b"foo <foo@bar.com>", b"bar", annotated=True
+            self.repo.path,
+            b"tryme",
+            b"foo <foo@bar.com>",
+            b"bar",
+            annotated=True,
         )
         with open(fullpath, "w") as f:
             f.write("BAR2")
@@ -2246,7 +2285,8 @@ class PathToTreeTests(PorcelainTestCase):
             self.assertEqual(
                 b"bar/baz",
                 porcelain.path_to_tree_path(
-                    os.path.join(os.getcwd(), ".."), os.path.join(os.getcwd(), "baz")
+                    os.path.join(os.getcwd(), ".."),
+                    os.path.join(os.getcwd(), "baz"),
                 ),
             )
             self.assertEqual(
@@ -2302,7 +2342,8 @@ class WriteTreeTests(PorcelainTestCase):
             f.write("BAR")
         porcelain.add(repo=self.repo.path, paths=[fullpath])
         self.assertEqual(
-            b"d2092c8a9f311f0311083bf8d177f2ca0ab5b241", porcelain.write_tree(self.repo)
+            b"d2092c8a9f311f0311083bf8d177f2ca0ab5b241",
+            porcelain.write_tree(self.repo),
         )
 
 

+ 6 - 3
dulwich/tests/test_protocol.py

@@ -218,10 +218,12 @@ class CapabilitiesTestCase(TestCase):
 
     def test_caps_want_line(self):
         self.assertEqual(
-            (b"want bla", [b"la"]), extract_want_line_capabilities(b"want bla la")
+            (b"want bla", [b"la"]),
+            extract_want_line_capabilities(b"want bla la"),
         )
         self.assertEqual(
-            (b"want bla", [b"la"]), extract_want_line_capabilities(b"want bla la\n")
+            (b"want bla", [b"la"]),
+            extract_want_line_capabilities(b"want bla la\n"),
         )
         self.assertEqual(
             (b"want bla", [b"la", b"la"]),
@@ -232,7 +234,8 @@ class CapabilitiesTestCase(TestCase):
         self.assertEqual(SINGLE_ACK, ack_type([b"foo", b"bar"]))
         self.assertEqual(MULTI_ACK, ack_type([b"foo", b"bar", b"multi_ack"]))
         self.assertEqual(
-            MULTI_ACK_DETAILED, ack_type([b"foo", b"bar", b"multi_ack_detailed"])
+            MULTI_ACK_DETAILED,
+            ack_type([b"foo", b"bar", b"multi_ack_detailed"]),
         )
         # choose detailed when both present
         self.assertEqual(

+ 31 - 12
dulwich/tests/test_refs.py

@@ -92,7 +92,9 @@ class PackedRefsFileTests(TestCase):
         self.assertRaises(errors.PackedRefsException, _split_ref_line, b"singlefield")
         self.assertRaises(errors.PackedRefsException, _split_ref_line, b"badsha name")
         self.assertRaises(
-            errors.PackedRefsException, _split_ref_line, ONES + b" bad/../refname"
+            errors.PackedRefsException,
+            _split_ref_line,
+            ONES + b" bad/../refname",
         )
 
     def test_read_without_peeled(self):
@@ -108,7 +110,12 @@ class PackedRefsFileTests(TestCase):
     def test_read_with_peeled(self):
         f = BytesIO(
             b"\n".join(
-                [ONES + b" ref/1", TWOS + b" ref/2", b"^" + THREES, FOURS + b" ref/4"]
+                [
+                    ONES + b" ref/1",
+                    TWOS + b" ref/2",
+                    b"^" + THREES,
+                    FOURS + b" ref/4",
+                ]
             )
         )
         self.assertEqual(
@@ -147,7 +154,8 @@ class PackedRefsFileTests(TestCase):
         f = BytesIO()
         write_packed_refs(f, {b"ref/1": ONES, b"ref/2": TWOS})
         self.assertEqual(
-            b"\n".join([ONES + b" ref/1", TWOS + b" ref/2"]) + b"\n", f.getvalue()
+            b"\n".join([ONES + b" ref/1", TWOS + b" ref/2"]) + b"\n",
+            f.getvalue(),
         )
 
 
@@ -206,7 +214,8 @@ class RefsContainerTests(object):
     def test_setitem(self):
         self._refs[b"refs/some/ref"] = b"42d06bd4b77fed026b154d16493e5deab78f02ec"
         self.assertEqual(
-            b"42d06bd4b77fed026b154d16493e5deab78f02ec", self._refs[b"refs/some/ref"]
+            b"42d06bd4b77fed026b154d16493e5deab78f02ec",
+            self._refs[b"refs/some/ref"],
         )
         self.assertRaises(
             errors.RefFormatError,
@@ -255,7 +264,8 @@ class RefsContainerTests(object):
     def test_set_symbolic_ref(self):
         self._refs.set_symbolic_ref(b"refs/heads/symbolic", b"refs/heads/master")
         self.assertEqual(
-            b"ref: refs/heads/master", self._refs.read_loose_ref(b"refs/heads/symbolic")
+            b"ref: refs/heads/master",
+            self._refs.read_loose_ref(b"refs/heads/symbolic"),
         )
         self.assertEqual(
             b"42d06bd4b77fed026b154d16493e5deab78f02ec",
@@ -269,7 +279,8 @@ class RefsContainerTests(object):
         self.assertEqual(nines, self._refs.read_loose_ref(b"refs/heads/symbolic"))
         self._refs.set_symbolic_ref(b"refs/heads/symbolic", b"refs/heads/master")
         self.assertEqual(
-            b"ref: refs/heads/master", self._refs.read_loose_ref(b"refs/heads/symbolic")
+            b"ref: refs/heads/master",
+            self._refs.read_loose_ref(b"refs/heads/symbolic"),
         )
         self.assertEqual(
             b"42d06bd4b77fed026b154d16493e5deab78f02ec",
@@ -305,7 +316,8 @@ class RefsContainerTests(object):
         )
         self.assertTrue(
             self._refs.remove_if_equals(
-                b"refs/tags/refs-0.2", b"3ec9c43c84ff242e3ef4a9fc5bc111fd780a76a8"
+                b"refs/tags/refs-0.2",
+                b"3ec9c43c84ff242e3ef4a9fc5bc111fd780a76a8",
             )
         )
         self.assertTrue(self._refs.remove_if_equals(b"refs/tags/refs-0.2", ZERO_SHA))
@@ -525,7 +537,10 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
             self._refs.follow(b"HEAD"),
         )
         self.assertEqual(
-            ([b"refs/heads/master"], b"42d06bd4b77fed026b154d16493e5deab78f02ec"),
+            (
+                [b"refs/heads/master"],
+                b"42d06bd4b77fed026b154d16493e5deab78f02ec",
+            ),
             self._refs.follow(b"refs/heads/master"),
         )
         self.assertRaises(KeyError, self._refs.follow, b"refs/heads/loop")
@@ -555,7 +570,8 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
         )
         self.assertTrue(
             self._refs.remove_if_equals(
-                b"refs/heads/master", b"42d06bd4b77fed026b154d16493e5deab78f02ec"
+                b"refs/heads/master",
+                b"42d06bd4b77fed026b154d16493e5deab78f02ec",
             )
         )
         self.assertRaises(KeyError, lambda: self._refs[b"refs/heads/master"])
@@ -589,7 +605,8 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
         refs = self._repo.refs
         self.assertTrue(
             refs.remove_if_equals(
-                b"refs/heads/packed", b"42d06bd4b77fed026b154d16493e5deab78f02ec"
+                b"refs/heads/packed",
+                b"42d06bd4b77fed026b154d16493e5deab78f02ec",
             )
         )
 
@@ -601,7 +618,8 @@ class DiskRefsContainerTests(RefsContainerTests, TestCase):
         )
         self.assertTrue(
             self._refs.remove_if_equals(
-                b"refs/tags/refs-0.1", b"df6800012397fb85c56e7418dd4eb9405dee075c"
+                b"refs/tags/refs-0.1",
+                b"df6800012397fb85c56e7418dd4eb9405dee075c",
             )
         )
         self.assertRaises(KeyError, lambda: self._refs[b"refs/tags/refs-0.1"])
@@ -727,7 +745,8 @@ class InfoRefsContainerTests(TestCase):
         refs = InfoRefsContainer(BytesIO(_TEST_REFS_SERIALIZED))
         # refs/heads/loop does not show up even if it exists
         self.assertEqual(
-            _TEST_REFS[b"refs/heads/master"], refs.get_peeled(b"refs/heads/master")
+            _TEST_REFS[b"refs/heads/master"],
+            refs.get_peeled(b"refs/heads/master"),
         )
 
 

+ 22 - 9
dulwich/tests/test_repository.py

@@ -163,7 +163,10 @@ class RepositoryRootTests(TestCase):
             assertRaisesRegexp = self.assertRaisesRegexp
         for k, _ in test_keys:
             assertRaisesRegexp(
-                TypeError, "'name' must be bytestring, not int", r.__getitem__, 12
+                TypeError,
+                "'name' must be bytestring, not int",
+                r.__getitem__,
+                12,
             )
 
     def test_delitem(self):
@@ -709,13 +712,16 @@ exit 1
     def test_as_dict(self):
         def check(repo):
             self.assertEqual(
-                repo.refs.subkeys(b"refs/tags"), repo.refs.subkeys(b"refs/tags/")
+                repo.refs.subkeys(b"refs/tags"),
+                repo.refs.subkeys(b"refs/tags/"),
             )
             self.assertEqual(
-                repo.refs.as_dict(b"refs/tags"), repo.refs.as_dict(b"refs/tags/")
+                repo.refs.as_dict(b"refs/tags"),
+                repo.refs.as_dict(b"refs/tags/"),
             )
             self.assertEqual(
-                repo.refs.as_dict(b"refs/heads"), repo.refs.as_dict(b"refs/heads/")
+                repo.refs.as_dict(b"refs/heads"),
+                repo.refs.as_dict(b"refs/heads/"),
             )
 
         bare = self.open_repo("a.git")
@@ -801,7 +807,8 @@ class BuildRepoRootTests(TestCase):
         with open(os.path.join(self._repo.path, ".git", "shallow"), "wb") as f:
             f.write(b"a90fa2d900a17e99b433217e988c4eb4a2e9a097\n")
         self.assertEqual(
-            {b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"}, self._repo.get_shallow()
+            {b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"},
+            self._repo.get_shallow(),
         )
 
     def test_update_shallow(self):
@@ -809,14 +816,16 @@ class BuildRepoRootTests(TestCase):
         self.assertEqual(set(), self._repo.get_shallow())
         self._repo.update_shallow([b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"], None)
         self.assertEqual(
-            {b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"}, self._repo.get_shallow()
+            {b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"},
+            self._repo.get_shallow(),
         )
         self._repo.update_shallow(
             [b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"],
             [b"f9e39b120c68182a4ba35349f832d0e4e61f485c"],
         )
         self.assertEqual(
-            {b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"}, self._repo.get_shallow()
+            {b"a90fa2d900a17e99b433217e988c4eb4a2e9a097"},
+            self._repo.get_shallow(),
         )
 
     def test_build_repo(self):
@@ -896,7 +905,8 @@ class BuildRepoRootTests(TestCase):
             author_timezone=0,
         )
         self.assertEqual(
-            [c1, b"c27a2d21dd136312d7fa9e8baabb82561a1727d0"], r[commit_sha].parents
+            [c1, b"c27a2d21dd136312d7fa9e8baabb82561a1727d0"],
+            r[commit_sha].parents,
         )
 
     def test_commit_deleted(self):
@@ -1192,7 +1202,10 @@ class BuildRepoRootTests(TestCase):
         r.stage(["c"])
         self.assertEqual([b"a"], list(r.open_index()))
 
-    @skipIf(sys.platform in ("win32", "darwin"), "tries to implicitly decode as utf8")
+    @skipIf(
+        sys.platform in ("win32", "darwin"),
+        "tries to implicitly decode as utf8",
+    )
     def test_commit_no_encode_decode(self):
         r = self._repo
         repo_path_bytes = os.fsencode(r.path)

+ 27 - 9
dulwich/tests/test_server.py

@@ -276,10 +276,12 @@ class FindShallowTests(TestCase):
             (set([c3.id]), set([])), _find_shallow(self._store, [c3.id], 1)
         )
         self.assertEqual(
-            (set([c2.id]), set([c3.id])), _find_shallow(self._store, [c3.id], 2)
+            (set([c2.id]), set([c3.id])),
+            _find_shallow(self._store, [c3.id], 2),
         )
         self.assertEqual(
-            (set([c1.id]), set([c2.id, c3.id])), _find_shallow(self._store, [c3.id], 3)
+            (set([c1.id]), set([c2.id, c3.id])),
+            _find_shallow(self._store, [c3.id], 3),
         )
         self.assertEqual(
             (set([]), set([c1.id, c2.id, c3.id])),
@@ -318,7 +320,8 @@ class FindShallowTests(TestCase):
         c3 = self.make_commit(parents=[c1.id, c2.id])
 
         self.assertEqual(
-            (set([c1.id, c2.id]), set([c3.id])), _find_shallow(self._store, [c3.id], 2)
+            (set([c1.id, c2.id]), set([c3.id])),
+            _find_shallow(self._store, [c3.id], 2),
         )
 
     def test_tag(self):
@@ -327,7 +330,8 @@ class FindShallowTests(TestCase):
         self._store.add_object(tag)
 
         self.assertEqual(
-            (set([c1.id]), set([c2.id])), _find_shallow(self._store, [tag.id], 2)
+            (set([c1.id]), set([c2.id])),
+            _find_shallow(self._store, [tag.id], 2),
         )
 
 
@@ -449,10 +453,16 @@ class ProtocolGraphWalkerTestCase(TestCase):
         )
         self.assertRaises(GitProtocolError, _split_proto_line, b"want xxxx\n", allowed)
         self.assertRaises(
-            UnexpectedCommandError, _split_proto_line, b"have " + THREE + b"\n", allowed
+            UnexpectedCommandError,
+            _split_proto_line,
+            b"have " + THREE + b"\n",
+            allowed,
         )
         self.assertRaises(
-            GitProtocolError, _split_proto_line, b"foo " + FOUR + b"\n", allowed
+            GitProtocolError,
+            _split_proto_line,
+            b"foo " + FOUR + b"\n",
+            allowed,
         )
         self.assertRaises(GitProtocolError, _split_proto_line, b"bar", allowed)
         self.assertEqual((b"done", None), _split_proto_line(b"done\n", allowed))
@@ -1064,7 +1074,9 @@ class FileSystemBackendTests(TestCase):
 
     def test_nonexistant(self):
         self.assertRaises(
-            NotGitRepository, self.backend.open_repository, "/does/not/exist/unless/foo"
+            NotGitRepository,
+            self.backend.open_repository,
+            "/does/not/exist/unless/foo",
         )
 
     def test_absolute(self):
@@ -1095,7 +1107,9 @@ class DictBackendTests(TestCase):
         repo = MemoryRepo.init_bare([], {})
         backend = DictBackend({b"/": repo})
         self.assertRaises(
-            NotGitRepository, backend.open_repository, "/does/not/exist/unless/foo"
+            NotGitRepository,
+            backend.open_repository,
+            "/does/not/exist/unless/foo",
         )
 
     def test_bad_repo_path(self):
@@ -1114,7 +1128,11 @@ class ServeCommandTests(TestCase):
 
     def serve_command(self, handler_cls, args, inf, outf):
         return serve_command(
-            handler_cls, [b"test"] + args, backend=self.backend, inf=inf, outf=outf
+            handler_cls,
+            [b"test"] + args,
+            backend=self.backend,
+            inf=inf,
+            outf=outf,
         )
 
     def test_receive_pack(self):

+ 18 - 5
dulwich/tests/test_walk.py

@@ -57,7 +57,10 @@ class TestWalkEntry(object):
         self.changes = changes
 
     def __repr__(self):
-        return "<TestWalkEntry commit=%s, changes=%r>" % (self.commit.id, self.changes)
+        return "<TestWalkEntry commit=%s, changes=%r>" % (
+            self.commit.id,
+            self.changes,
+        )
 
     def __eq__(self, other):
         if not isinstance(other, WalkEntry) or self.commit != other.commit:
@@ -192,7 +195,11 @@ class WalkerTest(TestCase):
         blob_a2 = make_object(Blob, data=b"a2")
         blob_b2 = make_object(Blob, data=b"b2")
         c1, c2 = self.make_linear_commits(
-            2, trees={1: [(b"a", blob_a1)], 2: [(b"a", blob_a2), (b"b", blob_b2)]}
+            2,
+            trees={
+                1: [(b"a", blob_a1)],
+                2: [(b"a", blob_a2), (b"b", blob_b2)],
+            },
         )
         e1 = TestWalkEntry(c1, [TreeChange.add((b"a", F, blob_a1.id))])
         e2 = TestWalkEntry(
@@ -315,10 +322,15 @@ class WalkerTest(TestCase):
         )
         entry_a = (b"a", F, blob.id)
         entry_b = (b"b", F, blob.id)
-        changes_without_renames = [TreeChange.delete(entry_a), TreeChange.add(entry_b)]
+        changes_without_renames = [
+            TreeChange.delete(entry_a),
+            TreeChange.add(entry_b),
+        ]
         changes_with_renames = [TreeChange(CHANGE_RENAME, entry_a, entry_b)]
         self.assertWalkYields(
-            [TestWalkEntry(c2, changes_without_renames)], [c2.id], max_entries=1
+            [TestWalkEntry(c2, changes_without_renames)],
+            [c2.id],
+            max_entries=1,
         )
         detector = RenameDetector(self.store)
         self.assertWalkYields(
@@ -473,7 +485,8 @@ class WalkerTest(TestCase):
         #    \-y3--y4-/--y5
         # Due to skew, y5 is the oldest commit.
         c1, x2, y3, y4, y5, m6 = self.make_commits(
-            [[1], [2, 1], [3, 1], [4, 3], [5, 4], [6, 2, 4]], times=[2, 3, 4, 5, 1, 6]
+            [[1], [2, 1], [3, 1], [4, 3], [5, 4], [6, 2, 4]],
+            times=[2, 3, 4, 5, 1, 6],
         )
         self.assertWalkYields([m6, y4, y3, x2, c1], [m6.id])
         # Ensure that c1..y4 get excluded even though they're popped from the

+ 12 - 3
dulwich/tests/test_web.py

@@ -329,7 +329,12 @@ class DumbHandlersTestCase(WebTestCase):
 class SmartHandlersTestCase(WebTestCase):
     class _TestUploadPackHandler(object):
         def __init__(
-            self, backend, args, proto, stateless_rpc=None, advertise_refs=False
+            self,
+            backend,
+            args,
+            proto,
+            stateless_rpc=None,
+            advertise_refs=False,
         ):
             self.args = args
             self.proto = proto
@@ -567,7 +572,9 @@ class GunzipTestCase(HTTPGitApplicationTestCase):
         """
         zstream, zlength = self._get_zstream(self.example_text)
         self._test_call(
-            self.example_text, MinimalistWSGIInputStream(zstream.read()), zlength
+            self.example_text,
+            MinimalistWSGIInputStream(zstream.read()),
+            zlength,
         )
 
     def test_call_no_working_seek(self):
@@ -577,5 +584,7 @@ class GunzipTestCase(HTTPGitApplicationTestCase):
         """
         zstream, zlength = self._get_zstream(self.example_text)
         self._test_call(
-            self.example_text, MinimalistWSGIInputStream2(zstream.read()), zlength
+            self.example_text,
+            MinimalistWSGIInputStream2(zstream.read()),
+            zlength,
         )

+ 5 - 1
dulwich/tests/utils.py

@@ -248,7 +248,11 @@ def build_pack(f, objects_spec, store=None):
                 base_type_num, _, _ = full_objects[base]
             else:
                 base_type_num, _ = store.get_raw(base)
-            full_objects[i] = (base_type_num, data, obj_sha(base_type_num, [data]))
+            full_objects[i] = (
+                base_type_num,
+                data,
+                obj_sha(base_type_num, [data]),
+            )
 
     for i, (type_num, obj) in enumerate(objects_spec):
         offset = f.tell()

+ 4 - 1
dulwich/walk.py

@@ -119,7 +119,10 @@ class WalkEntry(object):
         return self._changes[path_prefix]
 
     def __repr__(self):
-        return "<WalkEntry commit=%s, changes=%r>" % (self.commit.id, self.changes())
+        return "<WalkEntry commit=%s, changes=%r>" % (
+            self.commit.id,
+            self.changes(),
+        )
 
 
 class _CommitTimeQueue(object):

+ 30 - 8
dulwich/web.py

@@ -213,7 +213,11 @@ def get_info_refs(req, backend, mat):
         write = req.respond(HTTP_OK, "application/x-%s-advertisement" % service)
         proto = ReceivableProtocol(BytesIO().read, write)
         handler = handler_cls(
-            backend, [url_prefix(mat)], proto, stateless_rpc=req, advertise_refs=True
+            backend,
+            [url_prefix(mat)],
+            proto,
+            stateless_rpc=req,
+            advertise_refs=True,
         )
         handler.proto.write_pkt_line(b"# service=" + service.encode("ascii") + b"\n")
         handler.proto.write_pkt_line(None)
@@ -363,9 +367,18 @@ class HTTPGitApplication(object):
         ("GET", re.compile("/objects/info/alternates$")): get_text_file,
         ("GET", re.compile("/objects/info/http-alternates$")): get_text_file,
         ("GET", re.compile("/objects/info/packs$")): get_info_packs,
-        ("GET", re.compile("/objects/([0-9a-f]{2})/([0-9a-f]{38})$")): get_loose_object,
-        ("GET", re.compile("/objects/pack/pack-([0-9a-f]{40})\\.pack$")): get_pack_file,
-        ("GET", re.compile("/objects/pack/pack-([0-9a-f]{40})\\.idx$")): get_idx_file,
+        (
+            "GET",
+            re.compile("/objects/([0-9a-f]{2})/([0-9a-f]{38})$"),
+        ): get_loose_object,
+        (
+            "GET",
+            re.compile("/objects/pack/pack-([0-9a-f]{40})\\.pack$"),
+        ): get_pack_file,
+        (
+            "GET",
+            re.compile("/objects/pack/pack-([0-9a-f]{40})\\.idx$"),
+        ): get_idx_file,
         ("POST", re.compile("/git-upload-pack$")): handle_service_request,
         ("POST", re.compile("/git-receive-pack$")): handle_service_request,
     }
@@ -470,7 +483,8 @@ class ServerHandlerLogger(ServerHandler):
 
     def log_exception(self, exc_info):
         logger.exception(
-            "Exception happened during processing of request", exc_info=exc_info
+            "Exception happened during processing of request",
+            exc_info=exc_info,
         )
 
     def log_message(self, format, *args):
@@ -485,7 +499,8 @@ class WSGIRequestHandlerLogger(WSGIRequestHandler):
 
     def log_exception(self, exc_info):
         logger.exception(
-            "Exception happened during processing of request", exc_info=exc_info
+            "Exception happened during processing of request",
+            exc_info=exc_info,
         )
 
     def log_message(self, format, *args):
@@ -530,7 +545,12 @@ def main(argv=sys.argv):
         help="Binding IP address.",
     )
     parser.add_option(
-        "-p", "--port", dest="port", type=int, default=8000, help="Port to listen on."
+        "-p",
+        "--port",
+        dest="port",
+        type=int,
+        default=8000,
+        help="Port to listen on.",
     )
     options, args = parser.parse_args(argv)
 
@@ -550,7 +570,9 @@ def main(argv=sys.argv):
         server_class=WSGIServerLogger,
     )
     logger.info(
-        "Listening for HTTP connections on %s:%d", options.listen_address, options.port
+        "Listening for HTTP connections on %s:%d",
+        options.listen_address,
+        options.port,
     )
     server.serve_forever()
 

+ 0 - 2
pyproject.toml

@@ -1,2 +0,0 @@
-[tool.black]
-line-length = 79

+ 0 - 3
setup.cfg

@@ -1,5 +1,2 @@
-[flake8]
-exclude = build,.git,build-pypy,.tox
-
 [mypy]
 ignore_missing_imports = True