comparison mercurial/filemerge.py @ 34049:67cfffbfb6a0

filemerge: eliminate most uses of tempfiles Emphasize that they're unused so we can more easily remove them later. Differential Revision: https://phab.mercurial-scm.org/D399
author Phil Cohen <phillco@fb.com>
date Thu, 31 Aug 2017 11:28:59 -0700
parents 52bd006b4f49
children d37f1bb68169
comparison
equal deleted inserted replaced
34048:52bd006b4f49 34049:67cfffbfb6a0
316 316
317 def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None): 317 def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
318 tool, toolpath, binary, symlink = toolconf 318 tool, toolpath, binary, symlink = toolconf
319 if symlink or fcd.isabsent() or fco.isabsent(): 319 if symlink or fcd.isabsent() or fco.isabsent():
320 return 1 320 return 1
321 a, b, c, back = files 321 unused, unused, unused, back = files
322 322
323 ui = repo.ui 323 ui = repo.ui
324 324
325 validkeep = ['keep', 'keep-merge3'] 325 validkeep = ['keep', 'keep-merge3']
326 326
345 quiet=True, label=labels, repo=repo) 345 quiet=True, label=labels, repo=repo)
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 util.copyfile(back, a) # restore from backup and try again 350 # restore from backup and try again
351 util.copyfile(back, repo.wjoin(fcd.path()))
351 return 1 # continue merging 352 return 1 # continue merging
352 353
353 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf): 354 def _mergecheck(repo, mynode, orig, fcd, fco, fca, toolconf):
354 tool, toolpath, binary, symlink = toolconf 355 tool, toolpath, binary, symlink = toolconf
355 if symlink: 356 if symlink:
366 """ 367 """
367 Uses the internal non-interactive simple merge algorithm for merging 368 Uses the internal non-interactive simple merge algorithm for merging
368 files. It will fail if there are any conflicts and leave markers in 369 files. It will fail if there are any conflicts and leave markers in
369 the partially merged file. Markers will have two sections, one for each side 370 the partially merged file. Markers will have two sections, one for each side
370 of merge, unless mode equals 'union' which suppresses the markers.""" 371 of merge, unless mode equals 'union' which suppresses the markers."""
371 a, b, c, back = files
372
373 ui = repo.ui 372 ui = repo.ui
374 373
375 r = simplemerge.simplemerge(ui, fcd, fca, fco, 374 r = simplemerge.simplemerge(ui, fcd, fca, fco,
376 label=labels, mode=mode, repo=repo) 375 label=labels, mode=mode, repo=repo)
377 return True, r, False 376 return True, r, False
422 """ 421 """
423 Generic driver for _imergelocal and _imergeother 422 Generic driver for _imergelocal and _imergeother
424 """ 423 """
425 assert localorother is not None 424 assert localorother is not None
426 tool, toolpath, binary, symlink = toolconf 425 tool, toolpath, binary, symlink = toolconf
427 a, b, c, back = files
428 r = simplemerge.simplemerge(repo.ui, fcd, fca, fco, 426 r = simplemerge.simplemerge(repo.ui, fcd, fca, fco,
429 label=labels, localorother=localorother, 427 label=labels, localorother=localorother,
430 repo=repo) 428 repo=repo)
431 return True, r 429 return True, r
432 430
468 same directory as ``a.txt``. 466 same directory as ``a.txt``.
469 467
470 This implies permerge. Therefore, files aren't dumped, if premerge 468 This implies permerge. Therefore, files aren't dumped, if premerge
471 runs successfully. Use :forcedump to forcibly write files out. 469 runs successfully. Use :forcedump to forcibly write files out.
472 """ 470 """
473 a, b, c, back = files 471 a, unused, unused, unused = files
474 472
475 fd = fcd.path() 473 fd = fcd.path()
476 474
477 util.copyfile(a, a + ".local") 475 util.copyfile(a, a + ".local")
478 repo.wwrite(fd + ".other", fco.data(), fco.flags()) 476 repo.wwrite(fd + ".other", fco.data(), fco.flags())
718 util.unlink(files[1]) 716 util.unlink(files[1])
719 util.unlink(files[2]) 717 util.unlink(files[2])
720 718
721 def _check(r, ui, tool, fcd, files): 719 def _check(r, ui, tool, fcd, files):
722 fd = fcd.path() 720 fd = fcd.path()
723 a, b, c, back = files 721 a, unused, unused, back = files
724 722
725 if not r and (_toolbool(ui, tool, "checkconflicts") or 723 if not r and (_toolbool(ui, tool, "checkconflicts") or
726 'conflicts' in _toollist(ui, tool, "check")): 724 'conflicts' in _toollist(ui, tool, "check")):
727 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), 725 if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(),
728 re.MULTILINE): 726 re.MULTILINE):