comparison mercurial/cmdutil.py @ 21577:c62c5ce750ee

revert: group related data in tuple in the dispatch table The dispatch table used to be: - action if in target manifest - action if not in target manifest - make backup if in target manifest - make backup if not in target manifest We turn this into two (action, make backup) tuples. This helps both readability of the dispatch table and handling of each case. This also prepares a refactoring where the different actions we performs, whether "file is in target manifest" or not, are determined before reaching this loop.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 13 May 2014 17:28:19 -0700
parents 33395a7e5527
children 7cfe51661e98
comparison
equal deleted inserted replaced
21576:33395a7e5527 21577:c62c5ce750ee
2328 # file state 2328 # file state
2329 # action if in target manifest 2329 # action if in target manifest
2330 # action if not in target manifest 2330 # action if not in target manifest
2331 # make backup if in target manifest 2331 # make backup if in target manifest
2332 # make backup if not in target manifest 2332 # make backup if not in target manifest
2333 (modified, actions['revert'], actions['remove'], True, True), 2333 (modified, (actions['revert'], True),
2334 (added, actions['revert'], actions['remove'], True, False), 2334 (actions['remove'], True)),
2335 (removed, actions['undelete'], None, True, False), 2335 (added, (actions['revert'], True),
2336 (deleted, actions['revert'], actions['remove'], False, False), 2336 (actions['remove'], False)),
2337 (removed, (actions['undelete'], True),
2338 (None, False)),
2339 (deleted, (actions['revert'], False),
2340 (actions['remove'], False)),
2337 ) 2341 )
2338 2342
2339 for abs, (rel, exact) in sorted(names.items()): 2343 for abs, (rel, exact) in sorted(names.items()):
2340 # hash on file in target manifest (or None if missing from target) 2344 # hash on file in target manifest (or None if missing from target)
2341 mfentry = mf.get(abs) 2345 mfentry = mf.get(abs)
2357 msg = msg(abs) 2361 msg = msg(abs)
2358 ui.status(msg % rel) 2362 ui.status(msg % rel)
2359 # search the entry in the dispatch table. 2363 # search the entry in the dispatch table.
2360 # if the file is in any of this sets, it was touched in the working 2364 # if the file is in any of this sets, it was touched in the working
2361 # directory parent and we are sure it needs to be reverted. 2365 # directory parent and we are sure it needs to be reverted.
2362 for table, hitlist, misslist, backuphit, backupmiss in disptable: 2366 for table, hit, miss in disptable:
2363 if abs not in table: 2367 if abs not in table:
2364 continue 2368 continue
2365 # file has changed in dirstate 2369 # file has changed in dirstate
2366 if mfentry: 2370 if mfentry:
2367 handle(hitlist, backuphit) 2371 handle(*hit)
2368 elif misslist is not None: 2372 elif miss[0] is not None:
2369 handle(misslist, backupmiss) 2373 handle(*miss)
2370 break 2374 break
2371 else: 2375 else:
2372 # Not touched in current dirstate. 2376 # Not touched in current dirstate.
2373 2377
2374 # file is unknown in parent, restore older version or ignore. 2378 # file is unknown in parent, restore older version or ignore.