← Back to team overview

dulwich-users team mailing list archive

[PATCH 16/33] pack: Include offset in PackStreamReader results.

 

From: Dave Borowitz <dborowitz@xxxxxxxxxx>

Change-Id: I5dba678587677d81c9ef4fd8c8bf8789f79f849c
---
 dulwich/pack.py   |    4 +++-
 dulwich/server.py |    4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/dulwich/pack.py b/dulwich/pack.py
index e5d7000..42dade2 100644
--- a/dulwich/pack.py
+++ b/dulwich/pack.py
@@ -712,6 +712,7 @@ class PackStreamReader(object):
         :param compute_crc32: If True, compute the CRC32 of the compressed
             data. If False, the returned CRC32 will be None.
         :yield: Tuples of (
+            offset,
             type number,
             list of uncompressed chunks,
             length of compressed data,
@@ -725,9 +726,10 @@ class PackStreamReader(object):
         """
         pack_version, self._num_objects = read_pack_header(self.read)
         for i in xrange(self._num_objects):
+            offset = self.offset
             type_num, uncomp, comp_len, crc32, unused = unpack_object(
               self.read, read_some=self.recv, compute_crc32=compute_crc32)
-            yield type_num, uncomp, comp_len, crc32
+            yield offset, type_num, uncomp, comp_len, crc32
 
             # prepend any unused data to current read buffer
             buf = StringIO()
diff --git a/dulwich/server.py b/dulwich/server.py
index 20832e8..269b566 100644
--- a/dulwich/server.py
+++ b/dulwich/server.py
@@ -153,8 +153,8 @@ class PackStreamCopier(PackStreamReader):
         throw.
         """
         if self._delta_iter:
-            for type_num, uncomp, _, _ in self.read_objects():
-                self._delta_iter.record(self.offset, type_num, uncomp)
+            for offset, type_num, uncomp, _, _ in self.read_objects():
+                self._delta_iter.record(offset, type_num, uncomp)
         else:
             for _ in self.read_objects():
                 pass
-- 
1.7.3.1



References