Mercurial > public > mercurial-scm > hg
comparison mercurial/filemerge.py @ 26589:fb388aa26453
filemerge: clean up temp files in a finally block
This isn't really a big deal because the temp files are created in $TMPDIR, but
it makes some upcoming work simpler.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 07 Oct 2015 21:51:24 -0700 |
parents | d60815664c34 |
children | ef21a2c41629 |
comparison
equal
deleted
inserted
replaced
26588:b3f7516fa50e | 26589:fb388aa26453 |
---|---|
503 c = temp("other", fco) | 503 c = temp("other", fco) |
504 back = a + ".orig" | 504 back = a + ".orig" |
505 util.copyfile(a, back) | 505 util.copyfile(a, back) |
506 files = (a, b, c, back) | 506 files = (a, b, c, back) |
507 | 507 |
508 r = 1 | |
509 try: | |
508 markerstyle = ui.config('ui', 'mergemarkers', 'basic') | 510 markerstyle = ui.config('ui', 'mergemarkers', 'basic') |
509 if not labels: | 511 if not labels: |
510 labels = _defaultconflictlabels | 512 labels = _defaultconflictlabels |
511 if markerstyle != 'basic': | 513 if markerstyle != 'basic': |
512 labels = _formatlabels(repo, fcd, fco, fca, labels) | 514 labels = _formatlabels(repo, fcd, fco, fca, labels) |
513 | 515 |
514 r = 1 | |
515 if mergetype == fullmerge: | 516 if mergetype == fullmerge: |
516 r = _premerge(repo, toolconf, files, labels=labels) | 517 r = _premerge(repo, toolconf, files, labels=labels) |
517 | 518 |
518 if not r: # premerge successfully merged the file | 519 if not r: # premerge successfully merged the file |
519 needcheck = False | 520 needcheck = False |
525 r = _check(r, ui, tool, fcd, files) | 526 r = _check(r, ui, tool, fcd, files) |
526 | 527 |
527 if r: | 528 if r: |
528 if onfailure: | 529 if onfailure: |
529 ui.warn(onfailure % fd) | 530 ui.warn(onfailure % fd) |
530 else: | 531 |
532 return r | |
533 finally: | |
534 if not r: | |
531 util.unlink(back) | 535 util.unlink(back) |
532 | |
533 util.unlink(b) | 536 util.unlink(b) |
534 util.unlink(c) | 537 util.unlink(c) |
535 return r | |
536 | 538 |
537 def _check(r, ui, tool, fcd, files): | 539 def _check(r, ui, tool, fcd, files): |
538 fd = fcd.path() | 540 fd = fcd.path() |
539 a, b, c, back = files | 541 a, b, c, back = files |
540 | 542 |