Patchwork [01,of,11] context: add a followfirst flag to blockancestors

login
register
mail settings
Submitter Denis Laxalde
Date Feb. 22, 2017, 3:09 p.m.
Message ID <a65cc4f311cd1aab4502.1487776195@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18712/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Denis Laxalde - Feb. 22, 2017, 3:09 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1484582905 -3600
#      Mon Jan 16 17:08:25 2017 +0100
# Node ID a65cc4f311cd1aab4502811e865a67ef7205c010
# Parent  693a5bb478543a986808264e586073a3ceedc38f
# EXP-Topic linerange-log/hgweb-filelog
context: add a followfirst flag to blockancestors

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1166,7 +1166,7 @@  def _changesrange(fctx1, fctx2, linerang
     diffinrange = any(stype == '!' for _, stype in filteredblocks)
     return diffinrange, linerange1
 
-def blockancestors(fctx, fromline, toline):
+def blockancestors(fctx, fromline, toline, followfirst=False):
     """Yield ancestors of `fctx` with respect to the block of lines within
     `fromline`-`toline` range.
     """
@@ -1175,6 +1175,8 @@  def blockancestors(fctx, fromline, tolin
     while visit:
         c, linerange2 = visit.pop(max(visit))
         pl = c.parents()
+        if followfirst:
+            pl = pl[:1]
         if not pl:
             # The block originates from the initial revision.
             yield c