← 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
---
 NEWS              |    2 ++
 dulwich/pack.py   |    4 +++-
 dulwich/server.py |    4 ++--
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 1ed3e15..773fe74 100644
--- a/NEWS
+++ b/NEWS
@@ -44,6 +44,8 @@
   * Add a sha arg to write_pack_object to incrementally compute a SHA.
     (Dave Borowitz)
 
+  * Include offset in PackStreamReader results. (Dave Borowitz)
+
  TEST CHANGES
 
   * If setuptools is installed, "python setup.py test" will now run the testsuite.
diff --git a/dulwich/pack.py b/dulwich/pack.py
index 10da626..8eca593 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