Mercurial > emacs
comparison lisp/vc.el @ 91698:c22d8444f043
Make vc-diff-internal messages consistent across many cases.
(vc-exec-after): Append CODE to previous fragments.
(vc-diff-finish): Take BUFFER directly, not BUFFER-NAME;
take MESSAGES instead of VERBOSE; use it when non-nil.
(vc-diff-internal): Compute messages once; use them;
update call to vc-diff-finish.
author | Thien-Thi Nguyen <ttn@gnuvola.org> |
---|---|
date | Sat, 09 Feb 2008 12:32:04 +0000 |
parents | 194bf468eb2a |
children | 98b6c9d8faca |
comparison
equal
deleted
inserted
replaced
91697:056e52861ec3 | 91698:c22d8444f043 |
---|---|
1049 (let ((previous (process-sentinel proc))) | 1049 (let ((previous (process-sentinel proc))) |
1050 (unless (eq previous 'vc-process-sentinel) | 1050 (unless (eq previous 'vc-process-sentinel) |
1051 (process-put proc 'vc-previous-sentinel previous)) | 1051 (process-put proc 'vc-previous-sentinel previous)) |
1052 (set-process-sentinel proc 'vc-process-sentinel)) | 1052 (set-process-sentinel proc 'vc-process-sentinel)) |
1053 (process-put proc 'vc-sentinel-commands | 1053 (process-put proc 'vc-sentinel-commands |
1054 (cons code (process-get proc 'vc-sentinel-commands)))) | 1054 ;; We keep the code fragments in the order given |
1055 ;; so that vc-diff-finish's message shows up in | |
1056 ;; the presence of non-nil vc-command-messages. | |
1057 (append (process-get proc 'vc-sentinel-commands) | |
1058 (list code)))) | |
1055 (t (error "Unexpected process state")))) | 1059 (t (error "Unexpected process state")))) |
1056 nil) | 1060 nil) |
1057 | 1061 |
1058 (defvar vc-post-command-functions nil | 1062 (defvar vc-post-command-functions nil |
1059 "Hook run at the end of `vc-do-command'. | 1063 "Hook run at the end of `vc-do-command'. |
1989 | 1993 |
1990 ;; Old def for compatibility with Emacs-21.[123]. | 1994 ;; Old def for compatibility with Emacs-21.[123]. |
1991 (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff)) | 1995 (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff)) |
1992 (make-obsolete 'vc-diff-switches-list 'vc-switches "22.1") | 1996 (make-obsolete 'vc-diff-switches-list 'vc-switches "22.1") |
1993 | 1997 |
1994 (defun vc-diff-finish (buffer-name verbose) | 1998 (defun vc-diff-finish (buffer messages) |
1995 ;; The empty sync output case has already been handled, so the only | 1999 ;; The empty sync output case has already been handled, so the only |
1996 ;; possibility of an empty output is for an async process. | 2000 ;; possibility of an empty output is for an async process. |
1997 (when (buffer-live-p buffer-name) | 2001 (when (buffer-live-p buffer) |
1998 (with-current-buffer (get-buffer buffer-name) | 2002 (let ((window (get-buffer-window buffer t)) |
1999 (and verbose | 2003 (emptyp (zerop (buffer-size buffer)))) |
2000 (zerop (buffer-size)) | 2004 (with-current-buffer buffer |
2001 (let ((inhibit-read-only t)) | 2005 (and messages emptyp |
2002 (insert "No differences found.\n"))) | 2006 (let ((inhibit-read-only t)) |
2003 (goto-char (point-min)) | 2007 (insert (cdr messages) ".\n") |
2004 (let ((window (get-buffer-window (current-buffer) t))) | 2008 (message "%s" (cdr messages)))) |
2009 (goto-char (point-min)) | |
2005 (when window | 2010 (when window |
2006 (shrink-window-if-larger-than-buffer window)))))) | 2011 (shrink-window-if-larger-than-buffer window))) |
2012 (when (and messages (not emptyp)) | |
2013 (message "%sdone" (car messages)))))) | |
2007 | 2014 |
2008 (defvar vc-diff-added-files nil | 2015 (defvar vc-diff-added-files nil |
2009 "If non-nil, diff added files by comparing them to /dev/null.") | 2016 "If non-nil, diff added files by comparing them to /dev/null.") |
2010 | 2017 |
2011 (defun vc-diff-internal (async files rev1 rev2 &optional verbose) | 2018 (defun vc-diff-internal (async files rev1 rev2 &optional verbose) |
2012 "Report diffs between two revisions of a fileset. | 2019 "Report diffs between two revisions of a fileset. |
2013 Diff output goes to the *vc-diff* buffer. The function | 2020 Diff output goes to the *vc-diff* buffer. The function |
2014 returns t if the buffer had changes, nil otherwise." | 2021 returns t if the buffer had changes, nil otherwise." |
2015 (let* ((filenames (vc-delistify files)) | 2022 (let* ((messages (cons (format "Finding changes in %s..." |
2016 (rev1-name (or rev1 "working revision")) | 2023 (vc-delistify files)) |
2017 (rev2-name (or rev2 "workfile")) | 2024 (format "No changes between %s and %s" |
2025 (or rev1 "working revision") | |
2026 (or rev2 "workfile")))) | |
2018 ;; Set coding system based on the first file. It's a kluge, | 2027 ;; Set coding system based on the first file. It's a kluge, |
2019 ;; but the only way to set it for each file included would | 2028 ;; but the only way to set it for each file included would |
2020 ;; be to call the back end separately for each file. | 2029 ;; be to call the back end separately for each file. |
2021 (coding-system-for-read | 2030 (coding-system-for-read |
2022 (if files (vc-coding-system-for-diff (car files)) 'undecided))) | 2031 (if files (vc-coding-system-for-diff (car files)) 'undecided))) |
2023 (vc-setup-buffer "*vc-diff*") | 2032 (vc-setup-buffer "*vc-diff*") |
2024 (message "Finding changes in %s..." filenames) | 2033 (message "%s" (car messages)) |
2025 ;; Many backends don't handle well the case of a file that has been | 2034 ;; Many backends don't handle well the case of a file that has been |
2026 ;; added but not yet committed to the repo (notably CVS and Subversion). | 2035 ;; added but not yet committed to the repo (notably CVS and Subversion). |
2027 ;; Do that work here so the backends don't have to futz with it. --ESR | 2036 ;; Do that work here so the backends don't have to futz with it. --ESR |
2028 ;; | 2037 ;; |
2029 ;; Actually most backends (including CVS) have options to control the | 2038 ;; Actually most backends (including CVS) have options to control the |
2053 (set-buffer "*vc-diff*") | 2062 (set-buffer "*vc-diff*") |
2054 (if (and (zerop (buffer-size)) | 2063 (if (and (zerop (buffer-size)) |
2055 (not (get-buffer-process (current-buffer)))) | 2064 (not (get-buffer-process (current-buffer)))) |
2056 ;; Treat this case specially so as not to pop the buffer. | 2065 ;; Treat this case specially so as not to pop the buffer. |
2057 (progn | 2066 (progn |
2058 (message "No changes between %s and %s" rev1-name rev2-name) | 2067 (message "%s" (cdr messages)) |
2059 nil) | 2068 nil) |
2060 (diff-mode) | 2069 (diff-mode) |
2061 ;; Make the *vc-diff* buffer read only, the diff-mode key | 2070 ;; Make the *vc-diff* buffer read only, the diff-mode key |
2062 ;; bindings are nicer for read only buffers. pcl-cvs does the | 2071 ;; bindings are nicer for read only buffers. pcl-cvs does the |
2063 ;; same thing. | 2072 ;; same thing. |
2064 (setq buffer-read-only t) | 2073 (setq buffer-read-only t) |
2065 (vc-exec-after `(vc-diff-finish ,(buffer-name) ,verbose)) | 2074 (vc-exec-after `(vc-diff-finish ,(current-buffer) ',(when verbose |
2075 messages))) | |
2066 ;; Display the buffer, but at the end because it can change point. | 2076 ;; Display the buffer, but at the end because it can change point. |
2067 (pop-to-buffer (current-buffer)) | 2077 (pop-to-buffer (current-buffer)) |
2068 ;; In the async case, we return t even if there are no differences | 2078 ;; In the async case, we return t even if there are no differences |
2069 ;; because we don't know that yet. | 2079 ;; because we don't know that yet. |
2070 t))) | 2080 t))) |