Patchwork [2,of,2] sparse: use named parameters in i18n strings

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 4, 2018, 12:14 p.m.
Message ID <6be3eb0c37638c886c81.1533384866@mimosa>
Download mbox | patch
Permalink /patch/33234/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 4, 2018, 12:14 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1533370651 -32400
#      Sat Aug 04 17:17:31 2018 +0900
# Node ID 6be3eb0c37638c886c8113a7cf51d9c69b40fcb9
# Parent  b2afb0058fd7143c12cb6ef3466ec85ee71ba8ce
sparse: use named parameters in i18n strings

This should give more hints about what the %s means, and allow reordering.

Patch

diff --git a/mercurial/sparse.py b/mercurial/sparse.py
--- a/mercurial/sparse.py
+++ b/mercurial/sparse.py
@@ -56,8 +56,8 @@  def parseconfig(ui, raw, action):
         elif line == '[include]':
             if havesection and current != includes:
                 # TODO pass filename into this API so we can report it.
-                raise error.Abort(_('%s config cannot have includes '
-                                    'after excludes') % action)
+                raise error.Abort(_('%(action)s config cannot have includes '
+                                    'after excludes') % {'action': action})
             havesection = True
             current = includes
             continue
@@ -66,15 +66,16 @@  def parseconfig(ui, raw, action):
             current = excludes
         elif line:
             if current is None:
-                raise error.Abort(_('%s config entry outside of '
-                                    'section: %s') % (action, line),
+                raise error.Abort(_('%(action)s config entry outside of '
+                                    'section: %(line)s')
+                                  % {'action': action, 'line': line},
                                   hint=_('add an [include] or [exclude] line '
                                          'to declare the entry type'))
 
             if line.strip().startswith('/'):
-                ui.warn(_('warning: %s profile cannot use'
-                          ' paths starting with /, ignoring %s\n')
-                        % (action, line))
+                ui.warn(_('warning: %(action)s profile cannot use'
+                          ' paths starting with /, ignoring %(line)s\n')
+                        % {'action': action, 'line': line})
                 continue
             current.add(line)