comparison mercurial/simplemerge.py @ 44911:84614212ae39 stable

flags: actually merge flags in simplemerge Since b86fc43e4b73, the local flag were blindly taken. This resulted in bug when rename are involved. exec flag change are now properly merged (when merged from the rename side). Another bug is affecting this when merging from the side without the rename. Differential Revision: https://phab.mercurial-scm.org/D8533
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 16 May 2020 20:38:19 +0200
parents 3b581ad59459
children ad6971e6740c
comparison
equal deleted inserted replaced
44910:783f059509e4 44911:84614212ae39
20 20
21 from .i18n import _ 21 from .i18n import _
22 from . import ( 22 from . import (
23 error, 23 error,
24 mdiff, 24 mdiff,
25 node as nodemod,
25 pycompat, 26 pycompat,
27 util,
26 ) 28 )
27 from .utils import stringutil 29 from .utils import stringutil
28 30
29 31
30 class CantReprocessAndShowBase(Exception): 32 class CantReprocessAndShowBase(Exception):
447 for i, override in enumerate(overrides): 449 for i, override in enumerate(overrides):
448 result[i] = override 450 result[i] = override
449 return result 451 return result
450 452
451 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_null(ctx):
460 if not util.safehasattr(ctx, "node"):
461 return False
462 return ctx.node() != nodemod.nullid
463
464
452 def simplemerge(ui, localctx, basectx, otherctx, **opts): 465 def simplemerge(ui, localctx, basectx, otherctx, **opts):
453 """Performs the simplemerge algorithm. 466 """Performs the simplemerge algorithm.
454 467
455 The merged result is written into `localctx`. 468 The merged result is written into `localctx`.
456 """ 469 """
501 if opts.get(b'print'): 514 if opts.get(b'print'):
502 ui.fout.write(line) 515 ui.fout.write(line)
503 else: 516 else:
504 mergedtext += line 517 mergedtext += line
505 518
519 # merge flags if necessary
520 flags = localctx.flags()
521 localflags = _bytes_to_set(flags)
522 otherflags = _bytes_to_set(otherctx.flags())
523 if is_null(basectx) and localflags != otherflags:
524 baseflags = _bytes_to_set(basectx.flags())
525 flags = localflags & otherflags
526 for f in localflags.symmetric_difference(otherflags):
527 if f not in baseflags:
528 flags.add(f)
529 flags = b''.join(sorted(flags))
530
506 if not opts.get(b'print'): 531 if not opts.get(b'print'):
507 localctx.write(mergedtext, localctx.flags()) 532 localctx.write(mergedtext, flags)
508 533
509 if m3.conflicts and not mode == b'union': 534 if m3.conflicts and not mode == b'union':
510 return 1 535 return 1