Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundle2.py @ 20995:e995d104c87f
bundle2: add an integer id to part
For sending response to a pushed bundle, we need to link reply parts to request
part. We introduce a part id for this purpose. This is a 32 bit unique
integer stored in the header.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Tue, 01 Apr 2014 00:07:17 -0700 |
parents | b24ee5076b94 |
children | ed3c5e18a047 |
line wrap: on
line diff
--- a/mercurial/bundle2.py Mon Apr 07 23:10:20 2014 +0200 +++ b/mercurial/bundle2.py Tue Apr 01 00:07:17 2014 -0700 @@ -87,6 +87,9 @@ :typename: alphanumerical part name + :partid: A 32bits integer (unique in the bundle) that can be used to refer + to this part. + :parameters: Part's parameter may have arbitraty content, the binary structure is:: @@ -154,6 +157,7 @@ _fstreamparamsize = '>H' _fpartheadersize = '>H' _fparttypesize = '>B' +_fpartid = '>I' _fpayloadsize = '>I' _fpartparamcount = '>BB' @@ -319,6 +323,8 @@ """add a new part to the bundle2 container Parts contains the actuall applicative payload.""" + assert part.id is None + part.id = len(self._parts) # very cheap counter self._parts.append(part) def getchunks(self): @@ -449,6 +455,8 @@ typesize = unpackheader(_fparttypesize)[0] parttype = fromheader(typesize) self.ui.debug('part type: "%s"\n' % parttype) + partid = unpackheader(_fpartid)[0] + self.ui.debug('part id: "%s"\n' % partid) ## reading parameters # param count mancount, advcount = unpackheader(_fpartparamcount) @@ -478,6 +486,7 @@ self.ui.debug('payload chunk size: %i\n' % payloadsize) payload = ''.join(payload) current = part(parttype, manparams, advparams, data=payload) + current.id = partid return current @@ -490,6 +499,7 @@ def __init__(self, parttype, mandatoryparams=(), advisoryparams=(), data=''): + self.id = None self.type = parttype self.data = data self.mandatoryparams = mandatoryparams @@ -499,7 +509,7 @@ #### header ## parttype header = [_pack(_fparttypesize, len(self.type)), - self.type, + self.type, _pack(_fpartid, self.id), ] ## parameters # count