##// END OF EJS Templates
unbundle20: move header parsing into the 'getunbundler' function...
Pierre-Yves David -
r24642:54e5c239 default
parent child Browse files
Show More
@@ -523,7 +523,16 b' class unpackermixin(object):'
523
523
524 def getunbundler(ui, fp, header=None):
524 def getunbundler(ui, fp, header=None):
525 """return a valid unbundler object for a given header"""
525 """return a valid unbundler object for a given header"""
526 return unbundle20(ui, fp, header)
526 if header is None:
527 header = changegroup.readexactly(fp, 4)
528 magic, version = header[0:2], header[2:4]
529 if magic != 'HG':
530 raise util.Abort(_('not a Mercurial bundle'))
531 if version != '2Y':
532 raise util.Abort(_('unknown bundle version %s') % version)
533 unbundler = unbundle20(ui, fp)
534 ui.debug('start processing of %s stream\n' % header)
535 return unbundler
527
536
528 class unbundle20(unpackermixin):
537 class unbundle20(unpackermixin):
529 """interpret a bundle2 stream
538 """interpret a bundle2 stream
@@ -531,18 +540,10 b' class unbundle20(unpackermixin):'
531 This class is fed with a binary stream and yields parts through its
540 This class is fed with a binary stream and yields parts through its
532 `iterparts` methods."""
541 `iterparts` methods."""
533
542
534 def __init__(self, ui, fp, header=None):
543 def __init__(self, ui, fp):
535 """If header is specified, we do not read it out of the stream."""
544 """If header is specified, we do not read it out of the stream."""
536 self.ui = ui
545 self.ui = ui
537 super(unbundle20, self).__init__(fp)
546 super(unbundle20, self).__init__(fp)
538 if header is None:
539 header = self._readexact(4)
540 magic, version = header[0:2], header[2:4]
541 if magic != 'HG':
542 raise util.Abort(_('not a Mercurial bundle'))
543 if version != '2Y':
544 raise util.Abort(_('unknown bundle version %s') % version)
545 self.ui.debug('start processing of %s stream\n' % header)
546
547
547 @util.propertycache
548 @util.propertycache
548 def params(self):
549 def params(self):
General Comments 0
You need to be logged in to leave comments. Login now