Mercurial > emacs
annotate lisp/vc-cvs.el @ 37604:bd93cba9ef3e
(custom-file): Signal an error if user-init-file is
nil (running -q).
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 07 May 2001 14:02:56 +0000 |
parents | ae55f4048b3b |
children | 6934c28c6bc5 |
rev | line source |
---|---|
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1 ;;; vc-cvs.el --- non-resident support for CVS version-control |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2 |
35839
7349d241e60b
Remove autoloads. Require vc when compiling.
André Spiegel <spiegel@gnu.org>
parents:
35821
diff
changeset
|
3 ;; Copyright (C) 1995,98,99,2000,2001 Free Software Foundation, Inc. |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
4 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
5 ;; Author: FSF (see vc.el for full credits) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
7 |
37358
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
8 ;; $Id: vc-cvs.el,v 1.21 2001/03/10 10:49:05 spiegel Exp $ |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
9 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
11 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
15 ;; any later version. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
16 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
21 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
25 ;; Boston, MA 02111-1307, USA. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
26 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
27 ;;; Commentary: |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
28 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
29 ;;; Code: |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
30 |
35702
395d188bb71d
replaced require with autoloads
Sam Steingold <sds@gnu.org>
parents:
35584
diff
changeset
|
31 (eval-when-compile |
35839
7349d241e60b
Remove autoloads. Require vc when compiling.
André Spiegel <spiegel@gnu.org>
parents:
35821
diff
changeset
|
32 (require 'vc)) |
35584 | 33 |
35569 | 34 ;;; |
33560 | 35 ;;; Customization options |
36 ;;; | |
37 | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
38 (defcustom vc-cvs-register-switches nil |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
39 "*Extra switches for registering a file into CVS. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
40 A string or list of strings passed to the checkin program by |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
41 \\[vc-register]." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
42 :type '(choice (const :tag "None" nil) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
43 (string :tag "Argument String") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
44 (repeat :tag "Argument List" |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
45 :value ("") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
46 string)) |
31475 | 47 :version "21.1" |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
48 :group 'vc) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
49 |
35821
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
50 (defcustom vc-cvs-diff-switches nil |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
51 "*A string or list of strings specifying extra switches for cvs diff under VC." |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
52 :type '(choice (const :tag "None" nil) |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
53 (string :tag "Argument String") |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
54 (repeat :tag "Argument List" |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
55 :value ("") |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
56 string)) |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
57 :version "21.1" |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
58 :group 'vc) |
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
59 |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
60 (defcustom vc-cvs-header (or (cdr (assoc 'CVS vc-header-alist)) '("\$Id\$")) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
61 "*Header keywords to be inserted by `vc-insert-headers'." |
31475 | 62 :version "21.1" |
35177 | 63 :type '(repeat string) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
64 :group 'vc) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
65 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
66 (defcustom vc-cvs-use-edit t |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
67 "*Non-nil means to use `cvs edit' to \"check out\" a file. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
68 This is only meaningful if you don't use the implicit checkout model |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
69 \(i.e. if you have $CVSREAD set)." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
70 :type 'boolean |
31475 | 71 :version "21.1" |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
72 :group 'vc) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
73 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
74 (defcustom vc-cvs-stay-local t |
31475 | 75 "*Non-nil means use local operations when possible for remote repositories. |
76 This avoids slow queries over the network. Turning this option on | |
77 will instruct VC to use only heuristics and past information to | |
78 determine the current status of a file. The value can also be a | |
79 regular expression to match against the host name of a repository; | |
80 then VC only stays local for hosts that match it." | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
81 :type '(choice (const :tag "Always stay local" t) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
82 (string :tag "Host regexp") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
83 (const :tag "Don't stay local" nil)) |
31475 | 84 :version "21.1" |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
85 :group 'vc) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
86 |
35569 | 87 |
33560 | 88 ;;; |
89 ;;; Internal variables | |
90 ;;; | |
91 | |
92 (defvar vc-cvs-local-month-numbers | |
93 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4) | |
94 ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8) | |
95 ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12)) | |
96 "Local association list of month numbers.") | |
97 | |
35569 | 98 |
33560 | 99 ;;; |
35569 | 100 ;;; State-querying functions |
33560 | 101 ;;; |
102 | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
103 ;;;###autoload (defun vc-cvs-registered (f) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
104 ;;;###autoload (when (file-readable-p (expand-file-name |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
105 ;;;###autoload "CVS/Entries" (file-name-directory f))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
106 ;;;###autoload (require 'vc-cvs) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
107 ;;;###autoload (vc-cvs-registered f))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
108 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
109 (defun vc-cvs-registered (file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
110 "Check if FILE is CVS registered." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
111 (let ((dirname (or (file-name-directory file) "")) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
112 (basename (file-name-nondirectory file)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
113 ;; make sure that the file name is searched case-sensitively |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
114 (case-fold-search nil)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
115 (if (file-readable-p (expand-file-name "CVS/Entries" dirname)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
116 (with-temp-buffer |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
117 (vc-insert-file (expand-file-name "CVS/Entries" dirname)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
118 (goto-char (point-min)) |
31475 | 119 (cond |
120 ((re-search-forward | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
121 (concat "^/" (regexp-quote basename) "/") nil t) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
122 (beginning-of-line) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
123 (vc-cvs-parse-entry file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
124 t) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
125 (t nil))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
126 nil))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
127 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
128 (defun vc-cvs-state (file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
129 "CVS-specific version of `vc-state'." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
130 (if (vc-cvs-stay-local-p file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
131 (let ((state (vc-file-getprop file 'vc-state))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
132 ;; If we should stay local, use the heuristic but only if |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
133 ;; we don't have a more precise state already available. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
134 (if (memq state '(up-to-date edited)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
135 (vc-cvs-state-heuristic file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
136 state)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
137 (with-temp-buffer |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
138 (cd (file-name-directory file)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
139 (vc-do-command t 0 "cvs" file "status") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
140 (vc-cvs-parse-status t)))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
141 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
142 (defun vc-cvs-state-heuristic (file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
143 "CVS-specific state heuristic." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
144 ;; If the file has not changed since checkout, consider it `up-to-date'. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
145 ;; Otherwise consider it `edited'. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
146 (let ((checkout-time (vc-file-getprop file 'vc-checkout-time)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
147 (lastmod (nth 5 (file-attributes file)))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
148 (if (equal checkout-time lastmod) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
149 'up-to-date |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
150 'edited))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
151 |
33560 | 152 (defun vc-cvs-dir-state (dir) |
153 "Find the CVS state of all files in DIR." | |
154 (if (vc-cvs-stay-local-p dir) | |
155 (vc-cvs-dir-state-heuristic dir) | |
156 (let ((default-directory dir)) | |
157 ;; Don't specify DIR in this command, the default-directory is | |
158 ;; enough. Otherwise it might fail with remote repositories. | |
159 (with-temp-buffer | |
160 (vc-do-command t 0 "cvs" nil "status" "-l") | |
161 (goto-char (point-min)) | |
162 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t) | |
163 (narrow-to-region (match-beginning 0) (match-end 0)) | |
164 (vc-cvs-parse-status) | |
165 (goto-char (point-max)) | |
166 (widen)))))) | |
167 | |
168 (defun vc-cvs-workfile-version (file) | |
169 "CVS-specific version of `vc-workfile-version'." | |
170 ;; There is no need to consult RCS headers under CVS, because we | |
171 ;; get the workfile version for free when we recognize that a file | |
172 ;; is registered in CVS. | |
173 (vc-cvs-registered file) | |
174 (vc-file-getprop file 'vc-workfile-version)) | |
175 | |
176 (defun vc-cvs-checkout-model (file) | |
177 "CVS-specific version of `vc-checkout-model'." | |
178 (if (or (getenv "CVSREAD") | |
179 ;; If the file is not writable (despite CVSREAD being | |
180 ;; undefined), this is probably because the file is being | |
181 ;; "watched" by other developers. | |
182 ;; (If vc-mistrust-permissions was t, we actually shouldn't | |
183 ;; trust this, but there is no other way to learn this from CVS | |
184 ;; at the moment (version 1.9).) | |
185 (string-match "r-..-..-." (nth 8 (file-attributes file)))) | |
186 'announce | |
187 'implicit)) | |
188 | |
31404
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
189 (defun vc-cvs-mode-line-string (file) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
190 "Return string for placement into the modeline for FILE. |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
191 Compared to the default implementation, this function handles the |
35569 | 192 special case of a CVS file that is added but not yet committed." |
31404
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
193 (let ((state (vc-state file)) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
194 (rev (vc-workfile-version file))) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
195 (cond ((string= rev "0") |
35569 | 196 ;; A file that is added but not yet committed. |
31404
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
197 "CVS @@") |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
198 ((or (eq state 'up-to-date) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
199 (eq state 'needs-patch)) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
200 (concat "CVS-" rev)) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
201 ((stringp state) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
202 (concat "CVS:" state ":" rev)) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
203 (t |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
204 ;; Not just for the 'edited state, but also a fallback |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
205 ;; for all other states. Think about different symbols |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
206 ;; for 'needs-patch and 'needs-merge. |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
207 (concat "CVS:" rev))))) |
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
208 |
33560 | 209 (defun vc-cvs-dired-state-info (file) |
210 "CVS-specific version of `vc-dired-state-info'." | |
211 (let* ((cvs-state (vc-state file)) | |
212 (state (cond ((eq cvs-state 'edited) "modified") | |
213 ((eq cvs-state 'needs-patch) "patch") | |
214 ((eq cvs-state 'needs-merge) "merge") | |
215 ;; FIXME: those two states cannot occur right now | |
216 ((eq cvs-state 'unlocked-changes) "conflict") | |
217 ((eq cvs-state 'locally-added) "added") | |
218 ))) | |
219 (if state (concat "(" state ")")))) | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
220 |
35569 | 221 |
33560 | 222 ;;; |
223 ;;; State-changing functions | |
224 ;;; | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
225 |
33560 | 226 (defun vc-cvs-register (file &optional rev comment) |
227 "Register FILE into the CVS version-control system. | |
228 COMMENT can be used to provide an initial description of FILE. | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
229 |
33560 | 230 `vc-register-switches' and `vc-cvs-register-switches' are passed to |
231 the CVS command (in that order)." | |
232 (let ((switches (list | |
233 (if (stringp vc-register-switches) | |
234 (list vc-register-switches) | |
235 vc-register-switches) | |
236 (if (stringp vc-cvs-register-switches) | |
237 (list vc-cvs-register-switches) | |
238 vc-cvs-register-switches)))) | |
35569 | 239 |
33560 | 240 (apply 'vc-do-command nil 0 "cvs" file |
241 "add" | |
242 (and comment (string-match "[^\t\n ]" comment) | |
243 (concat "-m" comment)) | |
244 switches))) | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
245 |
33560 | 246 (defun vc-cvs-responsible-p (file) |
247 "Return non-nil if CVS thinks it is responsible for FILE." | |
248 (file-directory-p (expand-file-name "CVS" | |
249 (if (file-directory-p file) | |
250 file | |
251 (file-name-directory file))))) | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
252 |
33560 | 253 (defun vc-cvs-could-register (file) |
254 "Return non-nil if FILE could be registered in CVS. | |
255 This is only possible if CVS is responsible for FILE's directory." | |
256 (vc-cvs-responsible-p file)) | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
257 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
258 (defun vc-cvs-checkin (file rev comment) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
259 "CVS-specific version of `vc-backend-checkin'." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
260 (let ((switches (if (stringp vc-checkin-switches) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
261 (list vc-checkin-switches) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
262 vc-checkin-switches)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
263 status) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
264 ;; explicit check-in to the trunk requires a double check-in (first |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
265 ;; unexplicit) (CVS-1.3) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
266 (if (and rev (vc-trunk-p rev)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
267 (apply 'vc-do-command nil 1 "cvs" file |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
268 "ci" "-m" "intermediate" |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
269 switches)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
270 (setq status (apply 'vc-do-command nil 1 "cvs" file |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
271 "ci" (if rev (concat "-r" rev)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
272 (concat "-m" comment) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
273 switches)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
274 (set-buffer "*vc*") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
275 (goto-char (point-min)) |
32948
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
276 (when (not (zerop status)) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
277 ;; Check checkin problem. |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
278 (cond |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
279 ((re-search-forward "Up-to-date check failed" nil t) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
280 (vc-file-setprop file 'vc-state 'needs-merge) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
281 (error (substitute-command-keys |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
282 (concat "Up-to-date check failed: " |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
283 "type \\[vc-next-action] to merge in changes")))) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
284 (t |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
285 (pop-to-buffer (current-buffer)) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
286 (goto-char (point-min)) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
287 (shrink-window-if-larger-than-buffer) |
3c95af2888f6
(vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents:
32747
diff
changeset
|
288 (error "Check-in failed")))) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
289 ;; Update file properties |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
290 (vc-file-setprop |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
291 file 'vc-workfile-version |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
292 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
293 ;; Forget the checkout model of the file, because we might have |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
294 ;; guessed wrong when we found the file. After commit, we can |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
295 ;; tell it from the permissions of the file (see |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
296 ;; vc-cvs-checkout-model). |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
297 (vc-file-setprop file 'vc-checkout-model nil) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
298 ;; if this was an explicit check-in, remove the sticky tag |
36711
22fd463447c3
(vc-cvs-checkin): When removing the sticky tag, make output go to
André Spiegel <spiegel@gnu.org>
parents:
35839
diff
changeset
|
299 (if rev (vc-do-command nil 0 "cvs" file "update" "-A")))) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
300 |
35132
78bce41f17c5
(vc-cvs-latest-on-branch-p): Removed.
André Spiegel <spiegel@gnu.org>
parents:
33637
diff
changeset
|
301 (defun vc-cvs-checkout (file &optional editable rev workfile) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
302 "Retrieve a revision of FILE into a WORKFILE. |
35132
78bce41f17c5
(vc-cvs-latest-on-branch-p): Removed.
André Spiegel <spiegel@gnu.org>
parents:
33637
diff
changeset
|
303 EDITABLE non-nil means that the file should be writable. |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
304 REV is the revision to check out into WORKFILE." |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
305 (let ((filename (or workfile file)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
306 (file-buffer (get-file-buffer file)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
307 switches) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
308 (message "Checking out %s..." filename) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
309 (save-excursion |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
310 ;; Change buffers to get local value of vc-checkout-switches. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
311 (if file-buffer (set-buffer file-buffer)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
312 (setq switches (if (stringp vc-checkout-switches) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
313 (list vc-checkout-switches) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
314 vc-checkout-switches)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
315 ;; Save this buffer's default-directory |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
316 ;; and use save-excursion to make sure it is restored |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
317 ;; in the same buffer it was saved in. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
318 (let ((default-directory default-directory)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
319 (save-excursion |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
320 ;; Adjust the default-directory so that the check-out creates |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
321 ;; the file in the right place. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
322 (setq default-directory (file-name-directory filename)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
323 (if workfile |
35569 | 324 (let ((failed t) |
33637
6cab2125de9c
(vc-cvs-checkout): Fix bug that broke C-x v ~-style checkouts.
André Spiegel <spiegel@gnu.org>
parents:
33560
diff
changeset
|
325 (backup-name (if (string= file workfile) |
33549
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
326 (car (find-backup-file-name filename))))) |
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
327 (when backup-name |
35569 | 328 (copy-file filename backup-name |
33549
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
329 'ok-if-already-exists 'keep-date) |
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
330 (unless (file-writable-p filename) |
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
331 (set-file-modes filename |
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
332 (logior (file-modes filename) 128)))) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
333 (unwind-protect |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
334 (progn |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
335 (let ((coding-system-for-read 'no-conversion) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
336 (coding-system-for-write 'no-conversion)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
337 (with-temp-file filename |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
338 (apply 'vc-do-command |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
339 (current-buffer) 0 "cvs" file |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
340 "-Q" ; suppress diagnostic output |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
341 "update" |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
342 (and rev (not (string= rev "")) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
343 (concat "-r" rev)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
344 "-p" |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
345 switches))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
346 (setq failed nil)) |
35569 | 347 (if failed |
33637
6cab2125de9c
(vc-cvs-checkout): Fix bug that broke C-x v ~-style checkouts.
André Spiegel <spiegel@gnu.org>
parents:
33560
diff
changeset
|
348 (if backup-name |
35569 | 349 (rename-file backup-name filename |
33637
6cab2125de9c
(vc-cvs-checkout): Fix bug that broke C-x v ~-style checkouts.
André Spiegel <spiegel@gnu.org>
parents:
33560
diff
changeset
|
350 'ok-if-already-exists) |
6cab2125de9c
(vc-cvs-checkout): Fix bug that broke C-x v ~-style checkouts.
André Spiegel <spiegel@gnu.org>
parents:
33560
diff
changeset
|
351 (if (file-exists-p filename) |
6cab2125de9c
(vc-cvs-checkout): Fix bug that broke C-x v ~-style checkouts.
André Spiegel <spiegel@gnu.org>
parents:
33560
diff
changeset
|
352 (delete-file filename))) |
33549
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
353 (and backup-name |
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
354 (not vc-make-backup-files) |
8a998774febc
(vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on.
André Spiegel <spiegel@gnu.org>
parents:
33545
diff
changeset
|
355 (delete-file backup-name))))) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
356 (if (and (file-exists-p file) (not rev)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
357 ;; If no revision was specified, just make the file writable |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
358 ;; if necessary (using `cvs-edit' if requested). |
35132
78bce41f17c5
(vc-cvs-latest-on-branch-p): Removed.
André Spiegel <spiegel@gnu.org>
parents:
33637
diff
changeset
|
359 (and editable (not (eq (vc-cvs-checkout-model file) 'implicit)) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
360 (if vc-cvs-use-edit |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
361 (vc-do-command nil 0 "cvs" file "edit") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
362 (set-file-modes file (logior (file-modes file) 128)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
363 (if file-buffer (toggle-read-only -1)))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
364 ;; Check out a particular version (or recreate the file). |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
365 (vc-file-setprop file 'vc-workfile-version nil) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
366 (apply 'vc-do-command nil 0 "cvs" file |
35132
78bce41f17c5
(vc-cvs-latest-on-branch-p): Removed.
André Spiegel <spiegel@gnu.org>
parents:
33637
diff
changeset
|
367 (and editable |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
368 (or (not (file-exists-p file)) |
31475 | 369 (not (eq (vc-cvs-checkout-model file) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
370 'implicit))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
371 "-w") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
372 "update" |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
373 ;; default for verbose checkout: clear the sticky tag so |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
374 ;; that the actual update will get the head of the trunk |
31475 | 375 (if (or (not rev) (string= rev "")) |
376 "-A" | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
377 (concat "-r" rev)) |
31404
f2ab9420390f
2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31384
diff
changeset
|
378 switches)))) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
379 (vc-mode-line file) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
380 (message "Checking out %s...done" filename))))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
381 |
33560 | 382 (defun vc-cvs-revert (file) |
383 "Revert FILE to the version it was based on." | |
384 ;; Check out via standard output (caused by the final argument | |
385 ;; FILE below), so that no sticky tag is set. | |
386 (vc-cvs-checkout file nil (vc-workfile-version file) file) | |
387 ;; If "cvs edit" was used to make the file writable, | |
388 ;; call "cvs unedit" now to undo that. | |
389 (if (and (not (eq (vc-cvs-checkout-model file) 'implicit)) | |
390 vc-cvs-use-edit) | |
391 (vc-do-command nil 0 "cvs" file "unedit"))) | |
392 | |
393 (defun vc-cvs-merge (file first-version &optional second-version) | |
394 "Merge changes into current working copy of FILE. | |
395 The changes are between FIRST-VERSION and SECOND-VERSION." | |
396 (vc-do-command nil 0 "cvs" file | |
397 "update" "-kk" | |
398 (concat "-j" first-version) | |
399 (concat "-j" second-version)) | |
400 (vc-file-setprop file 'vc-state 'edited) | |
401 (save-excursion | |
402 (set-buffer (get-buffer "*vc*")) | |
403 (goto-char (point-min)) | |
404 (if (re-search-forward "conflicts during merge" nil t) | |
405 1 ; signal error | |
406 0))) ; signal success | |
407 | |
408 (defun vc-cvs-merge-news (file) | |
409 "Merge in any new changes made to FILE." | |
410 (message "Merging changes into %s..." file) | |
411 (save-excursion | |
412 ;; (vc-file-setprop file 'vc-workfile-version nil) | |
413 (vc-file-setprop file 'vc-checkout-time 0) | |
414 (vc-do-command nil 0 "cvs" file "update") | |
415 ;; Analyze the merge result reported by CVS, and set | |
416 ;; file properties accordingly. | |
417 (set-buffer (get-buffer "*vc*")) | |
418 (goto-char (point-min)) | |
419 ;; get new workfile version | |
420 (if (re-search-forward (concat "^Merging differences between " | |
421 "[01234567890.]* and " | |
422 "\\([01234567890.]*\\) into") | |
423 nil t) | |
424 (vc-file-setprop file 'vc-workfile-version (match-string 1)) | |
425 (vc-file-setprop file 'vc-workfile-version nil)) | |
426 ;; get file status | |
427 (prog1 | |
428 (if (eq (buffer-size) 0) | |
429 0 ;; there were no news; indicate success | |
430 (if (re-search-forward | |
431 (concat "^\\([CMUP] \\)?" | |
432 (regexp-quote (file-name-nondirectory file)) | |
433 "\\( already contains the differences between \\)?") | |
434 nil t) | |
435 (cond | |
436 ;; Merge successful, we are in sync with repository now | |
437 ((or (match-string 2) | |
438 (string= (match-string 1) "U ") | |
439 (string= (match-string 1) "P ")) | |
440 (vc-file-setprop file 'vc-state 'up-to-date) | |
441 (vc-file-setprop file 'vc-checkout-time | |
442 (nth 5 (file-attributes file))) | |
443 0);; indicate success to the caller | |
444 ;; Merge successful, but our own changes are still in the file | |
445 ((string= (match-string 1) "M ") | |
446 (vc-file-setprop file 'vc-state 'edited) | |
447 0);; indicate success to the caller | |
448 ;; Conflicts detected! | |
449 (t | |
450 (vc-file-setprop file 'vc-state 'edited) | |
451 1);; signal the error to the caller | |
452 ) | |
453 (pop-to-buffer "*vc*") | |
454 (error "Couldn't analyze cvs update result"))) | |
455 (message "Merging changes into %s...done" file)))) | |
456 | |
35569 | 457 |
33560 | 458 ;;; |
459 ;;; History functions | |
460 ;;; | |
461 | |
462 (defun vc-cvs-print-log (file) | |
463 "Get change log associated with FILE." | |
37358
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
464 (vc-do-command |
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
465 nil |
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
466 (if (and (vc-cvs-stay-local-p file) (fboundp 'start-process)) 'async 0) |
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
467 "cvs" file "log")) |
33560 | 468 |
469 (defun vc-cvs-show-log-entry (version) | |
470 (when (re-search-forward | |
471 ;; also match some context, for safety | |
472 (concat "----\nrevision " version | |
473 "\\(\tlocked by:.*\n\\|\n\\)date: ") nil t) | |
474 ;; set the display window so that | |
475 ;; the whole log entry is displayed | |
476 (let (start end lines) | |
477 (beginning-of-line) (forward-line -1) (setq start (point)) | |
478 (if (not (re-search-forward "^----*\nrevision" nil t)) | |
479 (setq end (point-max)) | |
480 (beginning-of-line) (forward-line -1) (setq end (point))) | |
481 (setq lines (count-lines start end)) | |
482 (cond | |
483 ;; if the global information and this log entry fit | |
484 ;; into the window, display from the beginning | |
485 ((< (count-lines (point-min) end) (window-height)) | |
486 (goto-char (point-min)) | |
487 (recenter 0) | |
488 (goto-char start)) | |
489 ;; if the whole entry fits into the window, | |
490 ;; display it centered | |
491 ((< (1+ lines) (window-height)) | |
492 (goto-char start) | |
493 (recenter (1- (- (/ (window-height) 2) (/ lines 2))))) | |
494 ;; otherwise (the entry is too large for the window), | |
495 ;; display from the start | |
496 (t | |
497 (goto-char start) | |
498 (recenter 0)))))) | |
499 | |
500 (defun vc-cvs-diff (file &optional oldvers newvers) | |
501 "Get a difference report using CVS between two versions of FILE." | |
35821
6b1ff979e045
(vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents:
35702
diff
changeset
|
502 (let (options status (diff-switches-list (vc-diff-switches-list cvs))) |
33560 | 503 (if (string= (vc-workfile-version file) "0") |
504 ;; This file is added but not yet committed; there is no master file. | |
505 (if (or oldvers newvers) | |
506 (error "No revisions of %s exist" file) | |
507 ;; we regard this as "changed". | |
508 ;; diff it against /dev/null. | |
36711
22fd463447c3
(vc-cvs-checkin): When removing the sticky tag, make output go to
André Spiegel <spiegel@gnu.org>
parents:
35839
diff
changeset
|
509 (apply 'vc-do-command "*vc-diff*" |
33560 | 510 1 "diff" file |
511 (append diff-switches-list '("/dev/null")))) | |
512 (setq status | |
36711
22fd463447c3
(vc-cvs-checkin): When removing the sticky tag, make output go to
André Spiegel <spiegel@gnu.org>
parents:
35839
diff
changeset
|
513 (apply 'vc-do-command "*vc-diff*" |
37358
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
514 (if (and (vc-cvs-stay-local-p file) |
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
515 (fboundp 'start-process)) |
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
516 'async |
ae55f4048b3b
(vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents:
36711
diff
changeset
|
517 1) |
33560 | 518 "cvs" file "diff" |
519 (and oldvers (concat "-r" oldvers)) | |
520 (and newvers (concat "-r" newvers)) | |
521 diff-switches-list)) | |
35569 | 522 (if (vc-cvs-stay-local-p file) |
523 1 ;; async diff, pessimistic assumption | |
33560 | 524 status)))) |
525 | |
33545
5411250e7971
(vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents:
32959
diff
changeset
|
526 (defun vc-cvs-annotate-command (file buffer &optional version) |
5411250e7971
(vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents:
32959
diff
changeset
|
527 "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. |
5411250e7971
(vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents:
32959
diff
changeset
|
528 Optional arg VERSION is a version to annotate from." |
5411250e7971
(vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents:
32959
diff
changeset
|
529 (vc-do-command buffer 0 "cvs" file "annotate" (if version |
5411250e7971
(vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents:
32959
diff
changeset
|
530 (concat "-r" version)))) |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
531 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
532 (defun vc-cvs-annotate-difference (point) |
31475 | 533 "Return the difference between the time of the line and the current time. |
534 Return values are as defined for `current-time'." | |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
535 ;; We need a list of months and their corresponding numbers. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
536 (if (looking-at "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): ") |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
537 (progn |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
538 (let* ((day (string-to-number (match-string 1))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
539 (month (cdr (assoc (match-string 2) vc-cvs-local-month-numbers))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
540 (year-tmp (string-to-number (match-string 3))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
541 ;; Years 0..68 are 2000..2068. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
542 ;; Years 69..99 are 1969..1999. |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
543 (year (+ (cond ((> 69 year-tmp) 2000) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
544 ((> 100 year-tmp) 1900) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
545 (t 0)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
546 year-tmp))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
547 (goto-char (match-end 0)) ; Position at end makes for nicer overlay result |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
548 (- (car (current-time)) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
549 (car (encode-time 0 0 0 day month year))))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
550 ;; If we did not look directly at an annotation, there might be |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
551 ;; some further down. This is the case if we are positioned at |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
552 ;; the very top of the buffer, for instance. |
31475 | 553 (if (re-search-forward |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
554 "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): " nil t) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
555 (progn |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
556 (beginning-of-line nil) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
557 (vc-cvs-annotate-difference (point)))))) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
558 |
35569 | 559 |
33560 | 560 ;;; |
561 ;;; Snapshot system | |
562 ;;; | |
563 | |
564 (defun vc-cvs-create-snapshot (dir name branchp) | |
565 "Assign to DIR's current version a given NAME. | |
566 If BRANCHP is non-nil, the name is created as a branch (and the current | |
567 workspace is immediately moved to that new branch)." | |
568 (vc-do-command nil 0 "cvs" dir "tag" "-c" (if branchp "-b") name) | |
569 (when branchp (vc-do-command nil 0 "cvs" dir "update" "-r" name))) | |
570 | |
571 (defun vc-cvs-retrieve-snapshot (dir name update) | |
572 "Retrieve a snapshot at and below DIR. | |
573 NAME is the name of the snapshot; if it is empty, do a `cvs update'. | |
574 If UPDATE is non-nil, then update (resynch) any affected buffers." | |
575 (with-current-buffer (get-buffer-create "*vc*") | |
576 (let ((default-directory dir)) | |
577 (erase-buffer) | |
578 (if (or (not name) (string= name "")) | |
579 (vc-do-command t 0 "cvs" nil "update") | |
580 (vc-do-command t 0 "cvs" nil "update" "-r" name)) | |
581 (when update | |
582 (goto-char (point-min)) | |
583 (while (not (eobp)) | |
584 (if (looking-at "\\([CMUP]\\) \\(.*\\)") | |
585 (let* ((file (expand-file-name (match-string 2) dir)) | |
586 (state (match-string 1)) | |
587 (buffer (find-buffer-visiting file))) | |
588 (when buffer | |
589 (cond | |
590 ((or (string= state "U") | |
591 (string= state "P")) | |
592 (vc-file-setprop file 'vc-state 'up-to-date) | |
593 (vc-file-setprop file 'vc-workfile-version nil) | |
594 (vc-file-setprop file 'vc-checkout-time | |
595 (nth 5 (file-attributes file)))) | |
596 ((or (string= state "M") | |
597 (string= state "C")) | |
598 (vc-file-setprop file 'vc-state 'edited) | |
599 (vc-file-setprop file 'vc-workfile-version nil) | |
600 (vc-file-setprop file 'vc-checkout-time 0))) | |
601 (vc-resynch-buffer file t t)))) | |
602 (forward-line 1)))))) | |
603 | |
35569 | 604 |
33560 | 605 ;;; |
606 ;;; Miscellaneous | |
607 ;;; | |
608 | |
609 (defun vc-cvs-make-version-backups-p (file) | |
610 "Return non-nil if version backups should be made for FILE." | |
611 (vc-cvs-stay-local-p file)) | |
612 | |
613 (defun vc-cvs-check-headers () | |
614 "Check if the current file has any headers in it." | |
615 (save-excursion | |
616 (goto-char (point-min)) | |
617 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\ | |
618 \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t))) | |
619 | |
35569 | 620 |
33560 | 621 ;;; |
622 ;;; Internal functions | |
623 ;;; | |
624 | |
625 (defun vc-cvs-stay-local-p (file) | |
626 "Return non-nil if VC should stay local when handling FILE." | |
627 (if vc-cvs-stay-local | |
628 (let* ((dirname (if (file-directory-p file) | |
629 (directory-file-name file) | |
630 (file-name-directory file))) | |
631 (prop | |
632 (or (vc-file-getprop dirname 'vc-cvs-stay-local-p) | |
633 (let ((rootname (expand-file-name "CVS/Root" dirname))) | |
634 (vc-file-setprop | |
635 dirname 'vc-cvs-stay-local-p | |
636 (when (file-readable-p rootname) | |
637 (with-temp-buffer | |
638 (vc-insert-file rootname) | |
639 (goto-char (point-min)) | |
640 (if (looking-at "\\([^:]*\\):") | |
641 (if (not (stringp vc-cvs-stay-local)) | |
642 'yes | |
643 (let ((hostname (match-string 1))) | |
644 (if (string-match vc-cvs-stay-local hostname) | |
645 'yes | |
646 'no))) | |
647 'no)))))))) | |
648 (if (eq prop 'yes) t nil)))) | |
649 | |
650 (defun vc-cvs-parse-status (&optional full) | |
651 "Parse output of \"cvs status\" command in the current buffer. | |
652 Set file properties accordingly. Unless FULL is t, parse only | |
653 essential information." | |
654 (let (file status) | |
655 (goto-char (point-min)) | |
656 (if (re-search-forward "^File: " nil t) | |
657 (cond | |
658 ((looking-at "no file") nil) | |
659 ((re-search-forward "\\=\\([^ \t]+\\)" nil t) | |
660 (setq file (expand-file-name (match-string 1))) | |
661 (vc-file-setprop file 'vc-backend 'CVS) | |
662 (if (not (re-search-forward "\\=[ \t]+Status: \\(.*\\)" nil t)) | |
663 (setq status "Unknown") | |
664 (setq status (match-string 1))) | |
665 (if (and full | |
666 (re-search-forward | |
667 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\ | |
668 \[\t ]+\\([0-9.]+\\)" | |
669 nil t)) | |
670 (vc-file-setprop file 'vc-latest-version (match-string 2))) | |
671 (cond | |
672 ((string-match "Up-to-date" status) | |
673 (vc-file-setprop file 'vc-checkout-time | |
674 (nth 5 (file-attributes file))) | |
675 'up-to-date) | |
676 ((string-match "Locally Modified" status) 'edited) | |
677 ((string-match "Needs Merge" status) 'needs-merge) | |
678 ((string-match "Needs \\(Checkout\\|Patch\\)" status) 'needs-patch) | |
679 (t 'edited))))))) | |
680 | |
681 (defun vc-cvs-dir-state-heuristic (dir) | |
682 "Find the CVS state of all files in DIR, using only local information." | |
683 (with-temp-buffer | |
684 (vc-insert-file (expand-file-name "CVS/Entries" dir)) | |
685 (goto-char (point-min)) | |
686 (while (not (eobp)) | |
687 (when (looking-at "/\\([^/]*\\)/") | |
688 (let ((file (expand-file-name (match-string 1) dir))) | |
689 (unless (vc-file-getprop file 'vc-state) | |
690 (vc-cvs-parse-entry file t)))) | |
691 (forward-line 1)))) | |
692 | |
693 (defun vc-cvs-parse-entry (file &optional set-state) | |
694 "Parse a line from CVS/Entries. | |
695 Compare modification time to that of the FILE, set file properties | |
696 accordingly. However, `vc-state' is set only if optional arg SET-STATE | |
697 is non-nil." | |
698 (cond | |
699 ;; entry for a "locally added" file (not yet committed) | |
700 ((looking-at "/[^/]+/0/") | |
701 (vc-file-setprop file 'vc-checkout-time 0) | |
702 (vc-file-setprop file 'vc-workfile-version "0") | |
703 (if set-state (vc-file-setprop file 'vc-state 'edited))) | |
704 ;; normal entry | |
705 ((looking-at | |
706 (concat "/[^/]+" | |
707 ;; revision | |
708 "/\\([^/]*\\)" | |
709 ;; timestamp | |
710 "/[A-Z][a-z][a-z]" ;; week day (irrelevant) | |
711 " \\([A-Z][a-z][a-z]\\)" ;; month name | |
712 " *\\([0-9]*\\)" ;; day of month | |
713 " \\([0-9]*\\):\\([0-9]*\\):\\([0-9]*\\)" ;; hms | |
714 " \\([0-9]*\\)" ;; year | |
715 ;; optional conflict field | |
716 "\\(+[^/]*\\)?/")) | |
717 (vc-file-setprop file 'vc-workfile-version (match-string 1)) | |
718 ;; compare checkout time and modification time | |
719 (let ((second (string-to-number (match-string 6))) | |
720 (minute (string-to-number (match-string 5))) | |
721 (hour (string-to-number (match-string 4))) | |
722 (day (string-to-number (match-string 3))) | |
723 (year (string-to-number (match-string 7))) | |
724 (month (/ (string-match | |
725 (match-string 2) | |
726 "xxxJanFebMarAprMayJunJulAugSepOctNovDec") | |
727 3)) | |
728 (mtime (nth 5 (file-attributes file)))) | |
729 (cond ((equal mtime | |
730 (encode-time second minute hour day month year 0)) | |
731 (vc-file-setprop file 'vc-checkout-time mtime) | |
732 (if set-state (vc-file-setprop file 'vc-state 'up-to-date))) | |
733 (t | |
734 (vc-file-setprop file 'vc-checkout-time 0) | |
735 (if set-state (vc-file-setprop file 'vc-state 'edited)))))) | |
736 ;; entry with arbitrary text as timestamp | |
737 ;; (this means we should consider it modified) | |
738 ((looking-at | |
739 (concat "/[^/]+" | |
740 ;; revision | |
741 "/\\([^/]*\\)" | |
742 ;; timestamp (arbitrary text) | |
743 "/[^/]*" | |
744 ;; optional conflict field | |
745 "\\(+[^/]*\\)?/")) | |
746 (vc-file-setprop file 'vc-workfile-version (match-string 1)) | |
747 (vc-file-setprop file 'vc-checkout-time 0) | |
748 (if set-state (vc-file-setprop file 'vc-state 'edited))))) | |
35569 | 749 |
31384
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
750 (provide 'vc-cvs) |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
751 |
f6cb7dfe5e7c
(vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
752 ;;; vc-cvs.el ends here |