Patchwork [1,of,6] ancestor: remove alias of initrevs from _lazyancestorsiter()

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 11, 2018, 11:02 p.m.
Message ID <2989618d644ce4694a32.1536706926@mimosa>
Download mbox | patch
Permalink /patch/34503/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 11, 2018, 11:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1536673112 -32400
#      Tue Sep 11 22:38:32 2018 +0900
# Node ID 2989618d644ce4694a3288f8f20107f446703f66
# Parent  a1b6b1fcfd29503e8cb9c8cef617571334a69339
ancestor: remove alias of initrevs from _lazyancestorsiter()

It's just redundant and less comprehensible.
Gregory Szorc - Sept. 11, 2018, 11:33 p.m.
On Tue, Sep 11, 2018 at 4:10 PM Yuya Nishihara <yuya@tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1536673112 -32400
> #      Tue Sep 11 22:38:32 2018 +0900
> # Node ID 2989618d644ce4694a3288f8f20107f446703f66
> # Parent  a1b6b1fcfd29503e8cb9c8cef617571334a69339
> ancestor: remove alias of initrevs from _lazyancestorsiter()
>

Queued, thanks.


>
> It's just redundant and less comprehensible.
>
> diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
> --- a/mercurial/ancestor.py
> +++ b/mercurial/ancestor.py
> @@ -262,20 +262,18 @@ class incrementalmissingancestors(object
>  # Extracted from lazyancestors.__iter__ to avoid a reference cycle
>  def _lazyancestorsiter(parentrevs, initrevs, stoprev, inclusive):
>      seen = {nullrev}
> -    revs = initrevs
> -
>      schedule = heapq.heappush
>      nextitem = heapq.heappop
>      see = seen.add
>
>      if inclusive:
> -        visit = [-r for r in revs]
> -        seen.update(revs)
> +        visit = [-r for r in initrevs]
> +        seen.update(initrevs)
>          heapq.heapify(visit)
>      else:
>          visit = []
>          heapq.heapify(visit)
> -        for r in revs:
> +        for r in initrevs:
>              for parent in parentrevs(r):
>                  if parent not in seen:
>                      schedule(visit, -parent)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py
--- a/mercurial/ancestor.py
+++ b/mercurial/ancestor.py
@@ -262,20 +262,18 @@  class incrementalmissingancestors(object
 # Extracted from lazyancestors.__iter__ to avoid a reference cycle
 def _lazyancestorsiter(parentrevs, initrevs, stoprev, inclusive):
     seen = {nullrev}
-    revs = initrevs
-
     schedule = heapq.heappush
     nextitem = heapq.heappop
     see = seen.add
 
     if inclusive:
-        visit = [-r for r in revs]
-        seen.update(revs)
+        visit = [-r for r in initrevs]
+        seen.update(initrevs)
         heapq.heapify(visit)
     else:
         visit = []
         heapq.heapify(visit)
-        for r in revs:
+        for r in initrevs:
             for parent in parentrevs(r):
                 if parent not in seen:
                     schedule(visit, -parent)