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

login
register
mail settings
Submitter Martin von Zweigbergk
Date March 24, 2015, 11:29 p.m.
Message ID <f1f5b18adb3c94d76812.1427239757@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/8248/
State Accepted
Commit 961790c35b4f130990b33afc94612cbfa2e95484
Headers show

Comments

Martin von Zweigbergk - March 24, 2015, 11:29 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@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.
Matt Mackall - March 25, 2015, 11:03 p.m.
On Tue, 2015-03-24 at 16:29 -0700, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@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 '.'

These are queued for default, thanks.

Patch

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)