comparison mercurial/simplemerge.py @ 44949:4bb0ea78a70f

simplemerge: rewrite flag merging loop as expression I feel binary operations are more readable.
author Yuya Nishihara <yuya@tcha.org>
date Tue, 02 Jun 2020 21:44:57 +0900
parents eb6380da47a5
children 89a2afe31e82
comparison
equal deleted inserted replaced
44948:eb6380da47a5 44949:4bb0ea78a70f
515 flags = localctx.flags() 515 flags = localctx.flags()
516 localflags = set(pycompat.iterbytestr(flags)) 516 localflags = set(pycompat.iterbytestr(flags))
517 otherflags = set(pycompat.iterbytestr(otherctx.flags())) 517 otherflags = set(pycompat.iterbytestr(otherctx.flags()))
518 if is_not_null(basectx) and localflags != otherflags: 518 if is_not_null(basectx) and localflags != otherflags:
519 baseflags = set(pycompat.iterbytestr(basectx.flags())) 519 baseflags = set(pycompat.iterbytestr(basectx.flags()))
520 flags = localflags & otherflags 520 commonflags = localflags & otherflags
521 for f in localflags.symmetric_difference(otherflags): 521 addedflags = (localflags ^ otherflags) - baseflags
522 if f not in baseflags: 522 flags = b''.join(sorted(commonflags | addedflags))
523 flags.add(f)
524 flags = b''.join(sorted(flags))
525 523
526 if not opts.get(b'print'): 524 if not opts.get(b'print'):
527 localctx.write(mergedtext, flags) 525 localctx.write(mergedtext, flags)
528 526
529 if m3.conflicts and not mode == b'union': 527 if m3.conflicts and not mode == b'union':