[PATCH 4 of 5] keyword, i18n: avoid untranslated strings as message parameters

Christian Ebert blacktrash at gmx.net
Tue Apr 21 03:47:52 CDT 2009


Hi Wagner,

* Wagner Bruna on Tuesday, April 21, 2009 at 07:28:31 +0000
> # HG changeset patch
> # User Wagner Bruna <wbruna at yahoo.com>
> # Date 1240272973 10800
> # Node ID 67efe5e3b0fba18688942411deb7338f8ae1aa2d
> # Parent  bdeb380a10dedd2e284e694f1e1b8d9fb11fd24f
> keyword, i18n: avoid untranslated strings as message parameters
> 
> diff --git a/hgext/keyword.py b/hgext/keyword.py
> --- a/hgext/keyword.py
> +++ b/hgext/keyword.py
> @@ -177,7 +177,6 @@
>         candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
>         if candidates:
>             self.restrict = True # do not expand when reading
> -            action = expand and 'expanding' or 'shrinking'

Good catch. I looked when the i18 thing came up, but overlooked.

>             for f in candidates:
>                 fp = self.repo.file(f)
>                 data = fp.read(mf[f])
> @@ -191,7 +190,11 @@
>                 else:
>                     found = self.re_kw.search(data)
>                 if found:
> -                    notify(_('overwriting %s %s keywords\n') % (f, action))
> +                    if expand:
> +                        msg = _('overwriting %s expanding keywords\n')
> +                    else:
> +                        msg = _('overwriting %s shrinking keywords\n')
> +                    notify(msg % f)
>                     self.repo.wwrite(f, data, mf.flags(f))
>                     self.repo.dirstate.normal(f)
>             self.restrict = False

Can we keep the setting of "msg" where "action" was set to avoid
an if-switch for every file?

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -177,7 +177,8 @@
         candidates = [f for f in files if self.iskwfile(f, ctx.flags)]
         if candidates:
             self.restrict = True # do not expand when reading
-            action = expand and 'expanding' or 'shrinking'
+            msg = (expand and _('overwriting %s expanding keywords\n')
+                   or _('overwriting %s shrinking keywords\n'))
             for f in candidates:
                 fp = self.repo.file(f)
                 data = fp.read(mf[f])
@@ -191,7 +192,7 @@
                 else:
                     found = self.re_kw.search(data)
                 if found:
-                    notify(_('overwriting %s %s keywords\n') % (f, action))
+                    notify(msg % f)
                     self.repo.wwrite(f, data, mf.flags(f))
                     self.repo.dirstate.normal(f)
             self.restrict = False



Again, thanks for catching this.

c
-- 
  Was heißt hier Dogma, ich bin Underdogma!
[ What the hell do you mean dogma, I am underdogma. ]
_F R E E_  _V I D E O S_  http://www.blacktrash.org/underdogma/
                          http://www.blacktrash.org/underdogma/index-en.html


More information about the Mercurial-devel mailing list