[PATCH STABLE] histedit: make comment part of the file describing rules as translatable

Wagner Bruna wagner.bruna+mercurial at gmail.com
Thu Aug 2 08:16:11 CDT 2012


Em 02-08-2012 10:05, Augie Fackler escreveu:
> 
> On Jul 29, 2012, at 1:54 PM, FUJIWARA Katsunori wrote:
> 
>> # HG changeset patch
>> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
>> # Date 1343586427 -32400
>> # Branch stable
>> # Node ID 60dee8c326d01efada33398ff1958b66fa8d5482
>> # Parent  3ccb49ed1cc13cf71cd780e998f200ed974ec271
>> histedit: make comment part of the file describing rules as translatable
>>
>> "i18n.gettext()" invocation for "editcomment" itself should have
>> little impact for whole initialization cost of histedit, because it is
>> already invoked for initialization of the command table entry.
>>
>> '\n\n' has to be added to the text being edited separately from
>> "editcomment", because leading 'line feed' characters are not exported
>> to "hg.pot" file correctly.
>>
>> diff -r 3ccb49ed1cc1 -r 60dee8c326d0 hgext/histedit.py
>> --- a/hgext/histedit.py	Sun Jul 29 12:29:35 2012 -0500
>> +++ b/hgext/histedit.py	Mon Jul 30 03:27:07 2012 +0900
>> @@ -162,9 +162,7 @@
>>
>> testedwith = 'internal'
>>
>> -editcomment = """
>> -
>> -# Edit history between %s and %s
>> +editcomment = _("""# Edit history between %s and %s
>> #
>> # Commands:
>> #  p, pick = use commit
>> @@ -173,7 +171,7 @@
>> #  d, drop = remove commit from history
>> #  m, mess = edit message without changing commit content
> 
> Is there a way to note for translators that the LHS of the
> "commands" section must remain untranslated?

Yes, like in:

http://selenic.com/hg/file/2.3/mercurial/revset.py#l269

BTW, would it be possible to have that block appear only once, for both the
doc string and the runtime message, to ensure they'll be kept in sync?
Currently it's _nearly_ duplicated: once starting with "Edit history between
%s and %s", once with the example hashes.

Thanks,
Wagner

>> #
>> -"""
>> +""")
>>
>> def between(repo, old, new, keep):
>>     revs = [old]
>> @@ -522,6 +520,7 @@
>>         rules = opts.get('commands', '')
>>         if not rules:
>>             rules = '\n'.join([makedesc(c) for c in ctxs])
>> +            rules += '\n\n'
>>             rules += editcomment % (node.hex(parent)[:12], node.hex(tip)[:12])
>>             rules = ui.edit(rules, ui.username())
>>             # Save edit rules in .hg/histedit-last-edit.txt in case


More information about the Mercurial-devel mailing list