mercurial/changegroup.py
branchstable
changeset 13456 ab3f4ee48adc
parent 12347 6277a9469dff
child 13457 e74fe15dc7fd
equal deleted inserted replaced
13455:053c042118bc 13456:ab3f4ee48adc
    10 import struct, os, bz2, zlib, tempfile
    10 import struct, os, bz2, zlib, tempfile
    11 
    11 
    12 def getchunk(source):
    12 def getchunk(source):
    13     """return the next chunk from changegroup 'source' as a string"""
    13     """return the next chunk from changegroup 'source' as a string"""
    14     d = source.read(4)
    14     d = source.read(4)
    15     if not d:
       
    16         return ""
       
    17     l = struct.unpack(">l", d)[0]
    15     l = struct.unpack(">l", d)[0]
    18     if l <= 4:
    16     if l <= 4:
    19         return ""
    17         return ""
    20     d = source.read(l - 4)
    18     d = source.read(l - 4)
    21     if len(d) < l - 4:
    19     if len(d) < l - 4:
   146     def close(self):
   144     def close(self):
   147         return self._stream.close()
   145         return self._stream.close()
   148 
   146 
   149     def chunklength(self):
   147     def chunklength(self):
   150         d = self.read(4)
   148         d = self.read(4)
   151         if not d:
       
   152             return 0
       
   153         l = max(0, struct.unpack(">l", d)[0] - 4)
   149         l = max(0, struct.unpack(">l", d)[0] - 4)
   154         if l and self.callback:
   150         if l and self.callback:
   155             self.callback()
   151             self.callback()
   156         return l
   152         return l
   157 
   153