Patchwork [9,of,9,v2] hidden: remove unnecessary guard condition

login
register
mail settings
Submitter via Mercurial-devel
Date May 30, 2017, 8:29 p.m.
Message ID <67bf929e29e4c8cf7e82.1496176176@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21083/
State Accepted
Headers show

Comments

via Mercurial-devel - May 30, 2017, 8:29 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1496175392 25200
#      Tue May 30 13:16:32 2017 -0700
# Node ID 67bf929e29e4c8cf7e824cc49d6bd271e1d78a86
# Parent  b3db386713b83543ad3b966a59caae359f0b67b4
hidden: remove unnecessary guard condition

The "if visible" guard is now pretty pointless, because the function
call it guards will do almost no work anyway when there are no visible
revisions.

We can also stop wrapping "visible" in a set since it just needs to be
an iterable now.
Augie Fackler - May 31, 2017, 6:31 p.m.
On Tue, May 30, 2017 at 01:29:36PM -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1496175392 25200
> #      Tue May 30 13:16:32 2017 -0700
> # Node ID 67bf929e29e4c8cf7e824cc49d6bd271e1d78a86
> # Parent  b3db386713b83543ad3b966a59caae359f0b67b4
> hidden: remove unnecessary guard condition

Very nice cleanup, queued the lot. Thanks!

(I did add one (API) flag on patch 2, since it seemed like it should
get some extra visibility to potential clients.)

>
> The "if visible" guard is now pretty pointless, because the function
> call it guards will do almost no work anyway when there are no visible
> revisions.
>
> We can also stop wrapping "visible" in a set since it just needs to be
> an iterable now.
>
> diff --git a/mercurial/repoview.py b/mercurial/repoview.py
> --- a/mercurial/repoview.py
> +++ b/mercurial/repoview.py
> @@ -76,9 +76,8 @@
>          mutablephases = (phases.draft, phases.secret)
>          mutable = repo._phasecache.getrevset(repo, mutablephases)
>
> -        visible = set(mutable - hidden)
> -        if visible:
> -            _revealancestors(pfunc, hidden, visible)
> +        visible = mutable - hidden
> +        _revealancestors(pfunc, hidden, visible)
>      return frozenset(hidden)
>
>  def computeunserved(repo):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
via Mercurial-devel - June 1, 2017, 4:04 a.m.
On Wed, May 31, 2017 at 11:31 AM, Augie Fackler <raf@durin42.com> wrote:
> On Tue, May 30, 2017 at 01:29:36PM -0700, Martin von Zweigbergk via Mercurial-devel wrote:
>> # HG changeset patch
>> # User Martin von Zweigbergk <martinvonz@google.com>
>> # Date 1496175392 25200
>> #      Tue May 30 13:16:32 2017 -0700
>> # Node ID 67bf929e29e4c8cf7e824cc49d6bd271e1d78a86
>> # Parent  b3db386713b83543ad3b966a59caae359f0b67b4
>> hidden: remove unnecessary guard condition
>
> Very nice cleanup, queued the lot. Thanks!
>
> (I did add one (API) flag on patch 2, since it seemed like it should
> get some extra visibility to potential clients.)

Makes sense. I know remotefilelog will have to update, because I saw
as recently as today that they just migrated *to* revealedrevs().
Sorry, Jun et al.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -76,9 +76,8 @@ 
         mutablephases = (phases.draft, phases.secret)
         mutable = repo._phasecache.getrevset(repo, mutablephases)
 
-        visible = set(mutable - hidden)
-        if visible:
-            _revealancestors(pfunc, hidden, visible)
+        visible = mutable - hidden
+        _revealancestors(pfunc, hidden, visible)
     return frozenset(hidden)
 
 def computeunserved(repo):