Patchwork [2,of,2] histedit: use repo.revs() instead of repo.set() where revisions are needed

login
register
mail settings
Submitter Yuya Nishihara
Date Feb. 25, 2018, 2:43 a.m.
Message ID <2e3cb08d7f13f48d6e3c.1519526582@mimosa>
Download mbox | patch
Permalink /patch/28354/
State Accepted
Headers show

Comments

Yuya Nishihara - Feb. 25, 2018, 2:43 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1519525235 -32400
#      Sun Feb 25 11:20:35 2018 +0900
# Node ID 2e3cb08d7f13f48d6e3c499717511ee5e56ebd25
# Parent  03eff66adb3b53f9776628f83b6433ee7b57ee52
histedit: use repo.revs() instead of repo.set() where revisions are needed

Follows up 72da480db4a5. This is just a micro optimization, but looks slightly
nicer.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1354,20 +1354,19 @@  def between(repo, old, new, keep):
     """select and validate the set of revision to edit
 
     When keep is false, the specified set can't have children."""
-    ctxs = list(repo.set('%n::%n', old, new))
-    if ctxs and not keep:
-        revs = [ctx.rev() for ctx in ctxs]
+    revs = repo.revs('%n::%n', old, new)
+    if revs and not keep:
         if (not obsolete.isenabled(repo, obsolete.allowunstableopt) and
             repo.revs('(%ld::) - (%ld)', revs, revs)):
             raise error.Abort(_('can only histedit a changeset together '
                                 'with all its descendants'))
         if repo.revs('(%ld) and merge()', revs):
             raise error.Abort(_('cannot edit history that contains merges'))
-        root = ctxs[0] # list is already sorted by repo.set
+        root = repo[revs.first()]  # list is already sorted by repo.revs()
         if not root.mutable():
             raise error.Abort(_('cannot edit public changeset: %s') % root,
                              hint=_("see 'hg help phases' for details"))
-    return [c.node() for c in ctxs]
+    return pycompat.maplist(repo.changelog.node, revs)
 
 def ruleeditor(repo, ui, actions, editcomment=""):
     """open an editor to edit rules