From a7691cf1689072f0b56be85de4721330c264a02c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 31 Mar 2010 20:11:03 +0200 Subject: [PATCH] Use raw_length in pack generation. --- dulwich/objects.py | 6 +++--- dulwich/pack.py | 2 +- dulwich/tests/test_objects.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dulwich/objects.py b/dulwich/objects.py index 6cc37d0..878f1a3 100644 --- a/dulwich/objects.py +++ b/dulwich/objects.py @@ -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) diff --git a/dulwich/pack.py b/dulwich/pack.py index 2dbdd9f..323dc9a 100644 --- a/dulwich/pack.py +++ b/dulwich/pack.py @@ -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 diff --git a/dulwich/tests/test_objects.py b/dulwich/tests/test_objects.py index 2d50195..31d3a45 100644 --- a/dulwich/tests/test_objects.py +++ b/dulwich/tests/test_objects.py @@ -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() -- 2.34.1