|
@@ -125,11 +125,23 @@ class PackStreamCopier(PackStreamReader):
|
|
appropriate and written out to the given file-like object.
|
|
appropriate and written out to the given file-like object.
|
|
"""
|
|
"""
|
|
|
|
|
|
- def __init__(self, read_all, read_some, outfile):
|
|
|
|
- super(PackStreamCopier, self).__init__(read_all, read_some)
|
|
|
|
|
|
+ def __init__(self, read_all, read_some, outfile, delta_iter=None):
|
|
|
|
+ """Initialize the copier.
|
|
|
|
+
|
|
|
|
+ :param read_all: Read function that blocks until the number of requested
|
|
|
|
+ bytes are read.
|
|
|
|
+ :param read_some: Read function that returns at least one byte, but may
|
|
|
|
+ not return the number of bytes requested.
|
|
|
|
+ :param outfile: File-like object to write output through.
|
|
|
|
+ :param delta_iter: Optional DeltaChainIterator to record deltas as we
|
|
|
|
+ read them.
|
|
|
|
+ """
|
|
|
|
+ super(PackStreamCopier, self).__init__(read_all, read_some=read_some)
|
|
self.outfile = outfile
|
|
self.outfile = outfile
|
|
|
|
+ self._delta_iter = delta_iter
|
|
|
|
|
|
def _read(self, read, size):
|
|
def _read(self, read, size):
|
|
|
|
+ """Read data from the read callback and write it to the file."""
|
|
data = super(PackStreamCopier, self)._read(read, size)
|
|
data = super(PackStreamCopier, self)._read(read, size)
|
|
self.outfile.write(data)
|
|
self.outfile.write(data)
|
|
return data
|
|
return data
|
|
@@ -140,8 +152,12 @@ class PackStreamCopier(PackStreamReader):
|
|
See PackStreamReader.iterobjects for a list of exceptions this may
|
|
See PackStreamReader.iterobjects for a list of exceptions this may
|
|
throw.
|
|
throw.
|
|
"""
|
|
"""
|
|
- for _ in self.read_objects():
|
|
|
|
- pass
|
|
|
|
|
|
+ if self._delta_iter:
|
|
|
|
+ for type_num, uncomp, _, _ in self.read_objects():
|
|
|
|
+ self._delta_iter.record(self.offset, type_num, uncomp)
|
|
|
|
+ else:
|
|
|
|
+ for _ in self.read_objects():
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
|
class DictBackend(Backend):
|
|
class DictBackend(Backend):
|