Patchwork revset: fix wrong keyword() behaviour for strings with spaces

login
register
mail settings
Submitter Alexander Plavin
Date Aug. 22, 2013, 6:38 p.m.
Message ID <e750d4c05d45410bfd51.1377196728@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/2254/
State Superseded
Commit 26ddce1a2a55809d430498f4ed1fa9594c390885
Headers show

Comments

Alexander Plavin - Aug. 22, 2013, 6:38 p.m.
# HG changeset patch
# User Alexander Plavin <alexander@plav.in>
# Date 1375735926 -14400
#      Tue Aug 06 00:52:06 2013 +0400
# Node ID e750d4c05d45410bfd51848374e9b2c479a8235a
# Parent  4050c78a939904254eae88e9fe48945afe4b92d6
revset: fix wrong keyword() behaviour for strings with spaces

Some changesets can be wrongly reported as matched by this predicate
due to searching in a string joined with spaces and not individually.
A test case added, which fails without this fix.
Alexander Plavin - Aug. 22, 2013, 6:41 p.m.
It is a simple resend of this patch, with no changes. As written in the wiki, "Feel free to resend patches after a few days if you haven't gotten a response", and last time I sent it on August 5. Actually, it's not even "a few days", but I just forgot to send it before :)

22.08.2013, 22:39, "Alexander Plavin" <alexander@plav.in>:
> # HG changeset patch
> # User Alexander Plavin <alexander@plav.in>
> # Date 1375735926 -14400
> #      Tue Aug 06 00:52:06 2013 +0400
> # Node ID e750d4c05d45410bfd51848374e9b2c479a8235a
> # Parent  4050c78a939904254eae88e9fe48945afe4b92d6
> revset: fix wrong keyword() behaviour for strings with spaces
>
> Some changesets can be wrongly reported as matched by this predicate
> due to searching in a string joined with spaces and not individually.
> A test case added, which fails without this fix.
>
> diff -r 4050c78a9399 -r e750d4c05d45 mercurial/revset.py
> --- a/mercurial/revset.py Sat Jun 29 14:36:51 2013 +0400
> +++ b/mercurial/revset.py Tue Aug 06 00:52:06 2013 +0400
> @@ -910,8 +910,8 @@
>      l = []
>      for r in subset:
>          c = repo[r]
> -        t = " ".join(c.files() + [c.user(), c.description()])
> -        if kw in encoding.lower(t):
> +        if util.any(kw in encoding.lower(t)
> +                    for t in c.files() + [c.user(), c.description()]):
>              l.append(r)
>      return l
>
> diff -r 4050c78a9399 -r e750d4c05d45 tests/test-revset.t
> --- a/tests/test-revset.t Sat Jun 29 14:36:51 2013 +0400
> +++ b/tests/test-revset.t Tue Aug 06 00:52:06 2013 +0400
> @@ -328,6 +328,7 @@
>    7
>    $ log 'keyword(issue)'
>    6
> +  $ log 'keyword("test a")'
>    $ log 'limit(head(), 1)'
>    0
>    $ log 'matching(6)'
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff -r 4050c78a9399 -r e750d4c05d45 mercurial/revset.py
--- a/mercurial/revset.py	Sat Jun 29 14:36:51 2013 +0400
+++ b/mercurial/revset.py	Tue Aug 06 00:52:06 2013 +0400
@@ -910,8 +910,8 @@ 
     l = []
     for r in subset:
         c = repo[r]
-        t = " ".join(c.files() + [c.user(), c.description()])
-        if kw in encoding.lower(t):
+        if util.any(kw in encoding.lower(t)
+                    for t in c.files() + [c.user(), c.description()]):
             l.append(r)
     return l
 
diff -r 4050c78a9399 -r e750d4c05d45 tests/test-revset.t
--- a/tests/test-revset.t	Sat Jun 29 14:36:51 2013 +0400
+++ b/tests/test-revset.t	Tue Aug 06 00:52:06 2013 +0400
@@ -328,6 +328,7 @@ 
   7
   $ log 'keyword(issue)'
   6
+  $ log 'keyword("test a")'
   $ log 'limit(head(), 1)'
   0
   $ log 'matching(6)'