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 the format string and "%" aren't placed in the
same line.
This patch replaces "\s" in that regexp pattern with "[ \t\n]" to
detect "% inside _()" problems in such case.
"[\s\n]" can't be used in this purpose, because "\s" is automatically
replaced with "[ \t]" by "_preparepats()" and "\s" in "[]" causes
nested "[]" unexpectedly.
--- a/contrib/check-code.py Tue Apr 01 02:46:03 2014 +0900
+++ b/contrib/check-code.py Tue Apr 01 02:46:03 2014 +0900
@@ -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'[^_]_\("[^"]+"\s*%', "don't use % inside _()"),
- (r"[^_]_\('[^']+'\s*%", "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"),
--- a/hgext/largefiles/lfcommands.py Tue Apr 01 02:46:03 2014 +0900
+++ b/hgext/largefiles/lfcommands.py Tue Apr 01 02:46:03 2014 +0900
@@ -303,14 +303,14 @@
try:
id, name = line.split(' ', 1)
except ValueError:
- ui.warn(_('skipping incorrectly formatted tag %s\n'
- % line))
+ ui.warn(_('skipping incorrectly formatted tag %s\n')
+ % line)
continue
try:
newid = node.bin(id)
except TypeError:
- ui.warn(_('skipping incorrectly formatted id %s\n'
- % id))
+ ui.warn(_('skipping incorrectly formatted id %s\n')
+ % id)
continue
try:
newdata.append('%s %s\n' % (node.hex(revmap[newid]),
--- a/mercurial/commands.py Tue Apr 01 02:46:03 2014 +0900
+++ b/mercurial/commands.py Tue Apr 01 02:46:03 2014 +0900
@@ -752,8 +752,8 @@
if not changesets:
extendnode = extendbisectrange(nodes, good)
if extendnode is not None:
- ui.write(_("Extending search to changeset %d:%s\n"
- % (extendnode.rev(), extendnode)))
+ ui.write(_("Extending search to changeset %d:%s\n")
+ % (extendnode.rev(), extendnode))
state['current'] = [extendnode.node()]
hbisect.save_state(repo, state)
if noupdate:
--- a/mercurial/hg.py Tue Apr 01 02:46:03 2014 +0900
+++ b/mercurial/hg.py Tue Apr 01 02:46:03 2014 +0900
@@ -433,7 +433,7 @@
if bn == 'default':
status = _("updating to bookmark @\n")
else:
- status = _("updating to bookmark @ on branch %s\n"
+ status = (_("updating to bookmark @ on branch %s\n")
% bn)
except KeyError:
try:
--- a/mercurial/merge.py Tue Apr 01 02:46:03 2014 +0900
+++ b/mercurial/merge.py Tue Apr 01 02:46:03 2014 +0900
@@ -70,8 +70,8 @@
bits = record.split("\0")
self._state[bits[0]] = bits[1:]
elif not rtype.islower():
- raise util.Abort(_('unsupported merge state record: %s'
- % rtype))
+ raise util.Abort(_('unsupported merge state record: %s')
+ % rtype)
self._dirty = False
def _readrecords(self):
v1records = self._readrecordsv1()
--- a/mercurial/subrepo.py Tue Apr 01 02:46:03 2014 +0900
+++ b/mercurial/subrepo.py Tue Apr 01 02:46:03 2014 +0900
@@ -321,8 +321,8 @@
for f in names:
if f.lower() == 'hgrc':
ui.warn(
- _("warning: removing potentially hostile .hg/hgrc in '%s'"
- % path))
+ _("warning: removing potentially hostile .hg/hgrc in '%s'")
+ % path)
os.unlink(os.path.join(dirname, f))
os.walk(path, v, None)