changeset 37473:7c2c7c749411

wireproto: show unknown id and flags in repr(frame) Perhaps we'll want it for debugging.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 08 Apr 2018 11:21:58 +0900
parents 2f81926c7f89
children d33997123ea5
files mercurial/wireprotoframing.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/wireprotoframing.py	Sun Apr 08 11:14:47 2018 +0900
+++ b/mercurial/wireprotoframing.py	Sun Apr 08 11:21:58 2018 +0900
@@ -110,10 +110,13 @@
 
 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, '<unknown 0x%02x>' % val))
+        val <<= 1
 
     return b'|'.join(flags)
 
@@ -140,7 +143,7 @@
     payload = attr.ib()
 
     def __repr__(self):
-        typename = '<unknown>'
+        typename = '<unknown 0x%02x>' % self.typeid
         for name, value in FRAME_TYPES.iteritems():
             if value == self.typeid:
                 typename = name