Patchwork [1,of,4] addremove: add labels for messages about added and removed files

login
register
mail settings
Submitter Boris Feld
Date Aug. 14, 2018, 3:13 p.m.
Message ID <4c46bfaba3767b33a7c2.1534259587@FB-lair>
Download mbox | patch
Permalink /patch/33717/
State Accepted
Headers show

Comments

Boris Feld - Aug. 14, 2018, 3:13 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1532531512 -7200
#      Wed Jul 25 17:11:52 2018 +0200
# Node ID 4c46bfaba3767b33a7c29c9ceb3dde57ba5d9653
# Parent  d99468d2b09acc8f5c6c5ce5c1b08b47a742841f
# EXP-Topic addremovelabel
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4c46bfaba376
addremove: add labels for messages about added and removed files

This is the first step to add color for add and remove output.
Gregory Szorc - Aug. 14, 2018, 8:53 p.m.
On Tue, Aug 14, 2018 at 8:13 AM, Boris Feld <boris.feld@octobus.net> wrote:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1532531512 -7200
> #      Wed Jul 25 17:11:52 2018 +0200
> # Node ID 4c46bfaba3767b33a7c29c9ceb3dde57ba5d9653
> # Parent  d99468d2b09acc8f5c6c5ce5c1b08b47a742841f
> # EXP-Topic addremovelabel
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 4c46bfaba376
> addremove: add labels for messages about added and removed files
>

Queued this series.

Thanks for the new feature!


>
> This is the first step to add color for add and remove output.
>
> diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -1005,9 +1005,11 @@ def addremove(repo, matcher, prefix, opt
>          if repo.ui.verbose or not m.exact(abs):
>              if abs in unknownset:
>                  status = _('adding %s\n') % m.uipath(abs)
> +                label = 'addremove.added'
>              else:
>                  status = _('removing %s\n') % m.uipath(abs)
> -            repo.ui.status(status)
> +                label = 'addremove.removed'
> +            repo.ui.status(status, label=label)
>
>      renames = _findrenames(repo, m, added + unknown, removed + deleted,
>                             similarity)
> diff --git a/tests/test-addremove.t b/tests/test-addremove.t
> --- a/tests/test-addremove.t
> +++ b/tests/test-addremove.t
> @@ -69,6 +69,12 @@
>    removing c
>    adding d
>    recording removal of a as rename to b (100% similar)
> +  $ hg addremove -ns 50 --color debug
> +  [addremove.removed ui.status|removing a]
> +  [addremove.added ui.status|adding b]
> +  [addremove.removed ui.status|removing c]
> +  [addremove.added ui.status|adding d]
> +  [ ui.status|recording removal of a as rename to b (100% similar)]
>    $ hg addremove -s 50
>    removing a
>    adding b
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1005,9 +1005,11 @@  def addremove(repo, matcher, prefix, opt
         if repo.ui.verbose or not m.exact(abs):
             if abs in unknownset:
                 status = _('adding %s\n') % m.uipath(abs)
+                label = 'addremove.added'
             else:
                 status = _('removing %s\n') % m.uipath(abs)
-            repo.ui.status(status)
+                label = 'addremove.removed'
+            repo.ui.status(status, label=label)
 
     renames = _findrenames(repo, m, added + unknown, removed + deleted,
                            similarity)
diff --git a/tests/test-addremove.t b/tests/test-addremove.t
--- a/tests/test-addremove.t
+++ b/tests/test-addremove.t
@@ -69,6 +69,12 @@ 
   removing c
   adding d
   recording removal of a as rename to b (100% similar)
+  $ hg addremove -ns 50 --color debug
+  [addremove.removed ui.status|removing a]
+  [addremove.added ui.status|adding b]
+  [addremove.removed ui.status|removing c]
+  [addremove.added ui.status|adding d]
+  [ ui.status|recording removal of a as rename to b (100% similar)]
   $ hg addremove -s 50
   removing a
   adding b