Use raw_length in pack generation.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 31 Mar 2010 18:11:03 +0000 (20:11 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Wed, 31 Mar 2010 18:11:03 +0000 (20:11 +0200)
dulwich/objects.py
dulwich/pack.py
dulwich/tests/test_objects.py

index 6cc37d0b3c58bc2d84b610f4d82ae584f1583771..878f1a33e8efd94dd8ac5b16b3010bd8352a3963 100644 (file)
@@ -214,12 +214,12 @@ class ShaFile(object):
         shafile.set_raw_string(string)
         return shafile
 
-    def _raw_length(self):
+    def raw_length(self):
         """Returns the length of the raw string of this object."""
         return len(self.as_raw_string())
 
     def _header(self):
-        return "%s %lu\0" % (self._type, self._raw_length())
+        return "%s %lu\0" % (self._type, self.raw_length())
 
     def _make_sha(self):
         ret = make_sha()
@@ -303,7 +303,7 @@ class Blob(ShaFile):
     def _serialize(self):
         self._text = "".join(self._chunked)
 
-    def _raw_length(self):
+    def raw_length(self):
         ret = 0
         for chunk in self.chunked:
             ret += len(chunk)
index 2dbdd9f9853e151d9b64594a88bb0fbe4c04c806..323dc9a00d9fa2fb219d4c68c7b0a0942eb3c9bc 100644 (file)
@@ -848,7 +848,7 @@ def write_pack_data(f, objects, num_objects, window=10):
     # This helps us find good objects to diff against us
     magic = []
     for obj, path in recency:
-        magic.append( (obj.type, path, 1, -len(obj.as_raw_string()), obj) )
+        magic.append( (obj.type, path, 1, -obj.raw_length(), obj) )
     magic.sort()
     # Build a map of objects and their index in magic - so we can find preceeding objects
     # to diff against
index 2d50195c984e938a7e847ec87ca18221e49e6497..31d3a4564921dfea8b629cc3e13dc4659d2f6172 100644 (file)
@@ -194,7 +194,7 @@ class CommitSerializationTests(unittest.TestCase):
 
     def test_raw_length(self):
         c = self.make_base()
-        self.assertEquals(len(c.as_raw_string()), c._raw_length())
+        self.assertEquals(len(c.as_raw_string()), c.raw_length())
 
     def test_simple(self):
         c = self.make_base()