mercurial/changegroup.py
changeset 10430 5cef810e588f
parent 10356 bc2414948012
child 11648 801533a52799
equal deleted inserted replaced
10429:1c50a954a524 10430:5cef810e588f
    22         raise util.Abort(_("premature EOF reading chunk"
    22         raise util.Abort(_("premature EOF reading chunk"
    23                            " (got %d bytes, expected %d)")
    23                            " (got %d bytes, expected %d)")
    24                           % (len(d), l - 4))
    24                           % (len(d), l - 4))
    25     return d
    25     return d
    26 
    26 
    27 def chunkiter(source):
    27 def chunkiter(source, progress=None):
    28     """iterate through the chunks in source, yielding a sequence of chunks
    28     """iterate through the chunks in source, yielding a sequence of chunks
    29     (strings)"""
    29     (strings)"""
    30     while 1:
    30     while 1:
    31         c = getchunk(source)
    31         c = getchunk(source)
    32         if not c:
    32         if not c:
    33             break
    33             break
       
    34         elif progress is not None:
       
    35             progress()
    34         yield c
    36         yield c
    35 
    37 
    36 def chunkheader(length):
    38 def chunkheader(length):
    37     """return a changegroup chunk header (string)"""
    39     """return a changegroup chunk header (string)"""
    38     return struct.pack(">l", length + 4)
    40     return struct.pack(">l", length + 4)