38 |
|
|
39 |
;; Customization Variables (the rest is in vc.el) |
;; Customization Variables (the rest is in vc.el) |
40 |
|
|
41 |
(defvar vc-ignore-vc-files nil "Obsolete -- use `vc-handled-backends'.") |
(defvar vc-ignore-vc-files nil) |
42 |
(defvar vc-master-templates () "Obsolete -- use vc-BACKEND-master-templates.") |
(make-obsolete-variable 'vc-ignore-vc-files 'vc-handled-backends) |
43 |
(defvar vc-header-alist () "Obsolete -- use vc-BACKEND-header.") |
(defvar vc-master-templates ()) |
44 |
|
(make-obsolete-variable 'vc-master-templates 'vc-BACKEND-master-templates) |
45 |
|
(defvar vc-header-alist ()) |
46 |
|
(make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header) |
47 |
|
|
48 |
(defcustom vc-handled-backends '(RCS CVS SCCS) |
(defcustom vc-handled-backends '(RCS CVS SCCS) |
49 |
"*List of version control backends for which VC will be used. |
"*List of version control backends for which VC will be used. |
117 |
(funcall vc-mistrust-permissions |
(funcall vc-mistrust-permissions |
118 |
(vc-backend-subdirectory-name file))))) |
(vc-backend-subdirectory-name file))))) |
119 |
|
|
120 |
|
;;; This is handled specially now. |
121 |
;; Tell Emacs about this new kind of minor mode |
;; Tell Emacs about this new kind of minor mode |
122 |
(add-to-list 'minor-mode-alist '(vc-mode vc-mode)) |
;; (add-to-list 'minor-mode-alist '(vc-mode vc-mode)) |
123 |
|
|
124 |
(make-variable-buffer-local 'vc-mode) |
(make-variable-buffer-local 'vc-mode) |
125 |
(put 'vc-mode 'permanent-local t) |
(put 'vc-mode 'permanent-local t) |
173 |
|
|
174 |
(defun vc-find-backend-function (backend fun) |
(defun vc-find-backend-function (backend fun) |
175 |
"Return BACKEND-specific implementation of FUN. |
"Return BACKEND-specific implementation of FUN. |
176 |
If there is no such implementation, return the default implementation; |
If there is no such implementation, return the default implementation; |
177 |
if that doesn't exist either, return nil." |
if that doesn't exist either, return nil." |
178 |
(let ((f (vc-make-backend-sym backend fun))) |
(let ((f (vc-make-backend-sym backend fun))) |
179 |
(if (fboundp f) f |
(if (fboundp f) f |
220 |
|
|
221 |
Optional argument LIMIT is a regexp. If present, the file is inserted |
Optional argument LIMIT is a regexp. If present, the file is inserted |
222 |
in chunks of size BLOCKSIZE (default 8 kByte), until the first |
in chunks of size BLOCKSIZE (default 8 kByte), until the first |
223 |
occurrence of LIMIT is found. The function returns non-nil if FILE |
occurrence of LIMIT is found. Anything from the start of that occurrence |
224 |
exists and its contents were successfully inserted." |
to the end of the buffer is then deleted. The function returns |
225 |
|
non-nil if FILE exists and its contents were successfully inserted." |
226 |
(erase-buffer) |
(erase-buffer) |
227 |
(when (file-exists-p file) |
(when (file-exists-p file) |
228 |
(if (not limit) |
(if (not limit) |
233 |
(and (< 0 (cadr (insert-file-contents |
(and (< 0 (cadr (insert-file-contents |
234 |
file nil filepos (incf filepos blocksize)))) |
file nil filepos (incf filepos blocksize)))) |
235 |
(progn (beginning-of-line) |
(progn (beginning-of-line) |
236 |
(not (re-search-forward limit nil 'move))))))) |
(let ((pos (re-search-forward limit nil 'move))) |
237 |
|
(if pos (delete-region (match-beginning 0) |
238 |
|
(point-max))) |
239 |
|
(not pos))))))) |
240 |
(set-buffer-modified-p nil) |
(set-buffer-modified-p nil) |
241 |
t)) |
t)) |
242 |
|
|
271 |
(and (vc-call-backend b 'registered file) |
(and (vc-call-backend b 'registered file) |
272 |
(vc-file-setprop file 'vc-backend b) |
(vc-file-setprop file 'vc-backend b) |
273 |
(throw 'found t))) |
(throw 'found t))) |
274 |
(if (or (not backend) (eq backend 'none)) |
(if (or (not backend) (eq backend 'none)) |
275 |
vc-handled-backends |
vc-handled-backends |
276 |
(cons backend vc-handled-backends)))) |
(cons backend vc-handled-backends)))) |
277 |
;; File is not registered. |
;; File is not registered. |
319 |
when the user saves the first changes to the file. |
when the user saves the first changes to the file. |
320 |
|
|
321 |
'locking FILE is read-only if up-to-date; user must type |
'locking FILE is read-only if up-to-date; user must type |
322 |
\\[vc-toggle-read-only] before editing. Strict locking |
\\[vc-next-action] before editing. Strict locking |
323 |
is assumed. |
is assumed. |
324 |
|
|
325 |
'announce FILE is read-only if up-to-date; user must type |
'announce FILE is read-only if up-to-date; user must type |
326 |
\\[vc-toggle-read-only] before editing. But other users |
\\[vc-next-action] before editing. But other users |
327 |
may be editing at the same time." |
may be editing at the same time." |
328 |
(or (vc-file-getprop file 'vc-checkout-model) |
(or (vc-file-getprop file 'vc-checkout-model) |
329 |
(if (vc-backend file) |
(if (vc-backend file) |
354 |
|
|
355 |
USER The current version of the working file is locked by |
USER The current version of the working file is locked by |
356 |
some other USER (a string). |
some other USER (a string). |
357 |
|
|
358 |
'needs-patch The file has not been edited by the user, but there is |
'needs-patch The file has not been edited by the user, but there is |
359 |
a more recent version on the current branch stored |
a more recent version on the current branch stored |
360 |
in the master file. |
in the master file. |
385 |
and does not employ any heuristic at all." |
and does not employ any heuristic at all." |
386 |
(vc-call-backend backend 'state file)) |
(vc-call-backend backend 'state file)) |
387 |
|
|
388 |
|
(defun vc-workfile-unchanged-p (file) |
389 |
|
"Return non-nil if FILE has not changed since the last checkout." |
390 |
|
(let ((checkout-time (vc-file-getprop file 'vc-checkout-time)) |
391 |
|
(lastmod (nth 5 (file-attributes file)))) |
392 |
|
(if checkout-time |
393 |
|
(equal checkout-time lastmod) |
394 |
|
(let ((unchanged (vc-call workfile-unchanged-p file))) |
395 |
|
(vc-file-setprop file 'vc-checkout-time (if unchanged lastmod 0)) |
396 |
|
unchanged)))) |
397 |
|
|
398 |
|
(defun vc-default-workfile-unchanged-p (backend file) |
399 |
|
"Check if FILE is unchanged by diffing against the master version. |
400 |
|
Return non-nil if FILE is unchanged." |
401 |
|
(zerop (vc-call diff file (vc-workfile-version file)))) |
402 |
|
|
403 |
(defun vc-workfile-version (file) |
(defun vc-workfile-version (file) |
404 |
"Return the version level of the current workfile FILE. |
"Return the version level of the current workfile FILE. |
405 |
If FILE is not registered, this function always returns nil." |
If FILE is not registered, this function always returns nil." |
408 |
(vc-file-setprop file 'vc-workfile-version |
(vc-file-setprop file 'vc-workfile-version |
409 |
(vc-call workfile-version file))))) |
(vc-call workfile-version file))))) |
410 |
|
|
|
;;; actual version-control code starts here |
|
|
|
|
411 |
(defun vc-default-registered (backend file) |
(defun vc-default-registered (backend file) |
412 |
"Check if FILE is registered in BACKEND using vc-BACKEND-master-templates." |
"Check if FILE is registered in BACKEND using vc-BACKEND-master-templates." |
413 |
(let ((sym (vc-make-backend-sym backend 'master-templates))) |
(let ((sym (vc-make-backend-sym backend 'master-templates))) |
474 |
|
|
475 |
(defun vc-toggle-read-only (&optional verbose) |
(defun vc-toggle-read-only (&optional verbose) |
476 |
"Change read-only status of current buffer, perhaps via version control. |
"Change read-only status of current buffer, perhaps via version control. |
477 |
|
|
478 |
If the buffer is visiting a file registered with version control, |
If the buffer is visiting a file registered with version control, |
479 |
then check the file in or out. Otherwise, just change the read-only flag |
then check the file in or out. Otherwise, just change the read-only flag |
480 |
of the buffer. |
of the buffer. |
481 |
With prefix argument, ask for version number to check in or check out. |
With prefix argument, ask for version number to check in or check out. |
482 |
Check-out of a specified version number does not lock the file; |
Check-out of a specified version number does not lock the file; |
483 |
to do that, use this command a second time with no argument." |
to do that, use this command a second time with no argument. |
484 |
|
|
485 |
|
If you bind this function to \\[toggle-read-only], then Emacs checks files |
486 |
|
in or out whenever you toggle the read-only flag." |
487 |
(interactive "P") |
(interactive "P") |
488 |
(if (or (and (boundp 'vc-dired-mode) vc-dired-mode) |
(if (or (and (boundp 'vc-dired-mode) vc-dired-mode) |
489 |
;; use boundp because vc.el might not be loaded |
;; use boundp because vc.el might not be loaded |
490 |
(vc-backend (buffer-file-name))) |
(vc-backend (buffer-file-name))) |
491 |
(vc-next-action verbose) |
(vc-next-action verbose) |
492 |
(toggle-read-only))) |
(toggle-read-only))) |
|
(define-key global-map "\C-x\C-q" 'vc-toggle-read-only) |
|
493 |
|
|
494 |
(defun vc-default-make-version-backups-p (backend file) |
(defun vc-default-make-version-backups-p (backend file) |
495 |
"Return non-nil if unmodified versions should be backed up locally. |
"Return non-nil if unmodified versions should be backed up locally. |
504 |
(if regexp |
(if regexp |
505 |
(concat (regexp-quote (file-name-nondirectory file)) |
(concat (regexp-quote (file-name-nondirectory file)) |
506 |
"\\.~[0-9.]+" (unless manual "\\.") "~") |
"\\.~[0-9.]+" (unless manual "\\.") "~") |
507 |
(expand-file-name (concat (file-name-nondirectory file) |
(expand-file-name (concat (file-name-nondirectory file) |
508 |
".~" (or rev (vc-workfile-version file)) |
".~" (or rev (vc-workfile-version file)) |
509 |
(unless manual ".") "~") |
(unless manual ".") "~") |
510 |
(file-name-directory file)))) |
(file-name-directory file)))) |
511 |
|
|
661 |
(get-file-buffer |
(get-file-buffer |
662 |
(abbreviate-file-name |
(abbreviate-file-name |
663 |
(file-chase-links buffer-file-name)))) |
(file-chase-links buffer-file-name)))) |
664 |
|
|
665 |
(vc-follow-link) |
(vc-follow-link) |
666 |
(message "Followed link to %s" buffer-file-name) |
(message "Followed link to %s" buffer-file-name) |
667 |
(vc-find-file-hook)) |
(vc-find-file-hook)) |
701 |
(if (buffer-file-name) |
(if (buffer-file-name) |
702 |
(vc-file-clearprops (buffer-file-name)))) |
(vc-file-clearprops (buffer-file-name)))) |
703 |
|
|
704 |
;; ??? DL: why is this not done? |
(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook) |
|
;;;(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook) |
|
705 |
|
|
706 |
;; Now arrange for (autoloaded) bindings of the main package. |
;; Now arrange for (autoloaded) bindings of the main package. |
707 |
;; Bindings for this have to go in the global map, as we'll often |
;; Bindings for this have to go in the global map, as we'll often |