Show More
@@ -17,8 +17,12 b' LOCAL="$1"' | |||||
17 | BASE="$2" |
|
17 | BASE="$2" | |
18 | OTHER="$3" |
|
18 | OTHER="$3" | |
19 |
|
19 | |||
20 |
if [ - |
|
20 | if [ -n "$VISUAL" ]; then | |
21 |
EDIT |
|
21 | EDIT_PROG="$VISUAL" | |
|
22 | elif [ -n "$EDITOR" ]; then | |||
|
23 | EDIT_PROG="$EDITOR" | |||
|
24 | else | |||
|
25 | EDIT_PROG="vi" | |||
22 | fi |
|
26 | fi | |
23 |
|
27 | |||
24 | # find decent versions of our utilities, insisting on the GNU versions where we |
|
28 | # find decent versions of our utilities, insisting on the GNU versions where we | |
@@ -165,16 +169,16 b' if [ -n "$DISPLAY" ]; then' | |||||
165 | fi |
|
169 | fi | |
166 | fi |
|
170 | fi | |
167 |
|
171 | |||
168 |
# Attempt to do a merge with $EDIT |
|
172 | # Attempt to do a merge with $EDIT_PROG | |
169 | if [ -n "$MERGE" -o -n "$DIFF3" ]; then |
|
173 | if [ -n "$MERGE" -o -n "$DIFF3" ]; then | |
170 | echo "conflicts detected in $LOCAL" |
|
174 | echo "conflicts detected in $LOCAL" | |
171 | cp "$BACKUP" "$CHGTEST" |
|
175 | cp "$BACKUP" "$CHGTEST" | |
172 |
case "$EDIT |
|
176 | case "$EDIT_PROG" in | |
173 | "emacs") |
|
177 | "emacs") | |
174 |
$EDIT |
|
178 | $EDIT_PROG "$LOCAL" --eval '(condition-case nil (smerge-mode 1) (error nil))' || failure | |
175 | ;; |
|
179 | ;; | |
176 | *) |
|
180 | *) | |
177 |
$EDIT |
|
181 | $EDIT_PROG "$LOCAL" || failure | |
178 | ;; |
|
182 | ;; | |
179 | esac |
|
183 | esac | |
180 | # Some editors do not return meaningful error codes |
|
184 | # Some editors do not return meaningful error codes | |
@@ -195,7 +199,7 b' if [ -n "$DIFF" -a -n "$PATCH" ]; then' | |||||
195 | success |
|
199 | success | |
196 | else |
|
200 | else | |
197 | # If rejects are empty after using the editor, merge was ok |
|
201 | # If rejects are empty after using the editor, merge was ok | |
198 |
$EDIT |
|
202 | $EDIT_PROG "$LOCAL" "$LOCAL.rej" || failure | |
199 | $TEST -s "$LOCAL.rej" || success |
|
203 | $TEST -s "$LOCAL.rej" || success | |
200 | fi |
|
204 | fi | |
201 | failure |
|
205 | failure |
@@ -430,8 +430,8 b' def commit(ui, repo, *pats, **opts):' | |||||
430 | If a list of files is omitted, all changes reported by "hg status" |
|
430 | If a list of files is omitted, all changes reported by "hg status" | |
431 | will be committed. |
|
431 | will be committed. | |
432 |
|
432 | |||
433 |
If no commit message is specified, the |
|
433 | If no commit message is specified, the configured editor is started to | |
434 | or in the EDITOR environment variable is started to enter a message. |
|
434 | enter a message. | |
435 | """ |
|
435 | """ | |
436 | def commitfunc(ui, repo, files, message, match, opts): |
|
436 | def commitfunc(ui, repo, files, message, match, opts): | |
437 | return repo.commit(files, message, opts['user'], opts['date'], match, |
|
437 | return repo.commit(files, message, opts['user'], opts['date'], match, | |
@@ -748,9 +748,7 b' def debuginstall(ui):' | |||||
748 |
|
748 | |||
749 | # editor |
|
749 | # editor | |
750 | ui.status(_("Checking commit editor...\n")) |
|
750 | ui.status(_("Checking commit editor...\n")) | |
751 | editor = (os.environ.get("HGEDITOR") or |
|
751 | editor = ui.geteditor() | |
752 | ui.config("ui", "editor") or |
|
|||
753 | os.environ.get("EDITOR", "vi")) |
|
|||
754 | cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) |
|
752 | cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0]) | |
755 | if not cmdpath: |
|
753 | if not cmdpath: | |
756 | if editor == 'vi': |
|
754 | if editor == 'vi': |
@@ -43,8 +43,7 b' HG::' | |||||
43 | 'hg' (with com/exe/bat/cmd extension on Windows) is searched. |
|
43 | 'hg' (with com/exe/bat/cmd extension on Windows) is searched. | |
44 |
|
44 | |||
45 | HGEDITOR:: |
|
45 | HGEDITOR:: | |
46 |
This is the name of the editor to use when committing. |
|
46 | This is the name of the editor to use when committing. See EDITOR. | |
47 | value of EDITOR. |
|
|||
48 |
|
47 | |||
49 | (deprecated, use .hgrc) |
|
48 | (deprecated, use .hgrc) | |
50 |
|
49 | |||
@@ -94,9 +93,16 b' LOGNAME::' | |||||
94 | If neither HGUSER nor EMAIL is set, LOGNAME will be used (with |
|
93 | If neither HGUSER nor EMAIL is set, LOGNAME will be used (with | |
95 | '@hostname' appended) as the author value for a commit. |
|
94 | '@hostname' appended) as the author value for a commit. | |
96 |
|
95 | |||
|
96 | VISUAL:: | |||
|
97 | This is the name of the editor to use when committing. See EDITOR. | |||
|
98 | ||||
97 | EDITOR:: |
|
99 | EDITOR:: | |
98 | This is the name of the editor used in the hgmerge script. It will be |
|
100 | Sometimes Mercurial needs to open a text file in an editor for a user | |
99 | used for commit messages if HGEDITOR isn't set. Defaults to 'vi'. |
|
101 | to modify, for example when writing commit messages or when using the | |
|
102 | hgmerge script. The editor it uses is determined by looking at the | |||
|
103 | environment variables HGEDITOR, VISUAL and EDITOR, in that order. The | |||
|
104 | first non-empty one is chosen. If all of them are empty, the editor | |||
|
105 | defaults to 'vi'. | |||
100 |
|
106 | |||
101 | PYTHONPATH:: |
|
107 | PYTHONPATH:: | |
102 | This is used by Python to find imported modules and may need to be set |
|
108 | This is used by Python to find imported modules and may need to be set |
@@ -440,9 +440,7 b' class ui(object):' | |||||
440 | f.write(text) |
|
440 | f.write(text) | |
441 | f.close() |
|
441 | f.close() | |
442 |
|
442 | |||
443 |
editor = ( |
|
443 | editor = self.geteditor() | |
444 | self.config("ui", "editor") or |
|
|||
445 | os.environ.get("EDITOR", "vi")) |
|
|||
446 |
|
444 | |||
447 | util.system("%s \"%s\"" % (editor, name), |
|
445 | util.system("%s \"%s\"" % (editor, name), | |
448 | environ={'HGUSER': user}, |
|
446 | environ={'HGUSER': user}, | |
@@ -464,3 +462,11 b' class ui(object):' | |||||
464 | if self.traceback: |
|
462 | if self.traceback: | |
465 | traceback.print_exc() |
|
463 | traceback.print_exc() | |
466 | return self.traceback |
|
464 | return self.traceback | |
|
465 | ||||
|
466 | def geteditor(self): | |||
|
467 | '''return editor to use''' | |||
|
468 | return (os.environ.get("HGEDITOR") or | |||
|
469 | self.config("ui", "editor") or | |||
|
470 | os.environ.get("VISUAL") or | |||
|
471 | os.environ.get("EDITOR", "vi")) | |||
|
472 |
General Comments 0
You need to be logged in to leave comments.
Login now