Patchwork [V2] scmutil: fix revrange when multiple revs are specified

login
register
mail settings
Submitter Durham Goode
Date March 20, 2014, 5:45 p.m.
Message ID <bbb3e24d1cc8593658d8.1395337533@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/4004/
State Accepted
Commit 170d6d591a7dbc09bfe1b509dfd8f39991e653a9
Headers show

Comments

Durham Goode - March 20, 2014, 5:45 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1395334544 25200
#      Thu Mar 20 09:55:44 2014 -0700
# Node ID bbb3e24d1cc8593658d8d63f4aa233c0e9d4e357
# Parent  43054dc84abd65e8c6f5dd93cf96e54ecf2b2612
scmutil: fix revrange when multiple revs are specified

revrange was trying to add a list to a revset class, but revset classes only
support adding with other revset classes. So wrap the lists in basesets.
Siddharth Agarwal - March 20, 2014, 5:47 p.m.
On 03/20/2014 10:45 AM, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1395334544 25200
> #      Thu Mar 20 09:55:44 2014 -0700
> # Node ID bbb3e24d1cc8593658d8d63f4aa233c0e9d4e357
> # Parent  43054dc84abd65e8c6f5dd93cf96e54ecf2b2612
> scmutil: fix revrange when multiple revs are specified

Looks good to me.

>
> revrange was trying to add a list to a revset class, but revset classes only
> support adding with other revset classes. So wrap the lists in basesets.
>
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -499,7 +499,7 @@
>           try:
>               if isinstance(spec, int):
>                   seen.add(spec)
> -                l = l + [spec]
> +                l = l + revset.baseset([spec])
>                   continue
>   
>               if _revrangesep in spec:
> @@ -520,14 +520,14 @@
>                       seen.update(newrevs)
>                   else:
>                       seen = newrevs
> -                l = l + sorted(newrevs, reverse=start > end)
> +                l = l + revset.baseset(sorted(newrevs, reverse=start > end))
>                   continue
>               elif spec and spec in repo: # single unquoted rev
>                   rev = revfix(repo, spec, None)
>                   if rev in seen:
>                       continue
>                   seen.add(rev)
> -                l = l + [rev]
> +                l = l + revset.baseset([rev])
>                   continue
>           except error.RepoLookupError:
>               pass
> @@ -536,7 +536,7 @@
>           m = revset.match(repo.ui, spec, repo)
>           if seen or l:
>               dl = [r for r in m(repo, revset.spanset(repo)) if r not in seen]
> -            l = l + dl
> +            l = l + revset.baseset(dl)
>               seen.update(dl)
>           else:
>               l = m(repo, revset.spanset(repo))
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -734,6 +734,16 @@
>     hg: parse error: ^ expects a number 0, 1, or 2
>     [255]
>   
> +multiple revspecs
> +
> +  $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
> +  8
> +  9
> +  4
> +  5
> +  6
> +  7
> +
>   aliases:
>   
>     $ echo '[revsetalias]' >> .hg/hgrc
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Matt Mackall - March 20, 2014, 7:32 p.m.
On Thu, 2014-03-20 at 10:45 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1395334544 25200
> #      Thu Mar 20 09:55:44 2014 -0700
> # Node ID bbb3e24d1cc8593658d8d63f4aa233c0e9d4e357
> # Parent  43054dc84abd65e8c6f5dd93cf96e54ecf2b2612
> scmutil: fix revrange when multiple revs are specified

Queued for default, thanks.

FYI, after this:

http://www.selenic.com/hg/rev/8ecfa225bd16

..it should now be possible to get rid of the legacy parser and join all
the -r args into a single revset.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -499,7 +499,7 @@ 
         try:
             if isinstance(spec, int):
                 seen.add(spec)
-                l = l + [spec]
+                l = l + revset.baseset([spec])
                 continue
 
             if _revrangesep in spec:
@@ -520,14 +520,14 @@ 
                     seen.update(newrevs)
                 else:
                     seen = newrevs
-                l = l + sorted(newrevs, reverse=start > end)
+                l = l + revset.baseset(sorted(newrevs, reverse=start > end))
                 continue
             elif spec and spec in repo: # single unquoted rev
                 rev = revfix(repo, spec, None)
                 if rev in seen:
                     continue
                 seen.add(rev)
-                l = l + [rev]
+                l = l + revset.baseset([rev])
                 continue
         except error.RepoLookupError:
             pass
@@ -536,7 +536,7 @@ 
         m = revset.match(repo.ui, spec, repo)
         if seen or l:
             dl = [r for r in m(repo, revset.spanset(repo)) if r not in seen]
-            l = l + dl
+            l = l + revset.baseset(dl)
             seen.update(dl)
         else:
             l = m(repo, revset.spanset(repo))
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -734,6 +734,16 @@ 
   hg: parse error: ^ expects a number 0, 1, or 2
   [255]
 
+multiple revspecs
+
+  $ hg log -r 'tip~1:tip' -r 'tip~2:tip~1' --template '{rev}\n'
+  8
+  9
+  4
+  5
+  6
+  7
+
 aliases:
 
   $ echo '[revsetalias]' >> .hg/hgrc