changeset 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 813c6855b97f
children c0213f2cb942
files mercurial/cmdutil.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Sep 10 14:42:52 2014 +0100
+++ b/mercurial/cmdutil.py	Sat Aug 30 01:52:08 2014 +0200
@@ -2541,6 +2541,7 @@
         needdata = ('revert', 'add', 'undelete')
         _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata])
 
+        wctx = repo[None]
         for abs, (rel, exact) in sorted(names.items()):
             # target file to be touch on disk (relative to cwd)
             target = repo.wjoin(abs)
@@ -2553,7 +2554,7 @@
                 if xlist is not None:
                     xlist.append(abs)
                     if (dobackup and os.path.lexists(target)
-                        and repo[None][abs].cmp(ctx[abs])):
+                        and wctx[abs].cmp(ctx[abs])):
                         bakname = "%s.orig" % rel
                         ui.note(_('saving current version of %s as %s\n') %
                                 (rel, bakname))