commit - 5dd478755a82fcbf49b8e35ed465b86613b1c080
commit + e71ece5e66f81979a2671e7476eaaf5330c250a8
blob - 3089c2c06fa5b1bb501bf0b97d52f2e370e60be1
blob + 82e92994deaf0d55feb23214584ba299d7f690cc
--- dulwich/client.py
+++ dulwich/client.py
"""Find command to run for system Git (usually C Git)."""
if sys.platform == "win32": # support .exe, .bat and .cmd
try: # to avoid overhead
- import win32api
import pywintypes
+ import win32api
except ImportError: # run through cmd.exe with some overhead
return ["cmd", "/c", "git"]
else:
return cls(urlunparse(parsedurl), **kwargs)
def __repr__(self) -> str:
- return "{}({!r}, dumb={!r})".format(
- type(self).__name__,
- self._base_url,
- self.dumb,
- )
+ return f"{type(self).__name__}({self._base_url!r}, dumb={self.dumb!r})"
class Urllib3HttpGitClient(AbstractHttpGitClient):
blob - 8c93672381d66b84bf21d64228aad3529a7cc5f4
blob + 459222434fbf0bfce2e2a1c3a9f51b6d375db6bd
--- dulwich/cloud/gcs.py
+++ dulwich/cloud/gcs.py
self.subpath = subpath
def __repr__(self) -> str:
- return "{}({!r}, subpath={!r})".format(
- type(self).__name__, self.bucket, self.subpath)
+ return f"{type(self).__name__}({self.bucket!r}, subpath={self.subpath!r})"
def _remove_pack(self, name):
self.bucket.delete_blobs([
blob - 888af088ee6f36d7927c91a404ef398910733c0d
blob + 5db7ebdf83d217fa6d1d44b0d32e7971536e31f9
--- dulwich/graph.py
+++ dulwich/graph.py
"""Implementation of merge-base following the approach of git."""
+from heapq import heappop, heappush
+
from .lru_cache import LRUCache
-from heapq import heappush, heappop
-
# priority queue using builtin python minheap tools
# why they do not have a builtin maxheap is simply ridiculous but
# liveable with integer time stamps using negation
-class WorkList(object):
+class WorkList:
def __init__(self):
self.pq = []
# remove any duplicates and sort it so that earliest is first
results = []
for dt, cmt in cands:
- if not ((cstates[cmt] & _DNC) == _DNC) and not (dt, cmt) in results:
+ if not ((cstates[cmt] & _DNC) == _DNC) and (dt, cmt) not in results:
results.append((dt, cmt))
results.sort(key=lambda x: x[0])
lcas = [cmt for dt, cmt in results]
blob - 56f1c6207e8627c143fbe585d152bd2c6b6e945e
blob + 8c0a5bd2fa9a507b28c2059c160f1e7b2ff3e1e7
--- dulwich/ignore.py
+++ dulwich/ignore.py
)
def __repr__(self) -> str:
- return "{}({!r}, {!r})".format(
- type(self).__name__,
- self.pattern,
- self.ignorecase,
- )
+ return f"{type(self).__name__}({self.pattern!r}, {self.ignorecase!r})"
def match(self, path: bytes) -> bool:
"""Try to match a path against this ignore pattern.
blob - e40c8bfe9e12ede707b58069424c2df0ddf25f81
blob + c2e7702606ff584c63afb8407477903731d16013
--- dulwich/lru_cache.py
+++ dulwich/lru_cache.py
raise AssertionError(
"the _most_recently_used entry is not"
" supposed to have a previous entry"
- " {}".format(node)
+ f" {node}"
)
while node is not None:
if node.next_key is _null_key:
if node is not self._least_recently_used:
raise AssertionError(
- "only the last node should have" " no next value: {}".format(node)
+ "only the last node should have" f" no next value: {node}"
)
node_next = None
else:
node_next = self._cache[node.next_key]
if node_next.prev is not node:
raise AssertionError(
- "inconsistency found, node.next.prev" " != node: {}".format(node)
+ "inconsistency found, node.next.prev" f" != node: {node}"
)
if node.prev is None:
if node is not self._most_recently_used:
raise AssertionError(
"only the _most_recently_used should"
- " not have a previous node: {}".format(node)
+ f" not have a previous node: {node}"
)
else:
if node.prev.next_key != node.key:
raise AssertionError(
- "inconsistency found, node.prev.next" " != node: {}".format(node)
+ "inconsistency found, node.prev.next" f" != node: {node}"
)
yield node
node = node_next
blob - 255ecbc34b593689be0cf13905ecb935f6c12311
blob + 9cfadd86cef71a9ec512158f9f5be548bf5628a9
--- dulwich/patch.py
+++ dulwich/patch.py
started = True
fromdate = f"\t{fromfiledate}" if fromfiledate else ""
todate = f"\t{tofiledate}" if tofiledate else ""
- yield "--- {}{}{}".format(
- fromfile.decode(tree_encoding), fromdate, lineterm
- ).encode(output_encoding)
- yield "+++ {}{}{}".format(
- tofile.decode(tree_encoding), todate, lineterm
- ).encode(output_encoding)
+ yield f"--- {fromfile.decode(tree_encoding)}{fromdate}{lineterm}".encode(output_encoding)
+ yield f"+++ {tofile.decode(tree_encoding)}{todate}{lineterm}".encode(output_encoding)
first, last = group[0], group[-1]
file1_range = _format_range_unified(first[1], last[2])
blob - 253989551f98928a3338363e87522d7de4703416
blob + 5f6ef31fd0805b2606be48b30ae33bde00126025
--- dulwich/tests/test_client.py
+++ dulwich/tests/test_client.py
original_password = "Ya#1$2%3"
quoted_password = urlquote(original_password)
- url = "https://{username}:{password}@github.com/jelmer/dulwich".format(
- username=quoted_username, password=quoted_password
- )
+ url = f"https://{quoted_username}:{quoted_password}@github.com/jelmer/dulwich"
c = HttpGitClient.from_parsedurl(urlparse(url))
self.assertEqual(original_username, c._username)
blob - ee940e834b431a15a1bb23dfe2f06a96b85133c0
blob + 08e00c6a732e2093cc6ca2c64906f360db243963
--- dulwich/tests/test_graph.py
+++ dulwich/tests/test_graph.py
from dulwich.tests import TestCase
-from ..graph import _find_lcas, can_fast_forward, WorkList
+from ..graph import WorkList, _find_lcas, can_fast_forward
from ..repo import MemoryRepo
from .utils import make_commit
blob - 4da428e941063c66f62b073d1d1adadc7d6d45ad
blob + 4c2c24ece78b41caa3271548a9743bf7e617ea59
--- dulwich/tests/test_walk.py
+++ dulwich/tests/test_walk.py
self.changes = changes
def __repr__(self) -> str:
- return "<TestWalkEntry commit={}, changes={!r}>".format(
- self.commit.id,
- self.changes,
- )
+ return f"<TestWalkEntry commit={self.commit.id}, changes={self.changes!r}>"
def __eq__(self, other):
if not isinstance(other, WalkEntry) or self.commit != other.commit:
blob - 7e20ce908a67af5b121ee7fecf8edadcda2e7aec
blob + 795eb4f07bdce6958d2c9ae2cc2dc4b726ba5b8f
--- dulwich/walk.py
+++ dulwich/walk.py
return self._changes[path_prefix]
def __repr__(self) -> str:
- return "<WalkEntry commit={}, changes={!r}>".format(
- self.commit.id,
- self.changes(),
- )
+ return f"<WalkEntry commit={self.commit.id}, changes={self.changes()!r}>"
class _CommitTimeQueue:
blob - bc301069f63bcc0beae4b695da282b44ef39cdfb
blob + 00e492bdb2dbed49a37a46ffaf37ed7e5d0465e4
--- setup.py
+++ setup.py
from setuptools import Extension, setup
-if sys.version_info < (3, 7):
- raise Exception(
- 'Dulwich only supports Python 3.6 and later. '
- 'For 2.7 support, please install a version prior to 0.20')
-
-
if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
# XCode 4.0 dropped support for ppc architecture, which is hardcoded in
# distutils.sysconfig