From patchwork Sun Feb 25 02:43:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 2] histedit: use repo.revs() instead of repo.set() where revisions are needed From: Yuya Nishihara X-Patchwork-Id: 28354 Message-Id: <2e3cb08d7f13f48d6e3c.1519526582@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sun, 25 Feb 2018 11:43:02 +0900 # HG changeset patch # User Yuya Nishihara # 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. 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