comparison lisp/vc.el @ 4725:126cf4bdfd35

(vc-version-other-window): New function. (vc-backend-checkout): Add optional arg workfile, which specifies where to put the working file.
author Paul Eggert <eggert@twinsun.com>
date Wed, 15 Sep 1993 23:19:13 +0000
parents 23b11c3b86b3
children 987685f55edd
comparison
equal deleted inserted replaced
4724:04714985ce20 4725:126cf4bdfd35
803 (set-buffer-modified-p nil) 803 (set-buffer-modified-p nil)
804 ) 804 )
805 (if (zerop (vc-backend-diff file rel1 rel2)) 805 (if (zerop (vc-backend-diff file rel1 rel2))
806 (message "No changes to %s between %s and %s." file rel1 rel2) 806 (message "No changes to %s between %s and %s." file rel1 rel2)
807 (pop-to-buffer "*vc*")))) 807 (pop-to-buffer "*vc*"))))
808
809 ;;;###autoload
810 (defun vc-version-other-window (rev)
811 "Visit version REV of the current buffer in another window.
812 If the current buffer is named `F', the version is named `F.~REV~'.
813 If `F.~REV~' already exists, it is used instead of being re-created."
814 (interactive "sVersion to visit (default is latest version): ")
815 (if vc-dired-mode
816 (set-buffer (find-file-noselect (dired-get-filename))))
817 (while vc-parent-buffer
818 (pop-to-buffer vc-parent-buffer))
819 (if (and buffer-file-name (vc-name buffer-file-name))
820 (let* ((version (if (string-equal rev "")
821 (vc-latest-version buffer-file-name)
822 rev))
823 (filename (concat buffer-file-name ".~" version "~")))
824 (or (file-exists-p filename)
825 (vc-backend-checkout buffer-file-name nil version filename))
826 (find-file-other-window filename))
827 (vc-registration-error buffer-file-name)))
808 828
809 ;; Header-insertion code 829 ;; Header-insertion code
810 830
811 ;;;###autoload 831 ;;;###autoload
812 (defun vc-insert-headers () 832 (defun vc-insert-headers ()
1421 file) 1441 file)
1422 ))) 1442 )))
1423 (message "Registering %s...done" file) 1443 (message "Registering %s...done" file)
1424 ) 1444 )
1425 1445
1426 (defun vc-backend-checkout (file &optional writable rev) 1446 (defun vc-backend-checkout (file &optional writable rev workfile)
1427 ;; Retrieve a copy of a saved version into a workfile 1447 ;; Retrieve a copy of a saved version into a workfile
1428 (message "Checking out %s..." file) 1448 (let ((filename (or workfile file)))
1429 (vc-backend-dispatch file 1449 (message "Checking out %s..." filename)
1430 (progn 1450 (vc-backend-dispatch file
1431 (vc-do-command 0 "get" file ;; SCCS 1451 (vc-do-command 0 "get" file ;; SCCS
1432 (if writable "-e") 1452 (if writable "-e")
1453 (if workfile (concat "-G" workfile))
1433 (and rev (concat "-r" (vc-lookup-triple file rev)))) 1454 (and rev (concat "-r" (vc-lookup-triple file rev))))
1455 (if workfile ;; RCS
1456 ;; RCS doesn't let us check out into arbitrary file names directly.
1457 ;; Use `co -p' and make stdout point to the correct file.
1458 (let ((default-modes (default-file-modes))
1459 (vc-modes (logior (file-modes (vc-name file))
1460 (if writable 128 0)))
1461 (failed t))
1462 (unwind-protect
1463 (progn
1464 (set-default-file-modes vc-modes)
1465 (vc-do-command
1466 0 "/bin/sh" file "-c"
1467 "filename=$1; shift; exec co \"$@\" >$filename"
1468 "" ; dummy argument for shell's $0
1469 filename
1470 (if writable "-l")
1471 (concat "-p" rev))
1472 (setq failed nil))
1473 (set-default-file-modes default-modes)
1474 (and failed (file-exists-p filename) (delete-file filename))))
1475 (vc-do-command 0 "co" file
1476 (if writable "-l")
1477 (and rev (concat "-r" rev))))
1434 ) 1478 )
1435 (vc-do-command 0 "co" file ;; RCS 1479 (or workfile
1436 (if writable "-l") 1480 (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file))))
1437 (and rev (concat "-r" rev))) 1481 (message "Checking out %s...done" filename))
1438 )
1439 (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file)))
1440 (message "Checking out %s...done" file)
1441 ) 1482 )
1442 1483
1443 (defun vc-backend-logentry-check (file) 1484 (defun vc-backend-logentry-check (file)
1444 (vc-backend-dispatch file 1485 (vc-backend-dispatch file
1445 (if (>= (buffer-size) 512) ;; SCCS 1486 (if (>= (buffer-size) 512) ;; SCCS
1570 \\[vc-insert-headers] insert version-control headers in current file 1611 \\[vc-insert-headers] insert version-control headers in current file
1571 \\[vc-print-log] display change history of current file 1612 \\[vc-print-log] display change history of current file
1572 \\[vc-revert-buffer] revert buffer to latest version 1613 \\[vc-revert-buffer] revert buffer to latest version
1573 \\[vc-cancel-version] undo latest checkin 1614 \\[vc-cancel-version] undo latest checkin
1574 \\[vc-diff] show diffs between file versions 1615 \\[vc-diff] show diffs between file versions
1616 \\[vc-version-other-window] visit old version in another window
1575 \\[vc-directory] show all files locked by any user in or below . 1617 \\[vc-directory] show all files locked by any user in or below .
1576 \\[vc-update-change-log] add change log entry from recent checkins 1618 \\[vc-update-change-log] add change log entry from recent checkins
1577 1619
1578 While you are entering a change log message for a version, the following 1620 While you are entering a change log message for a version, the following
1579 additional bindings will be in effect. 1621 additional bindings will be in effect.