comparison mercurial/manifest.py @ 31531:326bca5477d0

manifest: refer to bytestrings as bytes, not str Required on Python 3.
author Augie Fackler <augie@google.com>
date Sun, 19 Mar 2017 01:12:03 -0400
parents 160e7ad941e9
children 23391acfc421
comparison
equal deleted inserted replaced
31530:160e7ad941e9 31531:326bca5477d0
282 self.extrainfo = self.extrainfo[:needle] + self.extrainfo[needle + 1:] 282 self.extrainfo = self.extrainfo[:needle] + self.extrainfo[needle + 1:]
283 if cur >= 0: 283 if cur >= 0:
284 self.data = self.data[:cur] + '\x00' + self.data[cur + 1:] 284 self.data = self.data[:cur] + '\x00' + self.data[cur + 1:]
285 285
286 def __setitem__(self, key, value): 286 def __setitem__(self, key, value):
287 if not isinstance(key, str): 287 if not isinstance(key, bytes):
288 raise TypeError("setitem: manifest keys must be a string.") 288 raise TypeError("setitem: manifest keys must be a byte string.")
289 if not isinstance(value, tuple) or len(value) != 2: 289 if not isinstance(value, tuple) or len(value) != 2:
290 raise TypeError("Manifest values must be a tuple of (node, flags).") 290 raise TypeError("Manifest values must be a tuple of (node, flags).")
291 hashval = value[0] 291 hashval = value[0]
292 if not isinstance(hashval, str) or not 20 <= len(hashval) <= 22: 292 if not isinstance(hashval, bytes) or not 20 <= len(hashval) <= 22:
293 raise TypeError("node must be a 20-byte string") 293 raise TypeError("node must be a 20-byte byte string")
294 flags = value[1] 294 flags = value[1]
295 if len(hashval) == 22: 295 if len(hashval) == 22:
296 hashval = hashval[:-1] 296 hashval = hashval[:-1]
297 if not isinstance(flags, str) or len(flags) > 1: 297 if not isinstance(flags, bytes) or len(flags) > 1:
298 raise TypeError("flags must a 0 or 1 byte string, got %r", flags) 298 raise TypeError("flags must a 0 or 1 byte string, got %r", flags)
299 needle, found = self.bsearch2(key) 299 needle, found = self.bsearch2(key)
300 if found: 300 if found:
301 # put the item 301 # put the item
302 pos = self.positions[needle] 302 pos = self.positions[needle]