annotate lisp/vc-hooks.el @ 12251:f2519a110e5f

The RCS status is now found by reading the master file directly, instead of using rlog. The properties retrieved from the master file are kept separately. The two main properties, `vc-workfile-version' and `vc-locking-user', are inferred from those master file properties if the information cannot be found elsehow. All properties are consistently cached now. (vc-master-info, vc-log-info, vc-fetch-properties): functions removed. Their job is now done by `vc-fetch-master-properties' and `vc-insert-file'. (vc-fetch-master-properties): new function, replaces vc-fetch-properties. Retrieves all the properties that can be found in the master file, for all three backends (calls `cvs status' in the CVS case). (vc-insert-file): new function. Inserts an arbitrary file into the current buffer, optionally chunkwise, until a certain regexp shows up. (vc-parse-locks): new function. Translates SCCS or RCS lock lists, as found in the master files, into lisp lists. Sets the new property `vc-master-locks'. (vc-locked-version): property removed. Was unnecessary, and only referenced in vc-hooks.el. (vc-head-version, vc-default-branch, vc-master-locks): new properties. (vc-top-version): new name for the old property `vc-branch-version'. ("top-version" is better because it might also be the RCS "head" if there is no default branch.) (vc-master-locking-user): replaces `vc-true-locking-user'. Scans the new `vc-master-locks' property, yielding the master file's idea of who is locking the current workfile version. (vc-locking-user): slightly changed to use the new properties. Changed the actual property value for an unlocked file to 'none. This is to distinguish it from an unknown locking state, which is represented by nil. The function vc-locking-user returns nil if the property is 'none, to make it compatible with the rest of VC. (vc-consult-rcs-headers, vc-master-locking-user): adpated to the new 'none-value of vc-locking-user. (vc-consult-rcs-headers): fixed bug that prevented (not vc-consult-headers) from working (vc-file-not-found-hook): set the default-directory of the new buffer before check-out. (Otherwise, setting vc-keep-workfiles to nil doesn't work.) (vc-occurences, vc-branch-p): functions removed (no longer needed) Reordered some defuns so they are grouped in a logical way.
author Richard M. Stallman <rms@gnu.org>
date Thu, 15 Jun 1995 23:06:45 +0000
parents 01cc5af0985b
children e07d55d05864
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2232
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2227
diff changeset
1 ;;; vc-hooks.el --- resident support for version-control
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
11803
0e58ab232517 (vc-status): If vc-locking-user returns a number, compare it to (user-uid).
Roland McGrath <roland@gnu.org>
parents: 11604
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
6 ;; Modified by:
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
7 ;; Per Cederqvist <ceder@lysator.liu.se>
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
8 ;; Andre Spiegel <spiegel@berlin.informatik.uni-stuttgart.de>
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; any later version.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 ;;; Commentary:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
28 ;; This is the always-loaded portion of VC.
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
29 ;; It takes care VC-related activities that are done when you visit a file,
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
30 ;; so that vc.el itself is loaded only when you use a VC command.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 ;; See the commentary of vc.el.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 ;;; Code:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
35 ;; Customization Variables (the rest is in vc.el)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
36
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
37 (defvar vc-default-back-end nil
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
38 "*Back-end actually used by this interface; may be SCCS or RCS.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
39 The value is only computed when needed to avoid an expensive search.")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
40
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
41 (defvar vc-path
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
42 (if (file-directory-p "/usr/sccs")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
43 '("/usr/sccs")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
44 nil)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
45 "*List of extra directories to search for version control commands.")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
46
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
47 (defvar vc-master-templates
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 '(("%sRCS/%s,v" . RCS) ("%s%s,v" . RCS) ("%sRCS/%s" . RCS)
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
49 ("%sSCCS/s.%s" . SCCS) ("%ss.%s". SCCS)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
50 vc-find-cvs-master)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 "*Where to look for version-control master files.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 The first pair corresponding to a given back end is used as a template
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 when creating new masters.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 (defvar vc-make-backup-files nil
5164
04d6b9e7782a (vc-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4726
diff changeset
56 "*If non-nil, backups of registered files are made as with other files.
5783
6a97e54241a3 (vc-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5743
diff changeset
57 If nil (the default), files covered by version control don't get backups.")
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
59 (defvar vc-display-status t
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
60 "*If non-nil, display revision number and lock status in modeline.
3900
c6f3d2af0df7 (vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3459
diff changeset
61 Otherwise, not displayed.")
c6f3d2af0df7 (vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3459
diff changeset
62
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
63 (defvar vc-consult-headers t
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
64 "*Identify work files by searching for version headers.")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
65
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
66 (defvar vc-mistrust-permissions nil
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
67 "*Don't assume that permissions and ownership track version-control status.")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
68
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
69 (defvar vc-keep-workfiles t
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
70 "*If non-nil, don't delete working files after registering changes.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
71 If the back-end is CVS, workfiles are always kept, regardless of the
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
72 value of this flag.")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
73
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
74 ;; Tell Emacs about this new kind of minor mode
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
75 (if (not (assoc 'vc-mode minor-mode-alist))
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
76 (setq minor-mode-alist (cons '(vc-mode vc-mode)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
77 minor-mode-alist)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
78
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
79 (make-variable-buffer-local 'vc-mode)
2620
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
80 (put 'vc-mode 'permanent-local t)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
81
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82 ;; We need a notion of per-file properties because the version
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
83 ;; control state of a file is expensive to derive --- we compute
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
84 ;; them when the file is initially found, keep them up to date
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
85 ;; during any subsequent VC operations, and forget them when
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
86 ;; the buffer is killed.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87
2213
9ff513b5d296 vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1951
diff changeset
88 (defmacro vc-error-occurred (&rest body)
9ff513b5d296 vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1951
diff changeset
89 (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t)))
9ff513b5d296 vc-error-occurred: moved to vc-hooks.el in order for ^X^F of a
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1951
diff changeset
90
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
91 (defvar vc-file-prop-obarray [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
92 "Obarray for per-file properties.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
93
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
94 (defvar vc-buffer-backend t)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
95 (make-variable-buffer-local 'vc-buffer-backend)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
96
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
97 (defun vc-file-setprop (file property value)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
98 ;; set per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
99 (put (intern file vc-file-prop-obarray) property value))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
100
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
101 (defun vc-file-getprop (file property)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
102 ;; get per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
103 (get (intern file vc-file-prop-obarray) property))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
104
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
105 (defun vc-file-clearprops (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
106 ;; clear all properties of a given file
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
107 (setplist (intern file vc-file-prop-obarray) nil))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
108
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
109 ;;; Functions that determine property values, by examining the
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
110 ;;; working file, the master file, or log program output
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
111
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
112 (defun vc-match-substring (bn)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
113 (buffer-substring (match-beginning bn) (match-end bn)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
114
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
115 (defun vc-lock-file (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
116 ;; Generate lock file name corresponding to FILE
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
117 (let ((master (vc-name file)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
118 (and
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
119 master
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
120 (string-match "\\(.*/\\)s\\.\\(.*\\)" master)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
121 (concat
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
122 (substring master (match-beginning 1) (match-end 1))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
123 "p."
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
124 (substring master (match-beginning 2) (match-end 2))))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
125
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
126 (defun vc-parse-buffer (patterns &optional file properties)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
127 ;; Use PATTERNS to parse information out of the current buffer.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
128 ;; Each element of PATTERNS is a list of 2 to 3 elements. The first element
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
129 ;; is the pattern to be matched, and the second (an integer) is the
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
130 ;; number of the subexpression that should be returned. If there's
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
131 ;; a third element (also the number of a subexpression), that
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
132 ;; subexpression is assumed to be a date field and we want the most
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
133 ;; recent entry matching the template.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
134 ;; If FILE and PROPERTIES are given, the latter must be a list of
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
135 ;; properties of the same length as PATTERNS; each property is assigned
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
136 ;; the corresponding value.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
137 (mapcar (function (lambda (p)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
138 (goto-char (point-min))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
139 (cond
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
140 ((eq (length p) 2) ;; search for first entry
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
141 (let ((value nil))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
142 (if (re-search-forward (car p) nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
143 (setq value (vc-match-substring (elt p 1))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
144 (if file
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
145 (progn (vc-file-setprop file (car properties) value)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
146 (setq properties (cdr properties))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
147 value))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
148 ((eq (length p) 3) ;; search for latest entry
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
149 (let ((latest-date "") (latest-val))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
150 (while (re-search-forward (car p) nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
151 (let ((date (vc-match-substring (elt p 2))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
152 (if (string< latest-date date)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
153 (progn
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
154 (setq latest-date date)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
155 (setq latest-val
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
156 (vc-match-substring (elt p 1)))))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
157 (if file
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
158 (progn (vc-file-setprop file (car properties) latest-val)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
159 (setq properties (cdr properties))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
160 latest-val)))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
161 patterns)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
162 )
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
163
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
164 (defun vc-insert-file (file &optional limit blocksize)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
165 ;; Insert the contents of FILE into the current buffer.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
166 ;; Optional argument LIMIT is a regexp. If present,
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
167 ;; the file is inserted in chunks of size BLOCKSIZE
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
168 ;; (default 8 kByte), until the first occurence of
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
169 ;; LIMIT is found. The function returns nil if FILE
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
170 ;; doesn't exist.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
171 (cond ((file-exists-p file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
172 (cond (limit
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
173 (if (not blocksize) (setq blocksize 8192))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
174 (let (found s)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
175 (while (not found)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
176 (setq s (buffer-size))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
177 (goto-char (1+ s))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
178 (setq found
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
179 (or (zerop (car (cdr
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
180 (insert-file-contents file nil s
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
181 (+ s blocksize)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
182 (progn (beginning-of-line)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
183 (re-search-forward limit nil t)))))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
184 (t (insert-file-contents file)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
185 (set-buffer-modified-p nil)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
186 (auto-save-mode nil)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
187 t)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
188 (t nil)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
189
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
190 (defun vc-parse-locks (file locks)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
191 ;; Parse RCS or SCCS locks.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
192 ;; The result is a list of the form ((VERSION USER) (VERSION USER) ...),
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
193 ;; which is returned and stored into the property `vc-master-locks'.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
194 (if (not locks)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
195 (vc-file-setprop file 'vc-master-locks 'none)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
196 (let ((found t) (index 0) master-locks version user)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
197 (cond ((eq (vc-backend file) 'SCCS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
198 (while (string-match "^\\([0-9.]+\\) [0-9.]+ \\([^ ]+\\) .*\n?"
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
199 locks index)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
200 (setq version (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
201 (match-beginning 1) (match-end 1)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
202 (setq user (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
203 (match-beginning 2) (match-end 2)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
204 (setq master-locks (append master-locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
205 (list (cons version user))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
206 (setq index (match-end 0))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
207 ((eq (vc-backend file) 'RCS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
208 (while (string-match "[ \t\n]*\\([^:]+\\):\\([0-9.]+\\)"
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
209 locks index)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
210 (setq version (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
211 (match-beginning 2) (match-end 2)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
212 (setq user (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
213 (match-beginning 1) (match-end 1)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
214 (setq master-locks (append master-locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
215 (list (cons version user))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
216 (setq index (match-end 0)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
217 (vc-file-setprop file 'vc-master-locks (or master-locks 'none)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
218
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
219 (defun vc-fetch-master-properties (file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
220 ;; Fetch those properties of FILE that are stored in the master file.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
221 (save-excursion
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
222 (cond
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
223 ((eq (vc-backend file) 'SCCS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
224 (set-buffer (get-buffer-create "*vc-info*"))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
225 (if (vc-insert-file (vc-lock-file file))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
226 (progn (vc-parse-locks file (buffer-string))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
227 (erase-buffer))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
228 (vc-file-setprop file 'vc-master-locks 'none))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
229 (vc-insert-file (vc-name file) "^\001e")
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
230 (vc-parse-buffer
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
231 (list '("^\001d D \\([^ ]+\\)" 1)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
232 (list (concat "^\001d D \\([^ ]+\\) .* "
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
233 (regexp-quote (user-login-name)) " ") 1))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
234 file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
235 '(vc-latest-version vc-your-latest-version)))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
236
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
237 ((eq (vc-backend file) 'RCS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
238 (set-buffer (get-buffer-create "*vc-info*"))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
239 (vc-insert-file (vc-name file) "^desc")
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
240 (vc-parse-buffer
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
241 (list '("^head[ \t\n]+\\([^;]+\\);" 1)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
242 '("^branch[ \t\n]+\\([^;]+\\);" 1)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
243 '("^locks\\([^;]+\\);" 1)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
244 '("^\\([0-9]+\\.[0-9.]+\\)\ndate[ \t]+\\([0-9.]+\\);" 1 2)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
245 (list (concat "^\\([0-9]+\\.[0-9.]+\\)\n"
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
246 "date[ \t]+\\([0-9.]+\\);[ \t]+"
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
247 "author[ \t]+"
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
248 (regexp-quote (user-login-name)) ";") 1 2))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
249 file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
250 '(vc-head-version
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
251 vc-default-branch
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
252 vc-master-locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
253 vc-latest-version
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
254 vc-your-latest-version))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
255 ;; determine vc-top-version: it is either the head version,
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
256 ;; or the tip of the default branch
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
257 (let ((default-branch (vc-file-getprop file 'vc-default-branch)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
258 (cond
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
259 ;; no default branch
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
260 ((or (not default-branch) (string= "" default-branch))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
261 (vc-file-setprop file 'vc-top-version
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
262 (vc-file-getprop file 'vc-head-version)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
263 ;; default branch is actually a revision
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
264 ((string-match "^[0-9]+\\.[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*$"
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
265 default-branch)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
266 (vc-file-setprop file 'vc-top-version default-branch))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
267 ;; else, search for the tip of the default branch
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
268 (t (vc-parse-buffer (list (list
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
269 (concat "^\\("
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
270 (regexp-quote default-branch)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
271 "\\.[0-9]+\\)\ndate[ \t]+\\([0-9.]+\\);") 1 2))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
272 file '(vc-top-version)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
273 ;; translate the locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
274 (vc-parse-locks file (vc-file-getprop file 'vc-master-locks)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
275
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
276 ((eq (vc-backend file) 'CVS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
277 ;; don't switch to the *vc-info* buffer before running the
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
278 ;; command, because that would change its default directory
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
279 (save-excursion (set-buffer (get-buffer-create "*vc-info*"))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
280 (erase-buffer))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
281 (let ((exec-path (append vc-path exec-path))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
282 ;; Add vc-path to PATH for the execution of this command.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
283 (process-environment
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
284 (cons (concat "PATH=" (getenv "PATH")
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
285 ":" (mapconcat 'identity vc-path ":"))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
286 process-environment)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
287 (apply 'call-process "cvs" nil "*vc-info*" nil
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
288 (list "status" (file-name-nondirectory file))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
289 (set-buffer (get-buffer "*vc-info*"))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
290 (set-buffer-modified-p nil)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
291 (auto-save-mode nil)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
292 (vc-parse-buffer
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
293 ;; CVS 1.3 says "RCS Version:", other releases "RCS Revision:",
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
294 ;; and CVS 1.4a1 says "Repository revision:".
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
295 '(("\\(RCS Version\\|RCS Revision\\|Repository revision\\):[\t ]+\\([0-9.]+\\)" 2)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
296 ("^File: [^ \t]+[ \t]+Status: \\(.*\\)" 1))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
297 file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
298 '(vc-latest-version vc-cvs-status))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
299 ;; Translate those status values that are needed into symbols.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
300 ;; Any other value is converted to nil.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
301 (let ((status (vc-file-getprop file 'vc-cvs-status)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
302 (cond ((string-match "Up-to-date" status)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
303 (vc-file-setprop file 'vc-cvs-status 'up-to-date)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
304 (vc-file-setprop file 'vc-checkout-time
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
305 (nth 5 (file-attributes file))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
306 ((string-match "Locally Modified" status)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
307 (vc-file-setprop file 'vc-cvs-status 'locally-modified))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
308 ((string-match "Needs Merge" status)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
309 (vc-file-setprop file 'vc-cvs-status 'needs-merge))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
310 (t (vc-file-setprop file 'vc-cvs-status nil))))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
311 (kill-buffer (current-buffer))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
312
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
313 ;;; Functions that determine property values, by examining the
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
314 ;;; working file, the master file, or log program output
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
315
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
316 (defun vc-consult-rcs-headers (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
317 ;; Search for RCS headers in FILE, and set properties
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
318 ;; accordingly. This function can be disabled by setting
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
319 ;; vc-consult-headers to nil.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
320 ;; Returns: nil if no headers were found
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
321 ;; (or if the feature is disabled,
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
322 ;; or if there is currently no buffer
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
323 ;; visiting FILE)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
324 ;; 'rev if a workfile revision was found
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
325 ;; 'rev-and-lock if revision and lock info was found
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
326 (cond
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
327 ((or (not vc-consult-headers)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
328 (not (get-file-buffer file))) nil)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
329 ((save-excursion
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
330 (set-buffer (get-file-buffer file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
331 (goto-char (point-min))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
332 (cond
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
333 ;; search for $Id or $Header
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
334 ;; -------------------------
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
335 ((re-search-forward "\\$\\(Id\\|Header\\): [^ ]+ \\([0-9.]+\\) "
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
336 nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
337 ;; if found, store the revision number ...
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
338 (let ((rev (buffer-substring (match-beginning 2)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
339 (match-end 2))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
340 ;; ... and check for the locking state
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
341 (if (re-search-forward
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
342 (concat "\\=[0-9]+/[0-9]+/[0-9]+ " ; date
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
343 "[0-9]+:[0-9]+:[0-9]+ " ; time
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
344 "[^ ]+ [^ ]+ ") ; author & state
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
345 nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
346 (cond
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
347 ;; unlocked revision
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
348 ((looking-at "\\$")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
349 (vc-file-setprop file 'vc-workfile-version rev)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
350 (vc-file-setprop file 'vc-locking-user 'none)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
351 'rev-and-lock)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
352 ;; revision is locked by some user
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
353 ((looking-at "\\([^ ]+\\) \\$")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
354 (vc-file-setprop file 'vc-workfile-version rev)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
355 (vc-file-setprop file 'vc-locking-user
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
356 (buffer-substring (match-beginning 1)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
357 (match-end 1)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
358 'rev-and-lock)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
359 ;; everything else: false
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
360 (nil))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
361 ;; unexpected information in
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
362 ;; keyword string --> quit
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
363 nil)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
364 ;; search for $Revision
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
365 ;; --------------------
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
366 ((re-search-forward (concat "\\$"
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
367 "Revision: \\([0-9.]+\\) \\$")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
368 nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
369 ;; if found, store the revision number ...
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
370 (let ((rev (buffer-substring (match-beginning 1)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
371 (match-end 1))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
372 ;; and see if there's any lock information
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
373 (goto-char (point-min))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
374 (if (re-search-forward (concat "\\$" "Locker:") nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
375 (cond ((looking-at " \\([^ ]+\\) \\$")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
376 (vc-file-setprop file 'vc-workfile-version rev)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
377 (vc-file-setprop file 'vc-locking-user
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
378 (buffer-substring (match-beginning 1)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
379 (match-end 1)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
380 'rev-and-lock)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
381 ((looking-at " *\\$")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
382 (vc-file-setprop file 'vc-workfile-version rev)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
383 (vc-file-setprop file 'vc-locking-user 'none)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
384 'rev-and-lock)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
385 (t
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
386 (vc-file-setprop file 'vc-workfile-version rev)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
387 (vc-file-setprop file 'vc-locking-user 'none)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
388 'rev-and-lock))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
389 (vc-file-setprop file 'vc-workfile-version rev)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
390 'rev)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
391 ;; else: nothing found
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
392 ;; -------------------
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
393 (t nil))))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
394
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
395 ;;; Access functions to file properties
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
396 ;;; (Properties should be _set_ using vc-file-setprop, but
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
397 ;;; _retrieved_ only through these functions, which decide
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
398 ;;; if the property is already known or not. A property should
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
399 ;;; only be retrieved by vc-file-getprop if there is no
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
400 ;;; access function.)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
401
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
402 ;;; properties indicating the backend
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
403 ;;; being used for FILE
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
404
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
405 (defun vc-backend-subdirectory-name (&optional file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
406 ;; Where the master and lock files for the current directory are kept
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
407 (symbol-name
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
408 (or
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
409 (and file (vc-backend file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
410 vc-default-back-end
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
411 (setq vc-default-back-end (if (vc-find-binary "rcs") 'RCS 'SCCS)))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
412
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
413 (defun vc-name (file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
414 "Return the master name of a file, nil if it is not registered."
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
415 (or (vc-file-getprop file 'vc-name)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
416 (let ((name-and-type (vc-registered file)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
417 (if name-and-type
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
418 (progn
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
419 (vc-file-setprop file 'vc-backend (cdr name-and-type))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
420 (vc-file-setprop file 'vc-name (car name-and-type)))))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
421
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
422 (defun vc-backend (file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
423 "Return the version-control type of a file, nil if it is not registered."
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
424 (and file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
425 (or (vc-file-getprop file 'vc-backend)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
426 (let ((name-and-type (vc-registered file)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
427 (if name-and-type
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
428 (progn
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
429 (vc-file-setprop file 'vc-name (car name-and-type))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
430 (vc-file-setprop file 'vc-backend (cdr name-and-type))))))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
431
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
432 ;;; properties indicating the locking state
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
433
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
434 (defun vc-cvs-status (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
435 ;; Return the cvs status of FILE
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
436 ;; (Status field in output of "cvs status")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
437 (cond ((vc-file-getprop file 'vc-cvs-status))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
438 (t (vc-fetch-master-properties file)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
439 (vc-file-getprop file 'vc-cvs-status))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
440
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
441 (defun vc-master-locks (file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
442 ;; Return the lock entries in the master of FILE.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
443 ;; Return 'none if there are no such entries, and a list
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
444 ;; of the form ((VERSION USER) (VERSION USER) ...) otherwise.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
445 (cond ((vc-file-getprop file 'vc-master-locks))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
446 (t (vc-fetch-master-properties file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
447 (vc-file-getprop file 'vc-master-locks))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
448
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
449 (defun vc-master-locking-user (file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
450 ;; Return the master file's idea of who is locking
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
451 ;; the current workfile version of FILE.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
452 ;; Return 'none if it is not locked.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
453 (let ((master-locks (vc-master-locks file)) lock)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
454 (if (eq master-locks 'none) 'none
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
455 ;; search for a lock on the current workfile version
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
456 (setq lock (assoc (vc-workfile-version file) master-locks))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
457 (cond (lock (cdr lock))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
458 ('none)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
459
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
460 (defun vc-locking-user (file)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
461 ;; Return the name of the person currently holding a lock on FILE.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
462 ;; Return nil if there is no such person.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
463 ;; Under CVS, a file is considered locked if it has been modified since
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
464 ;; it was checked out. Under CVS, this will sometimes return the uid of
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
465 ;; the owner of the file (as a number) instead of a string.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
466 ;; The property is cached. It is only looked up if it is currently nil.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
467 ;; Note that, for a file that is not locked, the actual property value
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
468 ;; is 'none, to distinguish it from an unknown locking state. That value
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
469 ;; is converted to nil by this function, and returned to the caller.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
470 (let ((locking-user (vc-file-getprop file 'vc-locking-user)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
471 (if locking-user
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
472 ;; if we already know the property, return it
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
473 (if (eq locking-user 'none) nil locking-user)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
474
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
475 ;; otherwise, infer the property...
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
476 (cond
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
477 ;; in the CVS case, check the status
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
478 ((eq (vc-backend file) 'CVS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
479 (if (eq (vc-cvs-status file) 'up-to-date)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
480 (vc-file-setprop file 'vc-locking-user 'none)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
481 ;; The expression below should return the username of the owner
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
482 ;; of the file. It doesn't. It returns the username if it is
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
483 ;; you, or otherwise the UID of the owner of the file. The
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
484 ;; return value from this function is only used by
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
485 ;; vc-dired-reformat-line, and it does the proper thing if a UID
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
486 ;; is returned.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
487 ;;
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
488 ;; The *proper* way to fix this would be to implement a built-in
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
489 ;; function in Emacs, say, (username UID), that returns the
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
490 ;; username of a given UID.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
491 ;;
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
492 ;; The result of this hack is that vc-directory will print the
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
493 ;; name of the owner of the file for any files that are
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
494 ;; modified.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
495 (let ((uid (nth 2 (file-attributes file))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
496 (if (= uid (user-uid))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
497 (vc-file-setprop file 'vc-locking-user (user-login-name))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
498 (vc-file-setprop file 'vc-locking-user uid)))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
499
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
500 ;; RCS case: attempt a header search. If this feature is
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
501 ;; disabled, vc-consult-rcs-headers always returns nil.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
502 ((and (eq (vc-backend file) 'RCS)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
503 (eq (vc-consult-rcs-headers file) 'rev-and-lock)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
504
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
505 ;; if the file permissions are not trusted,
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
506 ;; use the information from the master file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
507 ((or (not vc-keep-workfiles)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
508 (eq vc-mistrust-permissions 't)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
509 (and vc-mistrust-permissions
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
510 (funcall vc-mistrust-permissions
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
511 (vc-backend-subdirectory-name file))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
512 (vc-file-setprop file 'vc-locking-user (vc-master-locking-user file)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
513
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
514 ;; Otherwise: Use the file permissions. (But if it turns out that the
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
515 ;; file is not owned by the user, use the master file.)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
516 ;; This implementation assumes that any file which is under version
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
517 ;; control and has -rw-r--r-- is locked by its owner. This is true
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
518 ;; for both RCS and SCCS, which keep unlocked files at -r--r--r--.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
519 ;; We have to be careful not to exclude files with execute bits on;
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
520 ;; scripts can be under version control too. Also, we must ignore the
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
521 ;; group-read and other-read bits, since paranoid users turn them off.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
522 ;; This hack wins because calls to the somewhat expensive
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
523 ;; `vc-fetch-master-properties' function only have to be made if
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
524 ;; (a) the file is locked by someone other than the current user,
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
525 ;; or (b) some untoward manipulation behind vc's back has changed
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
526 ;; the owner or the `group' or `other' write bits.
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
527 (t
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
528 (let ((attributes (file-attributes file)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
529 (cond ((string-match ".r-..-..-." (nth 8 attributes))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
530 (vc-file-setprop file 'vc-locking-user 'none))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
531 ((and (= (nth 2 attributes) (user-uid))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
532 (string-match ".rw..-..-." (nth 8 attributes)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
533 (vc-file-setprop file 'vc-locking-user (user-login-name)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
534 (t
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
535 (vc-file-setprop file 'vc-locking-user
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
536 (vc-master-locking-user file))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
537 )))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
538 ;; recursively call the function again,
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
539 ;; to convert a possible 'none value
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
540 (vc-locking-user file))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
541
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
542 ;;; properties to store current and recent version numbers
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
543
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
544 (defun vc-latest-version (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
545 ;; Return version level of the latest version of FILE
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
546 (cond ((vc-file-getprop file 'vc-latest-version))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
547 (t (vc-fetch-master-properties file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
548 (vc-file-getprop file 'vc-latest-version))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
549
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
550 (defun vc-your-latest-version (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
551 ;; Return version level of the latest version of FILE checked in by you
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
552 (cond ((vc-file-getprop file 'vc-your-latest-version))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
553 (t (vc-fetch-master-properties file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
554 (vc-file-getprop file 'vc-your-latest-version))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
555
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
556 (defun vc-top-version (file)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
557 ;; Return version level of the highest revision on the default branch
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
558 ;; If there is no default branch, return the highest version number
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
559 ;; on the trunk.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
560 ;; This property is defined for RCS only.
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
561 (cond ((vc-file-getprop file 'vc-top-version))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
562 (t (vc-fetch-master-properties file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
563 (vc-file-getprop file 'vc-top-version))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
564
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
565 (defun vc-workfile-version (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
566 ;; Return version level of the current workfile FILE
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
567 ;; This is attempted by first looking at the RCS keywords.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
568 ;; If there are no keywords in the working file,
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
569 ;; vc-top-version is taken.
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
570 ;; Note that this property is cached, that is, it is only
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
571 ;; looked up if it is nil.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
572 ;; For SCCS, this property is equivalent to vc-latest-version.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
573 (cond ((vc-file-getprop file 'vc-workfile-version))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
574 ((eq (vc-backend file) 'SCCS) (vc-latest-version file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
575 ((eq (vc-backend file) 'RCS)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
576 (if (vc-consult-rcs-headers file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
577 (vc-file-getprop file 'vc-workfile-version)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
578 (let ((rev (cond ((vc-top-version file))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
579 ((vc-latest-version file)))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
580 (vc-file-setprop file 'vc-workfile-version rev)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
581 rev)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
582 ((eq (vc-backend file) 'CVS)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
583 (if (vc-consult-rcs-headers file) ;; CVS
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
584 (vc-file-getprop file 'vc-workfile-version)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
585 (vc-find-cvs-master (file-name-directory file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
586 (file-name-nondirectory file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
587 (vc-file-getprop file 'vc-workfile-version)))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
588
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
589 ;;; actual version-control code starts here
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
590
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
591 (defun vc-registered (file)
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
592 (let (handler handlers)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
593 (if (boundp 'file-name-handler-alist)
7483
dfd719c64907 (vc-registered): Use find-file-name-handler.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
594 (setq handler (find-file-name-handler file 'vc-registered)))
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
595 (if handler
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
596 (funcall handler 'vc-registered file)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
597 ;; Search for a master corresponding to the given file
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
598 (let ((dirname (or (file-name-directory file) ""))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
599 (basename (file-name-nondirectory file)))
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
600 (catch 'found
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
601 (mapcar
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
602 (function (lambda (s)
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
603 (if (atom s)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
604 (funcall s dirname basename)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
605 (let ((trial (format (car s) dirname basename)))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
606 (if (and (file-exists-p trial)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
607 ;; Make sure the file we found with name
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
608 ;; TRIAL is not the source file itself.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
609 ;; That can happen with RCS-style names
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
610 ;; if the file name is truncated
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
611 ;; (e.g. to 14 chars). See if either
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
612 ;; directory or attributes differ.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
613 (or (not (string= dirname
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
614 (file-name-directory trial)))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
615 (not (equal
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
616 (file-attributes file)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
617 (file-attributes trial)))))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
618 (throw 'found (cons trial (cdr s))))))))
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
619 vc-master-templates)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
620 nil)))))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
621
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
622 (defun vc-find-cvs-master (dirname basename)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
623 ;; Check if DIRNAME/BASENAME is handled by CVS.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
624 ;; If it is, do a (throw 'found (cons MASTER 'CVS)).
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
625 ;; Note: If the file is ``cvs add''ed but not yet ``cvs commit''ed
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
626 ;; the MASTER will not actually exist yet. The other parts of VC
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
627 ;; checks for this condition. This function returns nil if
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
628 ;; DIRNAME/BASENAME is not handled by CVS.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
629 (if (and (file-directory-p (concat dirname "CVS/"))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
630 (file-readable-p (concat dirname "CVS/Entries")))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
631 (let ((bufs nil) (fold case-fold-search))
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
632 (unwind-protect
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
633 (save-excursion
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
634 (setq bufs (list
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
635 (find-file-noselect (concat dirname "CVS/Entries"))))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
636 (set-buffer (car bufs))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
637 (goto-char (point-min))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
638 ;; make sure the file name is searched
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
639 ;; case-sensitively
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
640 (setq case-fold-search nil)
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
641 (cond
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
642 ((re-search-forward
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
643 (concat "^/" (regexp-quote basename) "/\\([^/]*\\)/")
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
644 nil t)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
645 (setq case-fold-search fold) ;; restore the old value
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
646 ;; We found it. Store away version number, now
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
647 ;; that we are anyhow so close to finding it.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
648 (vc-file-setprop (concat dirname basename)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
649 'vc-workfile-version
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
650 (buffer-substring (match-beginning 1)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
651 (match-end 1)))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
652 (setq bufs (cons (find-file-noselect
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
653 (concat dirname "CVS/Repository"))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
654 bufs))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
655 (set-buffer (car bufs))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
656 (let ((master
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
657 (concat (file-name-as-directory
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
658 (buffer-substring (point-min)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
659 (1- (point-max))))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
660 basename
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
661 ",v")))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
662 (throw 'found (cons master 'CVS))))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
663 (t (setq case-fold-search fold) ;; restore the old value
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
664 nil)))
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
665 (mapcar (function kill-buffer) bufs)))))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
666
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
667 (defun vc-buffer-backend ()
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
668 "Return the version-control type of the visited file, or nil if none."
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
669 (if (eq vc-buffer-backend t)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
670 (setq vc-buffer-backend (vc-backend (buffer-file-name)))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
671 vc-buffer-backend))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
672
10176
332014233a2c (vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 9869
diff changeset
673 (defun vc-toggle-read-only (&optional verbose)
2620
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
674 "Change read-only status of current buffer, perhaps via version control.
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
675 If the buffer is visiting a file registered with version control,
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
676 then check the file in or out. Otherwise, just change the read-only flag
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
677 of the buffer. With prefix argument, ask for version number."
10176
332014233a2c (vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 9869
diff changeset
678 (interactive "P")
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
679 (if (vc-backend (buffer-file-name))
10176
332014233a2c (vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 9869
diff changeset
680 (vc-next-action verbose)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
681 (toggle-read-only)))
2620
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
682 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
683
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
684 (defun vc-mode-line (file &optional label)
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
685 "Set `vc-mode' to display type of version control for FILE.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
686 The value is set in the current buffer, which should be the buffer
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
687 visiting FILE. Second optional arg LABEL is put in place of version
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
688 control system name."
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
689 (interactive (list buffer-file-name nil))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
690 (let ((vc-type (vc-backend file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
691 (vc-status-string (and vc-display-status (vc-status file))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
692 (setq vc-mode
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
693 (concat " " (or label (symbol-name vc-type)) vc-status-string))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
694 ;; Make the buffer read-only if the file is not locked
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
695 ;; (or unchanged, in the CVS case).
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
696 ;; Determine this by looking at the mode string,
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
697 ;; so that no further external status query is necessary
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
698 (if vc-status-string
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
699 (if (eq (elt vc-status-string 0) ?-)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
700 (setq buffer-read-only t))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
701 (if (not (vc-locking-user file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
702 (setq buffer-read-only t)))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
703 ;; Even root shouldn't modify a registered file without
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
704 ;; locking it first.
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
705 (and vc-type
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
706 (not buffer-read-only)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
707 (zerop (user-uid))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
708 (require 'vc)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
709 (not (equal (user-login-name) (vc-locking-user file)))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
710 (setq buffer-read-only t))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
711 (and (null vc-type)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
712 (file-symlink-p file)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
713 (let ((link-type (vc-backend (file-symlink-p file))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
714 (if link-type
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
715 (message
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
716 "Warning: symbolic link to %s-controlled source file"
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
717 link-type))))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
718 (force-mode-line-update)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
719 ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
720 vc-type))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
721
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
722 (defun vc-status (file)
4063
cebb261b0f10 (vc-rcs-status): Include head version number in mode line if there
Paul Eggert <eggert@twinsun.com>
parents: 4024
diff changeset
723 ;; Return string for placement in modeline by `vc-mode-line'.
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
724 ;; Format:
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
725 ;;
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
726 ;; "-REV" if the revision is not locked
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
727 ;; ":REV" if the revision is locked by the user
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
728 ;; ":LOCKER:REV" if the revision is locked by somebody else
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
729 ;; " @@" for a CVS file that is added, but not yet committed
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
730 ;;
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
731 ;; In the CVS case, a "locked" working file is a
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
732 ;; working file that is modified with respect to the master.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
733 ;; The file is "locked" from the moment when the user makes
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
734 ;; the buffer writable.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
735 ;;
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
736 ;; This function assumes that the file is registered.
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
737
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
738 (let ((locker (vc-locking-user file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
739 (rev (vc-workfile-version file)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
740 (cond ((string= "0" rev)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
741 " @@")
11803
0e58ab232517 (vc-status): If vc-locking-user returns a number, compare it to (user-uid).
Roland McGrath <roland@gnu.org>
parents: 11604
diff changeset
742 ((not locker)
0e58ab232517 (vc-status): If vc-locking-user returns a number, compare it to (user-uid).
Roland McGrath <roland@gnu.org>
parents: 11604
diff changeset
743 (concat "-" rev))
0e58ab232517 (vc-status): If vc-locking-user returns a number, compare it to (user-uid).
Roland McGrath <roland@gnu.org>
parents: 11604
diff changeset
744 ((if (stringp locker)
0e58ab232517 (vc-status): If vc-locking-user returns a number, compare it to (user-uid).
Roland McGrath <roland@gnu.org>
parents: 11604
diff changeset
745 (string= locker (user-login-name))
0e58ab232517 (vc-status): If vc-locking-user returns a number, compare it to (user-uid).
Roland McGrath <roland@gnu.org>
parents: 11604
diff changeset
746 (= locker (user-uid)))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
747 (concat ":" rev))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
748 (t
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
749 (concat ":" locker ":" rev)))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
750
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
751 ;;; install a call to the above as a find-file hook
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
752 (defun vc-find-file-hook ()
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
753 ;; Recompute whether file is version controlled,
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
754 ;; if user has killed the buffer and revisited.
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
755 (cond
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
756 (buffer-file-name
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
757 (vc-file-clearprops buffer-file-name)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
758 (cond
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
759 ((vc-backend buffer-file-name)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
760 (vc-mode-line buffer-file-name)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
761 (cond ((not vc-make-backup-files)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
762 ;; Use this variable, not make-backup-files,
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
763 ;; because this is for things that depend on the file name.
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
764 (make-local-variable 'backup-inhibited)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
765 (setq backup-inhibited t))))))))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
766
4655
604a401e05a4 (vc-find-file-hook, vc-file-not-found-hook): Use add-hook to install.
Paul Eggert <eggert@twinsun.com>
parents: 4338
diff changeset
767 (add-hook 'find-file-hooks 'vc-find-file-hook)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
768
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
769 ;;; more hooks, this time for file-not-found
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
770 (defun vc-file-not-found-hook ()
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
771 "When file is not found, try to check it out from RCS or SCCS.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
772 Returns t if checkout was successful, nil otherwise."
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
773 (if (vc-backend buffer-file-name)
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
774 (save-excursion
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
775 (require 'vc)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
776 (setq default-directory (file-name-directory (buffer-file-name)))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
777 (not (vc-error-occurred (vc-checkout buffer-file-name))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
778
4655
604a401e05a4 (vc-find-file-hook, vc-file-not-found-hook): Use add-hook to install.
Paul Eggert <eggert@twinsun.com>
parents: 4338
diff changeset
779 (add-hook 'find-file-not-found-hooks 'vc-file-not-found-hook)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
780
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
781 ;; Discard info about a file when we kill its buffer.
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
782 (defun vc-kill-buffer-hook ()
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
783 (if (stringp (buffer-file-name))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
784 (progn
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
785 (vc-file-clearprops (buffer-file-name))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
786 (kill-local-variable 'vc-buffer-backend))))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
787
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
788 ;;;(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
789
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
790 ;;; Now arrange for bindings and autoloading of the main package.
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
791 ;;; Bindings for this have to go in the global map, as we'll often
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
792 ;;; want to call them from random buffers.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
793
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
794 (setq vc-prefix-map (lookup-key global-map "\C-xv"))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
795 (if (not (keymapp vc-prefix-map))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
796 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
797 (setq vc-prefix-map (make-sparse-keymap))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
798 (define-key global-map "\C-xv" vc-prefix-map)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
799 (define-key vc-prefix-map "a" 'vc-update-change-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
800 (define-key vc-prefix-map "c" 'vc-cancel-version)
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
801 (define-key vc-prefix-map "d" 'vc-directory)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
802 (define-key vc-prefix-map "h" 'vc-insert-headers)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
803 (define-key vc-prefix-map "i" 'vc-register)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
804 (define-key vc-prefix-map "l" 'vc-print-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
805 (define-key vc-prefix-map "r" 'vc-retrieve-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
806 (define-key vc-prefix-map "s" 'vc-create-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
807 (define-key vc-prefix-map "u" 'vc-revert-buffer)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
808 (define-key vc-prefix-map "v" 'vc-next-action)
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
809 (define-key vc-prefix-map "=" 'vc-diff)
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
810 (define-key vc-prefix-map "~" 'vc-version-other-window)))
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
811
9869
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
812 (if (not (boundp 'vc-menu-map))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
813 ;; Don't do the menu bindings if menu-bar.el wasn't loaded to defvar
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
814 ;; vc-menu-map.
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
815 ()
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
816 ;;(define-key vc-menu-map [show-files]
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
817 ;; '("Show Files under VC" . (vc-directory t)))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
818 (define-key vc-menu-map [vc-directory] '("Show Locked Files" . vc-directory))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
819 (define-key vc-menu-map [separator1] '("----"))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
820 (define-key vc-menu-map [vc-rename-file] '("Rename File" . vc-rename-file))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
821 (define-key vc-menu-map [vc-version-other-window]
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
822 '("Show Other Version" . vc-version-other-window))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
823 (define-key vc-menu-map [vc-diff] '("Compare with Last Version" . vc-diff))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
824 (define-key vc-menu-map [vc-update-change-log]
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
825 '("Update ChangeLog" . vc-update-change-log))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
826 (define-key vc-menu-map [vc-print-log] '("Show History" . vc-print-log))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
827 (define-key vc-menu-map [separator2] '("----"))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
828 (define-key vc-menu-map [undo] '("Undo Last Check-In" . vc-cancel-version))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
829 (define-key vc-menu-map [vc-revert-buffer]
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
830 '("Revert to Last Version" . vc-revert-buffer))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
831 (define-key vc-menu-map [vc-insert-header]
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
832 '("Insert Header" . vc-insert-headers))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
833 (define-key vc-menu-map [vc-menu-check-in] '("Check In" . vc-next-action))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
834 (define-key vc-menu-map [vc-check-out] '("Check Out" . vc-toggle-read-only))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
835 (define-key vc-menu-map [vc-register] '("Register" . vc-register))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
836 (put 'vc-rename-file 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
837 (put 'vc-version-other-window 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
838 (put 'vc-diff 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
839 (put 'vc-update-change-log 'menu-enable
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
840 '(eq (vc-buffer-backend) 'RCS))
9869
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
841 (put 'vc-print-log 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
842 (put 'vc-cancel-version 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
843 (put 'vc-revert-buffer 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
844 (put 'vc-insert-headers 'menu-enable 'vc-mode)
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
845 (put 'vc-next-action 'menu-enable '(and vc-mode (not buffer-read-only)))
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
846 (put 'vc-toggle-read-only 'menu-enable '(and vc-mode buffer-read-only))
12102
01cc5af0985b (vc-menu-map): Disable Register when no visited file.
Karl Heuer <kwzh@gnu.org>
parents: 11958
diff changeset
847 (put 'vc-register 'menu-enable '(and buffer-file-name (not vc-mode)))
9869
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
848 )
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
849
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
850 (provide 'vc-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
851
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
852 ;;; vc-hooks.el ends here