Patchwork [5,of,5] revert: inline a now useless closure

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 15, 2014, 4:48 p.m.
Message ID <478345b0d0218a9c0ab6.1408121327@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5434/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 15, 2014, 4:48 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1403627983 -3600
#      Tue Jun 24 17:39:43 2014 +0100
# Node ID 478345b0d0218a9c0ab633b33f362080af3008a4
# Parent  3c4496ffc5eb12218c8d07efb833ac99aff63ed5
revert: inline a now useless closure

Now that a single call site remains, we can just inline its content.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2476,11 +2476,20 @@  def revert(ui, repo, ctx, parents, *pats
             )
 
         for abs, (rel, exact) in sorted(names.items()):
             # target file to be touch on disk (relative to cwd)
             target = repo.wjoin(abs)
-            def handle(xlist, dobackup):
+            # search the entry in the dispatch table.
+            # if the file is in any of this sets, it was touched in the working
+            # directory parent and we are sure it needs to be reverted.
+            for table, (xlist, dobackup) in disptable:
+                if abs not in table:
+                    continue
+                if xlist is None:
+                    if exact:
+                        ui.warn(_('no changes needed to %s\n') % rel)
+                    break
                 xlist[0].append(abs)
                 if (dobackup and not opts.get('no_backup') and
                     os.path.lexists(target) and
                     abs in ctx and repo[None][abs].cmp(ctx[abs])):
                     bakname = "%s.orig" % rel
@@ -2491,22 +2500,10 @@  def revert(ui, repo, ctx, parents, *pats
                 if ui.verbose or not exact:
                     msg = xlist[1]
                     if not isinstance(msg, basestring):
                         msg = msg(abs)
                     ui.status(msg % rel)
-            # search the entry in the dispatch table.
-            # if the file is in any of this sets, it was touched in the working
-            # directory parent and we are sure it needs to be reverted.
-            for table, (action, backup) in disptable:
-                if abs not in table:
-                    continue
-                if action is None:
-                    if exact:
-                        ui.warn(_('no changes needed to %s\n') % rel)
-
-                else:
-                    handle(action, backup)
                 break
             else:
                 # Not touched in current dirstate.
 
                 # file is unknown in parent, restore older version or ignore.