Patchwork [1,of,5,resolve-ux] resolve: use early continue and deindent

login
register
mail settings
Submitter Gregory Szorc
Date May 3, 2014, 9:27 p.m.
Message ID <c7fce11e072d77d77746.1399152457@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4586/
State Superseded
Commit edac098e6a557a20c3e827703e1a66096e1aee9a
Headers show

Comments

Gregory Szorc - May 3, 2014, 9:27 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1397870386 25200
#      Fri Apr 18 18:19:46 2014 -0700
# Branch stable
# Node ID c7fce11e072d77d7774616eadc0579c1a43b8837
# Parent  cadad384c97c7956c98f3c9b92d8cc40fa16d93b
resolve: use early continue and deindent

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4926,47 +4926,49 @@  def resolve(ui, repo, *pats, **opts):
         raise util.Abort(_('no files or directories specified; '
                            'use --all to remerge all files'))
 
     ms = mergemod.mergestate(repo)
     m = scmutil.match(repo[None], pats, opts)
     ret = 0
 
     for f in ms:
-        if m(f):
-            if show:
-                if nostatus:
-                    ui.write("%s\n" % f)
-                else:
-                    ui.write("%s %s\n" % (ms[f].upper(), f),
-                             label='resolve.' +
-                             {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
-            elif mark:
-                ms.mark(f, "r")
-            elif unmark:
-                ms.mark(f, "u")
+        if not m(f):
+            continue
+
+        if show:
+            if nostatus:
+                ui.write("%s\n" % f)
             else:
-                wctx = repo[None]
-
-                # backup pre-resolve (merge uses .orig for its own purposes)
-                a = repo.wjoin(f)
-                util.copyfile(a, a + ".resolve")
-
-                try:
-                    # resolve file
-                    ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
-                                 'resolve')
-                    if ms.resolve(f, wctx):
-                        ret = 1
-                finally:
-                    ui.setconfig('ui', 'forcemerge', '', 'resolve')
-                    ms.commit()
-
-                # replace filemerge's .orig file with our resolve file
-                util.rename(a + ".resolve", a + ".orig")
+                ui.write("%s %s\n" % (ms[f].upper(), f),
+                         label='resolve.' +
+                         {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
+        elif mark:
+            ms.mark(f, "r")
+        elif unmark:
+            ms.mark(f, "u")
+        else:
+            wctx = repo[None]
+
+            # backup pre-resolve (merge uses .orig for its own purposes)
+            a = repo.wjoin(f)
+            util.copyfile(a, a + ".resolve")
+
+            try:
+                # resolve file
+                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                             'resolve')
+                if ms.resolve(f, wctx):
+                    ret = 1
+            finally:
+                ui.setconfig('ui', 'forcemerge', '', 'resolve')
+                ms.commit()
+
+            # replace filemerge's .orig file with our resolve file
+            util.rename(a + ".resolve", a + ".orig")
 
     ms.commit()
     return ret
 
 @command('revert',
     [('a', 'all', None, _('revert all changes when no arguments given')),
     ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
     ('r', 'rev', '', _('revert to the specified revision'), _('REV')),