Fix error message when No editor found

John A Meinel john at arbash-meinel.com
Wed Jan 25 18:51:56 GMT 2006


https://launchpad.net/products/bzr/+bug/28636

The current bzr.dev code calls subprocess.call() on the list of possible
errors, giving a long-form traceback if it fails.
Instead we should check and try multiple editors before giving up with a
"set BZR_EDITOR".
Probably the error message could be improved in the case that BZR_EDITOR
is set, and it just doesn't work.

This is present on my jam-pending branch. (Which still hasn't had the
'fix Makefile' stuff reviewed)

John
=:->


=== modified file 'bzrlib/msgeditor.py'
--- bzrlib/msgeditor.py
+++ bzrlib/msgeditor.py
@@ -20,6 +20,7 @@
 """Commit message editor support."""

 import os
+import errno
 from subprocess import call

 import bzrlib.config as config
@@ -51,7 +52,13 @@
     """Try to execute an editor to edit the commit message."""
     for e in _get_editor():
         edargs = e.split(' ')
-        x = call(edargs + [filename])
+        try:
+            x = call(edargs + [filename])
+        except OSError, e:
+           # ENOENT means no such editor
+           if e.errno == errno.ENOENT:
+               continue
+           raise
         if x == 0:
             return True
         elif x == 127:



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060125/cff9d76d/attachment.pgp 


More information about the bazaar mailing list