[PATCH 2 of 8] push: refuse to push obsolete changeset

Martin Geisler mg at aragost.com
Mon Jul 9 02:51:52 CDT 2012


Angel Ezquerra <angel.ezquerra at gmail.com> writes:

> On Fri, Jul 6, 2012 at 7:28 PM, Pierre-Yves David
> <pierre-yves.david at logilab.fr> wrote:
>> On Thu, Jul 05, 2012 at 09:08:03PM -0400, Augie Fackler wrote:
>>> > +                        if self.obsstore:
>>> > +                            msg = "push includes an obsolete changeset: %s!"
>>>
>>> Why is this string outlined rather than inside the util.Abort(_(…))?
>>
>> Because the abort line start with 40 char intendation making it
>> unsuitable for adding any text.
>
> Pierre-Yves,
>
> I am not 100% sure, but I think that the i18n tool will not pick up a
> string if it you first assign it to a variable (msg in this case) and
> then you call _() on it.
>
> Instead, it'd be best to do:
>
> if self.obsstore:
>     msg = _("push includes an obsolete changeset: %s!")
>
> And later pass msg to util.Abort().

That is correct: Gettext works by parsing the Python source and
extracting the *string* arguments to the '_' function. The extraction
tool will complain if it finds something that isn't a string. Commom
problems are:

  _("%d format strings" % n)
  _(variable)

It must be

  _("a string in any of the"
    'normal Python formats')

-- 
Martin Geisler

aragost Trifork
Commercial Mercurial support
http://aragost.com/mercurial/


More information about the Mercurial-devel mailing list