Patchwork [3,of,3,STABLE] i18n: fix "% inside _()" problems

login
register
mail settings
Submitter Katsunori FUJIWARA
Date March 31, 2014, 6:17 p.m.
Message ID <710e0f772a95cc712978.1396289854@feefifofum>
Download mbox | patch
Permalink /patch/4157/
State Superseded
Commit a45ed365904a2b260c0a63aa3b7e93752fe69761
Headers show

Comments

Katsunori FUJIWARA - March 31, 2014, 6:17 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1396287963 -32400
#      Tue Apr 01 02:46:03 2014 +0900
# Branch stable
# Node ID 710e0f772a95cc7129788fa836cc2d7389f91e1e
# Parent  1a28c327d40f2793356f04c0c54ef34fbcfa4b03
i18n: fix "% inside _()" problems

Before this patch, "contrib/check-code.py" can't detect these
problems, because the regexp pattern to detect "% inside _()" doesn't
suppose the case that format string consists of multiple string
components concatenated implicitly or explicitly,

This patch does below for that regexp pattern to detect "% inside _()"
problems in such case.

  - put "+" into separator part ("[ \t\n]") for explicit concatenation
    ("...." + "...." style)

  - enclose "component and separator" part by "(?:....)+" for
    concatenation itself ("...." "...." or "...." + "....")
Matt Mackall - March 31, 2014, 6:31 p.m.
On Tue, 2014-04-01 at 03:17 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1396287963 -32400
> #      Tue Apr 01 02:46:03 2014 +0900
> # Branch stable
> # Node ID 710e0f772a95cc7129788fa836cc2d7389f91e1e
> # Parent  1a28c327d40f2793356f04c0c54ef34fbcfa4b03
> i18n: fix "% inside _()" problems

Nice. These are queued for stable, thanks.
David Soria Parra - March 31, 2014, 6:40 p.m.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> writes:

> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1396287963 -32400
> #      Tue Apr 01 02:46:03 2014 +0900
> # Branch stable
> # Node ID 710e0f772a95cc7129788fa836cc2d7389f91e1e
> # Parent  1a28c327d40f2793356f04c0c54ef34fbcfa4b03
> i18n: fix "% inside _()" problems
>
> Before this patch, "contrib/check-code.py" can't detect these
> problems, because the regexp pattern to detect "% inside _()" doesn't
> suppose the case that format string consists of multiple string
> components concatenated implicitly or explicitly,
>
> This patch does below for that regexp pattern to detect "% inside _()"
> problems in such case.
>
>   - put "+" into separator part ("[ \t\n]") for explicit concatenation
>     ("...." + "...." style)
>
>   - enclose "component and separator" part by "(?:....)+" for
>     concatenation itself ("...." "...." or "...." + "....")
>

Very nice catch. all 3 queued for stable at
http://hg.netv6.net/hg-fb-reviewers . Thank you.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -198,8 +198,8 @@ 
     (r'\s<>\s', '<> operator is not available in Python 3+, use !='),
     (r'^\s*\t', "don't use tabs"),
     (r'\S;\s*\n', "semicolon"),
-    (r'[^_]_\("[^"]+"[ \t\n]*%', "don't use % inside _()"),
-    (r"[^_]_\('[^']+'[ \t\n]*%", "don't use % inside _()"),
+    (r'[^_]_\((?:"[^"]+"[ \t\n+]*)+%', "don't use % inside _()"),
+    (r"[^_]_\((?:'[^']+'[ \t\n+]*)+%", "don't use % inside _()"),
     (r'(\w|\)),\w', "missing whitespace after ,"),
     (r'(\w|\))[+/*\-<>]\w', "missing whitespace in expression"),
     (r'^\s+(\w|\.)+=\w[^,()\n]*$', "missing whitespace in assignment"),
diff --git a/hgext/eol.py b/hgext/eol.py
--- a/hgext/eol.py
+++ b/hgext/eol.py
@@ -344,7 +344,7 @@ 
                     continue
                 if inconsistenteol(data):
                     raise util.Abort(_("inconsistent newline style "
-                                       "in %s\n" % f))
+                                       "in %s\n") % f)
             return super(eolrepo, self).commitctx(ctx, error)
     repo.__class__ = eolrepo
     repo._hgcleardirstate()
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -711,7 +711,7 @@ 
         if self.exists and self.create:
             if self.copysource:
                 self.ui.warn(_("cannot create %s: destination already "
-                               "exists\n" % self.fname))
+                               "exists\n") % self.fname)
             else:
                 self.ui.warn(_("file %s already exists\n") % self.fname)
             self.rej.append(h)
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1021,7 +1021,7 @@ 
     def remove(self):
         if self.dirty():
             self._ui.warn(_('not removing repo %s because '
-                            'it has changes.\n' % self._path))
+                            'it has changes.\n') % self._path)
             return
         self._ui.note(_('removing subrepo %s\n') % self._path)