obshistory: make a {flag value: description} dict for _markerseffects()
authorAnton Shestakov <av6@dwimlabs.net>
Sat, 11 Jan 2020 20:06:26 +0700
changeset 5067 e07f6af3cfec
parent 5066 8dc865544aa1
child 5068 715c85f250e0
obshistory: make a {flag value: description} dict for _markerseffects()
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Sat Jan 11 19:49:45 2020 +0700
+++ b/hgext3rd/evolve/obshistory.py	Sat Jan 11 20:06:26 2020 +0700
@@ -786,6 +786,16 @@
 
     return {b'users': sorted(users)}
 
+EFFECTMAPPING = util.sortdict([
+    (DESCCHANGED, b'description'),
+    (METACHANGED, b'meta'),
+    (USERCHANGED, b'user'),
+    (DATECHANGED, b'date'),
+    (BRANCHCHANGED, b'branch'),
+    (PARENTCHANGED, b'parent'),
+    (DIFFCHANGED, b'content'),
+])
+
 def _markerseffects(markers):
     """ Return a list of effects as strings based on effect flags in markers
 
@@ -802,21 +812,9 @@
             combined |= int(ef)
 
     if combined:
-        # XXX should be a dict
-        if combined & DESCCHANGED:
-            effects.append(b'description')
-        if combined & METACHANGED:
-            effects.append(b'meta')
-        if combined & USERCHANGED:
-            effects.append(b'user')
-        if combined & DATECHANGED:
-            effects.append(b'date')
-        if combined & BRANCHCHANGED:
-            effects.append(b'branch')
-        if combined & PARENTCHANGED:
-            effects.append(b'parent')
-        if combined & DIFFCHANGED:
-            effects.append(b'content')
+        for key, value in EFFECTMAPPING.items():
+            if combined & key:
+                effects.append(value)
 
     return effects