From: Dave Borowitz <[email protected]>
Change-Id: I6e94e778beb221590dbf10c1a7aba302f700ef03
---
dulwich/pack.py | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/dulwich/pack.py b/dulwich/pack.py
index 60eb306..e487786 100644
--- a/dulwich/pack.py
+++ b/dulwich/pack.py
@@ -900,12 +900,11 @@ class PackData(object):
object count.
:return: iterator of tuples with (sha, offset, crc32)
"""
- for offset, type, obj, crc32 in self.iterobjects(progress=progress):
- assert isinstance(offset, int)
- assert isinstance(type, int)
- assert isinstance(obj, list) or isinstance(obj, tuple)
- type, obj = self.resolve_object(offset, type, obj)
- yield obj_sha(type, obj), offset, crc32
+ num_objects = self._num_objects
+ for i, result in enumerate(PackIndexer.for_pack_data(self)):
+ if progress is not None:
+ progress(i, num_objects)
+ yield result
def sorted_entries(self, progress=None):
"""Return entries in this pack, sorted by SHA.
@@ -1170,6 +1169,18 @@ class DeltaChainIterator(object):
for result in self._follow_chain(new_offset, base_type_num,
chunks):
yield result
+ def __iter__(self):
+ return self._walk_all_chains()
+
+
+class PackIndexer(DeltaChainIterator):
+ """Delta chain iterator that yields index entries."""
+
+ _compute_crc32 = True
+
+ def _result(self, offset, unused_type_num, unused_chunks, sha, crc32):
+ return sha, offset, crc32
+
class SHA1Reader(object):
"""Wrapper around a file-like object that remembers the SHA1 of its
data."""
--
1.7.3.1
_______________________________________________
Mailing list: https://launchpad.net/~dulwich-users
Post to : [email protected]
Unsubscribe : https://launchpad.net/~dulwich-users
More help : https://help.launchpad.net/ListHelp