comparison mercurial/cmdutil.py @ 22395:67588e47522a

revert: cache working context in a variable During the silicon age, humans on planet Earth discovered the use of variables. This marvelous invention let them improve both code readability and performance.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sat, 30 Aug 2014 01:52:08 +0200
parents 54e614a297ac
children c0213f2cb942
comparison
equal deleted inserted replaced
22394:813c6855b97f 22395:67588e47522a
2539 ) 2539 )
2540 2540
2541 needdata = ('revert', 'add', 'undelete') 2541 needdata = ('revert', 'add', 'undelete')
2542 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) 2542 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata])
2543 2543
2544 wctx = repo[None]
2544 for abs, (rel, exact) in sorted(names.items()): 2545 for abs, (rel, exact) in sorted(names.items()):
2545 # target file to be touch on disk (relative to cwd) 2546 # target file to be touch on disk (relative to cwd)
2546 target = repo.wjoin(abs) 2547 target = repo.wjoin(abs)
2547 # search the entry in the dispatch table. 2548 # search the entry in the dispatch table.
2548 # if the file is in any of these sets, it was touched in the working 2549 # if the file is in any of these sets, it was touched in the working
2551 if abs not in table: 2552 if abs not in table:
2552 continue 2553 continue
2553 if xlist is not None: 2554 if xlist is not None:
2554 xlist.append(abs) 2555 xlist.append(abs)
2555 if (dobackup and os.path.lexists(target) 2556 if (dobackup and os.path.lexists(target)
2556 and repo[None][abs].cmp(ctx[abs])): 2557 and wctx[abs].cmp(ctx[abs])):
2557 bakname = "%s.orig" % rel 2558 bakname = "%s.orig" % rel
2558 ui.note(_('saving current version of %s as %s\n') % 2559 ui.note(_('saving current version of %s as %s\n') %
2559 (rel, bakname)) 2560 (rel, bakname))
2560 if not opts.get('dry_run'): 2561 if not opts.get('dry_run'):
2561 util.rename(target, bakname) 2562 util.rename(target, bakname)