Rev 5538: Create commit message files in TMPDIR instead of the current dir. in file:///home/vila/src/bzr/bugs/673637-temp-commit-file/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Nov 11 13:38:23 GMT 2010


At file:///home/vila/src/bzr/bugs/673637-temp-commit-file/

------------------------------------------------------------
revno: 5538
revision-id: v.ladeuil+lp at free.fr-20101111133822-so798n5kuehj8uk4
parent: pqm at pqm.ubuntu.com-20101111084519-bmk1zmblp7kex41a
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 673637-temp-commit-file
timestamp: Thu 2010-11-11 14:38:22 +0100
message:
  Create commit message files in TMPDIR instead of the current dir.
-------------- next part --------------
=== modified file 'bzrlib/msgeditor.py'
--- a/bzrlib/msgeditor.py	2010-09-13 10:04:19 +0000
+++ b/bzrlib/msgeditor.py	2010-11-11 13:38:22 +0000
@@ -208,28 +208,25 @@
 
 def _create_temp_file_with_commit_template(infotext,
                                            ignoreline=DEFAULT_IGNORE_LINE,
-                                           start_message=None):
+                                           start_message=None,
+                                           tmpdir=None):
     """Create temp file and write commit template in it.
 
-    :param infotext:    Text to be displayed at bottom of message
-                        for the user's reference;
-                        currently similar to 'bzr status'.
-                        The text is already encoded.
+    :param infotext: Text to be displayed at bottom of message for the
+        user's reference; currently similar to 'bzr status'.  The text is
+        already encoded.
 
     :param ignoreline:  The separator to use above the infotext.
 
-    :param start_message:   The text to place above the separator, if any.
-                            This will not be removed from the message
-                            after the user has edited it.
-                            The string is already encoded
+    :param start_message: The text to place above the separator, if any.
+        This will not be removed from the message after the user has edited
+        it.  The string is already encoded
 
     :return:    2-tuple (temp file name, hasinfo)
     """
     import tempfile
     tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.',
-                                               dir='.',
-                                               text=True)
-    msgfilename = osutils.basename(msgfilename)
+                                               dir=tmpdir, text=True)
     msgfile = os.fdopen(tmp_fileno, 'w')
     try:
         if start_message is not None:

=== modified file 'bzrlib/tests/test_msgeditor.py'
--- a/bzrlib/tests/test_msgeditor.py	2010-08-29 14:32:45 +0000
+++ b/bzrlib/tests/test_msgeditor.py	2010-11-11 13:38:22 +0000
@@ -301,9 +301,12 @@
     def test__create_temp_file_with_commit_template_in_unicode_dir(self):
         self.requireFeature(tests.UnicodeFilenameFeature)
         if hasattr(self, 'info'):
-            os.mkdir(self.info['directory'])
-            os.chdir(self.info['directory'])
-            msgeditor._create_temp_file_with_commit_template('infotext')
+            tmpdir = self.info['directory']
+            os.mkdir(tmpdir)
+            # Force the creation of temp file in a directory whose name
+            # requires some encoding support
+            msgeditor._create_temp_file_with_commit_template('infotext',
+                                                             tmpdir=tmpdir)
         else:
             raise TestNotApplicable('Test run elsewhere with non-ascii data.')
 

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2010-11-10 11:15:50 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-11-11 13:38:22 +0000
@@ -44,6 +44,10 @@
 * Better message if there is an error while setting ownership of
   ``.bazaar`` directory. (Parth Malwankar, #657553)
 
+* Don't create commit message files in the current directory to avoid nasty
+  interactions with emacs (which tries to establish the status of the file
+  during the commit which breaks on windows). (Vincent Ladeuil, #673637)
+
 * ``bzr resolve --take-other <file>`` will not crash anymore if ``<file>``
   is involved in a text conflict (but the conflict is still not
   resolved). (Vincent Ladeuil, #646961)



More information about the bazaar-commits mailing list