Patchwork [2,of,7] dagop: comment why revancestors() doesn't heapify input revs at once

login
register
mail settings
Submitter Yuya Nishihara
Date June 22, 2017, 3:52 p.m.
Message ID <2288ecd79fca3e8ac9a6.1498146735@mimosa>
Download mbox | patch
Permalink /patch/21613/
State Accepted
Headers show

Comments

Yuya Nishihara - June 22, 2017, 3:52 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1497773762 -32400
#      Sun Jun 18 17:16:02 2017 +0900
# Node ID 2288ecd79fca3e8ac9a6211b81410c8d78271add
# Parent  a8dd4bd0604af65ee06cd942e9af4b7971725f43
dagop: comment why revancestors() doesn't heapify input revs at once

I wondered why we're doing this complicated stuff without noticing the input
revs may be iterated lazily in descending order. c1f666e27345 showed why.

Patch

diff --git a/mercurial/dagop.py b/mercurial/dagop.py
--- a/mercurial/dagop.py
+++ b/mercurial/dagop.py
@@ -26,6 +26,9 @@  def _genrevancestors(repo, revs, followf
     else:
         cut = None
     cl = repo.changelog
+
+    # load input revs lazily to heap so earlier revisions can be yielded
+    # without fully computing the input revs
     revs.sort(reverse=True)
     irevs = iter(revs)
     h = []