Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
29396:d0ae5b8f80dc | 29397:844f72885fb9 |
---|---|
2093 _debugchangegroup(ui, gen, all=all, **opts) | 2093 _debugchangegroup(ui, gen, all=all, **opts) |
2094 | 2094 |
2095 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): | 2095 def _debugchangegroup(ui, gen, all=None, indent=0, **opts): |
2096 indent_string = ' ' * indent | 2096 indent_string = ' ' * indent |
2097 if all: | 2097 if all: |
2098 ui.write("%sformat: id, p1, p2, cset, delta base, len(delta)\n" | 2098 ui.write(("%sformat: id, p1, p2, cset, delta base, len(delta)\n") |
2099 % indent_string) | 2099 % indent_string) |
2100 | 2100 |
2101 def showchunks(named): | 2101 def showchunks(named): |
2102 ui.write("\n%s%s\n" % (indent_string, named)) | 2102 ui.write("\n%s%s\n" % (indent_string, named)) |
2103 chain = None | 2103 chain = None |
2560 for i in r: | 2560 for i in r: |
2561 idlen = len(shortfn(r.node(i))) | 2561 idlen = len(shortfn(r.node(i))) |
2562 break | 2562 break |
2563 | 2563 |
2564 if format == 0: | 2564 if format == 0: |
2565 ui.write(" rev offset length " + basehdr + " linkrev" | 2565 ui.write((" rev offset length " + basehdr + " linkrev" |
2566 " %s %s p2\n" % ("nodeid".ljust(idlen), "p1".ljust(idlen))) | 2566 " %s %s p2\n") % ("nodeid".ljust(idlen), "p1".ljust(idlen))) |
2567 elif format == 1: | 2567 elif format == 1: |
2568 ui.write(" rev flag offset length" | 2568 ui.write((" rev flag offset length" |
2569 " size " + basehdr + " link p1 p2" | 2569 " size " + basehdr + " link p1 p2" |
2570 " %s\n" % "nodeid".rjust(idlen)) | 2570 " %s\n") % "nodeid".rjust(idlen)) |
2571 | 2571 |
2572 for i in r: | 2572 for i in r: |
2573 node = r.node(i) | 2573 node = r.node(i) |
2574 if generaldelta: | 2574 if generaldelta: |
2575 base = r.deltaparent(i) | 2575 base = r.deltaparent(i) |
3028 if host == socket.gethostname(): | 3028 if host == socket.gethostname(): |
3029 locker = 'user %s, process %s' % (user, pid) | 3029 locker = 'user %s, process %s' % (user, pid) |
3030 else: | 3030 else: |
3031 locker = 'user %s, process %s, host %s' \ | 3031 locker = 'user %s, process %s, host %s' \ |
3032 % (user, pid, host) | 3032 % (user, pid, host) |
3033 ui.write("%-6s %s (%ds)\n" % (name + ":", locker, age)) | 3033 ui.write(("%-6s %s (%ds)\n") % (name + ":", locker, age)) |
3034 return 1 | 3034 return 1 |
3035 except OSError as e: | 3035 except OSError as e: |
3036 if e.errno != errno.ENOENT: | 3036 if e.errno != errno.ENOENT: |
3037 raise | 3037 raise |
3038 | 3038 |
3039 ui.write("%-6s free\n" % (name + ":")) | 3039 ui.write(("%-6s free\n") % (name + ":")) |
3040 return 0 | 3040 return 0 |
3041 | 3041 |
3042 held += report(repo.svfs, "lock", repo.lock) | 3042 held += report(repo.svfs, "lock", repo.lock) |
3043 held += report(repo.vfs, "wlock", repo.wlock) | 3043 held += report(repo.vfs, "wlock", repo.wlock) |
3044 | 3044 |
3327 """show data and statistics about a revlog""" | 3327 """show data and statistics about a revlog""" |
3328 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) | 3328 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts) |
3329 | 3329 |
3330 if opts.get("dump"): | 3330 if opts.get("dump"): |
3331 numrevs = len(r) | 3331 numrevs = len(r) |
3332 ui.write("# rev p1rev p2rev start end deltastart base p1 p2" | 3332 ui.write(("# rev p1rev p2rev start end deltastart base p1 p2" |
3333 " rawsize totalsize compression heads chainlen\n") | 3333 " rawsize totalsize compression heads chainlen\n")) |
3334 ts = 0 | 3334 ts = 0 |
3335 heads = set() | 3335 heads = set() |
3336 | 3336 |
3337 for rev in xrange(numrevs): | 3337 for rev in xrange(numrevs): |
3338 dbase = r.deltaparent(rev) | 3338 dbase = r.deltaparent(rev) |
3517 if ui.verbose: | 3517 if ui.verbose: |
3518 tree = revset.parse(expr, lookup=repo.__contains__) | 3518 tree = revset.parse(expr, lookup=repo.__contains__) |
3519 ui.note(revset.prettyformat(tree), "\n") | 3519 ui.note(revset.prettyformat(tree), "\n") |
3520 newtree = revset.expandaliases(ui, tree) | 3520 newtree = revset.expandaliases(ui, tree) |
3521 if newtree != tree: | 3521 if newtree != tree: |
3522 ui.note("* expanded:\n", revset.prettyformat(newtree), "\n") | 3522 ui.note(("* expanded:\n"), revset.prettyformat(newtree), "\n") |
3523 tree = newtree | 3523 tree = newtree |
3524 newtree = revset.foldconcat(tree) | 3524 newtree = revset.foldconcat(tree) |
3525 if newtree != tree: | 3525 if newtree != tree: |
3526 ui.note("* concatenated:\n", revset.prettyformat(newtree), "\n") | 3526 ui.note(("* concatenated:\n"), revset.prettyformat(newtree), "\n") |
3527 if opts["optimize"]: | 3527 if opts["optimize"]: |
3528 optimizedtree = revset.optimize(newtree) | 3528 optimizedtree = revset.optimize(newtree) |
3529 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n") | 3529 ui.note(("* optimized:\n"), |
3530 revset.prettyformat(optimizedtree), "\n") | |
3530 func = revset.match(ui, expr, repo) | 3531 func = revset.match(ui, expr, repo) |
3531 revs = func(repo) | 3532 revs = func(repo) |
3532 if ui.verbose: | 3533 if ui.verbose: |
3533 ui.note("* set:\n", revset.prettyformatset(revs), "\n") | 3534 ui.note(("* set:\n"), revset.prettyformatset(revs), "\n") |
3534 for c in revs: | 3535 for c in revs: |
3535 ui.write("%s\n" % c) | 3536 ui.write("%s\n" % c) |
3536 | 3537 |
3537 @command('debugsetparents', [], _('REV1 [REV2]')) | 3538 @command('debugsetparents', [], _('REV1 [REV2]')) |
3538 def debugsetparents(ui, repo, rev1, rev2=None): | 3539 def debugsetparents(ui, repo, rev1, rev2=None): |
3683 aliases = ui.configitems('templatealias') | 3684 aliases = ui.configitems('templatealias') |
3684 tree = templater.parse(tmpl) | 3685 tree = templater.parse(tmpl) |
3685 ui.note(templater.prettyformat(tree), '\n') | 3686 ui.note(templater.prettyformat(tree), '\n') |
3686 newtree = templater.expandaliases(tree, aliases) | 3687 newtree = templater.expandaliases(tree, aliases) |
3687 if newtree != tree: | 3688 if newtree != tree: |
3688 ui.note("* expanded:\n", templater.prettyformat(newtree), '\n') | 3689 ui.note(("* expanded:\n"), templater.prettyformat(newtree), '\n') |
3689 | 3690 |
3690 mapfile = None | 3691 mapfile = None |
3691 if revs is None: | 3692 if revs is None: |
3692 k = 'debugtemplate' | 3693 k = 'debugtemplate' |
3693 t = formatter.maketemplater(ui, k, tmpl) | 3694 t = formatter.maketemplater(ui, k, tmpl) |