[MERGE][Bug #84043] Commit now invokes an external editor in non-ASCII directories
Daniel Watkins
D.M.Watkins at warwick.ac.uk
Sat Nov 17 15:49:18 GMT 2007
On Fri, 16 Nov 2007 21:33:24 +0200
Alexander Belchenko <bialix at ukr.net> wrote:
> bb:resubmit because I really want to see test for invoking external
> editor in non-ascii directory (it's the main problem on win32).
> It should be in bzrlib.tests.test_msgeditor
So should I be EncodingAdapter'ing all the tests in
bzrlib.tests.test_msgeditor or just the one that requires it?
Presumably the former approach will take a lot longer but not have any
other side effects...
> @@ -204,9 +205,9 @@
> """
> import tempfile
> tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.',
> - - dir=u'.',
>
> ^-- I don't think that removing dir parameter is right.
>
> text=True)
>
> - - msgfile = os.fdopen(tmp_fileno, 'w')
>
> mkstemp returns already opened file. why you don't want to use
> os.fdopen?
>
> + msgfilename = osutils.basename(msgfilename)
> + msgfile = file(msgfilename, 'w')
> try:
> if start_message is not None:
> msgfile.write("%s\n" % start_message)
The problem is that mkstemp isn't returning an already opened file
because it throws an encodings-related exception before it has the
opportunity to do so. This patch is effectively just using mkstemp to
return a name which is unlikely to have any collisions (though we lose
the guarantee of its being unique).
Should I write (and then use) an osutils function to generate unique
temporary filenames, rather than creating an entirely unused file in
the default temporary directory while losing guaranteed uniqueness? Is
there a compelling reason to not just use the default temporary location
rather than the current directory?
> === modified file 'bzrlib/tests/test_msgeditor.py'
> - --- bzrlib/tests/test_msgeditor.py 2007-10-04 22:24:29 +0000
> +++ bzrlib/tests/test_msgeditor.py 2007-11-16 18:02:03 +0000
> @@ -243,6 +243,11 @@
> 'infotext'])
> self.assertFileEqual(expected, msgfilename)
>
> + def
> test__create_temp_file_with_commit_template_in_unicode_dir(self):
> + os.mkdir('f\xc5\xb1')
> + os.chdir('f\xc5\xb1')
> + msgeditor._create_temp_file_with_commit_template('infotext')
> +
>
> ^-- I have suspicious that not all [win32] systems will be able to
> create such directory. Why not using \xb5 (mju character)? Or some
> predefined unicode constants from EncodingAdapter.py?
I'll change this to use EncodingAdapter in my next patch. Though there
was something pleasingly metasyntactic about fű. ;)
--
Daniel Watkins (Odd_Bloke)
University of Warwick Christian Focus President
University of Warwick Computing Society WUGLUG Liaison Officer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20071117/af7ac14c/attachment.pgp
More information about the bazaar
mailing list