upgrade-repo: colorize some of the output
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 29 Nov 2019 15:36:45 +0100
changeset 43823 ad84fc97d120
parent 43822 76d32a0edbc6
child 43824 acbb55b8e9dc
upgrade-repo: colorize some of the output Having clear color for requirement added and removed is useful.
mercurial/color.py
mercurial/upgrade.py
--- a/mercurial/color.py	Fri Dec 06 15:30:06 2019 +0100
+++ b/mercurial/color.py	Fri Nov 29 15:36:45 2019 +0100
@@ -145,6 +145,9 @@
     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',
 }
 
 
--- a/mercurial/upgrade.py	Fri Dec 06 15:30:06 2019 +0100
+++ b/mercurial/upgrade.py	Fri Nov 29 15:36:45 2019 +0100
@@ -1242,25 +1242,31 @@
             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(b', ')
+            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((b'\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((b'\n'))
+        added = newreqs - repo.requirements
+        if added:
+            ui.write(_(b'   added: '))
+            write_labeled(added, "upgrade-repo.requirement.added")
+            ui.write((b'\n'))
         ui.write(b'\n')
 
     def printupgradeactions():