409 msg = _(b"%s looks like a binary file.") % input.fctx.path() |
409 msg = _(b"%s looks like a binary file.") % input.fctx.path() |
410 ui.warn(_(b'warning: %s\n') % msg) |
410 ui.warn(_(b'warning: %s\n') % msg) |
411 raise error.Abort(msg) |
411 raise error.Abort(msg) |
412 |
412 |
413 |
413 |
414 def _premerge(repo, local, other, base, toolconf, backup): |
414 def _premerge(repo, local, other, base, toolconf): |
415 tool, toolpath, binary, symlink, scriptfn = toolconf |
415 tool, toolpath, binary, symlink, scriptfn = toolconf |
416 if symlink or local.fctx.isabsent() or other.fctx.isabsent(): |
416 if symlink or local.fctx.isabsent() or other.fctx.isabsent(): |
417 return 1 |
417 return 1 |
418 |
418 |
419 ui = repo.ui |
419 ui = repo.ui |
443 ): |
443 ): |
444 return 1 # continue merging |
444 return 1 # continue merging |
445 merged_text, conflicts = simplemerge.simplemerge( |
445 merged_text, conflicts = simplemerge.simplemerge( |
446 ui, local, base, other, mode=mode |
446 ui, local, base, other, mode=mode |
447 ) |
447 ) |
448 # fcd.flags() already has the merged flags (done in |
448 if not conflicts or premerge in validkeep: |
449 # mergestate.resolve()) |
449 # fcd.flags() already has the merged flags (done in |
450 local.fctx.write(merged_text, local.fctx.flags()) |
450 # mergestate.resolve()) |
|
451 local.fctx.write(merged_text, local.fctx.flags()) |
451 if not conflicts: |
452 if not conflicts: |
452 ui.debug(b" premerge successful\n") |
453 ui.debug(b" premerge successful\n") |
453 return 0 |
454 return 0 |
454 if premerge not in validkeep: |
|
455 # restore from backup and try again |
|
456 _restorebackup(local.fctx, backup) |
|
457 return 1 # continue merging |
455 return 1 # continue merging |
458 |
456 |
459 |
457 |
460 def _mergecheck(repo, mynode, fcd, fco, fca, toolconf): |
458 def _mergecheck(repo, mynode, fcd, fco, fca, toolconf): |
461 tool, toolpath, binary, symlink, scriptfn = toolconf |
459 tool, toolpath, binary, symlink, scriptfn = toolconf |
877 b"l": b" [%s]" % labels[0], |
875 b"l": b" [%s]" % labels[0], |
878 b"o": b" [%s]" % labels[1], |
876 b"o": b" [%s]" % labels[1], |
879 } |
877 } |
880 |
878 |
881 |
879 |
882 def _restorebackup(fcd, backup): |
|
883 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use |
|
884 # util.copy here instead. |
|
885 fcd.write(backup.data(), fcd.flags()) |
|
886 |
|
887 |
|
888 def _makebackup(repo, ui, wctx, fcd): |
880 def _makebackup(repo, ui, wctx, fcd): |
889 """Makes and returns a filectx-like object for ``fcd``'s backup file. |
881 """Makes and returns a filectx-like object for ``fcd``'s backup file. |
890 |
882 |
891 In addition to preserving the user's pre-existing modifications to `fcd` |
883 In addition to preserving the user's pre-existing modifications to `fcd` |
892 (if any), the backup is used to undo certain premerges, confirm whether a |
884 (if any), the backup is used to undo certain premerges, confirm whether a |