import socket
import subprocess
+from dulwich.errors import (
+ ChecksumMismatch,
+ )
from dulwich.protocol import (
Protocol,
TCP_GIT_PORT,
class SimpleFetchGraphWalker(object):
+ """Graph walker that finds out what commits are missing."""
def __init__(self, local_heads, get_parents):
+ """Create a new SimpleFetchGraphWalker instance.
+
+ :param local_heads: SHA1s that should be retrieved
+ :param get_parents: Function for finding the parents of a SHA1.
+ """
self.heads = set(local_heads)
self.get_parents = get_parents
self.parents = {}
def ack(self, sha):
- """Ack that a particular revision and its ancestors are present."""
+ """Ack that a particular revision and its ancestors are present in the target."""
if sha in self.heads:
self.heads.remove(sha)
if sha in self.parents:
self.proto.write(sha)
# read the final confirmation sha
- sha = self.proto.read(20)
- if sha:
- pass # FIXME: Check that this sha is valid
+ client_sha = self.proto.read(20)
+ if not client_sha in (None, sha)
+ raise ChecksumMismatch(sha, client_sha)
return changed_refs
wants = determine_wants(refs)
if not wants:
self.proto.write_pkt_line(None)
- return
+ return refs
self.proto.write_pkt_line("want %s %s\n" % (wants[0], self.capabilities()))
for want in wants[1:]:
self.proto.write_pkt_line("want %s\n" % want)
hex_to_sha,
sha_to_hex,
)
-from dulwich.misc import make_sha
+from dulwich.misc import (
+ make_sha,
+ )
supports_mmap_offset = (sys.version_info[0] >= 3 or
(sys.version_info[0] == 2 and sys.version_info[1] >= 6))