diff 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
line wrap: on
line diff
--- a/mercurial/filemerge.py	Thu Oct 08 12:53:09 2015 -0700
+++ b/mercurial/filemerge.py	Wed Oct 07 21:51:24 2015 -0700
@@ -505,13 +505,14 @@
         util.copyfile(a, back)
         files = (a, b, c, back)
 
+    r = 1
+    try:
         markerstyle = ui.config('ui', 'mergemarkers', 'basic')
         if not labels:
             labels = _defaultconflictlabels
         if markerstyle != 'basic':
             labels = _formatlabels(repo, fcd, fco, fca, labels)
 
-        r = 1
         if mergetype == fullmerge:
             r = _premerge(repo, toolconf, files, labels=labels)
 
@@ -527,12 +528,13 @@
         if r:
             if onfailure:
                 ui.warn(onfailure % fd)
-        else:
+
+        return r
+    finally:
+        if not r:
             util.unlink(back)
-
         util.unlink(b)
         util.unlink(c)
-        return r
 
 def _check(r, ui, tool, fcd, files):
     fd = fcd.path()