comparison lisp/vc.el @ 86055:f064a093bf93

(vc-register): Allow registering a file passed as a parameter instead of just the current buffer.
author Dan Nicolaescu <dann@ics.uci.edu>
date Tue, 13 Nov 2007 15:11:41 +0000
parents 430cc8630a39
children ac69f23a84ce
comparison
equal deleted inserted replaced
86054:306bd9f4ebd1 86055:f064a093bf93
1533 (mapcar (lambda (b) (list (downcase (symbol-name b)))) vc-handled-backends) 1533 (mapcar (lambda (b) (list (downcase (symbol-name b)))) vc-handled-backends)
1534 nil t))))) 1534 nil t)))))
1535 (vc-call-backend backend 'create-repo)) 1535 (vc-call-backend backend 'create-repo))
1536 1536
1537 ;;;###autoload 1537 ;;;###autoload
1538 (defun vc-register (&optional set-revision comment) 1538 (defun vc-register (&optional fname set-revision comment)
1539 "Register the current file into a version control system. 1539 "Register into a version control system.
1540 If FNAME is given register that file, otherwise register the current file.
1540 With prefix argument SET-REVISION, allow user to specify initial revision 1541 With prefix argument SET-REVISION, allow user to specify initial revision
1541 level. If COMMENT is present, use that as an initial comment. 1542 level. If COMMENT is present, use that as an initial comment.
1542 1543
1543 The version control system to use is found by cycling through the list 1544 The version control system to use is found by cycling through the list
1544 `vc-handled-backends'. The first backend in that list which declares 1545 `vc-handled-backends'. The first backend in that list which declares
1545 itself responsible for the file (usually because other files in that 1546 itself responsible for the file (usually because other files in that
1546 directory are already registered under that backend) will be used to 1547 directory are already registered under that backend) will be used to
1547 register the file. If no backend declares itself responsible, the 1548 register the file. If no backend declares itself responsible, the
1548 first backend that could register the file is used." 1549 first backend that could register the file is used."
1549 (interactive "P") 1550 (interactive "P")
1550 (unless buffer-file-name (error "No visited file")) 1551 (when (and (null fname) (null buffer-file-name)) (error "No visited file"))
1551 (when (vc-backend buffer-file-name) 1552
1552 (if (vc-registered buffer-file-name) 1553 (let ((bname (if fname (get-file-buffer fname) buffer-file-name)))
1553 (error "This file is already registered") 1554 (unless fname (setq fname buffer-file-name))
1554 (unless (y-or-n-p "Previous master file has vanished. Make a new one? ") 1555 (when (vc-backend fname)
1555 (error "Aborted")))) 1556 (if (vc-registered fname)
1556 ;; Watch out for new buffers of size 0: the corresponding file 1557 (error "This file is already registered")
1557 ;; does not exist yet, even though buffer-modified-p is nil. 1558 (unless (y-or-n-p "Previous master file has vanished. Make a new one? ")
1558 (if (and (not (buffer-modified-p)) 1559 (error "Aborted"))))
1559 (zerop (buffer-size)) 1560 ;; Watch out for new buffers of size 0: the corresponding file
1560 (not (file-exists-p buffer-file-name))) 1561 ;; does not exist yet, even though buffer-modified-p is nil.
1561 (set-buffer-modified-p t)) 1562 (when bname
1562 (vc-buffer-sync) 1563 (with-current-buffer bname
1563 1564 (if (and (not (buffer-modified-p))
1564 (vc-start-entry (list buffer-file-name) 1565 (zerop (buffer-size))
1565 (if set-revision 1566 (not (file-exists-p buffer-file-name)))
1566 (read-string (format "Initial revision level for %s: " 1567 (set-buffer-modified-p t))
1567 (buffer-name))) 1568 (vc-buffer-sync)))
1568 (vc-call-backend (vc-responsible-backend buffer-file-name) 1569 (vc-start-entry (list fname)
1569 'init-revision)) 1570 (if set-revision
1570 (or comment (not vc-initial-comment)) 1571 (read-string (format "Initial revision level for %s: "
1571 nil 1572 fname))
1572 "Enter initial comment." 1573 (vc-call-backend (vc-responsible-backend fname)
1573 (lambda (files rev comment) 1574 'init-revision))
1574 (dolist (file files) 1575 (or comment (not vc-initial-comment))
1575 (message "Registering %s... " file) 1576 nil
1576 (let ((backend (vc-responsible-backend file t))) 1577 "Enter initial comment."
1577 (vc-file-clearprops file) 1578 (lambda (files rev comment)
1578 (vc-call-backend backend 'register (list file) rev comment) 1579 (dolist (file files)
1579 (vc-file-setprop file 'vc-backend backend) 1580 (message "Registering %s... " file)
1580 (unless vc-make-backup-files 1581 (let ((backend (vc-responsible-backend file t)))
1581 (make-local-variable 'backup-inhibited) 1582 (vc-file-clearprops file)
1582 (setq backup-inhibited t))) 1583 (vc-call-backend backend 'register (list file) rev comment)
1583 (message "Registering %s... done" file))))) 1584 (vc-file-setprop file 'vc-backend backend)
1585 (unless vc-make-backup-files
1586 (make-local-variable 'backup-inhibited)
1587 (setq backup-inhibited t)))
1588 (message "Registering %s... done" file))))))
1584 1589
1585 (defun vc-register-with (backend) 1590 (defun vc-register-with (backend)
1586 "Register the current file with a specified back end." 1591 "Register the current file with a specified back end."
1587 (interactive "SBackend: ") 1592 (interactive "SBackend: ")
1588 (if (not (member backend vc-handled-backends)) 1593 (if (not (member backend vc-handled-backends))