[PATCH 2 of 2] revert: take fast path also when not reverting to '.'

Martin von Zweigbergk martinvonz at google.com
Tue Mar 24 18:29:17 CDT 2015


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1427237277 25200
#      Tue Mar 24 15:47:57 2015 -0700
# Node ID f1f5b18adb3c94d76812c45f01157625c989242b
# Parent  f1bf7c265f81e552f7e10501f47b663ebd18d85e
revert: take fast path also when not reverting to '.'

This speeds up 'hg revert -r .^ --all --dry-run' on the Mozilla repo
from 4.081s to 0.826s. Note that 'hg revert -r .^ .' does not get any
faster, since '.' does not make match.always() True.

I can't think of a reason it would break anything, and if it does,
it's clearly not covered by tests.

diff -r f1bf7c265f81 -r f1f5b18adb3c mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Tue Mar 24 13:56:51 2015 -0700
+++ b/mercurial/cmdutil.py	Tue Mar 24 15:47:57 2015 -0700
@@ -2811,7 +2811,7 @@
 
         wctx = repo[None]
         m = scmutil.match(wctx, pats, opts)
-        if not m.always() or node != parent:
+        if not m.always():
             m.bad = lambda x, y: False
             for abs in repo.walk(m):
                 names[abs] = m.rel(abs), m.exact(abs)
@@ -2840,7 +2840,7 @@
             changes = repo.status(node1=node, match=m,
                                   unknown=True, ignored=True, clean=True)
         else:
-            changes = repo.status(match=m)
+            changes = repo.status(node1=node, match=m)
             for kind in changes:
                 for abs in kind:
                     names[abs] = m.rel(abs), m.exact(abs)


More information about the Mercurial-devel mailing list