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