Mercurial > hg
changeset 21016:b477afb1c81e
bundle2: move unpackheader closure into the class
With the same argument as the other one, we move this closure into the
`unbundlepart` class.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 11 Apr 2014 15:47:38 -0400 |
parents | 14dd49260246 |
children | 8de8187e6f48 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Fri Apr 11 15:46:09 2014 -0400 +++ b/mercurial/bundle2.py Fri Apr 11 15:47:38 2014 -0400 @@ -559,27 +559,29 @@ self._headeroffset += size return data + def _unpackheader(self, format): + """read given format from header + + This automatically compute the size of the format to read.""" + data = self._fromheader(struct.calcsize(format)) + return _unpack(format, data) + def _readdata(self): """read the header and setup the object""" # some utility to help reading from the header block - def unpackheader(format): - """read given format from header - This automatically compute the size of the format to read.""" - data = self._fromheader(struct.calcsize(format)) - return _unpack(format, data) - - typesize = unpackheader(_fparttypesize)[0] + typesize = self._unpackheader(_fparttypesize)[0] self.type = self._fromheader(typesize) self.ui.debug('part type: "%s"\n' % self.type) - self.id = unpackheader(_fpartid)[0] + self.id = self._unpackheader(_fpartid)[0] self.ui.debug('part id: "%s"\n' % self.id) ## reading parameters # param count - mancount, advcount = unpackheader(_fpartparamcount) + mancount, advcount = self._unpackheader(_fpartparamcount) self.ui.debug('part parameters: %i\n' % (mancount + advcount)) # param size - paramsizes = unpackheader(_makefpartparamsizes(mancount + advcount)) + fparamsizes = _makefpartparamsizes(mancount + advcount) + paramsizes = self._unpackheader(fparamsizes) # make it a list of couple again paramsizes = zip(paramsizes[::2], paramsizes[1::2]) # split mandatory from advisory