Patchwork [12,of,12] upgrade: simplify the "origin" dispatch in dry run

login
register
mail settings
Submitter Pierre-Yves David
Date April 11, 2017, 10:47 p.m.
Message ID <b75621ae42efc24c55d1.1491950872@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/20123/
State Accepted
Headers show

Comments

Pierre-Yves David - April 11, 2017, 10:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1491861791 -7200
#      Tue Apr 11 00:03:11 2017 +0200
# Node ID b75621ae42efc24c55d15f064f44137197b06608
# Parent  ed384e9f47907a7521e33012a5cf6f15053f23d3
# EXP-Topic upgraderepo
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r b75621ae42ef
upgrade: simplify the "origin" dispatch in dry run

We could compute the final set we need directly.
Ryan McElroy - April 12, 2017, 11:52 a.m.
On 4/11/17 11:47 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1491861791 -7200
> #      Tue Apr 11 00:03:11 2017 +0200
> # Node ID b75621ae42efc24c55d15f064f44137197b06608
> # Parent  ed384e9f47907a7521e33012a5cf6f15053f23d3
> # EXP-Topic upgraderepo
> upgrade: simplify the "origin" dispatch in dry run

This series looks like a nice cleanup and a good overall win for clarity 
to me.

There are a couple of english nitpicks I had that could easily be fixed 
in flight. So I'll mark as pre-reviewed in patchwork.

>
> We could compute the final set we need directly.
>
> diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
> --- a/mercurial/upgrade.py
> +++ b/mercurial/upgrade.py
> @@ -664,19 +664,16 @@ def upgraderepo(ui, repo, run=False, opt
>               ui.write('%s\n   %s\n\n' % (a.name, a.upgrademessage))
>   
>       if not run:
> -        fromdefault = []
>           fromconfig = []
> +        onlydefault = []
>   
>           for d in deficiencies:
> -            if d.fromdefault:
> -                fromdefault.append(d)
>               if d.fromconfig:
>                   fromconfig.append(d)
> +            elif d.fromdefault:
> +                onlydefault.append(d)
>   
> -        if fromdefault or fromconfig:
> -            fromconfignames = set(x.name for x in fromconfig)
> -            onlydefault = [i for i in fromdefault
> -                           if i.name not in fromconfignames]
> +        if fromconfig or onlydefault:
>   
>               if fromconfig:
>                   ui.write(_('repository lacks features recommended by '
>
Augie Fackler - April 12, 2017, 8:21 p.m.
On Wed, Apr 12, 2017 at 12:47:52AM +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
> # Date 1491861791 -7200
> #      Tue Apr 11 00:03:11 2017 +0200
> # Node ID b75621ae42efc24c55d15f064f44137197b06608
> # Parent  ed384e9f47907a7521e33012a5cf6f15053f23d3
> # EXP-Topic upgraderepo
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r b75621ae42ef
> upgrade: simplify the "origin" dispatch in dry run

queued, thanks

Patch

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -664,19 +664,16 @@  def upgraderepo(ui, repo, run=False, opt
             ui.write('%s\n   %s\n\n' % (a.name, a.upgrademessage))
 
     if not run:
-        fromdefault = []
         fromconfig = []
+        onlydefault = []
 
         for d in deficiencies:
-            if d.fromdefault:
-                fromdefault.append(d)
             if d.fromconfig:
                 fromconfig.append(d)
+            elif d.fromdefault:
+                onlydefault.append(d)
 
-        if fromdefault or fromconfig:
-            fromconfignames = set(x.name for x in fromconfig)
-            onlydefault = [i for i in fromdefault
-                           if i.name not in fromconfignames]
+        if fromconfig or onlydefault:
 
             if fromconfig:
                 ui.write(_('repository lacks features recommended by '