changeset 40401:6bd477ee7294

logtoprocess: fix message formatting The logtoprocess used to try formatting the message using keyword options instead of always using the rest of the arguments. Update it to match blackbox behavior. Differential Revision: https://phab.mercurial-scm.org/D5180
author Boris Feld <boris.feld@octobus.net>
date Mon, 22 Oct 2018 15:47:30 +0200
parents db0dba2d157d
children 106adc261492
files hgext/logtoprocess.py tests/test-logtoprocess.t
diffstat 2 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/logtoprocess.py	Sat Aug 18 01:44:38 2018 +0200
+++ b/hgext/logtoprocess.py	Mon Oct 22 15:47:30 2018 +0200
@@ -113,10 +113,8 @@
                     # try to format the log message given the remaining
                     # arguments
                     try:
-                        # Python string formatting with % either uses a
-                        # dictionary *or* tuple, but not both. If we have
-                        # keyword options, assume we need a mapping.
-                        formatted = msg[0] % (opts or msg[1:])
+                        # Format the message as blackbox does
+                        formatted = msg[0] % msg[1:]
                     except (TypeError, KeyError):
                         # Failed to apply the arguments, ignore
                         formatted = msg[0]
--- a/tests/test-logtoprocess.t	Sat Aug 18 01:44:38 2018 +0200
+++ b/tests/test-logtoprocess.t	Mon Oct 22 15:47:30 2018 +0200
@@ -19,7 +19,7 @@
   > )
   > @command(b'foo', [])
   > def foo(ui, repo):
-  >     ui.log('foo', 'a message: %(bar)s\n', bar='spam')
+  >     ui.log('foo', 'a message: %s\n', 'spam')
   > EOF
   $ cp $HGRCPATH $HGRCPATH.bak
   $ cat >> $HGRCPATH << EOF
@@ -39,7 +39,7 @@
   > foo=(echo 'logtoprocess foo output:';
   >     echo "\$EVENT";
   >     echo "\$MSG1";
-  >     echo "\$OPT_BAR") > $TESTTMP/foo.log
+  >     echo "\$MSG2") > $TESTTMP/foo.log
   > EOF
 
 Running a command triggers both a ui.log('command') and a