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.
--- a/mercurial/revlog.py Sun Nov 27 20:44:52 2016 -0500
+++ b/mercurial/revlog.py Mon Nov 28 04:34:01 2016 -0800
@@ -72,6 +72,8 @@
return int(q & 0xFFFF)
def offset_type(offset, type):
+ if (type & ~REVIDX_KNOWN_FLAGS) != 0:
+ raise ValueError('unknown revlog index flags')
return long(long(offset) << 16 | type)
_nullhash = hashlib.sha1(nullid)