Patchwork [2,of,5] revsets: remove unnecessary calls to baseset(set).sort()

login
register
mail settings
Submitter via Mercurial-devel
Date June 24, 2016, 10:10 p.m.
Message ID <452eef4be6b5acbde6b0.1466806214@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/15608/
State Changes Requested
Headers show

Comments

via Mercurial-devel - June 24, 2016, 10:10 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1466712488 25200
#      Thu Jun 23 13:08:08 2016 -0700
# Node ID 452eef4be6b5acbde6b0fd988f6aab27a1c144d1
# Parent  070b3c85eaa93617508e0b4a69e724546566e2b6
revsets: remove unnecessary calls to baseset(set).sort()

Since 69c6e9623bdc (revset: force ascending order for baseset
initialized from a set, 2016-04-04), basesets created from a set are
already sorted.
Yuya Nishihara - June 25, 2016, 3:39 a.m.
On Fri, 24 Jun 2016 15:10:14 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1466712488 25200
> #      Thu Jun 23 13:08:08 2016 -0700
> # Node ID 452eef4be6b5acbde6b0fd988f6aab27a1c144d1
> # Parent  070b3c85eaa93617508e0b4a69e724546566e2b6
> revsets: remove unnecessary calls to baseset(set).sort()
> 
> Since 69c6e9623bdc (revset: force ascending order for baseset
> initialized from a set, 2016-04-04), basesets created from a set are
> already sorted.
> 
> diff -r 070b3c85eaa9 -r 452eef4be6b5 mercurial/revset.py
> --- a/mercurial/revset.py	Thu Jun 23 12:39:05 2016 -0700
> +++ b/mercurial/revset.py	Thu Jun 23 13:08:08 2016 -0700
> @@ -140,9 +140,7 @@
>          revs = repo.changelog.reachableroots(minroot, heads, roots, includepath)
>      except AttributeError:
>          revs = _reachablerootspure(repo, minroot, roots, heads, includepath)
> -    revs = baseset(revs)
> -    revs.sort()
> -    return revs
> +    return baseset(revs)

C implementation returns a list of revisions, which isn't always sorted in
ascending order.

Patch

diff -r 070b3c85eaa9 -r 452eef4be6b5 mercurial/revset.py
--- a/mercurial/revset.py	Thu Jun 23 12:39:05 2016 -0700
+++ b/mercurial/revset.py	Thu Jun 23 13:08:08 2016 -0700
@@ -140,9 +140,7 @@ 
         revs = repo.changelog.reachableroots(minroot, heads, roots, includepath)
     except AttributeError:
         revs = _reachablerootspure(repo, minroot, roots, heads, includepath)
-    revs = baseset(revs)
-    revs.sort()
-    return revs
+    return baseset(revs)
 
 elements = {
     # token-type: binding-strength, primary, prefix, infix, suffix
@@ -1541,7 +1539,6 @@ 
     if repo._phasecache._phasesets:
         s = repo._phasecache._phasesets[target] - repo.changelog.filteredrevs
         s = baseset(s)
-        s.sort() # set are non ordered, so we enforce ascending
         return subset & s
     else:
         phase = repo._phasecache.phase
@@ -1614,7 +1611,6 @@ 
         for u in repo._phasecache._phasesets[1:]:
             s.update(u)
         s = baseset(s - repo.changelog.filteredrevs)
-        s.sort()
         return subset & s
     else:
         phase = repo._phasecache.phase