Mercurial > public > mercurial-scm > hg
comparison mercurial/simplemerge.py @ 44948:eb6380da47a5
simplemerge: leverage pycompat function to convert byte string to set
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Tue, 02 Jun 2020 21:40:49 +0900 |
parents | ad6971e6740c |
children | 4bb0ea78a70f |
comparison
equal
deleted
inserted
replaced
44947:ad6971e6740c | 44948:eb6380da47a5 |
---|---|
449 for i, override in enumerate(overrides): | 449 for i, override in enumerate(overrides): |
450 result[i] = override | 450 result[i] = override |
451 return result | 451 return result |
452 | 452 |
453 | 453 |
454 def _bytes_to_set(b): | |
455 """turns a multiple bytes (usually flags) into a set of individual byte""" | |
456 return set(b[x : x + 1] for x in range(len(b))) | |
457 | |
458 | |
459 def is_not_null(ctx): | 454 def is_not_null(ctx): |
460 if not util.safehasattr(ctx, "node"): | 455 if not util.safehasattr(ctx, "node"): |
461 return False | 456 return False |
462 return ctx.node() != nodemod.nullid | 457 return ctx.node() != nodemod.nullid |
463 | 458 |
516 else: | 511 else: |
517 mergedtext += line | 512 mergedtext += line |
518 | 513 |
519 # merge flags if necessary | 514 # merge flags if necessary |
520 flags = localctx.flags() | 515 flags = localctx.flags() |
521 localflags = _bytes_to_set(flags) | 516 localflags = set(pycompat.iterbytestr(flags)) |
522 otherflags = _bytes_to_set(otherctx.flags()) | 517 otherflags = set(pycompat.iterbytestr(otherctx.flags())) |
523 if is_not_null(basectx) and localflags != otherflags: | 518 if is_not_null(basectx) and localflags != otherflags: |
524 baseflags = _bytes_to_set(basectx.flags()) | 519 baseflags = set(pycompat.iterbytestr(basectx.flags())) |
525 flags = localflags & otherflags | 520 flags = localflags & otherflags |
526 for f in localflags.symmetric_difference(otherflags): | 521 for f in localflags.symmetric_difference(otherflags): |
527 if f not in baseflags: | 522 if f not in baseflags: |
528 flags.add(f) | 523 flags.add(f) |
529 flags = b''.join(sorted(flags)) | 524 flags = b''.join(sorted(flags)) |