comparison mercurial/bundle2.py @ 43115:4aa72cdf616f

py3: delete b'' prefix from safehasattr arguments Differential Revision: https://phab.mercurial-scm.org/D7029
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 06 Oct 2019 20:17:41 -0700
parents 86e4daa2d54c
children 8ff1ecfadcd1
comparison
equal deleted inserted replaced
43114:8197b395710e 43115:4aa72cdf616f
934 self.params # load params 934 self.params # load params
935 return self._compressed 935 return self._compressed
936 936
937 def close(self): 937 def close(self):
938 """close underlying file""" 938 """close underlying file"""
939 if util.safehasattr(self._fp, b'close'): 939 if util.safehasattr(self._fp, 'close'):
940 return self._fp.close() 940 return self._fp.close()
941 941
942 942
943 formatmap = {b'20': unbundle20} 943 formatmap = {b'20': unbundle20}
944 944
1022 def copy(self): 1022 def copy(self):
1023 """return a copy of the part 1023 """return a copy of the part
1024 1024
1025 The new part have the very same content but no partid assigned yet. 1025 The new part have the very same content but no partid assigned yet.
1026 Parts with generated data cannot be copied.""" 1026 Parts with generated data cannot be copied."""
1027 assert not util.safehasattr(self.data, b'next') 1027 assert not util.safehasattr(self.data, 'next')
1028 return self.__class__( 1028 return self.__class__(
1029 self.type, 1029 self.type,
1030 self._mandatoryparams, 1030 self._mandatoryparams,
1031 self._advisoryparams, 1031 self._advisoryparams,
1032 self._data, 1032 self._data,
1091 if nbap: 1091 if nbap:
1092 msg.append(b' %i advisory' % nbmp) 1092 msg.append(b' %i advisory' % nbmp)
1093 msg.append(b')') 1093 msg.append(b')')
1094 if not self.data: 1094 if not self.data:
1095 msg.append(b' empty payload') 1095 msg.append(b' empty payload')
1096 elif util.safehasattr(self.data, b'next') or util.safehasattr( 1096 elif util.safehasattr(self.data, 'next') or util.safehasattr(
1097 self.data, b'__next__' 1097 self.data, b'__next__'
1098 ): 1098 ):
1099 msg.append(b' streamed payload') 1099 msg.append(b' streamed payload')
1100 else: 1100 else:
1101 msg.append(b' %i bytes payload' % len(self.data)) 1101 msg.append(b' %i bytes payload' % len(self.data))
1187 """yield chunks of a the part payload 1187 """yield chunks of a the part payload
1188 1188
1189 Exists to handle the different methods to provide data to a part.""" 1189 Exists to handle the different methods to provide data to a part."""
1190 # we only support fixed size data now. 1190 # we only support fixed size data now.
1191 # This will be improved in the future. 1191 # This will be improved in the future.
1192 if util.safehasattr(self.data, b'next') or util.safehasattr( 1192 if util.safehasattr(self.data, 'next') or util.safehasattr(
1193 self.data, b'__next__' 1193 self.data, b'__next__'
1194 ): 1194 ):
1195 buff = util.chunkbuffer(self.data) 1195 buff = util.chunkbuffer(self.data)
1196 chunk = buff.read(preferedchunksize) 1196 chunk = buff.read(preferedchunksize)
1197 while chunk: 1197 while chunk:
1334 class unbundlepart(unpackermixin): 1334 class unbundlepart(unpackermixin):
1335 """a bundle part read from a bundle""" 1335 """a bundle part read from a bundle"""
1336 1336
1337 def __init__(self, ui, header, fp): 1337 def __init__(self, ui, header, fp):
1338 super(unbundlepart, self).__init__(fp) 1338 super(unbundlepart, self).__init__(fp)
1339 self._seekable = util.safehasattr(fp, b'seek') and util.safehasattr( 1339 self._seekable = util.safehasattr(fp, 'seek') and util.safehasattr(
1340 fp, b'tell' 1340 fp, b'tell'
1341 ) 1341 )
1342 self.ui = ui 1342 self.ui = ui
1343 # unbundle state attr 1343 # unbundle state attr
1344 self._headerdata = header 1344 self._headerdata = header