Patchwork [1,of,3] context: drop a superfluous "if" clause in blockdescendants()

login
register
mail settings
Submitter Denis Laxalde
Date April 14, 2017, 1:03 p.m.
Message ID <45c2968ee4ed385aa6ab.1492175034@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/20202/
State Accepted
Headers show

Comments

Denis Laxalde - April 14, 2017, 1:03 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1492171660 -7200
#      Fri Apr 14 14:07:40 2017 +0200
# Node ID 45c2968ee4ed385aa6ab64b7136a38180ca03ec5
# Parent  b1fe2c5dd2c65a3774c848e0113b8fdf82e4bd95
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 45c2968ee4ed
context: drop a superfluous "if" clause in blockdescendants()

This `i in seen` should not occur since 'i' comes from filelog.descendants()
which yields unique revisions.
Yuya Nishihara - April 14, 2017, 2:34 p.m.
On Fri, 14 Apr 2017 15:03:54 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@logilab.fr>
> # Date 1492171660 -7200
> #      Fri Apr 14 14:07:40 2017 +0200
> # Node ID 45c2968ee4ed385aa6ab64b7136a38180ca03ec5
> # Parent  b1fe2c5dd2c65a3774c848e0113b8fdf82e4bd95
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 45c2968ee4ed
> context: drop a superfluous "if" clause in blockdescendants()
> 
> This `i in seen` should not occur since 'i' comes from filelog.descendants()
> which yields unique revisions.
> 
> diff --git a/mercurial/context.py b/mercurial/context.py
> --- a/mercurial/context.py
> +++ b/mercurial/context.py
> @@ -1216,8 +1216,6 @@ def blockdescendants(fctx, fromline, tol
>      fl = fctx.filelog()
>      seen = {fctx.filerev(): (fctx, (fromline, toline))}
>      for i in fl.descendants([fctx.filerev()]):
> -        if i in seen:
> -            continue

I've folded this with the previous patch, thanks. I'll look into the remainder
tomorrow. I need to refresh my brain.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1216,8 +1216,6 @@  def blockdescendants(fctx, fromline, tol
     fl = fctx.filelog()
     seen = {fctx.filerev(): (fctx, (fromline, toline))}
     for i in fl.descendants([fctx.filerev()]):
-        if i in seen:
-            continue
         c = fctx.filectx(i)
         inrange = False
         for x in fl.parentrevs(i):