simplemerge: rewrite flag merging loop as expression
authorYuya Nishihara <yuya@tcha.org>
Tue, 02 Jun 2020 21:44:57 +0900
changeset 44949 4bb0ea78a70f
parent 44948 eb6380da47a5
child 44950 f9734b2d59cc
simplemerge: rewrite flag merging loop as expression I feel binary operations are more readable.
mercurial/simplemerge.py
--- a/mercurial/simplemerge.py	Tue Jun 02 21:40:49 2020 +0900
+++ b/mercurial/simplemerge.py	Tue Jun 02 21:44:57 2020 +0900
@@ -517,11 +517,9 @@
     otherflags = set(pycompat.iterbytestr(otherctx.flags()))
     if is_not_null(basectx) and localflags != otherflags:
         baseflags = set(pycompat.iterbytestr(basectx.flags()))
-        flags = localflags & otherflags
-        for f in localflags.symmetric_difference(otherflags):
-            if f not in baseflags:
-                flags.add(f)
-        flags = b''.join(sorted(flags))
+        commonflags = localflags & otherflags
+        addedflags = (localflags ^ otherflags) - baseflags
+        flags = b''.join(sorted(commonflags | addedflags))
 
     if not opts.get(b'print'):
         localctx.write(mergedtext, flags)