Patchwork [4,of,7,V2,mergedriver] filemerge: deindent the parts of filemerge outside the try block

login
register
mail settings
Submitter Siddharth Agarwal
Date Oct. 12, 2015, 7:45 a.m.
Message ID <ca2216f6fcc59cc46085.1444635939@dev6666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/10952/
State Accepted
Headers show

Comments

Siddharth Agarwal - Oct. 12, 2015, 7:45 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1444288760 25200
#      Thu Oct 08 00:19:20 2015 -0700
# Node ID ca2216f6fcc59cc46085609e62f95f1fecf9e79b
# Parent  5c1221d9a424db9c9d27b5cda1194248746a6be3
filemerge: deindent the parts of filemerge outside the try block

It is no longer necessary to indent these parts.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -448,65 +448,64 @@  def _filemerge(premerge, repo, mynode, o
     Returns whether the merge is complete, and the return value of the merge.
     """
 
-    if True:
-        def temp(prefix, ctx):
-            pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
-            (fd, name) = tempfile.mkstemp(prefix=pre)
-            data = repo.wwritedata(ctx.path(), ctx.data())
-            f = os.fdopen(fd, "wb")
-            f.write(data)
-            f.close()
-            return name
+    def temp(prefix, ctx):
+        pre = "%s~%s." % (os.path.basename(ctx.path()), prefix)
+        (fd, name) = tempfile.mkstemp(prefix=pre)
+        data = repo.wwritedata(ctx.path(), ctx.data())
+        f = os.fdopen(fd, "wb")
+        f.write(data)
+        f.close()
+        return name
 
-        if not fco.cmp(fcd): # files identical?
-            return True, None
+    if not fco.cmp(fcd): # files identical?
+        return True, None
 
-        ui = repo.ui
-        fd = fcd.path()
-        binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
-        symlink = 'l' in fcd.flags() + fco.flags()
-        tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
-        if tool in internals and tool.startswith('internal:'):
-            # normalize to new-style names (':merge' etc)
-            tool = tool[len('internal'):]
-        ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
-                   (tool, fd, binary, symlink))
+    ui = repo.ui
+    fd = fcd.path()
+    binary = fcd.isbinary() or fco.isbinary() or fca.isbinary()
+    symlink = 'l' in fcd.flags() + fco.flags()
+    tool, toolpath = _picktool(repo, ui, fd, binary, symlink)
+    if tool in internals and tool.startswith('internal:'):
+        # normalize to new-style names (':merge' etc)
+        tool = tool[len('internal'):]
+    ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" %
+               (tool, fd, binary, symlink))
 
-        if tool in internals:
-            func = internals[tool]
-            mergetype = func.mergetype
-            onfailure = func.onfailure
-            precheck = func.precheck
-        else:
-            func = _xmerge
-            mergetype = fullmerge
-            onfailure = _("merging %s failed!\n")
-            precheck = None
+    if tool in internals:
+        func = internals[tool]
+        mergetype = func.mergetype
+        onfailure = func.onfailure
+        precheck = func.precheck
+    else:
+        func = _xmerge
+        mergetype = fullmerge
+        onfailure = _("merging %s failed!\n")
+        precheck = None
 
-        toolconf = tool, toolpath, binary, symlink
+    toolconf = tool, toolpath, binary, symlink
 
-        if mergetype == nomerge:
-            return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
+    if mergetype == nomerge:
+        return True, func(repo, mynode, orig, fcd, fco, fca, toolconf)
 
-        if orig != fco.path():
-            ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
-        else:
-            ui.status(_("merging %s\n") % fd)
+    if orig != fco.path():
+        ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd))
+    else:
+        ui.status(_("merging %s\n") % fd)
 
-        ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
+    ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
 
-        if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
-                                     toolconf):
-            if onfailure:
-                ui.warn(onfailure % fd)
-            return True, 1
+    if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
+                                 toolconf):
+        if onfailure:
+            ui.warn(onfailure % fd)
+        return True, 1
 
-        a = repo.wjoin(fd)
-        b = temp("base", fca)
-        c = temp("other", fco)
-        back = a + ".orig"
-        util.copyfile(a, back)
-        files = (a, b, c, back)
+    a = repo.wjoin(fd)
+    b = temp("base", fca)
+    c = temp("other", fco)
+    back = a + ".orig"
+    util.copyfile(a, back)
+    files = (a, b, c, back)
 
     r = 1
     try: