comparison mercurial/cmdutil.py @ 22229:3a7b45a0bd20

revert: use a flat dispatch table Now that the table is simpler, remove one level of depth from it. This simplifies its usage in the for loop.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 24 Jun 2014 17:44:31 +0100
parents 908c76e84ec5
children 316ba2ddc034
comparison
equal deleted inserted replaced
22228:a3dc2d385490 22229:3a7b45a0bd20
2474 disptable = ( 2474 disptable = (
2475 # dispatch table: 2475 # dispatch table:
2476 # file state 2476 # file state
2477 # action 2477 # action
2478 # make backup 2478 # make backup
2479 (modified, (actions['revert'], False)), 2479 (modified, actions['revert'], False),
2480 (dsmodified, (actions['revert'], True)), 2480 (dsmodified, actions['revert'], True),
2481 (dsadded, (actions['remove'], True)), 2481 (dsadded, actions['remove'], True),
2482 (removed, (actions['add'], True)), 2482 (removed, actions['add'], True),
2483 (dsremoved, (actions['undelete'], True)), 2483 (dsremoved, actions['undelete'], True),
2484 (clean, (None, False)), 2484 (clean, None, False),
2485 ) 2485 )
2486 2486
2487 for abs, (rel, exact) in sorted(names.items()): 2487 for abs, (rel, exact) in sorted(names.items()):
2488 # target file to be touch on disk (relative to cwd) 2488 # target file to be touch on disk (relative to cwd)
2489 target = repo.wjoin(abs) 2489 target = repo.wjoin(abs)
2490 # search the entry in the dispatch table. 2490 # search the entry in the dispatch table.
2491 # if the file is in any of these sets, it was touched in the working 2491 # if the file is in any of these sets, it was touched in the working
2492 # directory parent and we are sure it needs to be reverted. 2492 # directory parent and we are sure it needs to be reverted.
2493 for table, (xlist, dobackup) in disptable: 2493 for table, xlist, dobackup in disptable:
2494 if abs not in table: 2494 if abs not in table:
2495 continue 2495 continue
2496 if xlist is None: 2496 if xlist is None:
2497 if exact: 2497 if exact:
2498 ui.warn(_('no changes needed to %s\n') % rel) 2498 ui.warn(_('no changes needed to %s\n') % rel)