• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/

Lines Matching +refs:get +refs:current +refs:file

12 ;; This file is part of GNU Emacs.
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
74 ;; vc may get seriously confused. Don't do these things!
77 ;; the file.
87 ;; returns non-nil for a file, all SYS-specific versions of VC commands
88 ;; will be available for that file.
90 ;; VC keeps some per-file information in the form of properties (see
91 ;; vc-file-set/getprop in vc-hooks.el). The backend-specific functions
106 ;; * registered (file)
110 ;; * state (file)
112 ;; Return the current version control state of FILE. For a list of
116 ;; file, put that into `state-heuristic' below.
118 ;; - state-heuristic (file)
132 ;; * workfile-version (file)
134 ;; Return the current workfile version of FILE.
136 ;; - latest-on-branch-p (file)
138 ;; Return non-nil if the current workfile version of FILE is the latest
140 ;; means that working with non-current versions is not supported by
143 ;; * checkout-model (file)
148 ;; - workfile-unchanged-p (file)
150 ;; Return non-nil if FILE is unchanged from its current workfile
158 ;; - mode-line-string (file)
164 ;; - dired-state-info (file)
172 ;; * register (file &optional rev comment)
175 ;; and an initial description of the file, COMMENT, may be specified.
179 ;; - init-version (file)
185 ;; - responsible-p (file)
193 ;; - could-register (file)
198 ;; - receive-file (file rev)
200 ;; Let this backend "receive" a file that is already registered under
206 ;; - unregister (file)
211 ;; * checkin (file rev comment)
218 ;; * find-version (file rev buffer)
220 ;; Fetch revision REV of file FILE and put it into BUFFER.
225 ;; * checkout (file &optional editable rev)
230 ;; is the revision to check out (default is current workfile version).
231 ;; If REV is t, that means to check out the head of the current branch;
236 ;; * revert (file &optional contents-done)
238 ;; Revert FILE back to the current workfile version. If optional
243 ;; - cancel-version (file editable)
245 ;; Cancel the current workfile version of FILE, i.e. remove it from the
251 ;; - merge (file rev1 rev2)
253 ;; Merge the changes between REV1 and REV2 into the current working file.
255 ;; - merge-news (file)
257 ;; Merge recent changes from the current branch into FILE.
259 ;; - steal-lock (file &optional version)
261 ;; Steal any lock on the current workfile version of FILE, or on
268 ;; * print-log (file &optional buffer)
275 ;; If provided, search the log entry for VERSION in the current buffer,
279 ;; - wash-log (file)
288 ;; current buffer, and if it is not a valid one, the function should
291 ;; - comment-history (file)
294 ;; This is used for transferring a file from one backend to another,
306 ;; * diff (file &optional rev1 rev2 buffer)
310 ;; from REV1 to REV2. If REV1 is nil, use the current workfile
312 ;; REV2 is nil, use the current workfile contents as the newer
323 ;; walk, calling vc-BACKEND-diff for each individual file.
325 ;; - annotate-command (file buf &optional rev)
331 ;; file is fontified according to age.
339 ;; multi-part times as returned by `current-time' and `encode-time'
347 ;; - annotate-current-time ()
350 ;; AND you'd like the current time considered to be anything besides
351 ;; (vs-annotate-convert-time (current-time)) -- i.e. the current
353 ;; ignore. Return the current-time, in units of fractional days.
359 ;; corresponding to the current line, or nil if there is no revision
360 ;; corresponding to the current line.
366 ;; Take a snapshot of the current state of files under DIR and name it
368 ;; proceeding with the action. DIR can also be a file and if BRANCHP
372 ;; for each file calls `assign-name'.
374 ;; - assign-name (file name)
376 ;; Give name NAME to the current version of FILE, assuming it is
390 ;; - make-version-backups-p (file)
400 ;; in order to operate on a file in DIRNAME. If the return value
405 ;; - previous-version (file rev)
410 ;; - next-version (file rev)
417 ;; Return non-nil if the current buffer contains any version headers.
421 ;; In the current buffer, reset all version headers to their unexpanded
424 ;; a file. This function will then be called whenever VC changes the
428 ;; - delete-file (file)
431 ;; function is not provided, the command `vc-delete-file' will
434 ;; - rename-file (old new)
436 ;; Rename file OLD to NEW, both in the working area and in the
438 ;; will be done by (vc-delete-file old) and (vc-register new).
440 ;; - find-file-hook ()
442 ;; Operation called in current buffer when opening a file. This can
445 ;; - find-file-not-found-hook ()
447 ;; Operation called in current buffer when opening a non-existing file.
448 ;; By default, this asks the user if she wants to check out the file.
485 "If non-nil, prompt for initial comment when a file is registered."
490 "A string used as the default version number when a new file is registered.
523 "A string or list of strings; extra switches for registering a file.
559 get the switches for that command. Thus, `vc-diff-switches' should
580 if the local changes in the file have not been found and displayed yet."
588 "Normal hook (list of functions) run after checking out a file.
613 "Normal hook (list of functions) run before a file is checked in.
685 "Color for lines older than the current color range in \\[vc-annotate]]."
718 "*Associate static header string templates with file types.
720 the file's version control type in `vc-header-alist'."
740 Verify that the file really is not locked
741 and that its contents match what the master file says."
756 ;; (either a file, or a VC dired buffer).
767 (defvar vc-log-file)
797 (defun vc-default-previous-version (backend file rev)
816 (defun vc-default-next-version (backend file rev)
821 (when (not (string= rev (vc-workfile-version file)))
829 "Clear all cached file properties."
831 (fillarray vc-file-prop-obarray 0))
833 (defmacro with-vc-properties (file form settings)
834 "Execute FORM, then maybe set per-file properties for FILE.
844 (put (intern ,file vc-file-prop-obarray)
850 (defsubst vc-editable-p (file)
852 (or (eq (vc-checkout-model file) 'implicit)
853 (memq (vc-state file) '(edited needs-merge))))
857 (defmacro with-vc-file (file comment &rest body)
860 FILE is passed through `expand-file-name'; BODY executed within
864 (let ((filevar (make-symbol "file")))
865 `(let ((,filevar (expand-file-name ,file)))
867 (error "File not under version control: `%s'" file))
878 (defmacro edit-vc-file (file comment &rest body)
881 This macro uses `with-vc-file', passing args to it.
884 (let ((filevar (make-symbol "file")))
885 `(let ((,filevar (expand-file-name ,file)))
886 (with-vc-file
888 (set-buffer (find-file-noselect ,filevar))
893 "Make sure that the current buffer visits a version-controlled file."
895 (set-buffer (find-file-noselect (dired-get-filename)))
898 (if (not buffer-file-name)
899 (error "Buffer %s is not associated with a file" (buffer-name))
900 (if (not (vc-backend buffer-file-name))
901 (error "File %s is not under version control" buffer-file-name)))))
907 (with-current-buffer (process-buffer p)
916 "Prepare BUF for executing a VC command and make it current.
919 (let ((camefrom (current-buffer))
921 (set-buffer (get-buffer-create buf))
932 "Eval CODE when the current buffer's process is done.
933 If the current buffer has no process, just evaluate CODE.
935 (let ((proc (get-buffer-process (current-buffer))))
940 ;; lost. Terminated processes get deleted automatically
949 (with-current-buffer ',(current-buffer)
951 ,@(append (cdr (cdr (cdr ;strip off `with-current-buffer buf
966 (defun vc-do-command (buffer okstatus command file &rest flags)
969 current buffer if BUFFER is t. If the destination buffer is not
970 already current, set it up properly and erase it. The command is
975 name of the working file (may also be nil, to execute commands that
976 don't expect a file name). If an optional list of FLAGS is present,
978 (and file (setq file (expand-file-name file)))
980 (message "Running %s on %s..." command file))
981 (save-current-buffer
985 (eq buffer (current-buffer)))
990 (when file
991 ;; FIXME: file-relative-name can return a bogus result because
992 ;; it doesn't look at the actual file-system to see if symlinks
994 (setq squeezed (append squeezed (list (file-relative-name file)))))
1003 (if (and (eq okstatus 'async) (file-remote-p default-directory))
1009 (apply 'start-process command (current-buffer) command
1019 (setq status (apply 'process-file command nil t nil squeezed)))
1023 (pop-to-buffer (current-buffer))
1031 `(run-hook-with-args 'vc-post-command-functions ',command ',file ',flags))
1035 "Save a bit of the text around POSN in the current buffer.
1046 "Return the position of CONTEXT in the current buffer.
1079 (mark-context (if (eq (marker-buffer (mark-marker)) (current-buffer))
1090 ;; ;; that contains markers into the current buffer.
1091 ;; (save-current-buffer
1123 ;; (with-current-buffer (car reparse)
1124 ;; (let ((compilation-last-buffer (current-buffer)) ;select buffer
1158 ;; would fail. However, save-excursion might also get it wrong --
1168 "Make sure the current buffer and its working file are in sync.
1177 (defun vc-default-latest-on-branch-p (backend file)
1180 editing non-current versions is not supported by default."
1183 (defun vc-next-action-on-file (file verbose &optional comment)
1187 (let ((visited (get-file-buffer file))
1193 ;; Check relation of buffer and file, and make sure
1194 ;; user knows what he's doing. First, finding the file
1195 ;; will check whether the file on disk is newer.
1197 ;; preserve find-file-literally.
1198 (let ((buffer-read-only (not (file-writable-p file))))
1199 (find-file-noselect file nil find-file-literally))
1200 (if (not (verify-visited-file-modtime (current-buffer)))
1201 (if (yes-or-no-p "Replace file on disk with buffer contents? ")
1202 (write-file buffer-file-name)
1207 (or (y-or-n-p "Operate on disk file, keeping modified buffer? ")
1211 (if (not (vc-registered file))
1213 (vc-recompute-state file)
1214 (if visited (vc-mode-line file))
1215 (setq state (vc-state file))
1227 (vc-transfer-file file vsym)
1228 (vc-checkout file (eq (vc-checkout-model file) 'implicit)
1230 ((not (eq (vc-checkout-model file) 'implicit))
1231 ;; check the file out
1232 (vc-checkout file t))
1235 (message "%s is up-to-date" file))))
1239 buffer-read-only (not (file-writable-p file)))
1240 ;; Make the file+buffer read-write. If the user really wanted to
1241 ;; commit, he'll get a chance to do that next time around, anyway.
1243 (set-file-modes buffer-file-name
1244 (logior (file-modes buffer-file-name) 128))
1250 ;; For files with locking, if the file does not contain
1252 ((and (not (eq (vc-checkout-model file) 'implicit))
1253 (vc-workfile-unchanged-p file)
1259 ;; DO NOT revert the file without asking the user!
1260 (if (not visited) (find-file-other-window file))
1265 (vc-checkin file nil comment)
1269 (vc-transfer-file file vsym)
1270 (vc-checkin file version comment)))))))
1276 (file-name-nondirectory file)))
1277 (vc-steal-lock file
1279 (vc-workfile-version file))
1286 (file-name-nondirectory file)))
1287 (vc-checkout file (eq (vc-checkout-model file) 'implicit) t)
1288 (if (and (not (eq (vc-checkout-model file) 'implicit))
1290 (vc-checkout file t)
1297 (file-name-nondirectory file)))
1298 (vc-maybe-resolve-conflicts file (vc-call merge-news file))
1303 (if (not visited) (find-file-other-window file))
1305 (vc-version-diff file (vc-workfile-version file) nil)
1309 (format "Changes to %s since last lock:\n\n" file)))
1313 (progn (vc-call steal-lock file)
1314 (clear-visited-file-modtime)
1316 ;; show that the file is locked now.
1317 (vc-clear-headers file)
1318 (write-file buffer-file-name)
1319 (vc-mode-line file))
1324 (vc-checkout file t))))))))
1328 (defun vc-next-action-dired (file rev comment)
1329 "Call `vc-next-action-on-file' on all the marked files.
1331 (let ((dired-buffer (current-buffer)))
1333 (let ((file (dired-get-filename)))
1334 (message "Processing %s..." file)
1335 (vc-next-action-on-file file nil comment)
1338 (message "Processing %s...done" file))
1346 "Do the next logical version control operation on the current file.
1349 it will operate on the file in the current line.
1360 If the file is not already registered, this registers it for version
1362 If the file is registered and not locked by anyone, this checks out
1363 a writable and locked file ready for editing.
1364 If the file is checked out and locked by the calling user, this
1365 first checks to see if the file has changed since checkout. If not,
1367 If the file has been changed, this pops up a buffer for entry
1371 read-only copy of the changed file is left in place afterwards.
1372 If the file is registered and locked by someone else, you are given
1376 If the file is not already registered, this registers it for version
1378 If the file is added but not committed, it is committed.
1379 If your working file is changed, but the repository file is
1382 with the logmessage as change commentary. A writable file is retained.
1383 If the repository file is changed, you are asked if you want to
1389 (let ((files (dired-get-marked-files)))
1391 (current-window-configuration))
1404 (if buffer-file-name
1405 (vc-next-action-on-file buffer-file-name verbose)
1406 (error "Buffer %s is not associated with a file" (buffer-name)))))
1414 "Register the current file into a version control system.
1420 itself responsible for the file (usually because other files in that
1422 register the file. If no backend declares itself responsible, the
1423 first backend that could register the file is used."
1425 (unless buffer-file-name (error "No visited file"))
1426 (when (vc-backend buffer-file-name)
1427 (if (vc-registered buffer-file-name)
1428 (error "This file is already registered")
1429 (unless (y-or-n-p "Previous master file has vanished. Make a new one? ")
1431 ;; Watch out for new buffers of size 0: the corresponding file
1435 (not (file-exists-p buffer-file-name)))
1439 (vc-start-entry buffer-file-name
1443 (vc-call-backend (vc-responsible-backend buffer-file-name)
1448 (lambda (file rev comment)
1449 (message "Registering %s... " file)
1450 (let ((backend (vc-responsible-backend file t)))
1451 (vc-file-clearprops file)
1452 (vc-call-backend backend 'register file rev comment)
1453 (vc-file-setprop file 'vc-backend backend)
1457 (message "Registering %s... done" file))))
1460 (defun vc-responsible-backend (file &optional register)
1477 (or (and (not (file-directory-p file)) (not register) (vc-backend file))
1483 (not (vc-call-backend backend 'registered file)))
1484 (vc-call-backend backend 'responsible-p file)
1493 (and (not (vc-call-backend backend 'registered file))
1494 (vc-call-backend backend 'could-register file)
1498 (defun vc-default-responsible-p (backend file)
1503 (defun vc-default-could-register (backend file)
1508 (defun vc-resynch-window (file &optional keep noquery)
1509 "If FILE is in the current buffer, either revert or unvisit it.
1513 difference between the buffer and the file is due to version control
1515 (and (string= buffer-file-name file)
1523 (if (file-writable-p file)
1528 (not (eq (get major-mode 'mode-class) 'special))
1530 (vc-mode-line buffer-file-name))
1531 (kill-buffer (current-buffer)))))
1533 (defun vc-resynch-buffer (file &optional keep noquery)
1535 (if (string= buffer-file-name file)
1536 (vc-resynch-window file keep noquery)
1537 (let ((buffer (get-file-buffer file)))
1539 (with-current-buffer buffer
1540 (vc-resynch-window file keep noquery)))))
1541 (vc-dired-resynch-file file))
1543 (defun vc-start-entry (file rev comment initial-contents msg action &optional after-hook)
1551 empty comment. Remember the file's buffer in `vc-parent-buffer'
1552 \(current one if no file). AFTER-HOOK specifies the local value
1554 (let ((parent (or (and file (get-file-buffer file)) (current-buffer))))
1556 (if file
1557 (with-current-buffer parent
1561 (set-buffer (get-buffer-create "*VC-log*"))
1562 (pop-to-buffer (get-buffer-create "*VC-log*")))
1566 (if file (vc-mode-line file))
1567 (vc-log-edit file)
1580 (defun vc-checkout (file &optional writable rev)
1582 If WRITABLE is non-nil, make sure the retrieved file is writable.
1588 (vc-call make-version-backups-p file)
1589 (vc-up-to-date-p file)
1590 (vc-make-version-backup file))
1592 file
1594 (vc-call checkout file writable rev)
1595 (file-error
1598 (let ((buf (get-file-buffer file)))
1599 (when buf (with-current-buffer buf (toggle-read-only -1)))))
1601 `((vc-state . ,(if (or (eq (vc-checkout-model file) 'implicit)
1603 (if (vc-call latest-on-branch-p file)
1607 (vc-checkout-time . ,(nth 5 (file-attributes file)))))
1608 (vc-resynch-buffer file t t)
1611 (defun vc-steal-lock (file rev owner)
1613 (let (file-description)
1615 (setq file-description (format "%s:%s" file rev))
1616 (setq file-description file))
1618 file-description owner)))
1620 (message "Stealing lock on %s..." file)
1622 file
1623 (vc-call steal-lock file rev)
1625 (vc-resynch-buffer file t t)
1626 (message "Stealing lock on %s...done" file)
1629 (compose-mail owner (format "Stolen lock on %s" file-description))
1630 (setq default-directory (expand-file-name "~/"))
1633 (format "I stole the lock on %s, " file-description)
1634 (current-time-string)
1638 (defun vc-checkin (file &optional rev comment initial-contents)
1641 level (if nil increment the current level). COMMENT is a comment
1651 file rev comment initial-contents
1653 (lambda (file rev comment)
1654 (message "Checking in %s..." file)
1660 file
1661 ;; Change buffers to get local value of vc-checkin-switches.
1662 (with-current-buffer (or (get-file-buffer file) (current-buffer))
1664 (vc-call checkin file rev comment)
1665 (vc-delete-automatic-version-backups file)))
1667 (vc-checkout-time . ,(nth 5 (file-attributes file)))
1669 (message "Checking in %s...done" file))
1673 "Complete the operation implied by the current log entry.
1674 Use the contents of the current buffer as a check-in or registration
1681 (vc-call-backend (or (and vc-log-file (vc-backend vc-log-file))
1687 (with-current-buffer vc-parent-buffer
1692 (log-file vc-log-file)
1701 log-file
1706 (let ((logbuf (get-buffer "*VC-log*")))
1715 (if log-file
1716 (vc-resynch-buffer log-file vc-keep-workfiles t))
1727 "Display diffs between file versions.
1728 Normally this compares the current file and buffer with the most
1729 recent checked in version of that file. This uses no arguments. With
1730 a prefix argument HISTORIC, it reads the file name to use and two
1734 (interactive (list current-prefix-arg t))
1738 (let ((file buffer-file-name))
1740 (if (vc-workfile-unchanged-p buffer-file-name)
1741 (message "No changes to %s since latest version" file)
1742 (vc-version-diff file nil nil)))))
1744 (defun vc-version-diff (file rev1 rev2)
1746 If REV1 is empty or nil it means to use the current workfile version;
1747 REV2 empty or nil means the current file contents. FILE may also be
1751 (let ((file (expand-file-name
1752 (read-file-name (if buffer-file-name
1753 "File or dir to diff (default visited file): "
1755 default-directory buffer-file-name t)))
1757 ;; compute default versions based on the file state
1760 ((file-directory-p file)
1762 ;; if the file is not up-to-date, use current version as older version
1763 ((not (vc-up-to-date-p file))
1764 (setq rev1-default (vc-workfile-version file)))
1765 ;; if the file is not locked, use last and previous version as default
1767 (setq rev1-default (vc-call previous-version file
1768 (vc-workfile-version file)))
1770 (setq rev2-default (vc-workfile-version file))))
1772 (list file
1781 "Newer version (default current source): ")
1783 (if (file-directory-p file)
1793 (or rev2 "current workfile(s)")
1795 (let ((dir (file-name-as-directory file)))
1800 ;; Single file diff. It is important that the vc-controlled buffer
1801 ;; is still current at this time, because any local settings in that
1803 (vc-diff-internal file rev1 rev2))
1806 (not (get-buffer-process (current-buffer))))
1810 (message "No changes to %s between %s and %s" file rev1 rev2)
1811 (message "No changes to %s since %s" file rev1))
1812 (message "No changes to %s since latest version" file))
1814 (pop-to-buffer (current-buffer))
1825 (defun vc-diff-label (file file-rev rev)
1826 (concat (file-relative-name file)
1828 (nth 5 (file-attributes file-rev)))
1831 (defun vc-diff-internal (file rev1 rev2)
1840 (setq rev1 (vc-workfile-version file)))
1843 (let ((file-rev1 (vc-version-backup-file file rev1))
1844 (file-rev2 (if (not rev2)
1845 file
1846 (vc-version-backup-file file rev2)))
1847 (coding-system-for-read (vc-coding-system-for-diff file)))
1848 (if (and file-rev1 file-rev2)
1853 (list (file-relative-name file-rev1)
1854 (file-relative-name file-rev2))))
1859 ;; `file' rather than to `file-rev1'
1862 (list "-L" (vc-diff-label file file-rev1 rev1)
1863 "-L" (vc-diff-label file file-rev2 rev2)
1864 (file-relative-name file-rev1)
1865 (file-relative-name file-rev2)))))))
1872 (list (file-relative-name file-rev1)
1873 (file-relative-name file-rev2)))))
1877 (vc-call diff file rev1 rev2))))
1904 ;; vc-BACKEND-diff directly for each file. An optimization
1910 (vc-file-tree-walk
1919 (defun vc-coding-system-for-diff (file)
1922 ;; if we already have this file open,
1924 (let ((buf (find-buffer-visiting file)))
1925 (if buf (with-current-buffer buf
1926 buffer-file-coding-system)))
1927 ;; otherwise, try to find one based on the file name
1928 (car (find-operation-coding-system 'insert-file-contents file))
1934 "Visit version REV of the current file in another window.
1935 If the current file is named `F', the version is named `F.~REV~'.
1939 (let* ((file buffer-file-name)
1941 (vc-workfile-version file)
1943 (switch-to-buffer-other-window (vc-find-version file version))))
1945 (defun vc-find-version (file version)
1947 (let ((automatic-backup (vc-version-backup-file-name file version))
1948 (filebuf (or (get-file-buffer file) (current-buffer)))
1949 (filename (vc-version-backup-file-name file version 'manual)))
1950 (unless (file-exists-p filename)
1951 (if (file-exists-p automatic-backup)
1952 (rename-file automatic-backup filename nil)
1954 (with-current-buffer filebuf
1959 (with-temp-file filename
1960 (let ((outbuf (current-buffer)))
1961 ;; Change buffer to get local value of
1963 (with-current-buffer filebuf
1964 (vc-call find-version file version outbuf))))
1966 (if (and failed (file-exists-p filename))
1967 (delete-file filename))))
1968 (vc-mode-line file))
1970 (find-file-noselect filename)))
1972 (defun vc-default-find-version (backend file rev buffer)
1976 (let ((tmpfile (make-temp-file (expand-file-name file))))
1979 (vc-call-backend backend 'checkout file nil rev tmpfile)
1980 (with-current-buffer buffer
1981 (insert-file-contents-literally tmpfile)))
1982 (delete-file tmpfile))))
1988 "Insert headers into a file for use with a version control system.
2001 (hdsym (vc-make-backend-sym (vc-backend buffer-file-name)
2009 (if (string-match (car f) buffer-file-name)
2012 (defun vc-clear-headers (&optional file)
2013 "Clear all version headers in the current buffer (or FILE).
2015 (let* ((filename (or file buffer-file-name))
2027 (set-buffer (find-file-noselect filename))
2033 "Merge changes between two versions into the current buffer's file.
2037 from the current branch.
2043 (let* ((file buffer-file-name)
2044 (backend (vc-backend file))
2045 (state (vc-state file))
2050 ((not (vc-editable-p file))
2053 (vc-checkout file t)
2057 "(default news on current branch): ")))
2061 (setq status (vc-call merge-news file)))
2073 (setq status (vc-call merge file first-version second-version))))
2074 (vc-maybe-resolve-conflicts file status "WORKFILE" "MERGE SOURCE")))
2076 (defun vc-maybe-resolve-conflicts (file status &optional name-A name-B)
2077 (vc-resynch-buffer file t (not (buffer-modified-p)))
2086 ;; All VC commands get mapped into logical equivalents.
2104 the current VC state of each file being indicated in the place of the
2105 file's link count, owner, group and size. Subdirectories are also
2112 the file named in the current Dired buffer line. `vv' invokes
2113 `vc-next-action' on this file, or on all files currently marked.
2121 ;; because file lines look a bit different in vc-dired-mode
2175 (dired-mark-if (let ((f (dired-get-filename nil t)))
2177 (not (file-directory-p f))
2179 "locked file"))
2183 (defun vc-default-dired-state-info (backend file)
2184 (let ((state (vc-state file)))
2187 ((eq state 'edited) (concat "(" (vc-user-login-name file) ")"))
2214 ((setq subdir (dired-get-subdir))
2215 ;; if the backend supports it, get the state
2225 ;; file line
2226 ((setq filename (dired-get-filename nil t))
2229 ((file-directory-p filename)
2231 ((member (file-name-nondirectory filename)
2243 ((string-match "\\`\\.\\.?\\'" (file-name-nondirectory filename))
2248 ;; ordinary file
2269 (while (dired-get-subdir)
2271 (if (dired-get-filename nil t)
2275 (if (not (string= (dired-current-directory) default-directory))
2291 (with-current-buffer buffer
2297 (defun vc-dired-resynch-file (file)
2299 (let ((buffers (vc-dired-buffers-for-dir (file-name-directory file))))
2302 (with-current-buffer buffer
2303 (if (dired-goto-file file)
2321 (if (eq (string-match tramp-file-name-regexp dir) 0)
2330 (dired-internal-noselect (expand-file-name (file-name-as-directory dir))
2339 If any file is not up-to-date, return the name of the first such file.
2345 (vc-file-tree-walk
2349 (if (get-file-buffer f) (setq status 'visited)))))
2355 For each registered file, the version level of its latest version
2360 (list (read-file-name "Directory: " default-directory default-directory t)
2362 current-prefix-arg))
2364 (if (file-directory-p dir) (setq dir (file-name-as-directory dir)))
2375 (vc-file-tree-walk
2388 (list (read-file-name "Directory: " default-directory default-directory t)
2392 (format "Updating %s... " (abbreviate-file-name dir))
2394 (abbreviate-file-name dir)))))
2403 (vc-file-tree-walk
2414 (vc-file-tree-walk
2424 "List the change log of the current buffer in a window.
2428 (let ((file buffer-file-name))
2429 (or focus-rev (setq focus-rev (vc-workfile-version file)))
2435 (vc-call print-log file "*vc-change-log*")
2443 (vc-find-backend-function (vc-backend file)
2448 (vc-call print-log file)
2450 (pop-to-buffer (current-buffer))
2462 ;; move point to the log entry for the current version
2463 (vc-call-backend ',(vc-backend file)
2472 (defun vc-default-comment-history (backend file)
2475 (with-current-buffer "*vc*"
2476 (vc-call print-log file)
2477 (vc-call wash-log file)
2480 (defun vc-default-wash-log (backend file)
2502 "Revert the current buffer's file to the version it was based on.
2505 changes found in the master file; use \\[universal-argument] \\[vc-next-action] to do so."
2511 (let ((file buffer-file-name)
2514 (obuf (current-buffer))
2516 (if (vc-up-to-date-p file)
2519 (unless (vc-workfile-unchanged-p file)
2539 (message "Reverting %s..." file)
2540 (vc-revert-file file)
2541 (message "Reverting %s...done" file)))
2545 "Update the current buffer's file to the latest version on its branch.
2546 If the file contains no changes, and is not locked, then this simply replaces
2547 the working file with the latest version on its branch. If the file contains
2549 the current branch are merged into the working file."
2553 (let ((file buffer-file-name))
2554 (if (vc-up-to-date-p file)
2555 (vc-checkout file nil "")
2556 (if (eq (vc-checkout-model file) 'locking)
2557 (if (eq (vc-state file) 'edited)
2563 "Unexpected file state (%s)--type \\[vc-next-action] to correct")
2564 (vc-state file)))
2565 (if (not (vc-find-backend-function (vc-backend file) 'merge-news))
2567 (vc-backend file))
2568 (vc-call merge-news file)
2569 (vc-resynch-window file t t))))))
2571 (defun vc-version-backup-file (file &optional rev)
2572 "Return name of backup file for revision REV of FILE.
2574 such a backup for REV or the current workfile version of file,
2576 (when (vc-call make-version-backups-p file)
2577 (let ((backup-file (vc-version-backup-file-name file rev)))
2578 (if (file-exists-p backup-file)
2579 backup-file
2581 (setq backup-file (vc-version-backup-file-name file rev 'manual))
2582 (if (file-exists-p backup-file)
2583 backup-file)))))
2585 (defun vc-default-revert (backend file contents-done)
2587 (let ((rev (vc-workfile-version file))
2588 (file-buffer (or (get-file-buffer file) (current-buffer))))
2589 (message "Checking out %s..." file)
2591 (backup-name (car (find-backup-file-name file))))
2593 (copy-file file backup-name 'ok-if-already-exists 'keep-date)
2594 (unless (file-writable-p file)
2595 (set-file-modes file (logior (file-modes file) 128))))
2599 (with-temp-file file
2600 (let ((outbuf (current-buffer)))
2601 ;; Change buffer to get local value of vc-checkout-switches.
2602 (with-current-buffer file-buffer
2603 (let ((default-directory (file-name-directory file)))
2604 (vc-call find-version file rev outbuf)))))
2608 (rename-file backup-name file 'ok-if-already-exists)
2609 (and (not vc-make-backup-files) (delete-file backup-name))))))
2610 (message "Checking out %s...done" file))))
2612 (defun vc-revert-file (file)
2615 file
2616 (let ((backup-file (vc-version-backup-file file)))
2617 (when backup-file
2618 (copy-file backup-file file 'ok-if-already-exists 'keep-date)
2619 (vc-delete-automatic-version-backups file))
2620 (vc-call revert file backup-file))
2622 (vc-checkout-time . ,(nth 5 (file-attributes file)))))
2623 (vc-resynch-buffer file t t))
2627 "Get rid of most recently checked in version of this file.
2631 (let* ((file buffer-file-name)
2632 (backend (vc-backend file))
2633 (target (vc-workfile-version file)))
2637 ((not (vc-call latest-on-branch-p file))
2639 ((not (vc-up-to-date-p file))
2646 (message "Removing last change from %s..." file)
2648 file
2649 (vc-call cancel-version file norevert)
2653 (nth 5 (file-attributes file))))
2655 (message "Removing last change from %s...done" file)
2659 (set-visited-file-name file)
2666 (vc-mode-line file)
2667 (vc-dired-resynch-file file))
2668 (t ;; revert buffer to file on disk
2669 (vc-resynch-buffer file t t)))
2673 (defun vc-switch-backend (file backend)
2674 "Make BACKEND the current version control system for FILE.
2676 permanent, only for the current session. This function only changes
2679 To get a prompt, use a prefix argument."
2682 (or buffer-file-name
2683 (error "There is no version-controlled file in this buffer"))
2684 (let ((backend (vc-backend buffer-file-name))
2689 (error "File %s is not under version control" buffer-file-name))
2692 (when (vc-call-backend backend 'registered buffer-file-name)
2700 (current-prefix-arg
2708 ;; Calling the `registered' method can mess up the file
2711 (vc-call-backend backend 'registered buffer-file-name))))))
2712 (unless (eq backend (vc-backend file))
2713 (vc-file-clearprops file)
2714 (vc-file-setprop file 'vc-backend backend)
2716 (unless (vc-call-backend backend 'registered file)
2717 (vc-file-clearprops file)
2718 (error "%s is not registered in %s" file backend))
2719 (vc-mode-line file)))
2722 (defun vc-transfer-file (file new-backend)
2724 If NEW-BACKEND has a higher precedence than FILE's current backend
2726 NEW-BACKEND, using the version number from the current backend as the
2727 base level. If NEW-BACKEND has a lower precedence than the current
2728 backend, then commit all changes that were made under the current
2729 backend to NEW-BACKEND, and unregister FILE from the current backend.
2731 (let* ((old-backend (vc-backend file))
2732 (edited (memq (vc-state file) '(edited needs-merge)))
2733 (registered (vc-call-backend new-backend 'registered file))
2741 (error "%s is the current backend of %s" new-backend file))
2743 (set-file-modes file (logior (file-modes file) 128))
2745 (vc-switch-backend file old-backend)
2746 (let* ((rev (vc-workfile-version file))
2747 (modified-file (and edited (make-temp-file file)))
2748 (unmodified-file (and modified-file (vc-version-backup-file file))))
2749 ;; Go back to the base unmodified file.
2752 (when modified-file
2753 (copy-file file modified-file 'ok-if-already-exists)
2754 ;; If we have a local copy of the unmodified file, handle that
2755 ;; here and not in vc-revert-file because we don't want to
2757 (if unmodified-file
2758 (copy-file unmodified-file file
2761 (vc-revert-file file))))
2762 (vc-call-backend new-backend 'receive-file file rev))
2763 (when modified-file
2764 (vc-switch-backend file new-backend)
2765 (unless (eq (vc-checkout-model file) 'implicit)
2766 (vc-checkout file t nil))
2767 (rename-file modified-file file 'ok-if-already-exists)
2768 (vc-file-setprop file 'vc-checkout-time nil)))))
2770 (vc-switch-backend file old-backend)
2771 (setq comment (vc-call comment-history file))
2772 (vc-call unregister file))
2773 (vc-switch-backend file new-backend)
2775 (vc-file-setprop file 'vc-state 'edited)
2776 (vc-mode-line file)
2777 (vc-checkin file nil comment (stringp comment)))))
2779 (defun vc-default-unregister (backend file)
2783 (defun vc-default-receive-file (backend file rev)
2785 (vc-call-backend backend 'register file rev ""))
2788 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES."
2789 (let* ((dir (file-name-directory (expand-file-name oldmaster)))
2790 (newdir (or (file-name-directory newfile) ""))
2791 (newbase (file-name-nondirectory newfile))
2797 (if (or (file-symlink-p oldmaster)
2798 (file-symlink-p (file-name-directory oldmaster)))
2800 (rename-file
2803 ;; If possible, keep the master file in the same directory.
2805 (if (and f (string= (file-name-directory (expand-file-name f)) dir))
2809 (and f (or (not (setq dir (file-name-directory f)))
2810 (file-directory-p dir))
2812 (error "New file lacks a version control directory")))))
2814 (defun vc-delete-file (file)
2815 "Delete file and mark it as such in the version control system."
2816 (interactive "fVC delete file: ")
2817 (let ((buf (get-file-buffer file))
2818 (backend (vc-backend file)))
2821 (file-name-nondirectory file)))
2822 (unless (vc-find-backend-function backend 'delete-file)
2827 (file-name-nondirectory file)))
2829 (unless (or (file-directory-p file) (null make-backup-files))
2830 (with-current-buffer (or buf (find-file-noselect file))
2833 (vc-call delete-file file)
2834 ;; If the backend hasn't deleted the file itself, let's do it for him.
2835 (if (file-exists-p file) (delete-file file))))
2837 (defun vc-default-rename-file (backend old new)
2839 (add-name-to-file old new)
2840 (error (rename-file old new)))
2841 (vc-delete-file old)
2842 (with-current-buffer (find-file-noselect new)
2846 (defun vc-rename-file (old new)
2847 "Rename file OLD to NEW, and rename its master file likewise."
2848 (interactive "fVC rename file: \nFRename to: ")
2849 (let ((oldbuf (get-file-buffer old)))
2852 (if (get-file-buffer new)
2853 (error "Already editing new file name"))
2854 (if (file-exists-p new)
2855 (error "New file already exists"))
2860 (vc-call rename-file old new)
2861 (vc-file-clearprops old)
2862 ;; Move the actual file (unless the backend did it already)
2863 (if (file-exists-p old) (rename-file old new))
2864 ;; ?? Renaming a file might change its contents due to keyword expansion.
2868 (with-current-buffer oldbuf
2870 (set-visited-file-name new))
2877 "Find change log file and add entries from recent version control logs.
2881 With prefix arg of \\[universal-argument], only find log entries for the current buffer's file.
2890 (cond ((consp current-prefix-arg) ;C-u
2891 (list buffer-file-name))
2892 (current-prefix-arg ;Numeric argument.
2895 file)
2897 (setq file (buffer-file-name (car buffers)))
2898 (and file (vc-backend file)
2899 (setq files (cons file files)))
2907 (dolist (file (or args (list default-directory)))
2908 (if (eq (string-match tramp-file-name-regexp file) 0)
2920 (tempfile (make-temp-file
2921 (expand-file-name "vc"
2922 (or small-temporary-file-directory
2923 temporary-file-directory))))
2932 (find-file-other-window changelog)
2944 (expand-file-name "rcs2log"
2953 (file-relative-name
2954 (if (file-name-absolute-p f)
2959 (pop-to-buffer (get-buffer-create "*vc*"))
2961 (insert-file-contents tempfile)
2963 (setq default-directory (file-name-directory changelog))
2964 (delete-file tempfile)))))
2977 (defvar vc-annotate-parent-file nil)
2999 The current time is used as the offset."
3012 Autoscaling means that the map is scaled from the current time to the
3018 (current (vc-annotate-convert-time (current-time)))
3021 ;; Run through this file and find the oldest and newest dates annotated.
3032 (/ (- (if full newest current) oldest)
3038 (- current oldest)
3039 (- current newest))
3040 (format "Spanned to %.1f days old" (- current oldest))))))
3083 By default, the current buffer is highlighted, unless overridden by
3088 (pop-to-buffer (or buffer (current-buffer)))
3106 (defun vc-annotate (file rev &optional display-mode buf)
3107 "Display the edit history of the current file using colors.
3109 This command creates a buffer that shows, for each line of the current
3110 file, when it was last edited and by whom. Additionally, colors are
3118 displays and annotates that version instead of the current version
3132 (save-current-buffer
3134 (list buffer-file-name
3135 (let ((def (vc-workfile-version buffer-file-name)))
3136 (if (null current-prefix-arg) def
3140 (if (null current-prefix-arg)
3149 ;; If BUF is specified, we presume the caller maintains current line,
3152 (current-line (unless buf (line-number-at-pos))))
3157 (if buf (with-current-buffer buf
3162 (vc-call annotate-command file (get-buffer temp-buffer-name) rev)
3166 (with-current-buffer temp-buffer-name
3169 (set (make-local-variable 'vc-annotate-backend) (vc-backend file))
3170 (set (make-local-variable 'vc-annotate-parent-file) file)
3174 (when current-line
3175 (goto-line current-line temp-buffer-name))
3195 "Visit the annotation of the workfile version of this file."
3199 (let ((warp-rev (vc-workfile-version vc-annotate-parent-file)))
3205 "Extract the revision number of the current line."
3210 "Visit the annotation of the version identified in the current line."
3216 (message "Cannot extract revision number from the current line")
3229 (message "Cannot extract revision number from the current line")
3231 (vc-call previous-version vc-annotate-parent-file rev-at-line))
3241 (message "Cannot extract revision number from the current line")
3252 (message "Cannot extract revision number from the current line")
3254 (vc-call previous-version vc-annotate-parent-file rev-at-line))
3258 (vc-version-diff vc-annotate-parent-file prev-rev rev-at-line))
3272 (let* ((buf (current-buffer))
3281 vc-annotate-parent-file newrev))
3290 vc-annotate-parent-file newrev))
3298 (vc-annotate vc-annotate-parent-file newrev
3318 The argument TIME is a list as returned by `current-time' or
3325 difference in days between the time returned and the current time,
3330 (vc-call-backend vc-annotate-backend 'annotate-current-time))
3333 (defun vc-default-annotate-current-time (backend)
3334 "Return the current time, encoded as fractional days."
3335 (vc-annotate-convert-time (current-time)))
3340 "Highlight `vc-annotate' output in the current buffer.
3342 The annotations are relative to the current time, unless overridden by OFFSET."
3382 "Check if the current file has any headers in it."
3384 (vc-call-backend (vc-backend buffer-file-name) 'check-headers))
3394 (defun vc-log-edit (file)
3397 (if file (file-name-directory file)
3398 (with-current-buffer vc-parent-buffer default-directory)))
3400 (if file `(lambda () ',(list (file-name-nondirectory file)))
3403 (with-current-buffer vc-parent-buffer
3404 (dired-get-marked-files t)))))
3405 (set (make-local-variable 'vc-log-file) file)
3408 (setq buffer-file-name nil))
3412 (defun vc-file-tree-walk (dirname func &rest args)
3414 Invoke FUNC f ARGS on each VC-managed file f underneath it."
3415 (vc-file-tree-walk-internal (expand-file-name dirname) func args)
3418 (defun vc-file-tree-walk-internal (file func args)
3419 (if (not (file-directory-p file))
3420 (if (vc-backend file) (apply func file args))
3421 (message "Traversing directory %s..." (abbreviate-file-name file))
3422 (let ((dir (file-name-as-directory file)))
3428 (let ((dirf (expand-file-name f dir)))
3430 (file-symlink-p dirf);; Avoid possible loops
3431 (vc-file-tree-walk-internal dirf func args)))))
3444 ;; vc-next-action's computations of the file's version-control state and
3470 ;; vc-state. Usually, if a file is registered, we can read its locked/
3471 ;; unlocked state and its current owner from its permissions.
3501 ;; A . 1 2 3 4 ci -u -t- admin -fb -i<file> initial admin
3502 ;; B 5 . 6 7 8 co -l get -e checkout
3503 ;; C 9 10 . 11 12 co -u unget; get revert
3504 ;; D 13 14 15 . 16 ci -u -m<comment> delta -y<comment>; get checkin
3505 ;; E 17 18 19 20 . rcs -u -M -l unget -n ; get -g steal lock
3507 ;; All commands take the master file name as a last argument (not shown).
3516 ;; Between the check for existence of a master file and the call to
3565 ;; ci -i option and the message is "<file>,v: already exists".
3574 ;; RCS: Prior to version 5.6.4, reverts the file to the last saved
3576 ;; ci -i option, failing with message "<file>,v: already exists".
3588 ;; failing with message "<file>,v: already exists".
3599 ;; "<file>,v: already exists".
3608 ;; Potential cause: master file got nuked during window P.
3610 ;; RCS: will fail with "RCS/<file>: No such file or directory"
3655 ;; RCS: succeeds, refreshing the file from the identical version in
3657 ;; SCCS: fails with error ut4 (p file nonexistent).
3664 ;; Potential cause: the file would have to be touched by a self-race
3685 ;; Potential cause: master file got nuked during window P.
3689 ;; option, failing with message "no such file or directory".
3711 ;; SCCS: checks in a redundant delta and leaves the file unlocked as usual.
3712 ;; RCS: reverts to the file state as of the second user's checkin, leaving
3713 ;; the file unlocked.
3737 ;; RCS: The calling user will get the lock on the file.
3764 ;; only the information in the current workfile. This can only happen
3765 ;; if the master file gets nuked in window P.