annotate lisp/vc-hooks.el @ 24419:30e478cd167e

(shell-command-default-error-buffer): Renamed from shell-command-on-region-default-error-buffer. (shell-command-on-region): Mention in echo area when there is some error output. Mention success or failure, too. Accumulate multiple error outputs going forward, with formfeed in between. Display the error buffer when we have put something in it. (shell-command): Add the ERROR-BUFFER argument feature.
author Karl Heuer <kwzh@gnu.org>
date Mon, 01 Mar 1999 03:19:32 +0000
parents 295cf395a392
children 5fc7c26535d5
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
20844
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
16821
d57c1c1bb966 Changed my e-mail address in the header.
André Spiegel <spiegel@gnu.org>
parents: 16742
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
d57c1c1bb966 Changed my e-mail address in the header.
André Spiegel <spiegel@gnu.org>
parents: 16742
diff changeset
6 ;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de>
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7
23693
295cf395a392 (vc-toggle-read-only): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23255
diff changeset
8 ;; $Id: vc-hooks.el,v 1.112 1998/09/14 17:26:39 fx Exp kwzh $
20989
c11150812ca0 Added version id.
André Spiegel <spiegel@gnu.org>
parents: 20844
diff changeset
9
904
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14142
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14142
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14142
diff changeset
25 ;; Boston, MA 02111-1307, USA.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27 ;;; Commentary:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
29 ;; This is the always-loaded portion of VC.
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
30 ;; 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
31 ;; 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
32 ;; See the commentary of vc.el.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 ;;; Code:
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
36 ;; 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
37
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
38 (defcustom vc-default-back-end nil
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
39 "*Back-end actually used by this interface; may be SCCS or RCS.
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
40 The value is only computed when needed to avoid an expensive search."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
41 :type '(choice (const nil) (const RCS) (const SCCS))
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
42 :group 'vc)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
43
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
44 (defcustom vc-handle-cvs t
12359
6da25b126f03 (vc-fetch-master-properties): Pass an absolute
Richard M. Stallman <rms@gnu.org>
parents: 12330
diff changeset
45 "*If non-nil, use VC for files managed with CVS.
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
46 If it is nil, don't use VC for those files."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
47 :type 'boolean
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
48 :group 'vc)
12359
6da25b126f03 (vc-fetch-master-properties): Pass an absolute
Richard M. Stallman <rms@gnu.org>
parents: 12330
diff changeset
49
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
50 (defcustom vc-rcsdiff-knows-brief nil
13378
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
51 "*Indicates whether rcsdiff understands the --brief option.
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
52 The value is either `yes', `no', or nil. If it is nil, VC tries
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
53 to use --brief and sets this variable to remember whether it worked."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
54 :type '(choice (const nil) (const yes) (const no))
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
55 :group 'vc)
13378
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
56
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
57 (defcustom vc-path
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
58 (if (file-directory-p "/usr/sccs")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
59 '("/usr/sccs")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
60 nil)
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
61 "*List of extra directories to search for version control commands."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
62 :type '(repeat directory)
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
63 :group 'vc)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
64
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
65 (defcustom vc-master-templates
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
66 '(("%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
67 ("%sSCCS/s.%s" . SCCS) ("%ss.%s". SCCS)
21232
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
68 vc-find-cvs-master
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
69 vc-search-sccs-project-dir)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 "*Where to look for version-control master files.
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 The first pair corresponding to a given back end is used as a template
17581
9df604cbe7cc (vc-master-templates): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17528
diff changeset
72 when creating new masters.
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
73 Setting this variable to nil turns off use of VC entirely."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
74 :type '(repeat sexp)
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
75 :group 'vc)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
76
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
77 (defcustom vc-make-backup-files nil
5164
04d6b9e7782a (vc-make-backup-files): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 4726
diff changeset
78 "*If non-nil, backups of registered files are made as with other files.
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
79 If nil (the default), files covered by version control don't get backups."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
80 :type 'boolean
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
81 :group 'vc)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
83 (defcustom vc-follow-symlinks 'ask
14142
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
84 "*Indicates what to do if you visit a symbolic link to a file
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
85 that is under version control. Editing such a file through the
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
86 link bypasses the version control system, which is dangerous and
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
87 probably not what you want.
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
88 If this variable is t, VC follows the link and visits the real file,
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
89 telling you about it in the echo area. If it is `ask', VC asks for
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
90 confirmation whether it should follow the link. If nil, the link is
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
91 visited and a warning displayed."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
92 :type '(choice (const ask) (const nil) (const t))
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
93 :group 'vc)
14142
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
94
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
95 (defcustom vc-display-status t
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
96 "*If non-nil, display revision number and lock status in modeline.
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
97 Otherwise, not displayed."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
98 :type 'boolean
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
99 :group 'vc)
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
100
3900
c6f3d2af0df7 (vc-rcs-status): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 3459
diff changeset
101
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
102 (defcustom vc-consult-headers t
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
103 "*If non-nil, identify work files by searching for version headers."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
104 :type 'boolean
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
105 :group 'vc)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
106
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
107 (defcustom vc-keep-workfiles t
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
108 "*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
109 If the back-end is CVS, workfiles are always kept, regardless of the
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
110 value of this flag."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
111 :type 'boolean
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
112 :group 'vc)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
113
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
114 (defcustom vc-mistrust-permissions nil
13935
dbc31b752982 Better doc strings for a few variables.
André Spiegel <spiegel@gnu.org>
parents: 13571
diff changeset
115 "*If non-nil, don't assume that permissions and ownership track
dbc31b752982 Better doc strings for a few variables.
André Spiegel <spiegel@gnu.org>
parents: 13571
diff changeset
116 version-control status. If nil, do rely on the permissions.
20413
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
117 See also variable `vc-consult-headers'."
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
118 :type 'boolean
7d1e9fc47f9d Customized.
Karl Heuer <kwzh@gnu.org>
parents: 20008
diff changeset
119 :group 'vc)
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
120
20844
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
121 (defcustom vc-ignore-vc-files nil
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
122 "*If non-nil don't look for version control information when finding files.
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
123
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
124 It may be useful to set this if (say) you edit files in a directory
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
125 containing corresponding RCS files but don't have RCS available;
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
126 similarly for other version control systems."
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
127 :type 'boolean
21669
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21367
diff changeset
128 :group 'vc
9861518505cb *** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents: 21367
diff changeset
129 :version "20.3")
20844
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
130
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
131 (defun vc-mistrust-permissions (file)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
132 ;; Access function to the above.
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
133 (or (eq vc-mistrust-permissions 't)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
134 (and vc-mistrust-permissions
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
135 (funcall vc-mistrust-permissions
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
136 (vc-backend-subdirectory-name file)))))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
137
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
138 ;; 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
139 (if (not (assoc 'vc-mode minor-mode-alist))
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
140 (setq minor-mode-alist (cons '(vc-mode vc-mode)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
141 minor-mode-alist)))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
142
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
143 (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
144 (put 'vc-mode 'permanent-local t)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146 ;; 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
147 ;; 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
148 ;; 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
149 ;; 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
150 ;; the buffer is killed.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151
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
152 (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
153 (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
154
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 (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
156 "Obarray for per-file properties.")
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
157
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
158 (defvar vc-buffer-backend t)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
159 (make-variable-buffer-local 'vc-buffer-backend)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
160
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
161 (defun vc-file-setprop (file property value)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162 ;; set per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
163 (put (intern file vc-file-prop-obarray) property value))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
165 (defun vc-file-getprop (file property)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
166 ;; get per-file property
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
167 (get (intern file vc-file-prop-obarray) property))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
168
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
169 (defun vc-file-clearprops (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
170 ;; 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
171 (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
172
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
173 ;;; 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
174 ;;; 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
175
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
176 (defun vc-match-substring (bn)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
177 (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
178
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
179 (defun vc-lock-file (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
180 ;; 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
181 (let ((master (vc-name file)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
182 (and
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
183 master
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
184 (string-match "\\(.*/\\)s\\.\\(.*\\)" master)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
185 (concat
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
186 (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
187 "p."
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
188 (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
189
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
190 (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
191 ;; 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
192 ;; 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
193 ;; 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
194 ;; 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
195 ;; 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
196 ;; 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
197 ;; recent entry matching the template.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
198 ;; 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
199 ;; 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
200 ;; the corresponding value.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
201 (mapcar (function (lambda (p)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
202 (goto-char (point-min))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
203 (cond
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
204 ((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
205 (let ((value nil))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
206 (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
207 (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
208 (if file
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
209 (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
210 (setq properties (cdr properties))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
211 value))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
212 ((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
213 (let ((latest-date "") (latest-val))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
214 (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
215 (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
216 (if (string< latest-date date)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
217 (progn
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
218 (setq latest-date date)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
219 (setq latest-val
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
220 (vc-match-substring (elt p 1)))))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
221 (if file
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
222 (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
223 (setq properties (cdr properties))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
224 latest-val)))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
225 patterns)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
226 )
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
227
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
228 (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
229 ;; 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
230 ;; 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
231 ;; the file is inserted in chunks of size BLOCKSIZE
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13935
diff changeset
232 ;; (default 8 kByte), until the first occurrence of
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
233 ;; 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
234 ;; doesn't exist.
12367
f268f652055e (vc-insert-file): Erase the current buffer before inserting the file.
Richard M. Stallman <rms@gnu.org>
parents: 12359
diff changeset
235 (erase-buffer)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
236 (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
237 (cond (limit
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
238 (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
239 (let (found s)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
240 (while (not found)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
241 (setq s (buffer-size))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
242 (goto-char (1+ s))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
243 (setq found
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
244 (or (zerop (car (cdr
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
245 (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
246 (+ s blocksize)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
247 (progn (beginning-of-line)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
248 (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
249 (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
250 (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
251 (auto-save-mode nil)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
252 t)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
253 (t nil)))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
254
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
255 (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
256 ;; 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
257 ;; 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
258 ;; 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
259 (if (not locks)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
260 (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
261 (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
262 (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
263 (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
264 locks index)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
265 (setq version (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
266 (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
267 (setq user (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
268 (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
269 (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
270 (list (cons version user))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
271 (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
272 ((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
273 (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
274 locks index)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
275 (setq version (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
276 (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
277 (setq user (substring locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
278 (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
279 (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
280 (list (cons version user))))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
281 (setq index (match-end 0)))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
282 (if (string-match ";[ \t\n]+strict;" locks index)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
283 (vc-file-setprop file 'vc-checkout-model 'manual)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
284 (vc-file-setprop file 'vc-checkout-model 'implicit))))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
285 (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
286
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
287 (defun vc-simple-command (okstatus command file &rest args)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
288 ;; Simple version of vc-do-command, for use in vc-hooks only.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
289 ;; Don't switch to the *vc-info* buffer before running the
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
290 ;; command, because that would change its default directory
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
291 (save-excursion (set-buffer (get-buffer-create "*vc-info*"))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
292 (erase-buffer))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
293 (let ((exec-path (append vc-path exec-path)) exec-status
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
294 ;; Add vc-path to PATH for the execution of this command.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
295 (process-environment
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
296 (cons (concat "PATH=" (getenv "PATH")
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
297 path-separator
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
298 (mapconcat 'identity vc-path path-separator))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
299 process-environment)))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
300 (setq exec-status
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
301 (apply 'call-process command nil "*vc-info*" nil
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
302 (append args (list file))))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
303 (cond ((> exec-status okstatus)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
304 (switch-to-buffer (get-file-buffer file))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
305 (shrink-window-if-larger-than-buffer
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
306 (display-buffer "*vc-info*"))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
307 (error "Couldn't find version control information")))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
308 exec-status))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
309
21909
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
310 (defun vc-parse-cvs-status (&optional full)
21356
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
311 ;; Parse output of "cvs status" command in the current buffer and
21909
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
312 ;; set file properties accordingly. Unless FULL is t, parse only
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
313 ;; essential information.
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
314 (let (file status)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
315 (goto-char (point-min))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
316 (if (re-search-forward "^File: " nil t)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
317 (cond
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
318 ((looking-at "no file") nil)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
319 ((re-search-forward "\\=\\([^ \t]+\\)" nil t)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
320 (setq file (concat default-directory (match-string 1)))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
321 (vc-file-setprop file 'vc-backend 'CVS)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
322 (if (not (re-search-forward "\\=[ \t]+Status: \\(.*\\)" nil t))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
323 (setq status "Unknown")
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
324 (setq status (match-string 1)))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
325 (if (and full
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
326 (re-search-forward
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
327 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):[\t ]+\\([0-9.]+\\)"
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
328 nil t))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
329 (vc-file-setprop file 'vc-latest-version (match-string 2)))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
330 (cond
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
331 ((string-match "Up-to-date" status)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
332 (vc-file-setprop file 'vc-cvs-status 'up-to-date)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
333 (vc-file-setprop file 'vc-checkout-time
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
334 (nth 5 (file-attributes file))))
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
335 ((vc-file-setprop file 'vc-cvs-status
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
336 (cond
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
337 ((string-match "Locally Modified" status) 'locally-modified)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
338 ((string-match "Needs Merge" status) 'needs-merge)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
339 ((string-match "Needs \\(Checkout\\|Patch\\)" status)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
340 'needs-checkout)
22112
c10e054e2cb1 (vc-parse-cvs-status): Grok new form of conflict message.
André Spiegel <spiegel@gnu.org>
parents: 21985
diff changeset
341 ((string-match "Unresolved Conflict" status)
c10e054e2cb1 (vc-parse-cvs-status): Grok new form of conflict message.
André Spiegel <spiegel@gnu.org>
parents: 21985
diff changeset
342 'unresolved-conflict)
c10e054e2cb1 (vc-parse-cvs-status): Grok new form of conflict message.
André Spiegel <spiegel@gnu.org>
parents: 21985
diff changeset
343 ((string-match "File had conflicts on merge" status)
c10e054e2cb1 (vc-parse-cvs-status): Grok new form of conflict message.
André Spiegel <spiegel@gnu.org>
parents: 21985
diff changeset
344 'unresolved-conflict)
21909
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
345 ((string-match "Locally Added" status) 'locally-added)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
346 ((string-match "New file!" status) 'locally-added)
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
347 (t 'unknown))))))))))
21356
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
348
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
349 (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
350 ;; Fetch those properties of FILE that are stored in the master file.
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
351 ;; For an RCS file, we don't get vc-latest-version vc-your-latest-version
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
352 ;; here because that is slow.
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
353 ;; That gets done if/when the functions vc-latest-version
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
354 ;; and vc-your-latest-version get called.
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
355 (save-excursion
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
356 (cond
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
357 ((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
358 (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
359 (if (vc-insert-file (vc-lock-file file))
12367
f268f652055e (vc-insert-file): Erase the current buffer before inserting the file.
Richard M. Stallman <rms@gnu.org>
parents: 12359
diff changeset
360 (vc-parse-locks file (buffer-string))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
361 (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
362 (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
363 (vc-parse-buffer
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
364 (list '("^\001d D \\([^ ]+\\)" 1)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
365 (list (concat "^\001d D \\([^ ]+\\) .* "
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
366 (regexp-quote (vc-user-login-name)) " ") 1))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
367 file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
368 '(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
369
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
370 ((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
371 (set-buffer (get-buffer-create "*vc-info*"))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
372 (vc-insert-file (vc-name file) "^[0-9]")
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
373 (vc-parse-buffer
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
374 (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
375 '("^branch[ \t\n]+\\([^;]+\\);" 1)
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
376 '("^locks[ \t\n]*\\([^;]*;\\([ \t\n]*strict;\\)?\\)" 1))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
377 file
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
378 '(vc-head-version
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
379 vc-default-branch
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
380 vc-master-locks))
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
381 ;; determine vc-master-workfile-version: it is either the head
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
382 ;; of the trunk, the head of the default branch, or the
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
383 ;; "default branch" itself, if that is a full revision number.
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
384 (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
385 (cond
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
386 ;; no default branch
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
387 ((or (not default-branch) (string= "" default-branch))
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
388 (vc-file-setprop file 'vc-master-workfile-version
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
389 (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
390 ;; 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
391 ((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
392 default-branch)
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
393 (vc-file-setprop file 'vc-master-workfile-version default-branch))
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
394 ;; else, search for the head of the default branch
12367
f268f652055e (vc-insert-file): Erase the current buffer before inserting the file.
Richard M. Stallman <rms@gnu.org>
parents: 12359
diff changeset
395 (t (vc-insert-file (vc-name file) "^desc")
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
396 (vc-parse-buffer (list (list
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
397 (concat "^\\("
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
398 (regexp-quote default-branch)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
399 "\\.[0-9]+\\)\ndate[ \t]+\\([0-9.]+\\);") 1 2))
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
400 file '(vc-master-workfile-version)))))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
401 ;; translate the locks
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
402 (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
403
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
404 ((eq (vc-backend file) 'CVS)
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
405 (save-excursion
13034
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
406 ;; Call "cvs status" in the right directory, passing only the
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
407 ;; nondirectory part of the file name -- otherwise CVS might
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
408 ;; silently give a wrong result.
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
409 (let ((default-directory (file-name-directory file)))
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
410 (vc-simple-command 0 "cvs" (file-name-nondirectory file) "status"))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
411 (set-buffer (get-buffer "*vc-info*"))
21909
bd22ccd2151e (vc-parse-cvs-status): Optimized. Ignore "Locally Removed" files.
André Spiegel <spiegel@gnu.org>
parents: 21669
diff changeset
412 (vc-parse-cvs-status t))))
12327
2a02456ddc4b (vc-fetch-master-properties): Be more careful
Richard M. Stallman <rms@gnu.org>
parents: 12302
diff changeset
413 (if (get-buffer "*vc-info*")
2a02456ddc4b (vc-fetch-master-properties): Be more careful
Richard M. Stallman <rms@gnu.org>
parents: 12302
diff changeset
414 (kill-buffer (get-buffer "*vc-info*")))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
415
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
416 ;;; 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
417 ;;; 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
418
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
419 (defun vc-consult-rcs-headers (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
420 ;; 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
421 ;; 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
422 ;; vc-consult-headers to nil.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
423 ;; 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
424 ;; (or if the feature is disabled,
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
425 ;; 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
426 ;; visiting FILE)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
427 ;; '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
428 ;; 'rev-and-lock if revision and lock info was found
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
429 (cond
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
430 ((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
431 (not (get-file-buffer file))) nil)
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
432 ((let (status version locking-user)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
433 (save-excursion
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
434 (set-buffer (get-file-buffer file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
435 (goto-char (point-min))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
436 (cond
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
437 ;; search for $Id or $Header
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
438 ;; -------------------------
21985
cb989530f77b (vc-consult-rcs-headers): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21958
diff changeset
439 ;; The `\ 's below avoid an RCS 5.7 bug when checking in this file.
cb989530f77b (vc-consult-rcs-headers): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21958
diff changeset
440 ((or (and (search-forward "$Id\ : " nil t)
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
441 (looking-at "[^ ]+ \\([0-9.]+\\) "))
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
442 (and (progn (goto-char (point-min))
21985
cb989530f77b (vc-consult-rcs-headers): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 21958
diff changeset
443 (search-forward "$Header\ : " nil t))
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
444 (looking-at "[^ ]+ \\([0-9.]+\\) ")))
12302
6d99dc5117e3 (vc-fetch-master-properties): Use path-separator
Richard M. Stallman <rms@gnu.org>
parents: 12272
diff changeset
445 (goto-char (match-end 0))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
446 ;; if found, store the revision number ...
14566
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
447 (setq version (buffer-substring-no-properties (match-beginning 1)
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
448 (match-end 1)))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
449 ;; ... and check for the locking state
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
450 (cond
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
451 ((looking-at
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
452 (concat "[0-9]+[/-][01][0-9][/-][0-3][0-9] " ; date
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
453 "[0-2][0-9]:[0-5][0-9]+:[0-6][0-9]+\\([+-][0-9:]+\\)? " ; time
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
454 "[^ ]+ [^ ]+ ")) ; author & state
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
455 (goto-char (match-end 0)) ; [0-6] in regexp handles leap seconds
12402
62e4bc95cecd (vc-consult-rcs-headers): Use an even more
Richard M. Stallman <rms@gnu.org>
parents: 12391
diff changeset
456 (cond
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
457 ;; unlocked revision
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
458 ((looking-at "\\$")
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
459 (setq locking-user 'none)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
460 (setq status 'rev-and-lock))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
461 ;; revision is locked by some user
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
462 ((looking-at "\\([^ ]+\\) \\$")
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
463 (setq locking-user
14566
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
464 (buffer-substring-no-properties (match-beginning 1)
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
465 (match-end 1)))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
466 (setq status 'rev-and-lock))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
467 ;; everything else: false
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
468 (nil)))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
469 ;; unexpected information in
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
470 ;; keyword string --> quit
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
471 (nil)))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
472 ;; search for $Revision
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
473 ;; --------------------
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
474 ((re-search-forward (concat "\\$"
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
475 "Revision: \\([0-9.]+\\) \\$")
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
476 nil t)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
477 ;; if found, store the revision number ...
14566
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
478 (setq version (buffer-substring-no-properties (match-beginning 1)
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
479 (match-end 1)))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
480 ;; and see if there's any lock information
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
481 (goto-char (point-min))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
482 (if (re-search-forward (concat "\\$" "Locker:") nil t)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
483 (cond ((looking-at " \\([^ ]+\\) \\$")
14566
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
484 (setq locking-user (buffer-substring-no-properties
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
485 (match-beginning 1)
20d4400de24e (vc-consult-rcs-headers): Ignore text properties.
Karl Heuer <kwzh@gnu.org>
parents: 14236
diff changeset
486 (match-end 1)))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
487 (setq status 'rev-and-lock))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
488 ((looking-at " *\\$")
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
489 (setq locking-user 'none)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
490 (setq status 'rev-and-lock))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
491 (t
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
492 (setq locking-user 'none)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
493 (setq status 'rev-and-lock)))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
494 (setq status 'rev)))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
495 ;; else: nothing found
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
496 ;; -------------------
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
497 (t nil)))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
498 (if status (vc-file-setprop file 'vc-workfile-version version))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
499 (and (eq status 'rev-and-lock)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
500 (eq (vc-backend file) 'RCS)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
501 (vc-file-setprop file 'vc-locking-user locking-user)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
502 ;; If the file has headers, we don't want to query the master file,
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
503 ;; because that would eliminate all the performance gain the headers
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
504 ;; brought us. We therefore use a heuristic for the checkout model
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
505 ;; now: If we trust the file permissions, and the file is not
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
506 ;; locked, then if the file is read-only the checkout model is
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
507 ;; `manual', otherwise `implicit'.
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
508 (not (vc-mistrust-permissions file))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
509 (not (vc-locking-user file))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
510 (if (string-match ".r-..-..-." (nth 8 (file-attributes file)))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
511 (vc-file-setprop file 'vc-checkout-model 'manual)
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
512 (vc-file-setprop file 'vc-checkout-model 'implicit)))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
513 status))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
514
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
515 ;;; 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
516 ;;; (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
517 ;;; _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
518 ;;; 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
519 ;;; 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
520 ;;; access function.)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
521
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
522 ;;; properties indicating the backend
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
523 ;;; being used for FILE
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
524
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
525 (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
526 ;; 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
527 (symbol-name
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
528 (or
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
529 (and file (vc-backend file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
530 vc-default-back-end
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
531 (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
532
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
533 (defun vc-name (file)
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
534 "Return the master name of a file, nil if it is not registered.
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
535 For CVS, the full name of CVS/Entries is returned."
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
536 (or (vc-file-getprop file 'vc-name)
21356
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
537 ;; Use the caching mechanism of vc-backend, below.
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
538 (if (vc-backend file)
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
539 (vc-file-getprop file 'vc-name))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
540
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
541 (defun vc-backend (file)
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
542 "Return the version-control type of a file, nil if it is not registered."
21356
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
543 ;; Note that internally, Emacs remembers unregistered
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
544 ;; files by setting the property to `none'.
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
545 (if file
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
546 (let ((property (vc-file-getprop file 'vc-backend))
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
547 (name-and-type))
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
548 (cond ((eq property 'none) nil)
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
549 (property)
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
550 (t (setq name-and-type (vc-registered file))
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
551 (if name-and-type
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
552 (progn
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
553 (vc-file-setprop file 'vc-name (car name-and-type))
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
554 (vc-file-setprop file 'vc-backend (cdr name-and-type)))
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
555 (vc-file-setprop file 'vc-backend 'none)
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
556 nil))))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
557
12884
f47248851f26 (vc-fetch-master-properties): Recognize cvs status "Unresolved Conflict".
André Spiegel <spiegel@gnu.org>
parents: 12874
diff changeset
558 (defun vc-checkout-model (file)
f47248851f26 (vc-fetch-master-properties): Recognize cvs status "Unresolved Conflict".
André Spiegel <spiegel@gnu.org>
parents: 12874
diff changeset
559 ;; Return `manual' if the user has to type C-x C-q to check out FILE.
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
560 ;; Return `implicit' if the file can be modified without locking it first.
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
561 (or
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
562 (vc-file-getprop file 'vc-checkout-model)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
563 (cond
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
564 ((eq (vc-backend file) 'SCCS)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
565 (vc-file-setprop file 'vc-checkout-model 'manual))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
566 ((eq (vc-backend file) 'RCS)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
567 (vc-consult-rcs-headers file)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
568 (or (vc-file-getprop file 'vc-checkout-model)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
569 (progn (vc-fetch-master-properties file)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
570 (vc-file-getprop file 'vc-checkout-model))))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
571 ((eq (vc-backend file) 'CVS)
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
572 (vc-file-setprop file 'vc-checkout-model
19054
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
573 (cond
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
574 ((getenv "CVSREAD") 'manual)
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
575 ;; If the file is not writeable, this is probably because the
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
576 ;; file is being "watched" by other developers. Use "manual"
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
577 ;; checkout in this case. (If vc-mistrust-permissions was t,
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
578 ;; we actually shouldn't trust this, but there is no other way
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
579 ;; to learn this from CVS at the moment (version 1.9).)
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
580 ((string-match "r-..-..-." (nth 8 (file-attributes file)))
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
581 'manual)
e5c297c50838 (vc-checkout-model): For CVS, look at
Richard M. Stallman <rms@gnu.org>
parents: 18850
diff changeset
582 (t 'implicit)))))))
12884
f47248851f26 (vc-fetch-master-properties): Recognize cvs status "Unresolved Conflict".
André Spiegel <spiegel@gnu.org>
parents: 12874
diff changeset
583
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
584 ;;; properties indicating the locking state
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
585
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
586 (defun vc-cvs-status (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
587 ;; Return the cvs status of FILE
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
588 ;; (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
589 (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
590 (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
591 (vc-file-getprop file 'vc-cvs-status))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
592
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
593 (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
594 ;; 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
595 ;; 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
596 ;; 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
597 (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
598 (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
599 (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
600
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
601 (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
602 ;; 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
603 ;; 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
604 ;; 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
605 (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
606 (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
607 ;; 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
608 (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
609 (cond (lock (cdr lock))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
610 ('none)))))
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
611
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
612 (defun vc-lock-from-permissions (file)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
613 ;; If the permissions can be trusted for this file, determine the
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
614 ;; locking state from them. Returns (user-login-name), `none', or nil.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
615 ;; This implementation assumes that any file which is under version
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
616 ;; control and has -rw-r--r-- is locked by its owner. This is true
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
617 ;; for both RCS and SCCS, which keep unlocked files at -r--r--r--.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
618 ;; We have to be careful not to exclude files with execute bits on;
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
619 ;; scripts can be under version control too. Also, we must ignore the
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
620 ;; group-read and other-read bits, since paranoid users turn them off.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
621 ;; This hack wins because calls to the somewhat expensive
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
622 ;; `vc-fetch-master-properties' function only have to be made if
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
623 ;; (a) the file is locked by someone other than the current user,
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
624 ;; or (b) some untoward manipulation behind vc's back has changed
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
625 ;; the owner or the `group' or `other' write bits.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
626 (let ((attributes (file-attributes file)))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
627 (if (not (vc-mistrust-permissions file))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
628 (cond ((string-match ".r-..-..-." (nth 8 attributes))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
629 (vc-file-setprop file 'vc-locking-user 'none))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
630 ((and (= (nth 2 attributes) (user-uid))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
631 (string-match ".rw..-..-." (nth 8 attributes)))
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
632 (vc-file-setprop file 'vc-locking-user (vc-user-login-name)))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
633 (nil)))))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
634
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
635 (defun vc-user-login-name (&optional uid)
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
636 ;; Return the name under which the user is logged in, as a string.
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
637 ;; (With optional argument UID, return the name of that user.)
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
638 ;; This function does the same as `user-login-name', but unlike
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
639 ;; that, it never returns nil. If a UID cannot be resolved, that
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
640 ;; UID is returned as a string.
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
641 (or (user-login-name uid)
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
642 (and uid (number-to-string uid))
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
643 (number-to-string (user-uid))))
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
644
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
645 (defun vc-file-owner (file)
16446
df84adfbe883 (vc-file-owner): Always return user name, using the optional argument
André Spiegel <spiegel@gnu.org>
parents: 16216
diff changeset
646 ;; Return who owns FILE (user name, as a string).
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
647 (vc-user-login-name (nth 2 (file-attributes file))))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
648
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
649 (defun vc-rcs-lock-from-diff (file)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
650 ;; Diff the file against the master version. If differences are found,
13378
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
651 ;; mark the file locked. This is only used for RCS with non-strict
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
652 ;; locking. (If "rcsdiff" doesn't understand --brief, we do a double-take
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
653 ;; and remember the fact for the future.)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
654 (let* ((version (concat "-r" (vc-workfile-version file)))
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
655 (status (if (eq vc-rcsdiff-knows-brief 'no)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
656 (vc-simple-command 1 "rcsdiff" file version)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
657 (vc-simple-command 2 "rcsdiff" file "--brief" version))))
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
658 (if (eq status 2)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
659 (if (not vc-rcsdiff-knows-brief)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
660 (setq vc-rcsdiff-knows-brief 'no
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
661 status (vc-simple-command 1 "rcsdiff" file version))
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
662 (error "rcsdiff failed."))
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
663 (if (not vc-rcsdiff-knows-brief) (setq vc-rcsdiff-knows-brief 'yes)))
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
664 (if (zerop status)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
665 (vc-file-setprop file 'vc-locking-user 'none)
96ff45331eb4 (vc-utc-string): Use timezone of TIMEVAL for the correction, not the
André Spiegel <spiegel@gnu.org>
parents: 13034
diff changeset
666 (vc-file-setprop file 'vc-locking-user (vc-file-owner file)))))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
667
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
668 (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
669 ;; Return the name of the person currently holding a lock on FILE.
16446
df84adfbe883 (vc-file-owner): Always return user name, using the optional argument
André Spiegel <spiegel@gnu.org>
parents: 16216
diff changeset
670 ;; Return nil if there is no such person.
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
671 ;; Under CVS, a file is considered locked if it has been modified since
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
672 ;; it was checked out.
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
673 ;; 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
674 ;; Note that, for a file that is not locked, the actual property value
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
675 ;; is `none', to distinguish it from an unknown locking state. That value
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
676 ;; 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
677 (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
678 (if locking-user
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
679 ;; 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
680 (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
681
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
682 ;; otherwise, infer the property...
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
683 (cond
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
684 ((eq (vc-backend file) 'CVS)
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
685 (or (and (eq (vc-checkout-model file) 'manual)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
686 (vc-lock-from-permissions file))
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
687 (and (equal (vc-file-getprop file 'vc-checkout-time)
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
688 (nth 5 (file-attributes file)))
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
689 (vc-file-setprop file 'vc-locking-user 'none))
16446
df84adfbe883 (vc-file-owner): Always return user name, using the optional argument
André Spiegel <spiegel@gnu.org>
parents: 16216
diff changeset
690 (vc-file-setprop file 'vc-locking-user (vc-file-owner file))))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
691
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
692 ((eq (vc-backend file) 'RCS)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
693 (let (p-lock)
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
694
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
695 ;; Check for RCS headers first
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
696 (or (eq (vc-consult-rcs-headers file) 'rev-and-lock)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
697
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
698 ;; If there are no headers, try to learn it
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
699 ;; from the permissions.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
700 (and (setq p-lock (vc-lock-from-permissions file))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
701 (if (eq p-lock 'none)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
702
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
703 ;; If the permissions say "not locked", we know
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
704 ;; that the checkout model must be `manual'.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
705 (vc-file-setprop file 'vc-checkout-model 'manual)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
706
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
707 ;; If the permissions say "locked", we can only trust
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
708 ;; this *if* the checkout model is `manual'.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
709 (eq (vc-checkout-model file) 'manual)))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
710
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
711 ;; Otherwise, use lock information from the master file.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
712 (vc-file-setprop file 'vc-locking-user
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
713 (vc-master-locking-user file)))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
714
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
715 ;; Finally, if the file is not explicitly locked
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
716 ;; it might still be locked implicitly.
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
717 (and (eq (vc-file-getprop file 'vc-locking-user) 'none)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
718 (eq (vc-checkout-model file) 'implicit)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
719 (vc-rcs-lock-from-diff file))))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
720
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
721 ((eq (vc-backend file) 'SCCS)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
722 (or (vc-lock-from-permissions file)
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
723 (vc-file-setprop file 'vc-locking-user
13011
53b0ff7a477f (vc-locking-user): Fixed wrong parentheses.
André Spiegel <spiegel@gnu.org>
parents: 12967
diff changeset
724 (vc-master-locking-user file)))))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
725
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
726 ;; convert a possible 'none value
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
727 (setq locking-user (vc-file-getprop file 'vc-locking-user))
13011
53b0ff7a477f (vc-locking-user): Fixed wrong parentheses.
André Spiegel <spiegel@gnu.org>
parents: 12967
diff changeset
728 (if (eq locking-user 'none) nil locking-user))))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
729
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
730 ;;; 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
731
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
732 (defun vc-latest-version (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
733 ;; 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
734 (cond ((vc-file-getprop file 'vc-latest-version))
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
735 (t (vc-fetch-properties file)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
736 (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
737
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
738 (defun vc-your-latest-version (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
739 ;; 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
740 (cond ((vc-file-getprop file 'vc-your-latest-version))
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
741 (t (vc-fetch-properties file)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
742 (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
743
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
744 (defun vc-master-workfile-version (file)
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
745 ;; Return the master file's idea of what is the current workfile version.
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
746 ;; This property is defined for RCS only.
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
747 (cond ((vc-file-getprop file 'vc-master-workfile-version))
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
748 (t (vc-fetch-master-properties file)
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
749 (vc-file-getprop file 'vc-master-workfile-version))))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
750
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
751 (defun vc-fetch-properties (file)
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
752 ;; Fetch vc-latest-version and vc-your-latest-version
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
753 ;; if that wasn't already done.
12302
6d99dc5117e3 (vc-fetch-master-properties): Use path-separator
Richard M. Stallman <rms@gnu.org>
parents: 12272
diff changeset
754 (cond
6d99dc5117e3 (vc-fetch-master-properties): Use path-separator
Richard M. Stallman <rms@gnu.org>
parents: 12272
diff changeset
755 ((eq (vc-backend file) 'RCS)
12330
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
756 (save-excursion
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
757 (set-buffer (get-buffer-create "*vc-info*"))
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
758 (vc-insert-file (vc-name file) "^desc")
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
759 (vc-parse-buffer
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
760 (list '("^\\([0-9]+\\.[0-9.]+\\)\ndate[ \t]+\\([0-9.]+\\);" 1 2)
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
761 (list (concat "^\\([0-9]+\\.[0-9.]+\\)\n"
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
762 "date[ \t]+\\([0-9.]+\\);[ \t]+"
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
763 "author[ \t]+"
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
764 (regexp-quote (vc-user-login-name)) ";") 1 2))
12330
2e2af003b9c5 (vc-fetch-properties): Add save-excursion.
Richard M. Stallman <rms@gnu.org>
parents: 12327
diff changeset
765 file
12367
f268f652055e (vc-insert-file): Erase the current buffer before inserting the file.
Richard M. Stallman <rms@gnu.org>
parents: 12359
diff changeset
766 '(vc-latest-version vc-your-latest-version))
f268f652055e (vc-insert-file): Erase the current buffer before inserting the file.
Richard M. Stallman <rms@gnu.org>
parents: 12359
diff changeset
767 (if (get-buffer "*vc-info*")
f268f652055e (vc-insert-file): Erase the current buffer before inserting the file.
Richard M. Stallman <rms@gnu.org>
parents: 12359
diff changeset
768 (kill-buffer (get-buffer "*vc-info*")))))
12302
6d99dc5117e3 (vc-fetch-master-properties): Use path-separator
Richard M. Stallman <rms@gnu.org>
parents: 12272
diff changeset
769 (t (vc-fetch-master-properties file))
12252
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
770 ))
e07d55d05864 (vc-fetch-master-properties): For RCS file,
Richard M. Stallman <rms@gnu.org>
parents: 12251
diff changeset
771
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
772 (defun vc-workfile-version (file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
773 ;; 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
774 ;; 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
775 ;; If there are no keywords in the working file,
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
776 ;; vc-master-workfile-version is taken.
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
777 ;; 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
778 ;; looked up if it is nil.
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
779 ;; 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
780 (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
781 ((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
782 ((eq (vc-backend file) 'RCS)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
783 (if (vc-consult-rcs-headers file)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
784 (vc-file-getprop file 'vc-workfile-version)
12874
3afd71d56015 (vc-top-version): Renamed to vc-master-workfile-version. Updated all
André Spiegel <spiegel@gnu.org>
parents: 12590
diff changeset
785 (let ((rev (cond ((vc-master-workfile-version file))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
786 ((vc-latest-version file)))))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
787 (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
788 rev)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
789 ((eq (vc-backend file) 'CVS)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
790 (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
791 (vc-file-getprop file 'vc-workfile-version)
12561
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
792 (catch 'found
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
793 (vc-find-cvs-master (file-name-directory file)
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
794 (file-name-nondirectory file)))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
795 (vc-file-getprop file 'vc-workfile-version)))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
796
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
797 ;;; actual version-control code starts here
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
798
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
799 (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
800 (let (handler handlers)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
801 (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
802 (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
803 (if handler
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
804 (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
805 ;; 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
806 (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
807 (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
808 (catch 'found
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
809 (mapcar
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
810 (function (lambda (s)
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
811 (if (atom s)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
812 (funcall s dirname basename)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
813 (let ((trial (format (car s) dirname basename)))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
814 (if (and (file-exists-p trial)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
815 ;; Make sure the file we found with name
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
816 ;; TRIAL is not the source file itself.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
817 ;; That can happen with RCS-style names
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
818 ;; if the file name is truncated
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
819 ;; (e.g. to 14 chars). See if either
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
820 ;; directory or attributes differ.
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
821 (or (not (string= dirname
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
822 (file-name-directory trial)))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
823 (not (equal
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
824 (file-attributes file)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
825 (file-attributes trial)))))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
826 (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
827 vc-master-templates)
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
828 nil)))))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
829
21232
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
830 (defun vc-sccs-project-dir ()
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
831 ;; Return the full pathname of the SCCS PROJECTDIR, if it exists,
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
832 ;; otherwise nil. The PROJECTDIR is indicated by the environment
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
833 ;; variable of the same name. If its value starts with a slash,
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
834 ;; it must be an absolute path name that points to the
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
835 ;; directory where SCCS history files reside. If it does not
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
836 ;; begin with a slash, it is taken as the name of a user,
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
837 ;; and history files reside in an "src" or "source" subdirectory
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
838 ;; of that user's home directory.
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
839 (let ((project-dir (getenv "PROJECTDIR")))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
840 (and project-dir
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
841 (if (eq (elt project-dir 0) ?/)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
842 (if (file-exists-p (concat project-dir "/SCCS"))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
843 (concat project-dir "/SCCS/")
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
844 (if (file-exists-p project-dir)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
845 project-dir))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
846 (setq project-dir (expand-file-name (concat "~" project-dir)))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
847 (let (trial)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
848 (setq trial (concat project-dir "/src/SCCS"))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
849 (if (file-exists-p trial)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
850 (concat trial "/")
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
851 (setq trial (concat project-dir "/src"))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
852 (if (file-exists-p trial)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
853 (concat trial "/")
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
854 (setq trial (concat project-dir "/source/SCCS"))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
855 (if (file-exists-p trial)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
856 (concat trial "/")
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
857 (setq trial (concat project-dir "/source/"))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
858 (if (file-exists-p trial)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
859 (concat trial "/"))))))))))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
860
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
861 (defun vc-search-sccs-project-dir (dirname basename)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
862 ;; Check if there is a master file for BASENAME in the
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
863 ;; SCCS project directory. If yes, throw `found' as
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
864 ;; expected by vc-registered. If not, return nil.
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
865 (let* ((project-dir (vc-sccs-project-dir))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
866 (master-file (and project-dir (concat project-dir "s." basename))))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
867 (and master-file
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
868 (file-exists-p master-file)
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
869 (throw 'found (cons master-file 'SCCS)))))
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
870
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
871 (defun vc-find-cvs-master (dirname basename)
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
872 ;; Check if DIRNAME/BASENAME is handled by CVS.
21232
b682a769996d (vc-sccs-project-dir, vc-search-sccs-project-dir): New functions.
André Spiegel <spiegel@gnu.org>
parents: 20989
diff changeset
873 ;; If it is, do a (throw 'found (cons MASTER-FILE 'CVS)).
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
874 ;; Note: This function throws the name of CVS/Entries
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
875 ;; NOT that of the RCS master file (because we wouldn't be able
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
876 ;; to access it under remote CVS).
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
877 ;; The function returns nil if DIRNAME/BASENAME is not handled by CVS.
12359
6da25b126f03 (vc-fetch-master-properties): Pass an absolute
Richard M. Stallman <rms@gnu.org>
parents: 12330
diff changeset
878 (if (and vc-handle-cvs
6da25b126f03 (vc-fetch-master-properties): Pass an absolute
Richard M. Stallman <rms@gnu.org>
parents: 12330
diff changeset
879 (file-directory-p (concat dirname "CVS/"))
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
880 (file-readable-p (concat dirname "CVS/Entries")))
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
881 (let ((file (concat dirname basename))
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
882 ;; make sure that the file name is searched
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
883 ;; case-sensitively
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
884 (case-fold-search nil)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
885 buffer)
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
886 (unwind-protect
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
887 (save-excursion
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
888 (setq buffer (set-buffer (get-buffer-create "*vc-info*")))
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
889 (vc-insert-file (concat dirname "CVS/Entries"))
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
890 (goto-char (point-min))
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
891 (cond
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
892 ;; entry for a "locally added" file (not yet committed)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
893 ((re-search-forward
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
894 (concat "^/" (regexp-quote basename) "/0/") nil t)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
895 (vc-file-setprop file 'vc-checkout-time 0)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
896 (vc-file-setprop file 'vc-workfile-version "0")
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
897 (throw 'found (cons (concat dirname "CVS/Entries") 'CVS)))
16216
3c6aaa4f236a (vc-find-cvs-master): Fixed handling of "locally added" files.
André Spiegel <spiegel@gnu.org>
parents: 16139
diff changeset
898 ;; normal entry
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
899 ((re-search-forward
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
900 (concat "^/" (regexp-quote basename)
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
901 ;; revision
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
902 "/\\([^/]*\\)"
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
903 ;; timestamp
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
904 "/[A-Z][a-z][a-z]" ;; week day (irrelevant)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
905 " \\([A-Z][a-z][a-z]\\)" ;; month name
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
906 " *\\([0-9]*\\)" ;; day of month
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
907 " \\([0-9]*\\):\\([0-9]*\\):\\([0-9]*\\)" ;; hms
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
908 " \\([0-9]*\\)" ;; year
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
909 ;; optional conflict field
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
910 "\\(+[^/]*\\)?/")
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
911 nil t)
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
912 ;; We found it. Store away version number now that we
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
913 ;; are anyhow so close to finding it.
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
914 (vc-file-setprop file
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
915 'vc-workfile-version
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
916 (match-string 1))
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
917 ;; If the file hasn't been modified since checkout,
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
918 ;; store the checkout-time.
14236
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
919 (let ((mtime (nth 5 (file-attributes file)))
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
920 (second (string-to-number (match-string 6)))
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
921 (minute (string-to-number (match-string 5)))
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
922 (hour (string-to-number (match-string 4)))
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
923 (day (string-to-number (match-string 3)))
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
924 (year (string-to-number (match-string 7))))
14236
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
925 (if (equal mtime
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
926 (encode-time
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
927 second minute hour day
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
928 (/ (string-match
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
929 (match-string 2)
14236
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
930 "xxxJanFebMarAprMayJunJulAugSepOctNovDec")
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
931 3)
bd73837b861a (vc-utc-string): Remove; it wasn't reliable near DST or leap-second
Paul Eggert <eggert@twinsun.com>
parents: 14169
diff changeset
932 year 0))
13034
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
933 (vc-file-setprop file 'vc-checkout-time mtime)
1f9b08a989ea (vc-fetch-master-properties): Call "cvs status" in the right
André Spiegel <spiegel@gnu.org>
parents: 13011
diff changeset
934 (vc-file-setprop file 'vc-checkout-time 0)))
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
935 (throw 'found (cons (concat dirname "CVS/Entries") 'CVS)))
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
936 ;; entry with arbitrary text as timestamp
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
937 ;; (this means we should consider it modified)
17528
1518eb71378d (vc-find-cvs-master): Handle a "New file!" entry.
Richard M. Stallman <rms@gnu.org>
parents: 16821
diff changeset
938 ((re-search-forward
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
939 (concat "^/" (regexp-quote basename)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
940 ;; revision
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
941 "/\\([^/]*\\)"
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
942 ;; timestamp (arbitrary text)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
943 "/[^/]*"
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
944 ;; optional conflict field
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
945 "\\(+[^/]*\\)?/")
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
946 nil t)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
947 ;; We found it. Store away version number now that we
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
948 ;; are anyhow so close to finding it.
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
949 (vc-file-setprop file 'vc-workfile-version (match-string 1))
20008
173f2683e3c4 (vc-find-cvs-master): Added missing `throw' for
Karl Heuer <kwzh@gnu.org>
parents: 19103
diff changeset
950 (vc-file-setprop file 'vc-checkout-time 0)
173f2683e3c4 (vc-find-cvs-master): Added missing `throw' for
Karl Heuer <kwzh@gnu.org>
parents: 19103
diff changeset
951 (throw 'found (cons (concat dirname "CVS/Entries") 'CVS)))
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
952 (t nil)))
12925
77c9a594fe55 (vc-simple-command): New function.
André Spiegel <spiegel@gnu.org>
parents: 12914
diff changeset
953 (kill-buffer buffer)))))
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
954
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
955 (defun vc-buffer-backend ()
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
956 "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
957 (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
958 (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
959 vc-buffer-backend))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
960
10176
332014233a2c (vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 9869
diff changeset
961 (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
962 "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
963 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
964 then check the file in or out. Otherwise, just change the read-only flag
23693
295cf395a392 (vc-toggle-read-only): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23255
diff changeset
965 of the buffer.
295cf395a392 (vc-toggle-read-only): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23255
diff changeset
966 With prefix argument, ask for version number to check in or check out.
295cf395a392 (vc-toggle-read-only): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23255
diff changeset
967 Check-out of a specified version number does not lock the file;
295cf395a392 (vc-toggle-read-only): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 23255
diff changeset
968 to do that, use this command a second time with no argument."
10176
332014233a2c (vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 9869
diff changeset
969 (interactive "P")
18850
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
970 (if (or (and (boundp 'vc-dired-mode) vc-dired-mode)
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
971 ;; use boundp because vc.el might not be loaded
238067491696 (vc-find-cvs-master): Corrected parsing of CVS/Entries, according to CVS docs.
André Spiegel <spiegel@gnu.org>
parents: 18403
diff changeset
972 (vc-backend (buffer-file-name)))
10176
332014233a2c (vc-toggle-read-only): Accept prefix arg
Richard M. Stallman <rms@gnu.org>
parents: 9869
diff changeset
973 (vc-next-action verbose)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
974 (toggle-read-only)))
2620
d26f75fd9f5e (vc-mode-line): Don't alter key bindings.
Richard M. Stallman <rms@gnu.org>
parents: 2491
diff changeset
975 (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
976
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
977 (defun vc-after-save ()
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
978 ;; Function to be called by basic-save-buffer (in files.el).
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
979 ;; If the file in the current buffer is under version control,
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
980 ;; not locked, and the checkout model for it is `implicit',
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
981 ;; mark it "locked" and redisplay the mode line.
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
982 (let ((file (buffer-file-name)))
21356
c714817643a9 (vc-parse-cvs-status): New function.
Richard M. Stallman <rms@gnu.org>
parents: 21232
diff changeset
983 (and (vc-backend file)
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
984 (or (and (equal (vc-file-getprop file 'vc-checkout-time)
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
985 (nth 5 (file-attributes file)))
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
986 ;; File has been saved in the same second in which
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
987 ;; it was checked out. Clear the checkout-time
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
988 ;; to avoid confusion.
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
989 (vc-file-setprop file 'vc-checkout-time nil))
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
990 t)
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
991 (not (vc-locking-user file))
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
992 (eq (vc-checkout-model file) 'implicit)
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
993 (vc-file-setprop file 'vc-locking-user (vc-user-login-name))
12967
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
994 (or (and (eq (vc-backend file) 'CVS)
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
995 (vc-file-setprop file 'vc-cvs-status nil))
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
996 t)
ee545522ef2a (vc-utc-string): New function.
André Spiegel <spiegel@gnu.org>
parents: 12944
diff changeset
997 (vc-mode-line file))))
12884
f47248851f26 (vc-fetch-master-properties): Recognize cvs status "Unresolved Conflict".
André Spiegel <spiegel@gnu.org>
parents: 12874
diff changeset
998
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
999 (defun vc-mode-line (file &optional label)
2491
5f3061858f47 vc-mode: name change.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2232
diff changeset
1000 "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
1001 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
1002 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
1003 control system name."
2218
13be90dfef0c Merge today's change by eric with everybody else's
Paul Eggert <eggert@twinsun.com>
parents: 2213
diff changeset
1004 (interactive (list buffer-file-name nil))
12561
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
1005 (let ((vc-type (vc-backend file)))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1006 (setq vc-mode
12561
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
1007 (and vc-type
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
1008 (concat " " (or label (symbol-name vc-type))
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
1009 (and vc-display-status (vc-status file)))))
15448
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1010 ;; If the file is locked by some other user, make
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1011 ;; the buffer read-only. Like this, even root
15517
d9bb8f6b05a0 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 15448
diff changeset
1012 ;; cannot modify a file that someone else has locked.
12561
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
1013 (and vc-type
348341c2d7d1 (vc-mode-line): Don't write-protect a
Karl Heuer <kwzh@gnu.org>
parents: 12481
diff changeset
1014 (equal file (buffer-file-name))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
1015 (vc-locking-user file)
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
1016 (not (string= (vc-user-login-name) (vc-locking-user file)))
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
1017 (setq buffer-read-only t))
15517
d9bb8f6b05a0 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 15448
diff changeset
1018 ;; If the user is root, and the file is not owner-writable,
d9bb8f6b05a0 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 15448
diff changeset
1019 ;; then pretend that we can't write it
d9bb8f6b05a0 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 15448
diff changeset
1020 ;; even though we can (because root can write anything).
d9bb8f6b05a0 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 15448
diff changeset
1021 ;; This way, even root cannot modify a file that isn't locked.
15448
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1022 (and vc-type
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1023 (equal file (buffer-file-name))
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1024 (not buffer-read-only)
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1025 (zerop (user-real-uid))
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1026 (zerop (logand (file-modes (buffer-file-name)) 128))
593dadb4f287 (vc-mode-line): If user is root, verify file really has user-writable bit.
Richard M. Stallman <rms@gnu.org>
parents: 15196
diff changeset
1027 (setq buffer-read-only t))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1028 (force-mode-line-update)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1029 ;;(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
1030 vc-type))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1031
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1032 (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
1033 ;; 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
1034 ;; Format:
9248
325cee61ab7f (vc-status): Handle CVS.
Richard M. Stallman <rms@gnu.org>
parents: 8982
diff changeset
1035 ;;
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1036 ;; "-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
1037 ;; ":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
1038 ;; ":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
1039 ;; " @@" 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
1040 ;;
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1041 ;; 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
1042 ;; working file that is modified with respect to the master.
12914
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
1043 ;; The file is "locked" from the moment when the user saves
22f47b2375c1 (vc-fetch-master-properties): RCS case: get locking mode.
André Spiegel <spiegel@gnu.org>
parents: 12884
diff changeset
1044 ;; the modified buffer.
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1045 ;;
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1046 ;; 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
1047
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1048 (let ((locker (vc-locking-user file))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1049 (rev (vc-workfile-version file)))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1050 (cond ((string= "0" rev)
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1051 " @@")
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
1052 ((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
1053 (concat "-" rev))
16742
25558bcdfc93 (vc-user-login-name): New function.
André Spiegel <spiegel@gnu.org>
parents: 16446
diff changeset
1054 ((string= locker (vc-user-login-name))
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1055 (concat ":" rev))
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1056 (t
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1057 (concat ":" locker ":" rev)))))
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1058
14647
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1059 (defun vc-follow-link ()
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1060 ;; If the current buffer visits a symbolic link, this function makes it
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1061 ;; visit the real file instead. If the real file is already visited in
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1062 ;; another buffer, make that buffer current, and kill the buffer
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1063 ;; that visits the link.
15161
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1064 (let* ((truename (abbreviate-file-name (file-chase-links buffer-file-name)))
14673
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1065 (true-buffer (find-buffer-visiting truename))
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1066 (this-buffer (current-buffer)))
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1067 (if (eq true-buffer this-buffer)
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1068 (progn
14674
f585d3bf3a73 (vc-follow-link): Kill buffer before creating new one.
Richard M. Stallman <rms@gnu.org>
parents: 14673
diff changeset
1069 (kill-buffer this-buffer)
14673
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1070 ;; In principle, we could do something like set-visited-file-name.
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1071 ;; However, it can't be exactly the same as set-visited-file-name.
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1072 ;; I'm not going to work out the details right now. -- rms.
14674
f585d3bf3a73 (vc-follow-link): Kill buffer before creating new one.
Richard M. Stallman <rms@gnu.org>
parents: 14673
diff changeset
1073 (set-buffer (find-file-noselect truename)))
14673
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1074 (set-buffer true-buffer)
8f8a4224147b (vc-follow-link): Simplify by taking advantage
Richard M. Stallman <rms@gnu.org>
parents: 14647
diff changeset
1075 (kill-buffer this-buffer))))
14647
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1076
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1077 ;;; install a call to the above as a find-file hook
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1078 (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
1079 ;; 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
1080 ;; 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
1081 (cond
20844
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
1082 ((and (not vc-ignore-vc-files) buffer-file-name)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1083 (vc-file-clearprops buffer-file-name)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1084 (cond
11604
401afae906eb (vc-default-backend, vc-path, vc-consult-headers):
Karl Heuer <kwzh@gnu.org>
parents: 11598
diff changeset
1085 ((vc-backend buffer-file-name)
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1086 (vc-mode-line buffer-file-name)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1087 (cond ((not vc-make-backup-files)
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1088 ;; Use this variable, not make-backup-files,
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1089 ;; 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
1090 (make-local-variable 'backup-inhibited)
12590
a771c59393e7 (vc-mode-line, vc-find-file-hook): Moved the test for
Richard M. Stallman <rms@gnu.org>
parents: 12561
diff changeset
1091 (setq backup-inhibited t))))
a771c59393e7 (vc-mode-line, vc-find-file-hook): Moved the test for
Richard M. Stallman <rms@gnu.org>
parents: 12561
diff changeset
1092 ((let* ((link (file-symlink-p buffer-file-name))
15196
414e523050d5 (vc-find-file-hook): Follow multiple links all the way.
Richard M. Stallman <rms@gnu.org>
parents: 15161
diff changeset
1093 (link-type (and link (vc-backend (file-chase-links link)))))
12590
a771c59393e7 (vc-mode-line, vc-find-file-hook): Moved the test for
Richard M. Stallman <rms@gnu.org>
parents: 12561
diff changeset
1094 (if link-type
14142
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1095 (cond ((eq vc-follow-symlinks nil)
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1096 (message
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1097 "Warning: symbolic link to %s-controlled source file" link-type))
15161
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1098 ((or (not (eq vc-follow-symlinks 'ask))
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1099 ;; If we already visited this file by following
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1100 ;; the link, don't ask again if we try to visit
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1101 ;; it again. GUD does that, and repeated questions
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1102 ;; are painful.
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1103 (get-file-buffer
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1104 (abbreviate-file-name (file-chase-links buffer-file-name))))
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1105
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1106 (vc-follow-link)
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1107 (message "Followed link to %s" buffer-file-name)
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1108 (vc-find-file-hook))
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1109 (t
14142
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1110 (if (yes-or-no-p (format
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1111 "Symbolic link to %s-controlled source file; follow link? " link-type))
14647
b1a88c3a6912 (vc-follow-link): New function.
André Spiegel <spiegel@gnu.org>
parents: 14622
diff changeset
1112 (progn (vc-follow-link)
14142
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1113 (message "Followed link to %s" buffer-file-name)
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1114 (vc-find-file-hook))
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1115 (message
c9cb9dbb2d40 (vc-follow-symlinks): New variable.
André Spiegel <spiegel@gnu.org>
parents: 14040
diff changeset
1116 "Warning: editing through the link bypasses version control")
15161
ea07411f268e (vc-follow-link, vc-find-file-hook):
Richard M. Stallman <rms@gnu.org>
parents: 14734
diff changeset
1117 ))))))))))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1118
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
1119 (add-hook 'find-file-hooks 'vc-find-file-hook)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1120
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1121 ;;; more hooks, this time for file-not-found
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1122 (defun vc-file-not-found-hook ()
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1123 "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
1124 Returns t if checkout was successful, nil otherwise."
22947
f20bf5cd31d9 (vc-file-not-found-hook): Call vc-file-clearprops.
Richard M. Stallman <rms@gnu.org>
parents: 22112
diff changeset
1125 ;; When a file does not exist, ignore cached info about it
f20bf5cd31d9 (vc-file-not-found-hook): Call vc-file-clearprops.
Richard M. Stallman <rms@gnu.org>
parents: 22112
diff changeset
1126 ;; from a previous visit.
f20bf5cd31d9 (vc-file-not-found-hook): Call vc-file-clearprops.
Richard M. Stallman <rms@gnu.org>
parents: 22112
diff changeset
1127 (vc-file-clearprops buffer-file-name)
20844
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
1128 (if (and (not vc-ignore-vc-files)
d69034fe59c2 (vc-ignore-vc-files): New variable.
Dave Love <fx@gnu.org>
parents: 20413
diff changeset
1129 (vc-backend buffer-file-name))
8982
2a81d1c79162 (vc-menu-map): Set up menu items.
Richard M. Stallman <rms@gnu.org>
parents: 7568
diff changeset
1130 (save-excursion
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1131 (require 'vc)
12251
f2519a110e5f The RCS status is now found by reading the
Richard M. Stallman <rms@gnu.org>
parents: 12102
diff changeset
1132 (setq default-directory (file-name-directory (buffer-file-name)))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1133 (not (vc-error-occurred (vc-checkout buffer-file-name))))))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1134
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
1135 (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
1136
11598
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1137 ;; 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
1138 (defun vc-kill-buffer-hook ()
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1139 (if (stringp (buffer-file-name))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1140 (progn
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1141 (vc-file-clearprops (buffer-file-name))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1142 (kill-local-variable 'vc-buffer-backend))))
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1143
540868154dc9 (vc-buffer-backend): New function.
Richard M. Stallman <rms@gnu.org>
parents: 10176
diff changeset
1144 ;;;(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
1145
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1146 ;;; 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
1147 ;;; 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
1148 ;;; want to call them from random buffers.
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1149
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1150 (setq vc-prefix-map (lookup-key global-map "\C-xv"))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1151 (if (not (keymapp vc-prefix-map))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1152 (progn
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1153 (setq vc-prefix-map (make-sparse-keymap))
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1154 (define-key global-map "\C-xv" vc-prefix-map)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1155 (define-key vc-prefix-map "a" 'vc-update-change-log)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1156 (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
1157 (define-key vc-prefix-map "d" 'vc-directory)
18148
c6e694b6de26 (vc-annotate): Entry "Annotate" added to menu and
Richard M. Stallman <rms@gnu.org>
parents: 17642
diff changeset
1158 (define-key vc-prefix-map "g" 'vc-annotate)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1159 (define-key vc-prefix-map "h" 'vc-insert-headers)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1160 (define-key vc-prefix-map "i" 'vc-register)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1161 (define-key vc-prefix-map "l" 'vc-print-log)
21367
399e7453bf89 (vc-prefix-map): Added "m" for vc-merge.
André Spiegel <spiegel@gnu.org>
parents: 21356
diff changeset
1162 (define-key vc-prefix-map "m" 'vc-merge)
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1163 (define-key vc-prefix-map "r" 'vc-retrieve-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1164 (define-key vc-prefix-map "s" 'vc-create-snapshot)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1165 (define-key vc-prefix-map "u" 'vc-revert-buffer)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1166 (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
1167 (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
1168 (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
1169
9869
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
1170 (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
1171 ;; 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
1172 ;; vc-menu-map.
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
1173 ()
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
1174 ;;(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
1175 ;; '("Show Files under VC" . (vc-directory t)))
18403
bb63fa860267 (vc-menu-map): Add bindings for vc-retrieve-snapshot and vc-create-snapshot.
Richard M. Stallman <rms@gnu.org>
parents: 18148
diff changeset
1176 (define-key vc-menu-map [vc-retrieve-snapshot]
bb63fa860267 (vc-menu-map): Add bindings for vc-retrieve-snapshot and vc-create-snapshot.
Richard M. Stallman <rms@gnu.org>
parents: 18148
diff changeset
1177 '("Retrieve Snapshot" . vc-retrieve-snapshot))
bb63fa860267 (vc-menu-map): Add bindings for vc-retrieve-snapshot and vc-create-snapshot.
Richard M. Stallman <rms@gnu.org>
parents: 18148
diff changeset
1178 (define-key vc-menu-map [vc-create-snapshot]
bb63fa860267 (vc-menu-map): Add bindings for vc-retrieve-snapshot and vc-create-snapshot.
Richard M. Stallman <rms@gnu.org>
parents: 18148
diff changeset
1179 '("Create Snapshot" . vc-create-snapshot))
23255
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1180 (define-key vc-menu-map [vc-directory] '("VC Directory Listing" . vc-directory))
9869
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
1181 (define-key vc-menu-map [separator1] '("----"))
18148
c6e694b6de26 (vc-annotate): Entry "Annotate" added to menu and
Richard M. Stallman <rms@gnu.org>
parents: 17642
diff changeset
1182 (define-key vc-menu-map [vc-annotate] '("Annotate" . vc-annotate))
9869
ae7a27dc719d Only define items in vc-menu-map if it is boundp.
Roland McGrath <roland@gnu.org>
parents: 9826
diff changeset
1183 (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
1184 (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
1185 '("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
1186 (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
1187 (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
1188 '("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
1189 (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
1190 (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
1191 (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
1192 (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
1193 '("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
1194 (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
1195 '("Insert Header" . vc-insert-headers))
19103
3a841692390c (vc-menu-map): Replace entries for "Check In" and "Check Out" with
André Spiegel <spiegel@gnu.org>
parents: 19054
diff changeset
1196 (define-key vc-menu-map [vc-next-action] '("Check In/Out" . vc-next-action))
14622
3d47471d947d Move all the put's for menu-enable props to top level.
Karl Heuer <kwzh@gnu.org>
parents: 14566
diff changeset
1197 (define-key vc-menu-map [vc-register] '("Register" . vc-register)))
3d47471d947d Move all the put's for menu-enable props to top level.
Karl Heuer <kwzh@gnu.org>
parents: 14566
diff changeset
1198
23255
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1199 ;;; These are not correct and it's not currently clear how doing it
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1200 ;;; better (with more complicated expressions) might slow things down
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1201 ;;; on older systems.
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1202
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1203 ;;;(put 'vc-rename-file 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1204 ;;;(put 'vc-annotate 'menu-enable '(eq (vc-buffer-backend) 'CVS))
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1205 ;;;(put 'vc-version-other-window 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1206 ;;;(put 'vc-diff 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1207 ;;;(put 'vc-update-change-log 'menu-enable
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1208 ;;; '(eq (vc-buffer-backend) 'RCS))
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1209 ;;;(put 'vc-print-log 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1210 ;;;(put 'vc-cancel-version 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1211 ;;;(put 'vc-revert-buffer 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1212 ;;;(put 'vc-insert-headers 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1213 ;;;(put 'vc-next-action 'menu-enable 'vc-mode)
6b2b3ceeb3cd (vc-menu-map): Change the vc-directory label. Don't
Dave Love <fx@gnu.org>
parents: 22947
diff changeset
1214 ;;;(put 'vc-register 'menu-enable '(and buffer-file-name (not vc-mode)))
904
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1215
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1216 (provide 'vc-hooks)
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1217
4a1ac370d57a Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1218 ;;; vc-hooks.el ends here