From patchwork Sun Apr 8 08:59:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,5] wireproto: show unknown id and flags in repr(frame) From: Yuya Nishihara X-Patchwork-Id: 30553 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 08 Apr 2018 17:59:42 +0900 # HG changeset patch # User Yuya Nishihara # Date 1523154118 -32400 # Sun Apr 08 11:21:58 2018 +0900 # Node ID bb8635c7a6c30b988e9439ed9057857250838a7a # Parent 9cf44f780dc77847c7d8628c623148cadd0c252f wireproto: show unknown id and flags in repr(frame) Perhaps we'll want it for debugging. diff --git a/mercurial/wireprotoframing.py b/mercurial/wireprotoframing.py --- a/mercurial/wireprotoframing.py +++ b/mercurial/wireprotoframing.py @@ -110,10 +110,13 @@ ARGUMENT_RECORD_HEADER = struct.Struct(r def humanflags(mapping, value): """Convert a numeric flags value to a human value, using a mapping table.""" + namemap = {v: k for k, v in mapping.iteritems()} flags = [] - for val, name in sorted({v: k for k, v in mapping.iteritems()}.iteritems()): + val = 1 + while value >= val: if value & val: - flags.append(name) + flags.append(namemap.get(val, '' % val)) + val <<= 1 return b'|'.join(flags) @@ -140,7 +143,7 @@ class frame(object): payload = attr.ib() def __repr__(self): - typename = '' + typename = '' % self.typeid for name, value in FRAME_TYPES.iteritems(): if value == self.typeid: typename = name