Patchwork [3,of,5] revert: use actions[...] in all disptable case

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 18, 2014, 10:30 p.m.
Message ID <e5b148670e440fb57e01.1408401053@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5478/
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 1407008734 25200
#      Sat Aug 02 12:45:34 2014 -0700
# Node ID e5b148670e440fb57e018eb69e43dcb5585c2015
# Parent  df01b592e5060253f5d85c44b267b643c3ef396b
revert: use actions[...] in all disptable case

1. Special case are not special enough

2. There is two cases where nothing is done and a message is displayed. This
   prepares it.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2464,11 +2464,13 @@  def revert(ui, repo, ctx, parents, *pats
         # action to be actually performed by revert
         # (<list of file>, message>) tuple
         actions = {'revert': ([], _('reverting %s\n')),
                    'add': ([], _('adding %s\n')),
                    'remove': ([], removeforget),
-                   'undelete': ([], _('undeleting %s\n'))}
+                   'undelete': ([], _('undeleting %s\n')),
+                   'noop': None,
+                  }
 
 
         # should we do a backup ?
         backup = not opts.get('no_backup')
         discard = False
@@ -2481,11 +2483,11 @@  def revert(ui, repo, ctx, parents, *pats
             (modified,   actions['revert'],   discard),
             (dsmodified, actions['revert'],   backup),
             (dsadded,    actions['remove'],   backup),
             (removed,    actions['add'],      backup),
             (dsremoved,  actions['undelete'], backup),
-            (clean,      None,                discard),
+            (clean,      actions['noop'],     discard),
             )
 
         for abs, (rel, exact) in sorted(names.items()):
             # target file to be touch on disk (relative to cwd)
             target = repo.wjoin(abs)