Mercurial > hg
diff mercurial/commands.py @ 29397:844f72885fb9
check-code: detect "missing _() in ui message" more exactly
Before this patch, "missing _() in ui message" rule overlooks
translatable message, which starts with other than alphabet.
To detect "missing _() in ui message" more exactly, this patch
improves the regexp with assumptions below.
- sequence consisting of below might precede "translatable message"
in same string token
- formatting string, which starts with '%'
- escaped character, which starts with 'b' (as replacement of '\\'), or
- characters other than '%', 'b' and 'x' (as replacement of alphabet)
- any string tokens might precede a string token, which contains
"translatable message"
This patch builds an input file, which is used to examine "missing _()
in ui message" detection, before '"$check_code" stringjoin.py' in
test-contrib-check-code.t, because this reduces amount of change churn
in subsequent patch.
This patch also applies "()" instead of "_()" on messages below to
hide false-positives:
- messages for ui.debug() or debug commands/tools
- contrib/debugshell.py
- hgext/win32mbcs.py (ui.write() is used, though)
- mercurial/commands.py
- _debugchangegroup
- debugindex
- debuglocks
- debugrevlog
- debugrevspec
- debugtemplate
- untranslatable messages
- doc/gendoc.py (ReST specific text)
- hgext/hgk.py (permission string)
- hgext/keyword.py (text written into configuration file)
- mercurial/cmdutil.py (formatting strings for JSON)
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 21 Jun 2016 00:50:39 +0900 |
parents | c75c8ea2f573 |
children | 31d3ab7985b8 |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Jun 22 21:30:49 2016 +0100 +++ b/mercurial/commands.py Tue Jun 21 00:50:39 2016 +0900 @@ -2095,7 +2095,7 @@ def _debugchangegroup(ui, gen, all=None, indent=0, **opts): indent_string = ' ' * indent if all: - ui.write("%sformat: id, p1, p2, cset, delta base, len(delta)\n" + ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") % indent_string) def showchunks(named): @@ -2562,12 +2562,12 @@ break if format == 0: - ui.write(" rev offset length " + basehdr + " linkrev" - " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen))) + ui.write((" rev offset length " + basehdr + " linkrev" + " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) elif format == 1: - ui.write(" rev flag offset length" + ui.write((" rev flag offset length" " size " + basehdr + " link p1 p2" - " %s\n" % "nodeid".rjust(idlen)) + " %s\n") % "nodeid".rjust(idlen)) for i in r: node = r.node(i) @@ -3030,13 +3030,13 @@ else: locker = 'user %s, process %s, host %s' \ % (user, pid, host) - ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age)) + ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) return 1 except OSError as e: if e.errno != errno.ENOENT: raise - ui.write("%-6s free\n" % (name + ":")) + ui.write(("%-6s free\n") % (name + ":")) return 0 held += report(repo.svfs, "lock", repo.lock) @@ -3329,8 +3329,8 @@ if opts.get("dump"): numrevs = len(r) - ui.write("# rev p1rev p2rev start end deltastart base p1 p2" - " rawsize totalsize compression heads chainlen\n") + ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" + " rawsize totalsize compression heads chainlen\n")) ts = 0 heads = set() @@ -3519,18 +3519,19 @@ ui.note(revset.prettyformat(tree), "\n") newtree = revset.expandaliases(ui, tree) if newtree != tree: - ui.note("* expanded:\n", revset.prettyformat(newtree), "\n") + ui.note(("* expanded:\n"), revset.prettyformat(newtree), "\n") tree = newtree newtree = revset.foldconcat(tree) if newtree != tree: - ui.note("* concatenated:\n", revset.prettyformat(newtree), "\n") + ui.note(("* concatenated:\n"), revset.prettyformat(newtree), "\n") if opts["optimize"]: optimizedtree = revset.optimize(newtree) - ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n") + ui.note(("* optimized:\n"), + revset.prettyformat(optimizedtree), "\n") func = revset.match(ui, expr, repo) revs = func(repo) if ui.verbose: - ui.note("* set:\n", revset.prettyformatset(revs), "\n") + ui.note(("* set:\n"), revset.prettyformatset(revs), "\n") for c in revs: ui.write("%s\n" % c) @@ -3685,7 +3686,7 @@ ui.note(templater.prettyformat(tree), '\n') newtree = templater.expandaliases(tree, aliases) if newtree != tree: - ui.note("* expanded:\n", templater.prettyformat(newtree), '\n') + ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') mapfile = None if revs is None: