equal
deleted
inserted
replaced
978 self.params # load params |
978 self.params # load params |
979 return self._compressed |
979 return self._compressed |
980 |
980 |
981 def close(self): |
981 def close(self): |
982 """close underlying file""" |
982 """close underlying file""" |
983 if util.safehasattr(self._fp, 'close'): |
983 if hasattr(self._fp, 'close'): |
984 return self._fp.close() |
984 return self._fp.close() |
985 |
985 |
986 |
986 |
987 formatmap = {b'20': unbundle20} |
987 formatmap = {b'20': unbundle20} |
988 |
988 |
1066 def copy(self): |
1066 def copy(self): |
1067 """return a copy of the part |
1067 """return a copy of the part |
1068 |
1068 |
1069 The new part have the very same content but no partid assigned yet. |
1069 The new part have the very same content but no partid assigned yet. |
1070 Parts with generated data cannot be copied.""" |
1070 Parts with generated data cannot be copied.""" |
1071 assert not util.safehasattr(self.data, 'next') |
1071 assert not hasattr(self.data, 'next') |
1072 return self.__class__( |
1072 return self.__class__( |
1073 self.type, |
1073 self.type, |
1074 self._mandatoryparams, |
1074 self._mandatoryparams, |
1075 self._advisoryparams, |
1075 self._advisoryparams, |
1076 self._data, |
1076 self._data, |
1135 if nbap: |
1135 if nbap: |
1136 msg.append(b' %i advisory' % nbmp) |
1136 msg.append(b' %i advisory' % nbmp) |
1137 msg.append(b')') |
1137 msg.append(b')') |
1138 if not self.data: |
1138 if not self.data: |
1139 msg.append(b' empty payload') |
1139 msg.append(b' empty payload') |
1140 elif util.safehasattr(self.data, 'next') or util.safehasattr( |
1140 elif hasattr(self.data, 'next') or hasattr(self.data, '__next__'): |
1141 self.data, '__next__' |
|
1142 ): |
|
1143 msg.append(b' streamed payload') |
1141 msg.append(b' streamed payload') |
1144 else: |
1142 else: |
1145 msg.append(b' %i bytes payload' % len(self.data)) |
1143 msg.append(b' %i bytes payload' % len(self.data)) |
1146 msg.append(b'\n') |
1144 msg.append(b'\n') |
1147 ui.debug(b''.join(msg)) |
1145 ui.debug(b''.join(msg)) |
1231 """yield chunks of a the part payload |
1229 """yield chunks of a the part payload |
1232 |
1230 |
1233 Exists to handle the different methods to provide data to a part.""" |
1231 Exists to handle the different methods to provide data to a part.""" |
1234 # we only support fixed size data now. |
1232 # we only support fixed size data now. |
1235 # This will be improved in the future. |
1233 # This will be improved in the future. |
1236 if util.safehasattr(self.data, 'next') or util.safehasattr( |
1234 if hasattr(self.data, 'next') or hasattr(self.data, '__next__'): |
1237 self.data, '__next__' |
|
1238 ): |
|
1239 buff = util.chunkbuffer(self.data) |
1235 buff = util.chunkbuffer(self.data) |
1240 chunk = buff.read(preferedchunksize) |
1236 chunk = buff.read(preferedchunksize) |
1241 while chunk: |
1237 while chunk: |
1242 yield chunk |
1238 yield chunk |
1243 chunk = buff.read(preferedchunksize) |
1239 chunk = buff.read(preferedchunksize) |
1378 class unbundlepart(unpackermixin): |
1374 class unbundlepart(unpackermixin): |
1379 """a bundle part read from a bundle""" |
1375 """a bundle part read from a bundle""" |
1380 |
1376 |
1381 def __init__(self, ui, header, fp): |
1377 def __init__(self, ui, header, fp): |
1382 super(unbundlepart, self).__init__(fp) |
1378 super(unbundlepart, self).__init__(fp) |
1383 self._seekable = util.safehasattr(fp, 'seek') and util.safehasattr( |
1379 self._seekable = hasattr(fp, 'seek') and hasattr(fp, 'tell') |
1384 fp, 'tell' |
|
1385 ) |
|
1386 self.ui = ui |
1380 self.ui = ui |
1387 # unbundle state attr |
1381 # unbundle state attr |
1388 self._headerdata = header |
1382 self._headerdata = header |
1389 self._headeroffset = 0 |
1383 self._headeroffset = 0 |
1390 self._initialized = False |
1384 self._initialized = False |