Patchwork [2,of,2] phases: micro-optimize newheads() to not create context objects

login
register
mail settings
Submitter Yuya Nishihara
Date July 14, 2018, 5:43 a.m.
Message ID <503d14253b22603b1f76.1531546983@mimosa>
Download mbox | patch
Permalink /patch/32843/
State Accepted
Headers show

Comments

Yuya Nishihara - July 14, 2018, 5:43 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1531542109 -32400
#      Sat Jul 14 13:21:49 2018 +0900
# Node ID 503d14253b22603b1f76c80dd6b89b6ebcfe5e06
# Parent  c8f181c48ae26247478aea82c8d2ab2f886831f9
phases: micro-optimize newheads() to not create context objects
via Mercurial-devel - July 16, 2018, 6:04 a.m.
On Fri, Jul 13, 2018 at 10:43 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1531542109 -32400
> #      Sat Jul 14 13:21:49 2018 +0900
> # Node ID 503d14253b22603b1f76c80dd6b89b6ebcfe5e06
> # Parent  c8f181c48ae26247478aea82c8d2ab2f886831f9
> phases: micro-optimize newheads() to not create context objects


Queued these, thanks.

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -665,9 +665,8 @@  def newheads(repo, heads, roots):
     * `heads`: define the first subset
     * `roots`: define the second we subtract from the first"""
     repo = repo.unfiltered()
-    revset = repo.set('heads(::%ln - (%ln::%ln))', heads, roots, heads)
-    return [c.node() for c in revset]
-
+    revs = repo.revs('heads(::%ln - (%ln::%ln))', heads, roots, heads)
+    return pycompat.maplist(repo.changelog.node, revs)
 
 def newcommitphase(ui):
     """helper to get the target phase of new commit