Patchwork [1,of,5] revert: use a flat dispatch table

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 18, 2014, 10:30 p.m.
Message ID <06da9bf044178ea90877.1408401051@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5477/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 18, 2014, 10:30 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1403628271 -3600
#      Tue Jun 24 17:44:31 2014 +0100
# Node ID 06da9bf044178ea90877006dc6f6ced7dc6fad18
# Parent  04c11fd105e6e03516f5eb8a477b0cf8fb18fa43
revert: use a flat dispatch table

Now that the table is simpler, remove one level of deeps to it. This simplifies
its susage in the for loop.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2471,25 +2471,25 @@  def revert(ui, repo, ctx, parents, *pats
         disptable = (
             # dispatch table:
             #   file state
             #   action
             #   make backup
-            (modified,         (actions['revert'],   False)),
-            (dsmodified,       (actions['revert'],   True)),
-            (dsadded,          (actions['remove'],   True)),
-            (removed,          (actions['add'],      True)),
-            (dsremoved,        (actions['undelete'], True)),
-            (clean,            (None,                False)),
+            (modified,   actions['revert'],   False),
+            (dsmodified, actions['revert'],   True),
+            (dsadded,    actions['remove'],   True),
+            (removed,    actions['add'],      True),
+            (dsremoved,  actions['undelete'], True),
+            (clean,      None,                False),
             )
 
         for abs, (rel, exact) in sorted(names.items()):
             # target file to be touch on disk (relative to cwd)
             target = repo.wjoin(abs)
             # 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:
+            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)