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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Aug 18 22:30:51 UTC 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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)



More information about the Mercurial-devel mailing list