annotate lisp/ediff/ediff-vers.el @ 80:1ce6082ce73f r20-0b90

Import from CVS: tag r20-0b90
author cvs
date Mon, 13 Aug 2007 09:06:37 +0200
parents c7528f8e288d
children 6a378aca36af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; ediff-vers.el --- version control interface to Ediff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 16
diff changeset
3 ;;; Copyright (C) 1995, 1996 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; Compiler pacifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (defvar rcs-default-co-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (defvar sc-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (defvar cvs-shell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar cvs-program)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar cvs-cookie-handle)
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
33 (defvar ediff-temp-file-prefix)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
35 (eval-when-compile
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
36 (load "pcl-cvs" 'noerror)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
37 (load "rcs" 'noerror)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
38 (load "generic-sc" 'noerror)
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
39 (load "vc" 'noerror))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; end pacifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; VC.el support
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
43 (defun ediff-vc-internal (rev1 rev2 &optional startup-hooks)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Run Ediff on versions of the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; If REV2 is "" then compare current buffer with REV1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; If the current buffer is named `F', the version is named `F.~REV~'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; If `F.~REV~' already exists, it is used instead of being re-created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (let (file1 file2 rev1buf rev2buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (vc-version-other-window rev1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq rev1buf (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 file1 (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (or (string= rev2 "") ; use current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (vc-version-other-window rev2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (setq rev2buf (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 file2 (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (setq startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (cons (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (delete-file (, file1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (or (, (string= rev2 "")) (delete-file (, file2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (ediff-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 rev1buf rev2buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 'ediff-revision)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; RCS.el support
80
1ce6082ce73f Import from CVS: tag r20-0b90
cvs
parents: 78
diff changeset
70 (defun rcs-ediff-view-revision (&optional rev)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; View previous RCS revision of current file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; With prefix argument, prompts for a revision name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (interactive (list (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (read-string "Revision: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (let* ((filename (buffer-file-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (switches (append '("-p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if rev (list (concat "-r" rev)) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (buff (concat (file-name-nondirectory filename) ".~" rev "~")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (message "Working ...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (setq filename (expand-file-name filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (with-output-to-temp-buffer buff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (delete-windows-on output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (set-buffer output-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (apply 'call-process "co" nil t nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; -q: quiet (no diagnostics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (append switches rcs-default-co-switches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (list "-q" filename)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (message "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 buff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun ediff-rcs-get-output-buffer (file name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; Get a buffer for RCS output for FILE, make it writable and clean it up.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; Optional NAME is name to use instead of `*RCS-output*'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; This is a modified version from rcs.el v1.1. I use it here to make
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Ediff immune to changes in rcs.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (let* ((default-major-mode 'fundamental-mode) ; no frills!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (buf (get-buffer-create name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq buffer-read-only nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 default-directory (file-name-directory (expand-file-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
107 (defun ediff-rcs-internal (rev1 rev2 &optional startup-hooks)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; Run Ediff on versions of the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; If REV2 is "" then use current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (let ((rev2buf (if (string= rev2 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (rcs-ediff-view-revision rev2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (rev1buf (rcs-ediff-view-revision rev1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; rcs.el doesn't create temp version files, so we don't have to delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; anything in startup hooks to ediff-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (ediff-buffers rev1buf rev2buf startup-hooks 'ediff-revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; GENERIC-SC.el support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (defun generic-sc-get-latest-rev ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (cond ((eq sc-mode 'CCASE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (eval "main/LATEST"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (t (eval ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
128 (defun ediff-generic-sc-internal (rev1 rev2 &optional startup-hooks)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; Run Ediff on versions of the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; If REV2 is "" then compare current buffer with REV1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; If the current buffer is named `F', the version is named `F.~REV~'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;; If `F.~REV~' already exists, it is used instead of being re-created.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let (rev1buf rev2buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if (or (not rev1) (string= rev1 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (setq rev1 (generic-sc-get-latest-rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (sc-visit-previous-revision rev1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (setq rev1buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (or (string= rev2 "") ; use current buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (sc-visit-previous-revision rev2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (setq rev2buf (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (ediff-buffers rev1buf rev2buf startup-hooks 'ediff-revision)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;;; Merge with Version Control
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
148 (defun ediff-vc-merge-internal (rev1 rev2 ancestor-rev &optional startup-hooks)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; If ANCESTOR-REV non-nil, merge with ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (let (buf1 buf2 ancestor-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (vc-version-other-window rev1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (setq buf1 (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (or (string= rev2 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (vc-version-other-window rev2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq buf2 (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (if ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (or (string= ancestor-rev "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (vc-version-other-window ancestor-rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (setq ancestor-buf (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (setq startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (delete-file (, (buffer-file-name buf1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (or (, (string= rev2 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (delete-file (, (buffer-file-name buf2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (or (, (string= ancestor-rev ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (, (not ancestor-rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (delete-file (, (buffer-file-name ancestor-buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (ediff-merge-buffers-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 buf1 buf2 ancestor-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 startup-hooks 'ediff-merge-revisions-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (ediff-merge-buffers buf1 buf2 startup-hooks 'ediff-merge-revisions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
181 (defun ediff-rcs-merge-internal (rev1 rev2 ancestor-rev
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; If ANCESTOR-REV non-nil, merge with ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (let (buf1 buf2 ancestor-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (setq buf1 (rcs-ediff-view-revision rev1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 buf2 (if (string= rev2 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (rcs-ediff-view-revision rev2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ancestor-buf (if ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (string= ancestor-rev "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (current-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (rcs-ediff-view-revision ancestor-rev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; rcs.el doesn't create temp version files, so we don't have to delete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; anything in startup hooks to ediff-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (if ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (ediff-merge-buffers-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 buf1 buf2 ancestor-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 startup-hooks 'ediff-merge-revisions-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (ediff-merge-buffers buf1 buf2 startup-hooks 'ediff-merge-revisions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
201 (defun ediff-generic-sc-merge-internal (rev1 rev2 ancestor-rev
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;; If ANCESTOR-REV non-nil, merge with ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (let (buf1 buf2 ancestor-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (string= rev1 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (setq rev1 (generic-sc-get-latest-rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (sc-visit-previous-revision rev1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (setq buf1 (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (or (string= rev2 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (sc-visit-previous-revision rev2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (setq buf2 (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (if ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (or (string= ancestor-rev "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (sc-visit-previous-revision ancestor-rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (setq ancestor-buf (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (if ancestor-rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (ediff-merge-buffers-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 buf1 buf2 ancestor-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 startup-hooks 'ediff-merge-revisions-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (ediff-merge-buffers buf1 buf2 startup-hooks 'ediff-merge-revisions))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;; PCL-CVS.el support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
228 (defun ediff-pcl-cvs-internal (rev1 rev2 &optional startup-hooks)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; Run Ediff on a pair of revisions of the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; If REV1 is "", use the latest revision.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; If REV2 is "", use the current buffer as the second file to compare.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let ((orig-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 orig-file-name buf1 buf2 file1 file2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (or (setq orig-file-name (buffer-file-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (error "Current buffer is not visiting any file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (if (string= rev1 "") (setq rev1 nil)) ; latest revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq buf1 (ediff-pcl-cvs-view-revision orig-file-name rev1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 buf2 (if (string= rev2 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 orig-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (ediff-pcl-cvs-view-revision orig-file-name rev2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 file1 (buffer-file-name buf1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 file2 (buffer-file-name buf2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (setq startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (cons (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (delete-file (, file1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (or (, (string= rev2 "")) (delete-file (, file2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (ediff-buffers buf1 buf2 startup-hooks 'ediff-revision)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; This function is the standard Ediff's interface to pcl-cvs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;; Works like with other interfaces: runs ediff on versions of the file in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; current buffer.
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
255 (defun ediff-pcl-cvs-merge-internal (rev1 rev2 ancestor-rev
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 &optional startup-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; Ediff-merge appropriate revisions of the selected file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; If REV1 is "" then use the latest revision.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; If REV2 is "" then merge current buffer's file with REV1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; If ANCESTOR-REV is "" then use current buffer's file as ancestor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; If ANCESTOR-REV is nil, then merge without the ancestor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (let ((orig-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 orig-file-name buf1 buf2 ancestor-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (or (setq orig-file-name (buffer-file-name (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (error "Current buffer is not visiting any file"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (if (string= rev1 "") (setq rev1 nil)) ; latest revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq buf1 (ediff-pcl-cvs-view-revision orig-file-name rev1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq buf2 (if (string= rev2 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 orig-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (ediff-pcl-cvs-view-revision orig-file-name rev2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (if (stringp ancestor-rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq ancestor-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if (string= ancestor-rev "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 orig-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (ediff-pcl-cvs-view-revision orig-file-name ancestor-rev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (setq startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (cons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (` (lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (delete-file (, (buffer-file-name buf1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (or (, (string= rev2 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (delete-file (, (buffer-file-name buf2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (or (, (string= ancestor-rev ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (, (not ancestor-rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (delete-file (, (buffer-file-name ancestor-buf))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 startup-hooks))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (if ancestor-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (ediff-merge-buffers-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 buf1 buf2 ancestor-buf startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 'ediff-merge-revisions-with-ancestor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (ediff-merge-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 buf1 buf2 startup-hooks 'ediff-merge-revisions))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun ediff-pcl-cvs-view-revision (file rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; if rev = "", get the latest revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let ((temp-name (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (concat ediff-temp-file-prefix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "ediff_" rev))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (cvs-kill-buffer-visiting temp-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (if rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (message "Retrieving revision %s..." rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (message "Retrieving latest revision..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (let ((res (call-process cvs-shell nil nil nil "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (concat cvs-program " update -p "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (if rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (concat "-r " rev " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 " > " temp-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (if (and res (not (and (integerp res) (zerop res))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (error "Failed to retrieve revision: %s" res))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (if rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (message "Retrieving revision %s... Done." rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (message "Retrieving latest revision... Done."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (find-file-noselect temp-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (defun cvs-run-ediff-on-file-descriptor (tin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 ;; This is a replacement for cvs-emerge-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; Run after cvs-update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 ;; Ediff-merge appropriate revisions of the selected file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (let* ((fileinfo (tin-cookie cvs-cookie-handle tin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (type (cvs-fileinfo->type fileinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (tmp-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (cvs-retrieve-revision-to-tmpfile fileinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ancestor-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (or (memq type '(MERGED CONFLICT MODIFIED))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 "Can only merge `Modified', `Merged' or `Conflict' files"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (cond ((memq type '(MERGED CONFLICT))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq ancestor-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (cvs-retrieve-revision-to-tmpfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 fileinfo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 ;; revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (cvs-fileinfo->base-revision fileinfo)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (ediff-merge-buffers-with-ancestor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (find-file-noselect tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (find-file-noselect (cvs-fileinfo->backup-file fileinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (find-file-noselect ancestor-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 nil ; startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 'ediff-merge-revisions-with-ancestor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ((eq type 'MODIFIED)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (ediff-merge-buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (find-file-noselect tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (find-file-noselect (cvs-fileinfo->full-path fileinfo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 nil ; startup-hooks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 'ediff-merge-revisions)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (if (stringp tmp-file) (delete-file tmp-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (if (stringp ancestor-file) (delete-file ancestor-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;;; Local Variables:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1)
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 70
diff changeset
362 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;; End:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (provide 'ediff-vers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;;; ediff-vers.el ends here