;;; -*-Scheme-*-
;;;
-;;; $Id: vc.scm,v 1.55 2000/03/31 20:10:56 cph Exp $
+;;; $Id: vc.scm,v 1.56 2000/04/01 02:14:09 cph Exp $
;;;
;;; Copyright (c) 1994-2000 Massachusetts Institute of Technology
;;;
;;;; Mode line
(define (vc-mode-line master buffer)
- (let ((workfile-buffer (vc-workfile-buffer master)))
+ (let ((workfile-buffer (vc-workfile-buffer master #f)))
(let ((buffer (or buffer workfile-buffer))
(revision
(or (vc-backend-workfile-revision master)
\f
;;;; VC-MASTER association
+(define (current-vc-master error?)
+ (buffer-vc-master (selected-buffer) error?))
+
(define (buffer-vc-master buffer error?)
(let ((buffer (chase-parent-buffer buffer)))
(let ((master (buffer-get buffer 'VC-MASTER #f)))
(error "VC master file disappeared:" (vc-master-pathname master))))
(define (vc-registration-error object)
- (if (or (buffer? object) (not object))
- (editor-error "Buffer "
- (buffer-name (or object (selected-buffer)))
+ (if (buffer? object)
+ (editor-error "Buffer " (buffer-name object)
" is not associated with a file.")
- (editor-error "File "
- (->namestring object)
+ (editor-error "File " (->namestring object)
" is not under version control.")))
\f
;;;; Primary Commands
of the buffer."
()
(lambda ()
- (if (buffer-vc-master (selected-buffer) #f)
+ (if (current-vc-master #f)
((ref-command vc-next-action) #f)
((ref-command toggle-read-only)))))
(if (vc-dired-buffer? buffer)
(vc-next-action-dired buffer)
(vc-next-action-on-file (or (buffer-pathname buffer)
- (vc-registration-error #f))
+ (vc-registration-error buffer))
#f revision? #f)))))
(define-command vc-register
(lambda (revision?)
(let ((workfile
(let ((buffer (selected-buffer)))
- (if (vc-dired-buffer? buffer)
- (dired-this-file buffer #t)
- (buffer-pathname (selected-buffer))))))
- (if (not workfile) (vc-registration-error #f))
+ (or (if (vc-dired-buffer? buffer)
+ (dired-this-file buffer #t)
+ (buffer-pathname buffer))
+ (vc-registration-error buffer)))))
(if (file-vc-master workfile #f)
(editor-error "This file is already registered."))
(vc-register workfile revision? #f #f))))
(if (eq? (vc-master-type master) vc-type:cvs)
(case (cvs-status master)
((UP-TO-DATE)
- (let ((buffer (vc-workfile-buffer master)))
+ (let ((buffer (vc-workfile-buffer master #f)))
(cond ((or (and buffer (buffer-modified? buffer))
(cvs-file-edited? master))
(do-checkin))
"File has unlocked changes, claim lock retaining changes")))
(guarantee-vc-master-valid master)
(vc-backend-steal master revision)
- (let ((buffer (vc-workfile-buffer master)))
+ (let ((buffer (vc-workfile-buffer master #f)))
(if buffer
(vc-mode-line master buffer))))
((prompt-for-yes-or-no? "Revert to checked-in version, instead")
(lambda ()
(event-distributor/invoke!
(ref-variable vc-checkin-hooks
- (vc-workfile-buffer master))
+ (vc-workfile-buffer master #f))
master)))))
\f
(define (vc-steal-lock master revision? comment owner)
" Type C-c C-c when done."))
(define (vc-next-action-merge master from-dired?)
- (let ((buffer (vc-workfile-buffer master)))
+ (let ((buffer (vc-workfile-buffer master #f)))
;; (NOT FROM-DIRED?) implies (NOT (NOT BUFFER)).
(if (or from-dired?
(prompt-for-yes-or-no?
(lambda (revisions?)
(if revisions?
(dispatch-on-command (ref-command-object vc-version-diff))
- (vc-diff (buffer-vc-master (selected-buffer) #t) #f #f))))
+ (vc-diff (current-vc-master #t) #f #f))))
(define-command vc-version-diff
"For FILE, report diffs between two stored versions REV1 and REV2 of it.
"sVersion to visit (default is latest version)"
(lambda (revision)
(let ((revision (vc-normalize-revision revision))
- (master (buffer-vc-master (selected-buffer) #t)))
+ (master (current-vc-master #t)))
(if (not revision)
(editor-error "Must specify a revision."))
(let ((workfile
Headers are inserted at the start of the buffer."
()
(lambda ()
- (let* ((buffer (selected-buffer))
- (master (buffer-vc-master buffer #t)))
+ (let* ((master (buffer-vc-master buffer #t))
+ (buffer (vc-workfile-buffer master #t)))
(without-group-clipped! (buffer-group buffer)
(lambda ()
(if (or (not (vc-backend-check-headers master buffer))
"List the change log of the current buffer in a window."
()
(lambda ()
- (vc-backend-print-log (buffer-vc-master (selected-buffer) #t))
+ (vc-backend-print-log (current-vc-master #t))
(pop-up-vc-command-buffer #f)))
(define-command vc-revert-buffer
to that version."
()
(lambda ()
- (let* ((buffer (selected-buffer))
- (master (buffer-vc-master buffer #t)))
+ (let* ((master (buffer-vc-master buffer #t))
+ (buffer (vc-workfile-buffer master #t)))
(if (or (and (vc-workfile-modified? master)
(or (ref-variable vc-suppress-confirm)
(cleanup-pop-up-buffers
(if simple?
(and (diff-brief-available?) "--brief")
(ref-variable diff-switches
- (vc-workfile-buffer master)))
+ (vc-workfile-buffer master #f)))
(vc-master-workfile master))))
(define-vc-type-operation 'PRINT-LOG vc-type:rcs
(= 1
(vc-run-command master options "diff"
(ref-variable diff-switches
- (vc-workfile-buffer master))
+ (vc-workfile-buffer master
+ #f))
"/dev/null"
(vc-master-workfile master)))))
(= 1
(if simple?
(and (diff-brief-available?) "--brief")
(ref-variable diff-switches
- (vc-workfile-buffer master)))
+ (vc-workfile-buffer master #f)))
(and rev1 (string-append "-r" rev1))
(and rev2 (string-append "-r" rev2))
(vc-master-workfile master)))))))
(define (vc-keep-workfiles? master)
(or (eq? vc-type:cvs (vc-master-type master))
- (ref-variable vc-keep-workfiles (vc-workfile-buffer master))))
+ (ref-variable vc-keep-workfiles (vc-workfile-buffer master #f))))
(define (->workfile object)
(cond ((vc-master? object) (vc-master-workfile object))
((pathname? object) object)
(else (error:wrong-type-argument object "workfile" '->WORKFILE))))
-(define (vc-workfile-buffer master)
- (pathname->buffer (vc-master-workfile master)))
+(define (vc-workfile-buffer master find?)
+ (let ((pathname (vc-master-workfile master)))
+ (if find?
+ (find-file-noselect pathname #f)
+ (pathname->buffer pathname))))
(define (vc-workfile-string master)
(->namestring (vc-master-workfile master)))
(define (vc-save-buffer buffer error?)
(if (buffer-modified? buffer)
- (begin
- (if (and (not (or (ref-variable vc-suppress-confirm buffer)
- (prompt-for-confirmation?
- (string-append "Buffer "
- (buffer-name buffer)
- " modified; save it"))))
- error?)
- (editor-error "Aborted"))
- (save-buffer buffer #f))))
+ (if (or (ref-variable vc-suppress-confirm buffer)
+ (prompt-for-confirmation?
+ (string-append "Buffer " (buffer-name buffer)
+ " modified; save it")))
+ (save-buffer buffer #f)
+ (if error? (editor-error "Aborted")))))
(define (vc-resync-workfile-buffer workfile keep?)
(let ((buffer (pathname->buffer workfile)))
(vc-revert-buffer buffer #t)
(kill-buffer buffer)))))
-(define (vc-revert-workfile-buffer master dont-confirm?)
- (let ((buffer (vc-workfile-buffer master)))
- (if buffer
- (vc-revert-buffer buffer dont-confirm?))))
-
(define diff-brief-available?
(let ((result 'UNKNOWN))
(lambda ()
'OUTPUT #F))))
result)))
\f
+(define (vc-revert-workfile-buffer master dont-confirm?)
+ (let ((buffer (vc-workfile-buffer master #f)))
+ (if buffer
+ (vc-revert-buffer buffer dont-confirm?))))
+
(define (vc-revert-buffer buffer dont-confirm?)
;; Revert BUFFER, try to keep point and mark where user expects them
;; in spite of changes due to expanded version-control keywords.