[PATCH 1 of 5] paths: drop ui.status label from output of "hg paths name"

Matt Mackall mpm at selenic.com
Tue Jan 12 14:46:10 CST 2016

On Sat, 2016-01-09 at 18:45 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1450011240 -32400
> #      Sun Dec 13 21:54:00 2015 +0900
> # Node ID 16099841acaa4fa42dffa994b9ac9e16c89a43be
> # Parent  0db7943a4e1f843814865dc1b2cb22b994acc74f
> paths: drop ui.status label from output of "hg paths name"
> We just need to not print path if --quiet. ui.status label is unwanted.


My guess is: we don't have a problem with the label but the formatter doesn't
support "status" and "note" output levels. That's probably a weakness of the
formatter API. Yep:

$ hgrep condwrite
mercurial/commands.py:            fm.condwrite(not ui.quiet, 'rev node', pad + '
mercurial/commands.py:        fm.condwrite(not ui.quiet, 'rev node', fmt, rev,
mercurial/commands.py:        fm.condwrite(ui.verbose and extsource, 'source',
mercurial/commands.py:        fm.condwrite(ui.verbose and exttestedwith,
mercurial/commands.py:        fm.condwrite(ui.verbose and extbuglink, 'buglink',
mercurial/commands.py:        fm.condwrite(ui.debugflag, 'hash', '%s ',
mercurial/commands.py:        fm.condwrite(ui.verbose, 'mode type', '%s %1s ',
mode[fl], char[fl])
mercurial/commands.py:            fm.condwrite(not nostatus, 'status', '%s ',
ms[f].upper(), label=l)
mercurial/commands.py:                fm.condwrite(showchar, 'status', '%s ',
char, label=label)
mercurial/commands.py:        fm.condwrite(not ui.quiet, 'rev node', fmt,
mercurial/commands.py:        fm.condwrite(ui.verbose and tagtype, 'type', '

Most of the use of fm.condwrite is to deal with the lack of ui.status/ui.note

We should probably actually have these components available to the templater
regardless of verbosity level (though debug is a different matter, because it's
usually expensive). We should probably do something like this:

diff -r c36fa631cb6e mercurial/formatter.py
--- a/mercurial/formatter.py	Sun Dec 13 21:54:00 2015 +0900
+++ b/mercurial/formatter.py	Tue Jan 12 14:45:00 2016 -0600
@@ -51,6 +51,12 @@
         fieldkeys = fields.split()
         assert len(fieldkeys) == len(fielddata)
         self._item.update(zip(fieldkeys, fielddata))
+    def status(self, fields, deftext, *fielddata, **opts):
+        '''do status-level text output while assigning data to item'''
+        self.write(fields, deftext, *fielddata, **opts)
+    def note(self, fields, deftext, *fielddata, **opts):
+        '''do verbose text output while assigning data to item'''
+        self.write(fields, deftext, *fielddata, **opts)
     def condwrite(self, cond, fields, deftext, *fielddata, **opts):
         '''do conditional write (primarily for plain formatter)'''
         fieldkeys = fields.split()
@@ -80,6 +86,10 @@
     def write(self, fields, deftext, *fielddata, **opts):
         self._ui.write(deftext % fielddata, **opts)
+    def status(self, fields, deftext, *fielddata, **opts):
+        self._ui.status(deftext % fielddata, **opts)
+    def note(self, fields, deftext, *fielddata, **opts):
+        self._ui.note(deftext % fielddata, **opts)
     def condwrite(self, cond, fields, deftext, *fielddata, **opts):
         '''do conditional write'''
         if cond:
Mathematics is the supreme nostalgia of our time.

More information about the Mercurial-devel mailing list