Return chunks from apply_delta.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 31 Mar 2010 19:21:45 +0000 (21:21 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 31 Mar 2010 19:21:45 +0000 (21:21 +0200)
dulwich/_pack.c
dulwich/pack.py
dulwich/tests/test_pack.py

index 2890739de471c3aa0e549879eb0a481fb597cb24..7cdfe304a4ca8737f4706150b8cf81dbc88fc7d7 100644 (file)
@@ -127,7 +127,7 @@ static PyObject *py_apply_delta(PyObject *self, PyObject *args)
                return NULL;
        }
 
-    return ret;
+    return Py_BuildValue("[N]", ret);
 }
 
 static PyObject *py_bisect_find_sha(PyObject *self, PyObject *args)
index 6174667c343aa7b9fffb0fa13a234d72bdb2b349..2a13e724cdc7647832f9932d4579113bbc41b643 100644 (file)
@@ -540,7 +540,7 @@ class PackData(object):
         :return: Tuple with object type and contents.
         """
         if type not in (6, 7): # Not a delta
-            return type, obj
+            return type, "".join(obj)
 
         if get_offset is None:
             get_offset = self.get_object_at
@@ -561,11 +561,11 @@ class PackData(object):
             # Can't be a ofs delta, as we wouldn't know the base offset
             assert type != 6
             base_offset = None
-        type, base_text = self.resolve_object(base_offset, type, base_obj, get_ref)
+        type, base_text = self.resolve_object(base_offset, type, base_obj,
+            get_ref)
         if base_offset is not None:
             self._offset_cache[base_offset] = type, base_text
-        ret = (type, apply_delta(base_text, delta))
-        return ret
+        return (type, "".join(apply_delta(base_text, delta)))
   
     def iterobjects(self, progress=None):
 
@@ -717,8 +717,7 @@ class PackData(object):
                 "offset was %r" % offset
         assert offset >= self._header_size
         self._file.seek(offset)
-        (type, obj_chunks) = unpack_object(self._file.read)[:2]
-        return (type, "".join(obj_chunks))
+        return unpack_object(self._file.read)[:2]
 
 
 class SHA1Reader(object):
@@ -1014,8 +1013,7 @@ def apply_delta(src_buf, delta):
     if index != delta_length:
         raise ApplyDeltaError("delta not empty: %r" % delta[index:])
 
-    out = ''.join(out)
-    if dest_size != len(out):
+    if dest_size != chunks_length(out):
         raise ApplyDeltaError("dest size incorrect")
 
     return out
@@ -1156,7 +1154,7 @@ class Pack(object):
             get_raw = self.get_raw
         for offset, type, obj, crc32 in self.data.iterobjects():
             assert isinstance(offset, int)
-            yield ShaFile.from_raw_string(
+            yield ShaFile.from_raw_chunks(
                     *self.data.resolve_object(offset, type, obj, get_raw))
 
 
index 84ac0d3323a5a0e887cda996c453f3c9dae3c791..fb7cba84d268a425cc13fb6af53b45b9f6c655fd 100644 (file)
@@ -108,7 +108,7 @@ class TestPackDeltas(unittest.TestCase):
     test_string_big = "Z" * 8192
   
     def _test_roundtrip(self, base, target):
-        self.assertEquals(target,
+        self.assertEquals([target],
             apply_delta(base, create_delta(base, target)))
   
     def test_nochange(self):