comparison mercurial/filemerge.py @ 34036:fe04c018eaac

filemerge: add _restorebackup Differential Revision: https://phab.mercurial-scm.org/D404
author Phil Cohen <phillco@fb.com>
date Thu, 31 Aug 2017 11:28:59 -0700
parents 96123bdea43e
children 6330df9d6393
comparison
equal deleted inserted replaced
34035:96123bdea43e 34036:fe04c018eaac
346 if not r: 346 if not r:
347 ui.debug(" premerge successful\n") 347 ui.debug(" premerge successful\n")
348 return 0 348 return 0
349 if premerge not in validkeep: 349 if premerge not in validkeep:
350 # restore from backup and try again 350 # restore from backup and try again
351 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use 351 _restorebackup(fcd, back)
352 # util.copy here instead.
353 fcd.write(util.readfile(back), fcd.flags())
354 return 1 # continue merging 352 return 1 # continue merging
355 353
356 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): 354 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
357 tool, toolpath, binary, symlink = toolconf 355 tool, toolpath, binary, symlink = toolconf
358 if symlink: 356 if symlink:
588 return { 586 return {
589 "l": " [%s]" % labels[0], 587 "l": " [%s]" % labels[0],
590 "o": " [%s]" % labels[1], 588 "o": " [%s]" % labels[1],
591 } 589 }
592 590
591 def _restorebackup(fcd, back):
592 # TODO: Add a workingfilectx.write(otherfilectx) path so we can use
593 # util.copy here instead.
594 fcd.write(util.readfile(back), fcd.flags())
595
593 def _makebackup(repo, ui, fcd, premerge): 596 def _makebackup(repo, ui, fcd, premerge):
594 """Makes a backup of the local `fcd` file prior to merging. 597 """Makes a backup of the local `fcd` file prior to merging.
595 598
596 In addition to preserving the user's pre-existing modifications to `fcd` 599 In addition to preserving the user's pre-existing modifications to `fcd`
597 (if any), the backup is used to undo certain premerges, confirm whether a 600 (if any), the backup is used to undo certain premerges, confirm whether a