hgext3rd/evolve/obsexchange.py
changeset 3148 0ed75e700ad8
parent 3080 461c9d940519
child 3149 79a926b557f1
equal deleted inserted replaced
3147:20a0792c1773 3148:0ed75e700ad8
   180     for chunk in obsolete.encodemarkers(markers, True):
   180     for chunk in obsolete.encodemarkers(markers, True):
   181         obsdata.write(chunk)
   181         obsdata.write(chunk)
   182     obsdata.seek(0)
   182     obsdata.seek(0)
   183     return obsdata
   183     return obsdata
   184 
   184 
   185 # The wireproto.streamres API changed, handling chunking and compression
       
   186 # directly. Handle either case.
       
   187 if util.safehasattr(wireproto.abstractserverproto, 'groupchunks'):
       
   188     # We need to handle chunking and compression directly
       
   189     def streamres(d, proto):
       
   190         return wireproto.streamres(proto.groupchunks(d))
       
   191 else:
       
   192     # Leave chunking and compression to streamres
       
   193     def streamres(d, proto):
       
   194         return wireproto.streamres(reader=d, v1compressible=True)
       
   195 
       
   196 def srv_pullobsmarkers(repo, proto, others):
   185 def srv_pullobsmarkers(repo, proto, others):
   197     """serves a binary stream of markers.
   186     """serves a binary stream of markers.
   198 
   187 
   199     Serves relevant to changeset between heads and common. The stream is prefix
   188     Serves relevant to changeset between heads and common. The stream is prefix
   200     by a -string- representation of an integer. This integer is the size of the
   189     by a -string- representation of an integer. This integer is the size of the
   207     finaldata = StringIO()
   196     finaldata = StringIO()
   208     obsdata = obsdata.getvalue()
   197     obsdata = obsdata.getvalue()
   209     finaldata.write('%20i' % len(obsdata))
   198     finaldata.write('%20i' % len(obsdata))
   210     finaldata.write(obsdata)
   199     finaldata.write(obsdata)
   211     finaldata.seek(0)
   200     finaldata.seek(0)
   212     return streamres(finaldata, proto)
   201     return wireproto.streamres(reader=finaldata, v1compressible=True)
   213 
   202 
   214 ###############################################
   203 ###############################################
   215 ### Support for old legacy exchange methods ###
   204 ### Support for old legacy exchange methods ###
   216 ###############################################
   205 ###############################################
   217 
   206