Add 2010 to copyright years.
[bpt/emacs.git] / lisp / log-view.el
CommitLineData
e57a1038 1;;; log-view.el --- Major mode for browsing RCS/CVS/SCCS log output
5b467bf4 2
c4f6e489 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
114f9c96 4;; 2008, 2009, 2010 Free Software Foundation, Inc.
5b467bf4 5
cc1eecfd 6;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
c44a4822 7;; Keywords: rcs sccs cvs log version-control tools
5b467bf4
SM
8
9;; This file is part of GNU Emacs.
10
eb3fa2cf 11;; GNU Emacs is free software: you can redistribute it and/or modify
5b467bf4 12;; it under the terms of the GNU General Public License as published by
eb3fa2cf
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
5b467bf4
SM
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
eb3fa2cf 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
5b467bf4
SM
23
24;;; Commentary:
25
aa230d94
SM
26;; Major mode to browse revision log histories.
27;; Currently supports the format output by:
62c5f375 28;; RCS, SCCS, CVS, Subversion, and DaRCS.
aa230d94
SM
29
30;; Examples of log output:
31
32;;;; RCS/CVS:
33
34;; ----------------------------
35;; revision 1.35 locked by: turlutut
36;; date: 2005-03-22 18:48:38 +0000; author: monnier; state: Exp; lines: +6 -8
37;; (gnus-display-time-event-handler):
38;; Check display-time-timer at runtime rather than only at load time
39;; in case display-time-mode is turned off in the mean time.
40;; ----------------------------
41;; revision 1.34
42;; date: 2005-02-09 15:50:38 +0000; author: kfstorm; state: Exp; lines: +7 -7
43;; branches: 1.34.2;
44;; Change release version from 21.4 to 22.1 throughout.
45;; Change development version from 21.3.50 to 22.0.50.
46
47;;;; SCCS:
48
49;;;; Subversion:
50
813e8939
ER
51;; ------------------------------------------------------------------------
52;; r4622 | ckuethe | 2007-12-23 18:18:01 -0500 (Sun, 23 Dec 2007) | 2 lines
20ac86f4 53;;
813e8939 54;; uBlox AEK-4T in binary mode. Added to unstable because it breaks gpsfake
20ac86f4 55;;
813e8939
ER
56;; ------------------------------------------------------------------------
57;; r4621 | ckuethe | 2007-12-23 16:48:11 -0500 (Sun, 23 Dec 2007) | 3 lines
20ac86f4 58;;
813e8939
ER
59;; Add a note about requiring usbfs to use the garmin gps18 (usb)
60;; Mention firmware testing the AC12 with firmware BQ00 and BQ04
20ac86f4 61;;
813e8939
ER
62;; ------------------------------------------------------------------------
63;; r4620 | ckuethe | 2007-12-23 15:52:34 -0500 (Sun, 23 Dec 2007) | 1 line
20ac86f4 64;;
813e8939
ER
65;; add link to latest hardware reference
66;; ------------------------------------------------------------------------
67;; r4619 | ckuethe | 2007-12-23 14:37:31 -0500 (Sun, 23 Dec 2007) | 1 line
20ac86f4 68;;
813e8939
ER
69;; there is now a regression test for AC12 without raw data output
70
62c5f375
SM
71;;;; Darcs:
72
73;; Changes to darcsum.el:
20ac86f4 74;;
62c5f375
SM
75;; Mon Nov 28 15:19:38 GMT 2005 Dave Love <fx@gnu.org>
76;; * Abstract process startup into darcsum-start-process. Use TERM=dumb.
20ac86f4 77;; TERM=dumb avoids escape characters, at least, for any old darcs that
62c5f375 78;; doesn't understand DARCS_DONT_COLOR & al.
20ac86f4 79;;
62c5f375
SM
80;; Thu Nov 24 15:20:45 GMT 2005 Dave Love <fx@gnu.org>
81;; * darcsum-mode-related changes.
82;; Don't call font-lock-mode (unnecessary) or use-local-map (redundant).
83;; Use mode-class 'special. Add :group.
84;; Add trailing-whitespace option to mode hook and fix
85;; darcsum-display-changeset not to use trailing whitespace.
86
813e8939
ER
87;;;; Mercurial
88
89;; changeset: 11:8ff1a4166444
90;; tag: tip
91;; user: Eric S. Raymond <esr@thyrsus.com>
92;; date: Wed Dec 26 12:18:58 2007 -0500
93;; summary: Explain keywords. Add markup fixes.
20ac86f4 94;;
813e8939
ER
95;; changeset: 10:20abc7ab09c3
96;; user: Eric S. Raymond <esr@thyrsus.com>
97;; date: Wed Dec 26 11:37:28 2007 -0500
98;; summary: Typo fixes.
20ac86f4 99;;
813e8939
ER
100;; changeset: 9:ada9f4da88aa
101;; user: Eric S. Raymond <esr@thyrsus.com>
102;; date: Wed Dec 26 11:23:00 2007 -0500
103;; summary: Add RCS example session.
104
aa230d94 105;;; Todo:
5b467bf4 106
5b467bf4 107;; - add ability to modify a log-entry (via cvs-mode-admin ;-)
e57a1038 108;; - remove references to cvs-*
aa230d94 109;; - make it easier to add support for new backends without changing the code.
5b467bf4
SM
110
111;;; Code:
112
113(eval-when-compile (require 'cl))
5b467bf4 114(require 'pcvs-util)
ac3f4c6f 115(autoload 'vc-find-revision "vc")
c66b7ac0 116(autoload 'vc-diff-internal "vc")
5b467bf4 117
71f6f911
JB
118(defvar cvs-minor-wrap-function)
119
5b467bf4 120(defgroup log-view nil
e57a1038 121 "Major mode for browsing log output of RCS/CVS/SCCS."
5b467bf4
SM
122 :group 'pcl-cvs
123 :prefix "log-view-")
124
125(easy-mmode-defmap log-view-mode-map
c9829c70 126 '(("z" . kill-this-buffer)
9eaeec5b 127 ("q" . quit-window)
83db937c 128 ("m" . log-view-toggle-mark-entry)
9b64a7f0 129 ("e" . log-view-modify-change-comment)
99cb8c8b 130 ("d" . log-view-diff)
238a0f3a 131 ("=" . log-view-diff)
6653c6b7 132 ("D" . log-view-diff-changeset)
a3f5d84d 133 ("a" . log-view-annotate-version)
ac3f4c6f 134 ("f" . log-view-find-revision)
99cb8c8b 135 ("n" . log-view-msg-next)
cdbb990f 136 ("p" . log-view-msg-prev)
25edda53
DN
137 ("\t" . log-view-msg-next)
138 ([backtab] . log-view-msg-prev)
cdbb990f
SM
139 ("N" . log-view-file-next)
140 ("P" . log-view-file-prev)
e2c2a3e2
KG
141 ("\M-n" . log-view-file-next)
142 ("\M-p" . log-view-file-prev))
5b467bf4 143 "Log-View's keymap."
fb0c18ff 144 :inherit widget-keymap
c9829c70 145 :group 'log-view)
5b467bf4 146
d621bc0a
DN
147(easy-menu-define log-view-mode-menu log-view-mode-map
148 "Log-View Display Menu"
149 `("Log-View"
150 ;; XXX Do we need menu entries for these?
151 ;; ["Quit" quit-window]
152 ;; ["Kill This Buffer" kill-this-buffer]
799224fe
DN
153 ["Mark Log Entry for Diff" set-mark-command
154 :help ""]
155 ["Diff Revisions" log-view-diff
156 :help "Get the diff between two revisions"]
6653c6b7
DN
157 ["Changeset Diff" log-view-diff-changeset
158 :help "Get the changeset diff between two revisions"]
799224fe
DN
159 ["Visit Version" log-view-find-revision
160 :help "Visit the version at point"]
161 ["Annotate Version" log-view-annotate-version
162 :help "Annotate the version at point"]
031f1766
DN
163 ["Modify Log Comment" log-view-modify-change-comment
164 :help "Edit the change comment displayed at point"]
165 "-----"
799224fe
DN
166 ["Next Log Entry" log-view-msg-next
167 :help "Go to the next count'th log message"]
168 ["Previous Log Entry" log-view-msg-prev
169 :help "Go to the previous count'th log message"]
170 ["Next File" log-view-file-next
171 :help "Go to the next count'th file"]
172 ["Previous File" log-view-file-prev
173 :help "Go to the previous count'th file"]))
d621bc0a 174
5b467bf4
SM
175(defvar log-view-mode-hook nil
176 "Hook run at the end of `log-view-mode'.")
177
d842de85 178(defface log-view-file
5b467bf4 179 '((((class color) (background light))
1fd714a4
RS
180 (:background "grey70" :weight bold))
181 (t (:weight bold)))
5b467bf4
SM
182 "Face for the file header line in `log-view-mode'."
183 :group 'log-view)
c4f6e489 184(define-obsolete-face-alias 'log-view-file-face 'log-view-file "22.1")
d842de85 185(defvar log-view-file-face 'log-view-file)
5b467bf4 186
d842de85 187(defface log-view-message
5b467bf4
SM
188 '((((class color) (background light))
189 (:background "grey85"))
1fd714a4 190 (t (:weight bold)))
5b467bf4
SM
191 "Face for the message header line in `log-view-mode'."
192 :group 'log-view)
d842de85 193;; backward-compatibility alias
c4f6e489 194(define-obsolete-face-alias 'log-view-message-face 'log-view-message "22.1")
d842de85 195(defvar log-view-message-face 'log-view-message)
5b467bf4 196
18b2e5b9 197(defvar log-view-file-re
95588f91
SM
198 (concat "^\\(?:Working file: \\(?1:.+\\)" ;RCS and CVS.
199 ;; Subversion has no such thing??
200 "\\|\\(?:SCCS/s\\.\\|Changes to \\)\\(?1:.+\\):" ;SCCS and Darcs.
2ef3b3fe
SM
201 "\\)\n") ;Include the \n for font-lock reasons.
202 "Regexp matching the text identifying the file.
203The match group number 1 should match the file name itself.")
aa230d94 204
6653c6b7
DN
205(defvar log-view-per-file-logs t
206 "Set if to t if the logs are shown one file at a time.")
207
18b2e5b9 208(defvar log-view-message-re
95588f91
SM
209 (concat "^\\(?:revision \\(?1:[.0-9]+\\)\\(?:\t.*\\)?" ; RCS and CVS.
210 "\\|r\\(?1:[0-9]+\\) | .* | .*" ; Subversion.
211 "\\|D \\(?1:[.0-9]+\\) .*" ; SCCS.
62c5f375
SM
212 ;; Darcs doesn't have revision names. VC-darcs uses patch names
213 ;; instead. Darcs patch names are hashcodes, which do not appear
214 ;; in the log output :-(, but darcs accepts any prefix of the log
215 ;; message as a patch name, so we match the first line of the log
216 ;; message.
217 ;; First loosely match the date format.
218 (concat "\\|[^ \n].*[^0-9\n][0-9][0-9]:[0-9][0-9][^0-9\n].*[^ \n]"
219 ;;Email of user and finally Msg, used as revision name.
95588f91 220 " .*@.*\n\\(?: \\* \\(?1:.*\\)\\)?")
2ef3b3fe
SM
221 "\\)$")
222 "Regexp matching the text identifying a revision.
223The match group number 1 should match the revision number itself.")
5b467bf4 224
18b2e5b9
SM
225(defvar log-view-font-lock-keywords
226 ;; We use `eval' so as to use the buffer-local value of log-view-file-re
227 ;; and log-view-message-re, if applicable.
228 '((eval . `(,log-view-file-re
229 (1 (if (boundp 'cvs-filename-face) cvs-filename-face))
230 (0 log-view-file-face append)))
231 (eval . `(,log-view-message-re . log-view-message-face))))
5bdc71d0 232
5b467bf4
SM
233(defconst log-view-font-lock-defaults
234 '(log-view-font-lock-keywords t nil nil nil))
235
6653c6b7
DN
236(defvar log-view-vc-fileset nil
237 "Set this to the fileset corresponding to the current log.")
238
239(defvar log-view-vc-backend nil
240 "Set this to the VC backend that created the current log.")
241
edb33387 242;;;;
5b467bf4 243;;;; Actual code
edb33387 244;;;;
5b467bf4
SM
245
246;;;###autoload
c9829c70 247(define-derived-mode log-view-mode special-mode "Log-View"
5b467bf4 248 "Major mode for browsing CVS log output."
99cb8c8b 249 (setq buffer-read-only t)
5b467bf4 250 (set (make-local-variable 'font-lock-defaults) log-view-font-lock-defaults)
20ac86f4 251 (set (make-local-variable 'beginning-of-defun-function)
a3f5d84d 252 'log-view-beginning-of-defun)
20ac86f4 253 (set (make-local-variable 'end-of-defun-function)
a3f5d84d 254 'log-view-end-of-defun)
5b467bf4
SM
255 (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap))
256
257;;;;
258;;;; Navigation
259;;;;
260
cdbb990f
SM
261;; define log-view-{msg,file}-{next,prev}
262(easy-mmode-define-navigation log-view-msg log-view-message-re "log message")
263(easy-mmode-define-navigation log-view-file log-view-file-re "file")
5b467bf4 264
3e87f5fc
SM
265(defun log-view-goto-rev (rev)
266 (goto-char (point-min))
267 (ignore-errors
268 (while (not (equal rev (log-view-current-tag)))
269 (log-view-msg-next))
270 t))
271
5b467bf4
SM
272;;;;
273;;;; Linkage to PCL-CVS (mostly copied from cvs-status.el)
274;;;;
275
276(defconst log-view-dir-re "^cvs[.ex]* [a-z]+: Logging \\(.+\\)$")
277
278(defun log-view-current-file ()
279 (save-excursion
280 (forward-line 1)
281 (or (re-search-backward log-view-file-re nil t)
22f4e5c1 282 (re-search-forward log-view-file-re nil t)
ccf89694 283 (error "Unable to determine the current file"))
95588f91 284 (let* ((file (match-string 1))
5b467bf4
SM
285 (cvsdir (and (re-search-backward log-view-dir-re nil t)
286 (match-string 1)))
e57a1038
SM
287 (pcldir (and (boundp 'cvs-pcl-cvs-dirchange-re)
288 (re-search-backward cvs-pcl-cvs-dirchange-re nil t)
5b467bf4
SM
289 (match-string 1)))
290 (dir ""))
291 (let ((default-directory ""))
292 (when pcldir (setq dir (expand-file-name pcldir dir)))
99cb8c8b
SS
293 (when cvsdir (setq dir (expand-file-name cvsdir dir))))
294 (expand-file-name file dir))))
5b467bf4 295
99cb8c8b 296(defun log-view-current-tag (&optional where)
cdbb990f 297 (save-excursion
99cb8c8b 298 (when where (goto-char where))
cdbb990f
SM
299 (forward-line 1)
300 (let ((pt (point)))
301 (when (re-search-backward log-view-message-re nil t)
3a44b2ae 302 (let ((rev (match-string-no-properties 1)))
cdbb990f
SM
303 (unless (re-search-forward log-view-file-re pt t)
304 rev))))))
5b467bf4 305
83db937c 306(defun log-view-toggle-mark-entry ()
a0902360
DN
307 "Toggle the marked state for the log entry at point.
308Individual log entries can be marked and unmarked. The marked
309entries are denoted by changing their background color.
310`log-view-get-marked' returns the list of tags for the marked
311log entries."
83db937c
DN
312 (interactive)
313 (save-excursion
314 (forward-line 1)
315 (let ((pt (point)))
316 (when (re-search-backward log-view-message-re nil t)
317 (let ((beg (match-beginning 0))
318 end ov ovlist found tag)
319 (unless (re-search-forward log-view-file-re pt t)
3a44b2ae
DN
320 ;; Look to see if the current entry is marked.
321 (setq found (get-char-property (point) 'log-view-self))
83db937c 322 (if found
3a44b2ae
DN
323 (delete-overlay found)
324 ;; Create an overlay that covers this entry and change
813e8939 325 ;; its color.
83db937c 326 (setq tag (log-view-current-tag (point)))
83db937c 327 (forward-line 1)
3a44b2ae 328 (setq end
83db937c
DN
329 (if (re-search-forward log-view-message-re nil t)
330 (match-beginning 0)
331 (point-max)))
332 (setq ov (make-overlay beg end))
333 (overlay-put ov 'face 'log-view-file)
3a44b2ae
DN
334 ;; This is used to check if the overlay is present.
335 (overlay-put ov 'log-view-self ov)
83db937c
DN
336 (overlay-put ov 'log-view-marked tag))))))))
337
3a44b2ae 338(defun log-view-get-marked ()
a0902360 339 "Return the list of tags for the marked log entries."
3a44b2ae
DN
340 (save-excursion
341 (let ((pos (point-min))
342 marked-list ov)
343 (while (setq pos (next-single-property-change pos 'face))
344 (when (setq ov (get-char-property pos 'log-view-self))
345 (push (overlay-get ov 'log-view-marked) marked-list)
346 (setq pos (overlay-end ov))))
347 marked-list)))
348
a3f5d84d
DN
349(defun log-view-beginning-of-defun ()
350 ;; This assumes that a log entry starts with a line matching
351 ;; `log-view-message-re'. Modes that derive from `log-view-mode'
352 ;; for which this assumption is not valid will have to provide
353 ;; another implementation of this function. `log-view-msg-prev'
354 ;; does a similar job to this function, we can't use it here
355 ;; directly because it prints messages that are not appropriate in
356 ;; this context and it does not move to the beginning of the buffer
357 ;; when the point is before the first log entry.
358
359 ;; `log-view-beginning-of-defun' and `log-view-end-of-defun' have
360 ;; been checked to work with logs produced by RCS, CVS, git,
361 ;; mercurial and subversion.
362
363 (re-search-backward log-view-message-re nil 'move))
364
365(defun log-view-end-of-defun ()
366 ;; The idea in this function is to search for the beginning of the
367 ;; next log entry using `log-view-message-re' and then go back one
368 ;; line when finding it. Modes that derive from `log-view-mode' for
369 ;; which this assumption is not valid will have to provide another
370 ;; implementation of this function.
371
372 ;; Look back and if there is no entry there it means we are before
373 ;; the first log entry, so go forward until finding one.
374 (unless (save-excursion (re-search-backward log-view-message-re nil t))
375 (re-search-forward log-view-message-re nil t))
376
377 ;; In case we are at the end of log entry going forward a line will
378 ;; make us find the next entry when searching. If we are inside of
379 ;; an entry going forward a line will still keep the point inside
380 ;; the same entry.
381 (forward-line 1)
382
383 ;; In case we are at the beginning of an entry, move past it.
384 (when (looking-at log-view-message-re)
385 (goto-char (match-end 0))
386 (forward-line 1))
387
388 ;; Search for the start of the next log entry. Go to the end of the
389 ;; buffer if we could not find a next entry.
390 (when (re-search-forward log-view-message-re nil 'move)
391 (goto-char (match-beginning 0))
392 (forward-line -1)))
393
aa230d94
SM
394(defvar cvs-minor-current-files)
395(defvar cvs-branch-prefix)
396(defvar cvs-secondary-branch-prefix)
397
5b467bf4
SM
398(defun log-view-minor-wrap (buf f)
399 (let ((data (with-current-buffer buf
243afed7
SM
400 (let* ((beg (point))
401 (end (if mark-active (mark) (point)))
cbc98273
JL
402 (fr (log-view-current-tag beg))
403 (to (log-view-current-tag end)))
404 (when (string-equal fr to)
405 (save-excursion
406 (goto-char end)
407 (log-view-msg-next)
408 (setq to (log-view-current-tag))))
409 (cons
243afed7
SM
410 ;; The first revision has to be the one at point, for
411 ;; operations that only take one revision
412 ;; (e.g. cvs-mode-edit).
413 (cons (log-view-current-file) fr)
414 (cons (log-view-current-file) to))))))
5b467bf4
SM
415 (let ((cvs-branch-prefix (cdar data))
416 (cvs-secondary-branch-prefix (and (cdar data) (cddr data)))
417 (cvs-minor-current-files
418 (cons (caar data)
419 (when (and (cadr data) (not (equal (caar data) (cadr data))))
420 (list (cadr data)))))
421 ;; FIXME: I need to force because the fileinfos are UNKNOWN
422 (cvs-force-command "/F"))
423 (funcall f))))
424
ac3f4c6f 425(defun log-view-find-revision (pos)
c0313667
AS
426 "Visit the version at point."
427 (interactive "d")
6653c6b7
DN
428 (unless log-view-per-file-logs
429 (when (> (length log-view-vc-fileset) 1)
430 (error "Multiple files shown in this buffer, cannot use this command here")))
c0313667
AS
431 (save-excursion
432 (goto-char pos)
6653c6b7
DN
433 (switch-to-buffer (vc-find-revision (if log-view-per-file-logs
434 (log-view-current-file)
435 (car log-view-vc-fileset))
436 (log-view-current-tag)))))
c0313667 437
9b64a7f0
ER
438
439(defun log-view-extract-comment ()
440 "Parse comment from around the current point in the log."
441 (save-excursion
442 (let (st en (backend (vc-backend (log-view-current-file))))
443 (log-view-end-of-defun)
444 (cond ((eq backend 'SVN)
445 (forward-line -1)))
446 (setq en (point))
447 (log-view-beginning-of-defun)
448 (cond ((memq backend '(SCCS RCS CVS MCVS SVN))
449 (forward-line 2))
450 ((eq backend 'Hg)
451 (forward-line 4)
20ac86f4 452 (re-search-forward "summary: *" nil t)))
9b64a7f0
ER
453 (setq st (point))
454 (buffer-substring st en))))
455
8df5b06d
GM
456(declare-function vc-modify-change-comment "vc" (files rev oldcomment))
457
9b64a7f0
ER
458(defun log-view-modify-change-comment ()
459 "Edit the change comment displayed at point."
460 (interactive)
6653c6b7
DN
461 (vc-modify-change-comment (list (if log-view-per-file-logs
462 (log-view-current-file)
463 (car log-view-vc-fileset)))
464 (log-view-current-tag)
465 (log-view-extract-comment)))
9b64a7f0 466
a3f5d84d
DN
467(defun log-view-annotate-version (pos)
468 "Annotate the version at point."
469 (interactive "d")
6653c6b7
DN
470 (unless log-view-per-file-logs
471 (when (> (length log-view-vc-fileset) 1)
472 (error "Multiple files shown in this buffer, cannot use this command here")))
a3f5d84d
DN
473 (save-excursion
474 (goto-char pos)
c9c95fc3
CY
475 (vc-annotate (if log-view-per-file-logs
476 (log-view-current-file)
477 (car log-view-vc-fileset))
478 (log-view-current-tag))))
a3f5d84d 479
467ee23f
SM
480;;
481;; diff
482;;
99cb8c8b
SS
483
484(defun log-view-diff (beg end)
e8171d36
JL
485 "Get the diff between two revisions.
486If the mark is not active or the mark is on the revision at point,
487get the diff between the revision at point and its previous revision.
488Otherwise, get the diff between the revisions where the region starts
1acec32e
SM
489and ends.
490Contrary to `log-view-diff-changeset', it will only show the part of the
491changeset that affected the currently considered file(s)."
da4ae7d3
JL
492 (interactive
493 (list (if mark-active (region-beginning) (point))
494 (if mark-active (region-end) (point))))
99cb8c8b
SS
495 (let ((fr (log-view-current-tag beg))
496 (to (log-view-current-tag end)))
497 (when (string-equal fr to)
498 (save-excursion
499 (goto-char end)
500 (log-view-msg-next)
501 (setq to (log-view-current-tag))))
c66b7ac0
DN
502 (vc-diff-internal
503 t (list log-view-vc-backend
504 (if log-view-per-file-logs
505 (list (log-view-current-file))
506 log-view-vc-fileset))
507 to fr)))
6653c6b7 508
20ac86f4
JB
509(declare-function vc-diff-internal "vc"
510 (async vc-fileset rev1 rev2 &optional verbose))
511
6653c6b7
DN
512(defun log-view-diff-changeset (beg end)
513 "Get the diff between two revisions.
514If the mark is not active or the mark is on the revision at point,
515get the diff between the revision at point and its previous revision.
516Otherwise, get the diff between the revisions where the region starts
1acec32e
SM
517and ends.
518Contrary to `log-view-diff', it will show the whole changeset including
519the changes that affected other files than the currently considered file(s)."
6653c6b7
DN
520 (interactive
521 (list (if mark-active (region-beginning) (point))
522 (if mark-active (region-end) (point))))
523 (when (eq (vc-call-backend log-view-vc-backend 'revision-granularity) 'file)
524 (error "The %s backend does not support changeset diffs" log-view-vc-backend))
525 (let ((fr (log-view-current-tag beg))
526 (to (log-view-current-tag end)))
527 (when (string-equal fr to)
528 ;; TO and FR are the same, look at the previous revision.
529 (setq to (vc-call-backend log-view-vc-backend 'previous-revision nil fr)))
530 (vc-diff-internal
531 t
532 ;; We want to see the diff for all the files in the changeset, so
533 ;; pass NIL for the file list. The value passed here should
534 ;; follow what `vc-deduce-fileset' returns.
535 (list log-view-vc-backend nil)
536 to fr)))
99cb8c8b 537
5b467bf4 538(provide 'log-view)
cdbb990f 539
9be92b96 540;; arch-tag: 0d64220b-ce7e-4f62-9c2a-6b04c2f81f4f
5b467bf4 541;;; log-view.el ends here