comparison mercurial/revlog.py @ 30552:03fae9048fa1

revlog: ensure that flags do not overflow 2 bytes This patch adds a line that ensures we are not setting by mistake a set of flags overlfowing the 2 bytes they are allocated. Given the way the data is packed in the revlog header, overflowing 2 bytes will result in setting a wrong offset.
author Cotizo Sima <cotizo@fb.com>
date Mon, 28 Nov 2016 04:34:01 -0800
parents 2ded17b64f09
children be5b2098a817
comparison
equal deleted inserted replaced
30551:64b55bffc1c0 30552:03fae9048fa1
70 70
71 def gettype(q): 71 def gettype(q):
72 return int(q & 0xFFFF) 72 return int(q & 0xFFFF)
73 73
74 def offset_type(offset, type): 74 def offset_type(offset, type):
75 if (type & ~REVIDX_KNOWN_FLAGS) != 0:
76 raise ValueError('unknown revlog index flags')
75 return long(long(offset) << 16 | type) 77 return long(long(offset) << 16 | type)
76 78
77 _nullhash = hashlib.sha1(nullid) 79 _nullhash = hashlib.sha1(nullid)
78 80
79 def hash(text, p1, p2): 81 def hash(text, p1, p2):