filemerge: clean up temp files in a finally block
authorSiddharth Agarwal <sid0@fb.com>
Wed, 07 Oct 2015 21:51:24 -0700
changeset 26589 fb388aa26453
parent 26588 b3f7516fa50e
child 26590 473a63c45394
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.
mercurial/filemerge.py
--- 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()