mercurial/changegroup.py
branchstable
changeset 27920 da5f23362517
parent 27867 7ced54ebf972
child 27928 c0f11347b107
equal deleted inserted replaced
27919:db24d6888896 27920:da5f23362517
   187     bundlerepo and some debug commands - their use is discouraged.
   187     bundlerepo and some debug commands - their use is discouraged.
   188     """
   188     """
   189     deltaheader = _CHANGEGROUPV1_DELTA_HEADER
   189     deltaheader = _CHANGEGROUPV1_DELTA_HEADER
   190     deltaheadersize = struct.calcsize(deltaheader)
   190     deltaheadersize = struct.calcsize(deltaheader)
   191     version = '01'
   191     version = '01'
       
   192     _grouplistcount = 1 # One list of files after the manifests
       
   193 
   192     def __init__(self, fh, alg):
   194     def __init__(self, fh, alg):
   193         if alg == 'UN':
   195         if alg == 'UN':
   194             alg = None # get more modern without breaking too much
   196             alg = None # get more modern without breaking too much
   195         if not alg in util.decompressors:
   197         if not alg in util.decompressors:
   196             raise error.Abort(_('unknown stream compression type: %s')
   198             raise error.Abort(_('unknown stream compression type: %s')
   268         network API. To do so, it parse the changegroup data, otherwise it will
   270         network API. To do so, it parse the changegroup data, otherwise it will
   269         block in case of sshrepo because it don't know the end of the stream.
   271         block in case of sshrepo because it don't know the end of the stream.
   270         """
   272         """
   271         # an empty chunkgroup is the end of the changegroup
   273         # an empty chunkgroup is the end of the changegroup
   272         # a changegroup has at least 2 chunkgroups (changelog and manifest).
   274         # a changegroup has at least 2 chunkgroups (changelog and manifest).
   273         # after that, an empty chunkgroup is the end of the changegroup
   275         # after that, changegroup versions 1 and 2 have a series of groups
   274         empty = False
   276         # with one group per file. changegroup 3 has a series of directory
       
   277         # manifests before the files.
   275         count = 0
   278         count = 0
   276         while not empty or count <= 2:
   279         emptycount = 0
       
   280         while emptycount < self._grouplistcount:
   277             empty = True
   281             empty = True
   278             count += 1
   282             count += 1
   279             while True:
   283             while True:
   280                 chunk = getchunk(self)
   284                 chunk = getchunk(self)
   281                 if not chunk:
   285                 if not chunk:
       
   286                     if empty and count > 2:
       
   287                         emptycount += 1
   282                     break
   288                     break
   283                 empty = False
   289                 empty = False
   284                 yield chunkheader(len(chunk))
   290                 yield chunkheader(len(chunk))
   285                 pos = 0
   291                 pos = 0
   286                 while pos < len(chunk):
   292                 while pos < len(chunk):
   513     separating manifests and files.
   519     separating manifests and files.
   514     """
   520     """
   515     deltaheader = _CHANGEGROUPV3_DELTA_HEADER
   521     deltaheader = _CHANGEGROUPV3_DELTA_HEADER
   516     deltaheadersize = struct.calcsize(deltaheader)
   522     deltaheadersize = struct.calcsize(deltaheader)
   517     version = '03'
   523     version = '03'
       
   524     _grouplistcount = 2 # One list of manifests and one list of files
   518 
   525 
   519     def _deltaheader(self, headertuple, prevnode):
   526     def _deltaheader(self, headertuple, prevnode):
   520         node, p1, p2, deltabase, cs, flags = headertuple
   527         node, p1, p2, deltabase, cs, flags = headertuple
   521         return node, p1, p2, deltabase, cs, flags
   528         return node, p1, p2, deltabase, cs, flags
   522 
   529