Patchwork [1,of,2] upgrade-repo: colorize some of the output

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 29, 2019, 3:51 p.m.
Message ID <55c69c19cb183f2c315c.1575042671@nodosa.octobus.net>
Download mbox | patch
Permalink /patch/43527/
State Superseded
Headers show

Comments

Pierre-Yves David - Nov. 29, 2019, 3:51 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1575038205 -3600
#      Fri Nov 29 15:36:45 2019 +0100
# Node ID 55c69c19cb183f2c315cda4cacfc2d40741cf6e5
# Parent  aef7b91dba51b5f3fad8cf675e0b51b35d0fd5bb
# EXP-Topic sidedata-copies-perf
# Available At https://dev.heptapod.net/octobus/mercurial-devel/
#              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 55c69c19cb18
upgrade-repo: colorize some of the output

Having clear color for requirement added and removed is useful.
Yuya Nishihara - Nov. 30, 2019, 4:46 a.m.
On Fri, 29 Nov 2019 16:51:11 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1575038205 -3600
> #      Fri Nov 29 15:36:45 2019 +0100
> # Node ID 55c69c19cb183f2c315cda4cacfc2d40741cf6e5
> # Parent  aef7b91dba51b5f3fad8cf675e0b51b35d0fd5bb
> # EXP-Topic sidedata-copies-perf
> # Available At https://dev.heptapod.net/octobus/mercurial-devel/
> #              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 55c69c19cb18
> upgrade-repo: colorize some of the output

(I only reviewed this since I don't know the multiprocessing module.)

> diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
> --- a/mercurial/upgrade.py
> +++ b/mercurial/upgrade.py
> @@ -1242,25 +1242,31 @@ def upgraderepo(
>              ui.warn(msg % b', '.join(sorted(incompatible)))
>              revlogs = UPGRADE_ALL_REVLOGS
>  
> +    def write_labeled(l, label):
> +        first = True
> +        for r in sorted(l):
> +            if not first:
> +                ui.write(', ')
> +            ui.write(r, label=label)
> +            first = False
> +
>      def printrequirements():
>          ui.write(_(b'requirements\n'))
> -        ui.write(
> -            _(b'   preserved: %s\n')
> -            % _(b', ').join(sorted(newreqs & repo.requirements))
> +        ui.write(_(b'   preserved: '))
> +        write_labeled(
> +            newreqs & repo.requirements, "upgrade-repo.requirement.preserved"
>          )
> -
> +        ui.write(_('\n'))

> +            ui.write(_('\n'))

Nit: these translation marker is pretty much useless.
Pierre-Yves David - Dec. 2, 2019, 10:44 a.m.
On 11/30/19 5:46 AM, Yuya Nishihara wrote:
> On Fri, 29 Nov 2019 16:51:11 +0100, Pierre-Yves David wrote:
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@octobus.net>
>> # Date 1575038205 -3600
>> #      Fri Nov 29 15:36:45 2019 +0100
>> # Node ID 55c69c19cb183f2c315cda4cacfc2d40741cf6e5
>> # Parent  aef7b91dba51b5f3fad8cf675e0b51b35d0fd5bb
>> # EXP-Topic sidedata-copies-perf
>> # Available At https://dev.heptapod.net/octobus/mercurial-devel/
>> #              hg pull https://dev.heptapod.net/octobus/mercurial-devel/ -r 55c69c19cb18
>> upgrade-repo: colorize some of the output
> 
> (I only reviewed this since I don't know the multiprocessing module.)
> 
>> diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
>> --- a/mercurial/upgrade.py
>> +++ b/mercurial/upgrade.py
>> @@ -1242,25 +1242,31 @@ def upgraderepo(
>>               ui.warn(msg % b', '.join(sorted(incompatible)))
>>               revlogs = UPGRADE_ALL_REVLOGS
>>   
>> +    def write_labeled(l, label):
>> +        first = True
>> +        for r in sorted(l):
>> +            if not first:
>> +                ui.write(', ')
>> +            ui.write(r, label=label)
>> +            first = False
>> +
>>       def printrequirements():
>>           ui.write(_(b'requirements\n'))
>> -        ui.write(
>> -            _(b'   preserved: %s\n')
>> -            % _(b', ').join(sorted(newreqs & repo.requirements))
>> +        ui.write(_(b'   preserved: '))
>> +        write_labeled(
>> +            newreqs & repo.requirements, "upgrade-repo.requirement.preserved"
>>           )
>> -
>> +        ui.write(_('\n'))
> 
>> +            ui.write(_('\n'))
> 
> Nit: these translation marker is pretty much useless.

Ha right. I don't see this change in the committed repository so I am 
sending a v2.

Patch

diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -145,6 +145,9 @@  except ImportError:
     b'status.unknown': b'magenta bold underline',
     b'tags.normal': b'green',
     b'tags.local': b'black bold',
+    b'upgrade-repo.requirement.preserved': b'cyan',
+    b'upgrade-repo.requirement.added': b'green',
+    b'upgrade-repo.requirement.removed': b'red',
 }
 
 
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -1242,25 +1242,31 @@  def upgraderepo(
             ui.warn(msg % b', '.join(sorted(incompatible)))
             revlogs = UPGRADE_ALL_REVLOGS
 
+    def write_labeled(l, label):
+        first = True
+        for r in sorted(l):
+            if not first:
+                ui.write(', ')
+            ui.write(r, label=label)
+            first = False
+
     def printrequirements():
         ui.write(_(b'requirements\n'))
-        ui.write(
-            _(b'   preserved: %s\n')
-            % _(b', ').join(sorted(newreqs & repo.requirements))
+        ui.write(_(b'   preserved: '))
+        write_labeled(
+            newreqs & repo.requirements, "upgrade-repo.requirement.preserved"
         )
-
+        ui.write(_('\n'))
+        removed = repo.requirements - newreqs
         if repo.requirements - newreqs:
-            ui.write(
-                _(b'   removed: %s\n')
-                % _(b', ').join(sorted(repo.requirements - newreqs))
-            )
-
-        if newreqs - repo.requirements:
-            ui.write(
-                _(b'   added: %s\n')
-                % _(b', ').join(sorted(newreqs - repo.requirements))
-            )
-
+            ui.write(_(b'   removed: '))
+            write_labeled(removed, "upgrade-repo.requirement.removed")
+            ui.write(_('\n'))
+        added = newreqs - repo.requirements
+        if added:
+            ui.write(_(b'   added: '))
+            write_labeled(added, "upgrade-repo.requirement.added")
+            ui.write(_('\n'))
         ui.write(b'\n')
 
     def printupgradeactions():