Patchwork log: make "slowpath" condition slightly more readable

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 19, 2017, 2:37 p.m.
Message ID <2ce83446b12b43dfeddf.1513694274@mimosa>
Download mbox | patch
Permalink /patch/26365/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 19, 2017, 2:37 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1513687299 -32400
#      Tue Dec 19 21:41:39 2017 +0900
# Node ID 2ce83446b12b43dfeddf1c0aadb5c8753047797a
# Parent  c836f3fd99ec97b248434e1523c73d77066c1d43
log: make "slowpath" condition slightly more readable

Before 8e0e334bad42 and 6c76c42a5893, the condition was "anypats() or
(files() and --removed)". This can be read as "<match is actually slow>
or <walk files including removed revs>". So "not always()" (i.e. walk
file revs) seems more appropriate here.

The logic should be unchanged:

  not anypats() => always() or isexact() or prefix()
  isexact()     => not always()
  prefix()      => not always()
Augie Fackler - Dec. 20, 2017, 3:30 a.m.
> On Dec 19, 2017, at 09:37, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1513687299 -32400
> #      Tue Dec 19 21:41:39 2017 +0900
> # Node ID 2ce83446b12b43dfeddf1c0aadb5c8753047797a
> # Parent  c836f3fd99ec97b248434e1523c73d77066c1d43
> log: make "slowpath" condition slightly more readable
> 

queued, thanks

> Before 8e0e334bad42 and 6c76c42a5893, the condition was "anypats() or
> (files() and --removed)". This can be read as "<match is actually slow>
> or <walk files including removed revs>". So "not always()" (i.e. walk
> file revs) seems more appropriate here.
> 
> The logic should be unchanged:
> 
>  not anypats() => always() or isexact() or prefix()
>  isexact()     => not always()
>  prefix()      => not always()
> 
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2193,8 +2193,7 @@ def walkchangerevs(repo, match, opts, pr
>     if not revs:
>         return []
>     wanted = set()
> -    slowpath = match.anypats() or ((match.isexact() or match.prefix()) and
> -                                   opts.get('removed'))
> +    slowpath = match.anypats() or (not match.always() and opts.get('removed'))
>     fncache = {}
>     change = repo.changectx
> 
> @@ -2390,8 +2389,7 @@ def _makelogrevset(repo, pats, opts, rev
>     # platforms without shell expansion (windows).
>     wctx = repo[None]
>     match, pats = scmutil.matchandpats(wctx, pats, opts)
> -    slowpath = match.anypats() or ((match.isexact() or match.prefix()) and
> -                                   opts.get('removed'))
> +    slowpath = match.anypats() or (not match.always() and opts.get('removed'))
>     if not slowpath:
>         for f in match.files():
>             if follow and f not in wctx:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2193,8 +2193,7 @@  def walkchangerevs(repo, match, opts, pr
     if not revs:
         return []
     wanted = set()
-    slowpath = match.anypats() or ((match.isexact() or match.prefix()) and
-                                   opts.get('removed'))
+    slowpath = match.anypats() or (not match.always() and opts.get('removed'))
     fncache = {}
     change = repo.changectx
 
@@ -2390,8 +2389,7 @@  def _makelogrevset(repo, pats, opts, rev
     # platforms without shell expansion (windows).
     wctx = repo[None]
     match, pats = scmutil.matchandpats(wctx, pats, opts)
-    slowpath = match.anypats() or ((match.isexact() or match.prefix()) and
-                                   opts.get('removed'))
+    slowpath = match.anypats() or (not match.always() and opts.get('removed'))
     if not slowpath:
         for f in match.files():
             if follow and f not in wctx: