[SPAM] [RFC] external diff on win32 and locale
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Dec 22 14:15:14 GMT 2006
>>>>> "bialix" == Alexander Belchenko <bialix at ukr.net> writes:
bialix> There are 2 tests for external diff that failed on win32
bialix> if gettext library installed:
bialix> test_diff.TestDiff.test_external_diff_binary_lang_c ERROR
bialix> 129ms
bialix> external diff failed with exit code 2; command: ['diff', '--label', 'old',
bialix> 'c:\\docume~1\\modul98\\locals~1\\temp\\bzr-diff-old-wuhbly', '--label', 'new',
bialix> 'c:\\docume~1\\modul98\\locals~1\\temp\\bzr-diff-new--qepfs', '--binary', '-u']
bialix> test_diff.TestDiffFiles.test_external_diff_binary ERROR
bialix> 440ms
bialix> external diff failed with exit code 2; command: ['diff', '--label', 'old',
bialix> 'c:\\docume~1\\modul98\\locals~1\\temp\\bzr-diff-old-2neogw', '--label', 'new',
bialix> 'c:\\docume~1\\modul98\\locals~1\\temp\\bzr-diff-new-nk4wyp', '--binary', '-u']
bialix> IIRC Vincent try to address this problem,
Initially no. But a discussion followed that arrived to the
locale problems on windows.
bialix> but I don't remember what result of review of his
bialix> patch.
As I had no solution, I excluded the concerned part of the patch
in order to have it merged.
bialix> I'm quickly looking at gettext sources (from
bialix> http://gnuwin32.sf.net project) and see in comments:
bialix> /* Determine the user's language preferences, as a colon separated list of
bialix> locale names in XPG syntax
bialix> language[_territory[.codeset]][@modifier]
bialix> The result must not be freed; it is statically allocated.
bialix> The LANGUAGE environment variable does not need to be considered; it is
bialix> already taken into account by the caller. */
bialix> This is from the code related to MacOs support but I try to check
bialix> $LANGUAGE environment variable. And it really works, i.e. diff
bialix> response for this variable and switch from my language (russian)
bialix> to english:
bialix> $ set LANGUAGE=C
bialix> $ python bzr --no-plugins selftest -v test_external_diff_binary
bialix> test_diff.TestDiff.test_external_diff_binary_lang_c OK
bialix> 110ms
bialix> test_diff.TestDiffFiles.test_external_diff_binary FAIL
bialix> 430ms
bialix> ['Files old and new differ\r\n', '\n'] != ['Files old and new differ\n', '\n']
bialix> So, I think our current support of external diff need
bialix> to be adjusted for win32.
bialix> Does my analysis correct?
I would say yes, but last time, the discussion went like this:
>>>>> "jam" == John Arbash Meinel <john at arbash-meinel.com> writes:
jam> Andrew Bennetts wrote:
<snip/>
>>
>>
>>> out, err = self.run_bzr('init', 'subdir2/nothere', retcode=3)
>>> self.assertEqual('', out)
>>> + # Rely on bzr error message part only or we fail on
>>> + # non-english systems
>>> self.assertContainsRe(err,
>>> - r'^bzr: ERROR: .*'
>>> - '\[Errno 2\] No such file or directory')
>>> -
>>> + r'^bzr: ERROR: No such file:.*')
>>> +
>>
>> Can we do the equivalent of setting LANG=C on windows to
>> avoid this problem? run_bzr happens in-process, so
>> perhaps it should do "locale.setlocale(locale.LC_ALL,
>> 'C')" (with an appropriate cleanup to restore the locale
>> to the previous state)?
jam> Well, I have been unsuccessful in getting LANG=C to mean
jam> anything on Windows. So I'm not sure how it determines
jam> the locale and how to generate internationalized error
jam> messages.
jam> We have a good resource in Alexander, since his machine
jam> uses a non-english Windows install.
jam> It does seem like you can call 'setlocale'. But I wonder
jam> if there is something that you could use when calling
jam> out to another process. (We would like to use it when
jam> spawning an external diff).
I.e. in the general case, setting LANGUAGE is not good enough,
but I, for one, knows no better way to reliably set an
environment under windows with the correct locale settings.
Vincent
More information about the bazaar
mailing list