Raise sha error if necessary, always return refs, fix docs.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 8 May 2009 19:28:52 +0000 (21:28 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 8 May 2009 19:28:52 +0000 (21:28 +0200)
dulwich/client.py
dulwich/pack.py

index c837448229703d5fc47c2c31339c515b48cce967..1b92ad00a9c9cef16ccb97b5a050bc6f3186c008 100644 (file)
@@ -26,6 +26,9 @@ import select
 import socket
 import subprocess
 
+from dulwich.errors import (
+    ChecksumMismatch,
+    )
 from dulwich.protocol import (
     Protocol,
     TCP_GIT_PORT,
@@ -42,14 +45,20 @@ def _fileno_can_read(fileno):
 
 
 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:
@@ -138,9 +147,9 @@ class GitClient(object):
         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
 
@@ -157,7 +166,7 @@ class GitClient(object):
         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)
index 81dfe633ff5c1d6daf40afbe46d0abcf460da79b..e3884f0e65de8afa7aa626ac33a3a2d426863b18 100644 (file)
@@ -59,7 +59,9 @@ from dulwich.objects import (
     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))