Reducing startup time

Martin Geisler mg at daimi.au.dk
Sun Feb 1 17:48:03 CST 2009


Hi,

Brendan and I discussed on IRC how we can avoid doing several hundred
translations on every startup, even when hg makes no output.

I think this would work nicely:

* We remove the calls to _() in the cmdtables in extensions and in
  commands.table. So

    "^add": (add, walkopts + dryrunopts, _('[OPTION]... [FILE]...')),

  becomes

    "^add": (add, walkopts + dryrunopts, '[OPTION]... [FILE]...'),

* We teach commands.help to run all strings through i18n.gettext before
  outputting them.

* With no _() markings, the help strings wont get extracted. But we can
  make a tool which will run through commands.table and hgext.*.cmdtable
  and dump these strings with the _() markers.

  This tool should also be able to do a more accurate extraction of
  docstrings from the extensions. For example, the acl extension has a
  buildmatch function with a docstring and this string is put in the
  hg.pot file even though it wont ever be output.

If everything goes well, this should make hg start faster than ever
before since we save the calls to the noop lambda m: m function used
when no translation is used.

As for backwards compatibility, everything will keep working the same
way as now. If an extension by mistake uses _("show progress") in its
cmdtable, this string will be translated twice by gettext:

  "show progress" -> "vis fremskridt" -> "vis fremskridt"

The second translation will be a noop since "vis fremskridt" wont appear
anywhere else in the translation.

If we happen to find a string triple (x, y, z) where both x and y appear
in the English source text, x translates into y, and y != z, then I
think we should deal with it then :-)

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20090202/66e11b76/attachment.pgp 


More information about the Mercurial-devel mailing list