Patchwork revset-head: use '&' instead of '.filter'

login
register
mail settings
Submitter Pierre-Yves David
Date June 20, 2015, 5:37 a.m.
Message ID <6eb0d76caf48d4ddc6e8.1434778626@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9725/
State Accepted
Headers show

Comments

Pierre-Yves David - June 20, 2015, 5:37 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1412987409 25200
#      Fri Oct 10 17:30:09 2014 -0700
# Node ID 6eb0d76caf48d4ddc6e8d2148540b941f02223b1
# Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
revset-head: use '&' instead of '.filter'

More high level operations are more likely to be optimised.
Matt Mackall - June 20, 2015, 7:54 p.m.
On Fri, 2015-06-19 at 22:37 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1412987409 25200
> #      Fri Oct 10 17:30:09 2014 -0700
> # Node ID 6eb0d76caf48d4ddc6e8d2148540b941f02223b1
> # Parent  2748bf78a5bf610da4f2d90fd1eea19a3b360c04
> revset-head: use '&' instead of '.filter'

Queued for default, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1107,14 +1107,13 @@  def head(repo, subset, x):
     cl = repo.changelog
     for b, ls in repo.branchmap().iteritems():
         hs.update(cl.rev(h) for h in ls)
     # XXX using a set to feed the baseset is wrong. Sets are not ordered.
     # This does not break because of other fullreposet misbehavior.
-    # XXX We should not be using '.filter' here, but combines subset with '&'
     # XXX We should combine with subset first: 'subset & baseset(...)'. This is
     # necessary to ensure we preserve the order in subset.
-    return baseset(hs).filter(subset.__contains__)
+    return baseset(hs) & subset
 
 def heads(repo, subset, x):
     """``heads(set)``
     Members of set with no children in set.
     """