[PATCH 3 of 6] filemerge: deindent the parts of filemerge outside the try block
Siddharth Agarwal
sid0 at fb.com
Fri Oct 9 13:46:10 CDT 2015
# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1444288760 25200
# Thu Oct 08 00:19:20 2015 -0700
# Node ID 9d37da98fac061179cd1f8215cafe1c119c7e8f1
# Parent 66ed0fddfd25ea6070c578d0c58e4d198e9236d1
filemerge: deindent the parts of filemerge outside the try block
It is no longer necessary to indent these parts.
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -455,66 +455,65 @@ def filemerge(repo, mynode, orig, fcd, f
fcd = local file context for current/destination file
"""
- 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?
- raise StopIteration(None)
+ if not fco.cmp(fcd): # files identical?
+ raise StopIteration(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:
- r = func(repo, mynode, orig, fcd, fco, fca, toolconf)
- raise StopIteration(r)
+ if mergetype == nomerge:
+ r = func(repo, mynode, orig, fcd, fco, fca, toolconf)
+ raise StopIteration(r)
- 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)
- raise StopIteration(1)
+ if precheck and not precheck(repo, mynode, orig, fcd, fco, fca,
+ toolconf):
+ if onfailure:
+ ui.warn(onfailure % fd)
+ raise StopIteration(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:
More information about the Mercurial-devel
mailing list