comparison lisp/vc.el @ 5201:b27badfb4040

(vc-buffer-sync): Signal error if user says no.
author Richard M. Stallman <rms@gnu.org>
date Sat, 27 Nov 1993 11:39:02 +0000
parents 368dd7e8095d
children 7fdef355cdc2
comparison
equal deleted inserted replaced
5200:1006461bf759 5201:b27badfb4040
115 '((nroff-mode ".\\\"" "")) 115 '((nroff-mode ".\\\"" ""))
116 "*Special comment delimiters to be used in generating vc headers only. 116 "*Special comment delimiters to be used in generating vc headers only.
117 Add an entry in this list if you need to override the normal comment-start 117 Add an entry in this list if you need to override the normal comment-start
118 and comment-end variables. This will only be necessary if the mode language 118 and comment-end variables. This will only be necessary if the mode language
119 is sensitive to blank lines.") 119 is sensitive to blank lines.")
120
121 ;; Default is to be extra careful for super-user.
122 (defvar vc-checkout-carefully (= (user-uid) 0)
123 "*Non-nil means be extra-careful in checkout.
124 Verify that the file really is not locked
125 and that its contents match what the master file says.")
120 126
121 ;; Variables the user doesn't need to know about. 127 ;; Variables the user doesn't need to know about.
122 (defvar vc-log-entry-mode nil) 128 (defvar vc-log-entry-mode nil)
123 (defvar vc-log-operation nil) 129 (defvar vc-log-operation nil)
124 (defvar vc-log-after-operation-hook nil) 130 (defvar vc-log-after-operation-hook nil)
325 (if new-mark (set-mark new-mark)))))) 331 (if new-mark (set-mark new-mark))))))
326 332
327 333
328 (defun vc-buffer-sync () 334 (defun vc-buffer-sync ()
329 ;; Make sure the current buffer and its working file are in sync 335 ;; Make sure the current buffer and its working file are in sync
330 (if (and (buffer-modified-p) 336 (if (buffer-modified-p)
331 (or 337 (progn
332 vc-suppress-confirm 338 (or vc-suppress-confirm
333 (y-or-n-p (format "%s has been modified. Write it out? " 339 (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name)))
334 (buffer-name))))) 340 (error "Aborted"))
335 (save-buffer))) 341 (save-buffer))))
336 342
337 (defun vc-workfile-unchanged-p (file) 343 (defun vc-workfile-unchanged-p (file)
338 ;; Has the given workfile changed since last checkout? 344 ;; Has the given workfile changed since last checkout?
339 (let ((checkout-time (vc-file-getprop file 'vc-checkout-time)) 345 (let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
340 (lastmod (nth 5 (file-attributes file)))) 346 (lastmod (nth 5 (file-attributes file))))
363 'vc-checkout-writable-buffer-hook) 369 'vc-checkout-writable-buffer-hook)
364 (vc-checkout-writable-buffer file))) 370 (vc-checkout-writable-buffer file)))
365 371
366 ;; if there is no lock on the file, assert one and get it 372 ;; if there is no lock on the file, assert one and get it
367 ((not (setq owner (vc-locking-user file))) 373 ((not (setq owner (vc-locking-user file)))
368 (vc-checkout-writable-buffer file)) 374 (if (and vc-checkout-carefully
375 (not (vc-workfile-unchanged-p file))
376 (not (zerop (vc-backend-diff file nil))))
377 (if (save-window-excursion
378 (pop-to-buffer "*vc*")
379 (goto-char (point-min))
380 (insert-string (format "Changes to %s since last lock:\n\n"
381 file))
382 (not (beep))
383 (yes-or-no-p
384 (concat "File has unlocked changes, "
385 "claim lock retaining changes? ")))
386 (progn (vc-backend-steal file)
387 (vc-mode-line file))
388 (if (not (yes-or-no-p "Revert to checked-in version, instead? "))
389 (error "Checkout aborted.")
390 (vc-revert-buffer1 t t)
391 (vc-checkout-writable-buffer file))
392 )
393 (vc-checkout-writable-buffer file)))
369 394
370 ;; a checked-out version exists, but the user may not own the lock 395 ;; a checked-out version exists, but the user may not own the lock
371 ((not (string-equal owner (user-login-name))) 396 ((not (string-equal owner (user-login-name)))
372 (if comment 397 (if comment
373 (error "Sorry, you can't steal the lock on %s this way" file)) 398 (error "Sorry, you can't steal the lock on %s this way" file))
439 it will operate on the file in the current line. 464 it will operate on the file in the current line.
440 If you call this from within a VC dired buffer, and one or more 465 If you call this from within a VC dired buffer, and one or more
441 files are marked, it will accept a log message and then operate on 466 files are marked, it will accept a log message and then operate on
442 each one. The log message will be used as a comment for any register 467 each one. The log message will be used as a comment for any register
443 or checkin operations, but ignored when doing checkouts. Attempted 468 or checkin operations, but ignored when doing checkouts. Attempted
444 lock steals will raise an error." 469 lock steals will raise an error.
470
471 For checkin, a prefix argument lets you specify the version number to use."
445 (interactive "P") 472 (interactive "P")
446 (catch 'nogo 473 (catch 'nogo
447 (if vc-dired-mode 474 (if vc-dired-mode
448 (let ((files (dired-get-marked-files))) 475 (let ((files (dired-get-marked-files)))
449 (if (= (length files) 1) 476 (if (= (length files) 1)