diff options
| -rw-r--r-- | lisp/vc.el | 97 |
1 files changed, 70 insertions, 27 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 4b37dd516db..4d12657424c 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: FSF (see below for full credits) | 5 | ;; Author: FSF (see below for full credits) |
| 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
| 7 | 7 | ||
| 8 | ;; $Id: vc.el,v 1.275 2000/10/03 11:22:13 spiegel Exp $ | 8 | ;; $Id: vc.el,v 1.276 2000/10/03 12:24:15 spiegel Exp $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -138,6 +138,8 @@ | |||
| 138 | ;; * print-log (file) | 138 | ;; * print-log (file) |
| 139 | ;; Insert the revision log of FILE into the current buffer. | 139 | ;; Insert the revision log of FILE into the current buffer. |
| 140 | ;; - show-log-entry (version) | 140 | ;; - show-log-entry (version) |
| 141 | ;; - wash-log (file) | ||
| 142 | ;; Remove all non-comment information from the output of print-log | ||
| 141 | ;; - comment-history (file) | 143 | ;; - comment-history (file) |
| 142 | ;; - update-changelog (files) | 144 | ;; - update-changelog (files) |
| 143 | ;; Find changelog entries for FILES, or for all files at or below | 145 | ;; Find changelog entries for FILES, or for all files at or below |
| @@ -1206,6 +1208,12 @@ for vc-log-operation-hook." | |||
| 1206 | "Retrieve a copy of the revision REV of FILE. | 1208 | "Retrieve a copy of the revision REV of FILE. |
| 1207 | If WRITABLE is non-nil, make sure the retrieved file is writable. | 1209 | If WRITABLE is non-nil, make sure the retrieved file is writable. |
| 1208 | REV defaults to the latest revision." | 1210 | REV defaults to the latest revision." |
| 1211 | (and writable | ||
| 1212 | (not rev) | ||
| 1213 | (vc-call make-version-backups file) | ||
| 1214 | (vc-up-to-date-p file) | ||
| 1215 | (copy-file file (vc-version-backup-file-name file) | ||
| 1216 | 'ok-if-already-exists 'keep-date)) | ||
| 1209 | (with-vc-properties | 1217 | (with-vc-properties |
| 1210 | file | 1218 | file |
| 1211 | (condition-case err | 1219 | (condition-case err |
| @@ -1280,7 +1288,9 @@ Runs the normal hook `vc-checkin-hook'." | |||
| 1280 | file | 1288 | file |
| 1281 | ;; Change buffers to get local value of vc-checkin-switches. | 1289 | ;; Change buffers to get local value of vc-checkin-switches. |
| 1282 | (with-current-buffer (or (get-file-buffer file) (current-buffer)) | 1290 | (with-current-buffer (or (get-file-buffer file) (current-buffer)) |
| 1283 | (vc-call checkin file rev comment)) | 1291 | (let ((backup-file (vc-version-backup-file file))) |
| 1292 | (vc-call checkin file rev comment) | ||
| 1293 | (if backup-file (delete-file backup-file)))) | ||
| 1284 | `((vc-state up-to-date) | 1294 | `((vc-state up-to-date) |
| 1285 | (vc-checkout-time ,(nth 5 (file-attributes file))) | 1295 | (vc-checkout-time ,(nth 5 (file-attributes file))) |
| 1286 | (vc-workfile-version nil))) | 1296 | (vc-workfile-version nil))) |
| @@ -1493,11 +1503,12 @@ files in or below it." | |||
| 1493 | rel2-default ") ") | 1503 | rel2-default ") ") |
| 1494 | "Newer version (default: current source): ") | 1504 | "Newer version (default: current source): ") |
| 1495 | nil nil rel2-default)))) | 1505 | nil nil rel2-default)))) |
| 1496 | (if (string-equal rel1 "") (setq rel1 nil)) | ||
| 1497 | (if (string-equal rel2 "") (setq rel2 nil)) | ||
| 1498 | (vc-setup-buffer "*vc-diff*") | 1506 | (vc-setup-buffer "*vc-diff*") |
| 1499 | (if (file-directory-p file) | 1507 | (if (file-directory-p file) |
| 1508 | ;; recursive directory diff | ||
| 1500 | (let ((inhibit-read-only t)) | 1509 | (let ((inhibit-read-only t)) |
| 1510 | (if (string-equal rel1 "") (setq rel1 nil)) | ||
| 1511 | (if (string-equal rel2 "") (setq rel2 nil)) | ||
| 1501 | (insert "Diffs between " | 1512 | (insert "Diffs between " |
| 1502 | (or rel1 "last version checked in") | 1513 | (or rel1 "last version checked in") |
| 1503 | " and " | 1514 | " and " |
| @@ -1514,9 +1525,19 @@ files in or below it." | |||
| 1514 | (vc-call-backend ',(vc-backend file) 'diff ',f ',rel1 ',rel2))))) | 1525 | (vc-call-backend ',(vc-backend file) 'diff ',f ',rel1 ',rel2))))) |
| 1515 | (vc-exec-after `(let ((inhibit-read-only t)) | 1526 | (vc-exec-after `(let ((inhibit-read-only t)) |
| 1516 | (insert "\nEnd of diffs.\n")))) | 1527 | (insert "\nEnd of diffs.\n")))) |
| 1517 | 1528 | ;; single file diff | |
| 1518 | (cd (file-name-directory file)) | 1529 | (if (or (not rel1) (string-equal rel1 "")) |
| 1519 | (vc-call diff file rel1 rel2)) | 1530 | (setq rel1 (vc-workfile-version file))) |
| 1531 | (if (string-equal rel2 "") | ||
| 1532 | (setq rel2 nil)) | ||
| 1533 | (let ((file-rel1 (vc-version-backup-file file rel1)) | ||
| 1534 | (file-rel2 (if (not rel2) | ||
| 1535 | file | ||
| 1536 | (vc-version-backup-file file rel2)))) | ||
| 1537 | (if (and file-rel1 file-rel2) | ||
| 1538 | (vc-do-command t 1 "diff" nil diff-switches file-rel1 file-rel2) | ||
| 1539 | (cd (file-name-directory file)) | ||
| 1540 | (vc-call diff file rel1 rel2)))) | ||
| 1520 | (if (and (zerop (buffer-size)) | 1541 | (if (and (zerop (buffer-size)) |
| 1521 | (not (get-buffer-process (current-buffer)))) | 1542 | (not (get-buffer-process (current-buffer)))) |
| 1522 | (progn | 1543 | (progn |
| @@ -2156,30 +2177,43 @@ changes found in the master file; use \\[universal-argument] \\[vc-next-action] | |||
| 2156 | (let ((file buffer-file-name) | 2177 | (let ((file buffer-file-name) |
| 2157 | ;; This operation should always ask for confirmation. | 2178 | ;; This operation should always ask for confirmation. |
| 2158 | (vc-suppress-confirm nil) | 2179 | (vc-suppress-confirm nil) |
| 2159 | (obuf (current-buffer))) | 2180 | (obuf (current-buffer)) |
| 2181 | status) | ||
| 2160 | (unless (vc-workfile-unchanged-p file) | 2182 | (unless (vc-workfile-unchanged-p file) |
| 2161 | (vc-diff nil t) | 2183 | (setq status (vc-diff nil t)) |
| 2162 | (vc-exec-after `(message nil)) | 2184 | (vc-exec-after `(message nil)) |
| 2163 | (unwind-protect | 2185 | (when status |
| 2164 | (if (not (yes-or-no-p "Discard changes? ")) | 2186 | (unwind-protect |
| 2165 | (error "Revert canceled")) | 2187 | (if (not (yes-or-no-p "Discard changes? ")) |
| 2166 | (if (and (window-dedicated-p (selected-window)) | 2188 | (error "Revert canceled")) |
| 2167 | (one-window-p t)) | 2189 | (if (and (window-dedicated-p (selected-window)) |
| 2168 | (make-frame-invisible) | 2190 | (one-window-p t)) |
| 2169 | (delete-window)))) | 2191 | (make-frame-invisible) |
| 2192 | (delete-window))))) | ||
| 2170 | (set-buffer obuf) | 2193 | (set-buffer obuf) |
| 2171 | ;; Do the reverting | 2194 | ;; Do the reverting |
| 2172 | (message "Reverting %s..." file) | 2195 | (message "Reverting %s..." file) |
| 2173 | (vc-revert-file file) | 2196 | (vc-revert-file file) |
| 2174 | (message "Reverting %s...done" file))) | 2197 | (message "Reverting %s...done" file))) |
| 2175 | 2198 | ||
| 2199 | (defun vc-version-backup-file (file &optional rev) | ||
| 2200 | "If version backups should be used for FILE, and there exists | ||
| 2201 | such a backup for REV or the current workfile version of file, | ||
| 2202 | return the name of it; otherwise return nil." | ||
| 2203 | (when (vc-call make-version-backups file) | ||
| 2204 | (let ((backup-file (vc-version-backup-file-name file rev))) | ||
| 2205 | (and (file-exists-p backup-file) | ||
| 2206 | backup-file)))) | ||
| 2207 | |||
| 2176 | (defun vc-revert-file (file) | 2208 | (defun vc-revert-file (file) |
| 2177 | "Revert FILE back to the version it was based on." | 2209 | "Revert FILE back to the version it was based on." |
| 2178 | ;; TODO: With local version caching, this function will get the | ||
| 2179 | ;; base version locally and not from the server. | ||
| 2180 | (with-vc-properties | 2210 | (with-vc-properties |
| 2181 | file | 2211 | file |
| 2182 | (vc-call revert file) | 2212 | (let ((backup-file (vc-version-backup-file file))) |
| 2213 | (if (not backup-file) | ||
| 2214 | (vc-call revert file) | ||
| 2215 | (copy-file backup-file file 'ok-if-already-exists 'keep-date) | ||
| 2216 | (delete-file backup-file))) | ||
| 2183 | `((vc-state up-to-date) | 2217 | `((vc-state up-to-date) |
| 2184 | (vc-checkout-time ,(nth 5 (file-attributes file))))) | 2218 | (vc-checkout-time ,(nth 5 (file-attributes file))))) |
| 2185 | (vc-resynch-buffer file t t)) | 2219 | (vc-resynch-buffer file t t)) |
| @@ -2288,7 +2322,7 @@ backend to NEW-BACKEND, and unregister FILE from the current backend. | |||
| 2288 | (and registered ; Never move if not registered in new-backend yet. | 2322 | (and registered ; Never move if not registered in new-backend yet. |
| 2289 | ;; move if new-backend comes later in vc-handled-backends | 2323 | ;; move if new-backend comes later in vc-handled-backends |
| 2290 | (or (memq new-backend (memq old-backend vc-handled-backends)) | 2324 | (or (memq new-backend (memq old-backend vc-handled-backends)) |
| 2291 | (y-or-n-p "Final transfer ? ")))) | 2325 | (y-or-n-p "Final transfer? ")))) |
| 2292 | (comment nil)) | 2326 | (comment nil)) |
| 2293 | (if (eq old-backend new-backend) | 2327 | (if (eq old-backend new-backend) |
| 2294 | (error "%s is the current backend of %s" new-backend file)) | 2328 | (error "%s is the current backend of %s" new-backend file)) |
| @@ -2296,20 +2330,28 @@ backend to NEW-BACKEND, and unregister FILE from the current backend. | |||
| 2296 | (set-file-modes file (logior (file-modes file) 128)) | 2330 | (set-file-modes file (logior (file-modes file) 128)) |
| 2297 | ;; `registered' might have switched under us. | 2331 | ;; `registered' might have switched under us. |
| 2298 | (vc-switch-backend file old-backend) | 2332 | (vc-switch-backend file old-backend) |
| 2299 | (let ((copy (and edited (make-temp-name file))) | 2333 | (let* ((rev (vc-workfile-version file)) |
| 2300 | (rev (vc-workfile-version file))) | 2334 | (modified-file (and edited (make-temp-name file))) |
| 2335 | (unmodified-file (and modified-file (vc-version-backup-file file)))) | ||
| 2301 | ;; Go back to the base unmodified file. | 2336 | ;; Go back to the base unmodified file. |
| 2302 | (unwind-protect | 2337 | (unwind-protect |
| 2303 | (progn | 2338 | (progn |
| 2304 | (when copy (copy-file file copy)) ; (vc-revert-file file)) | 2339 | (when modified-file |
| 2305 | ; TODO: uncomment when we | 2340 | (copy-file file modified-file) |
| 2306 | ; have local version caching | 2341 | ;; If we have a local copy of the unmodified file, handle that |
| 2342 | ;; here and not in vc-revert-file because we don't want to | ||
| 2343 | ;; delete that copy -- it is still useful for OLD-BACKEND. | ||
| 2344 | (if unmodified-file | ||
| 2345 | (copy-file unmodified-file file 'ok-if-already-exists) | ||
| 2346 | (if (y-or-n-p "Get base version from master? ") | ||
| 2347 | (vc-revert-file file)))) | ||
| 2307 | (vc-call-backend new-backend 'receive-file file rev)) | 2348 | (vc-call-backend new-backend 'receive-file file rev)) |
| 2308 | (when copy | 2349 | (when modified-file |
| 2309 | (vc-switch-backend file new-backend) | 2350 | (vc-switch-backend file new-backend) |
| 2310 | (unless (eq (vc-checkout-model file) 'implicit) | 2351 | (unless (eq (vc-checkout-model file) 'implicit) |
| 2311 | (vc-checkout file t nil)) | 2352 | (vc-checkout file t nil)) |
| 2312 | (rename-file copy file 'ok-if-already-exists))))) | 2353 | (rename-file modified-file file 'ok-if-already-exists) |
| 2354 | (vc-file-setprop file 'vc-checkout-time nil))))) | ||
| 2313 | (when move | 2355 | (when move |
| 2314 | (vc-switch-backend file old-backend) | 2356 | (vc-switch-backend file old-backend) |
| 2315 | (setq comment (vc-call comment-history file)) | 2357 | (setq comment (vc-call comment-history file)) |
| @@ -2317,6 +2359,7 @@ backend to NEW-BACKEND, and unregister FILE from the current backend. | |||
| 2317 | (vc-switch-backend file new-backend) | 2359 | (vc-switch-backend file new-backend) |
| 2318 | (when (or move edited) | 2360 | (when (or move edited) |
| 2319 | (vc-file-setprop file 'vc-state 'edited) | 2361 | (vc-file-setprop file 'vc-state 'edited) |
| 2362 | (vc-mode-line file) | ||
| 2320 | (vc-checkin file nil comment (stringp comment))))) | 2363 | (vc-checkin file nil comment (stringp comment))))) |
| 2321 | 2364 | ||
| 2322 | (defun vc-default-unregister (backend file) | 2365 | (defun vc-default-unregister (backend file) |