annotate lisp/vc-cvs.el @ 42515:83e8bdf0a48b

(basic-save-buffer): Undo previous change.
author Richard M. Stallman <rms@gnu.org>
date Fri, 04 Jan 2002 02:13:37 +0000
parents 0f4506820432
children ddeba2931dd4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
42206
0f4506820432 Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 41707
diff changeset
8 ;; $Id: vc-cvs.el,v 1.28 2001/11/30 13:47:39 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
498bcc1e7c00 require vc
Sam Steingold <sds@gnu.org>
parents: 35569
diff changeset
33
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
34 ;;;
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
35 ;;; Customization options
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
36 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
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
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
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
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
62 :version "21.1"
35177
f7c511463b68 (vc-cvs-header): Fix :type.
Dave Love <fx@gnu.org>
parents: 35132
diff changeset
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
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
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
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
75 "*Non-nil means use local operations when possible for remote repositories.
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
76 This avoids slow queries over the network and instead uses heuristics
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
77 and past information to determine the current status of a file.
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
78 The value can also be a regular expression to match against the host name
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
79 of a repository; 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
80 :type '(choice (const :tag "Always stay local" t)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 (string :tag "Host regexp")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (const :tag "Don't stay local" nil))
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
83 :version "21.1"
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :group 'vc)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
86
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
87 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
88 ;;; Internal variables
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
89 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
90
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
91 (defvar vc-cvs-local-month-numbers
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
92 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
93 ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
94 ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
95 "Local association list of month numbers.")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
96
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
97
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
98 ;;;
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
99 ;;; State-querying functions
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
100 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
101
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ;;;###autoload (defun vc-cvs-registered (f)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 ;;;###autoload (when (file-readable-p (expand-file-name
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 ;;;###autoload "CVS/Entries" (file-name-directory f)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 ;;;###autoload (require 'vc-cvs)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 ;;;###autoload (vc-cvs-registered f)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (defun vc-cvs-registered (file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 "Check if FILE is CVS registered."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (let ((dirname (or (file-name-directory file) ""))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 (basename (file-name-nondirectory file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 ;; 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
113 (case-fold-search nil))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 (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
115 (with-temp-buffer
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (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
117 (goto-char (point-min))
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
118 (cond
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
119 ((re-search-forward
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 (concat "^/" (regexp-quote basename) "/") nil t)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (beginning-of-line)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (vc-cvs-parse-entry file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 t)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (t nil)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 nil)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (defun vc-cvs-state (file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 "CVS-specific version of `vc-state'."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (if (vc-cvs-stay-local-p file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (let ((state (vc-file-getprop file 'vc-state)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 ;; 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
132 ;; 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
133 (if (memq state '(up-to-date edited))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (vc-cvs-state-heuristic file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 state))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (with-temp-buffer
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (cd (file-name-directory file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (vc-do-command t 0 "cvs" file "status")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (vc-cvs-parse-status t))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (defun vc-cvs-state-heuristic (file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 "CVS-specific state heuristic."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 ;; 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
144 ;; Otherwise consider it `edited'.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (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
146 (lastmod (nth 5 (file-attributes file))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (if (equal checkout-time lastmod)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 'up-to-date
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 'edited)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
151 (defun vc-cvs-dir-state (dir)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
152 "Find the CVS state of all files in DIR."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
153 (if (vc-cvs-stay-local-p dir)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
154 (vc-cvs-dir-state-heuristic dir)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
155 (let ((default-directory dir))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
156 ;; Don't specify DIR in this command, the default-directory is
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
157 ;; enough. Otherwise it might fail with remote repositories.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
158 (with-temp-buffer
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
159 (vc-do-command t 0 "cvs" nil "status" "-l")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
160 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
161 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
162 (narrow-to-region (match-beginning 0) (match-end 0))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
163 (vc-cvs-parse-status)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
164 (goto-char (point-max))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
165 (widen))))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
166
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
167 (defun vc-cvs-workfile-version (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
168 "CVS-specific version of `vc-workfile-version'."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
169 ;; There is no need to consult RCS headers under CVS, because we
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
170 ;; get the workfile version for free when we recognize that a file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
171 ;; is registered in CVS.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
172 (vc-cvs-registered file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
173 (vc-file-getprop file 'vc-workfile-version))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
174
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
175 (defun vc-cvs-checkout-model (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
176 "CVS-specific version of `vc-checkout-model'."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
177 (if (or (getenv "CVSREAD")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
178 ;; If the file is not writable (despite CVSREAD being
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
179 ;; undefined), this is probably because the file is being
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
180 ;; "watched" by other developers.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
181 ;; (If vc-mistrust-permissions was t, we actually shouldn't
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
182 ;; trust this, but there is no other way to learn this from CVS
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
183 ;; at the moment (version 1.9).)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
184 (string-match "r-..-..-." (nth 8 (file-attributes file))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
185 'announce
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
186 'implicit))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
187
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
188 (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
189 "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
190 Compared to the default implementation, this function handles the
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
191 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
192 (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
193 (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
194 (cond ((string= rev "0")
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
195 ;; 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
196 "CVS @@")
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
197 ((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
198 (eq state 'needs-patch))
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
199 (concat "CVS-" rev))
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
200 ((stringp state)
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
201 (concat "CVS:" state ":" rev))
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
202 (t
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
203 ;; 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
204 ;; 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
205 ;; 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
206 (concat "CVS:" rev)))))
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
207
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
208 (defun vc-cvs-dired-state-info (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
209 "CVS-specific version of `vc-dired-state-info'."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
210 (let* ((cvs-state (vc-state file))
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
211 (state (cond ((eq cvs-state 'edited) "modified")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
212 ((eq cvs-state 'needs-patch) "patch")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
213 ((eq cvs-state 'needs-merge) "merge")
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
214 ;; FIXME: those two states cannot occur right now
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
215 ((eq cvs-state 'unlocked-changes) "conflict")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
216 ((eq cvs-state 'locally-added) "added")
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
217 )))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
218 (if state (concat "(" state ")"))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
220
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
221 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
222 ;;; State-changing functions
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
223 ;;;
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
225 (defun vc-cvs-register (file &optional rev comment)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
226 "Register FILE into the CVS version-control system.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
227 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
228
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
229 `vc-register-switches' and `vc-cvs-register-switches' are passed to
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
230 the CVS command (in that order)."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
231 (let ((switches (list
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
232 (if (stringp vc-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
233 (list vc-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
234 vc-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
235 (if (stringp vc-cvs-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
236 (list vc-cvs-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
237 vc-cvs-register-switches))))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
238
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
239 (apply 'vc-do-command nil 0 "cvs" file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
240 "add"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
241 (and comment (string-match "[^\t\n ]" comment)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
242 (concat "-m" comment))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
243 switches)))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
245 (defun vc-cvs-responsible-p (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
246 "Return non-nil if CVS thinks it is responsible for FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
247 (file-directory-p (expand-file-name "CVS"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
248 (if (file-directory-p file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
249 file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
250 (file-name-directory file)))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
252 (defun vc-cvs-could-register (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
253 "Return non-nil if FILE could be registered in CVS.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
254 This is only possible if CVS is responsible for FILE's directory."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
255 (vc-cvs-responsible-p file))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (defun vc-cvs-checkin (file rev comment)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 "CVS-specific version of `vc-backend-checkin'."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (let ((switches (if (stringp vc-checkin-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (list vc-checkin-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 vc-checkin-switches))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 status)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 ;; 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
264 ;; unexplicit) (CVS-1.3)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (if (and rev (vc-trunk-p rev))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (apply 'vc-do-command nil 1 "cvs" file
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 "ci" "-m" "intermediate"
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 switches))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (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
270 "ci" (if rev (concat "-r" rev))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (concat "-m" comment)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 switches))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (set-buffer "*vc*")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (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
275 (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
276 ;; Check checkin problem.
3c95af2888f6 (vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents: 32747
diff changeset
277 (cond
3c95af2888f6 (vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents: 32747
diff changeset
278 ((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
279 (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
280 (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
281 (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
282 "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
283 (t
3c95af2888f6 (vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents: 32747
diff changeset
284 (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
285 (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
286 (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
287 (error "Check-in failed"))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 ;; Update file properties
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (vc-file-setprop
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 file 'vc-workfile-version
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (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
292 ;; 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
293 ;; 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
294 ;; 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
295 ;; vc-cvs-checkout-model).
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (vc-file-setprop file 'vc-checkout-model nil)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 ;; 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
298 (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
299
35132
78bce41f17c5 (vc-cvs-latest-on-branch-p): Removed.
André Spiegel <spiegel@gnu.org>
parents: 33637
diff changeset
300 (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
301 "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
302 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
303 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
304 (let ((filename (or workfile file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (file-buffer (get-file-buffer file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (message "Checking out %s..." filename)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (save-excursion
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 ;; 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
310 (if file-buffer (set-buffer file-buffer))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (setq switches (if (stringp vc-checkout-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (list vc-checkout-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 vc-checkout-switches))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 ;; Save this buffer's default-directory
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 ;; 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
316 ;; in the same buffer it was saved in.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 (let ((default-directory default-directory))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (save-excursion
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 ;; 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
320 ;; the file in the right place.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (setq default-directory (file-name-directory filename))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 (if workfile
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
323 (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
324 (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
325 (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
326 (when backup-name
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
327 (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
328 '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
329 (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
330 (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
331 (logior (file-modes filename) 128))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (unwind-protect
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (progn
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (let ((coding-system-for-read 'no-conversion)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (coding-system-for-write 'no-conversion))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (with-temp-file filename
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (apply 'vc-do-command
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (current-buffer) 0 "cvs" file
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 "-Q" ; suppress diagnostic output
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
340 "update"
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (and rev (not (string= rev ""))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 (concat "-r" rev))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 "-p"
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 switches)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (setq failed nil))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
346 (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
347 (if backup-name
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
348 (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
349 '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
350 (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
351 (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
352 (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
353 (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
354 (delete-file backup-name)))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (if (and (file-exists-p file) (not rev))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 ;; 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
357 ;; if necessary (using `cvs-edit' if requested).
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
358 (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
359 (if vc-cvs-use-edit
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (vc-do-command nil 0 "cvs" file "edit")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (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
362 (if file-buffer (toggle-read-only -1))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 ;; 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
364 (vc-file-setprop file 'vc-workfile-version nil)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (apply 'vc-do-command nil 0 "cvs" file
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
366 (and editable
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
367 (or (not (file-exists-p file))
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
368 (not (eq (vc-cvs-checkout-model file)
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
369 'implicit)))
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
370 "-w")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
371 "update"
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
372 ;; default for verbose checkout: clear the sticky tag so
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
373 ;; that the actual update will get the head of the trunk
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
374 (if (or (not rev) (string= rev ""))
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
375 "-A"
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (concat "-r" rev))
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
377 switches))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (vc-mode-line file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (message "Checking out %s...done" filename)))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380
39001
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
381 (defun vc-cvs-revert (file &optional contents-done)
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
382 "Revert FILE to the version it was based on."
39001
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
383 (unless contents-done
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
384 ;; Check out via standard output (caused by the final argument
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
385 ;; FILE below), so that no sticky tag is set.
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
386 (vc-cvs-checkout file nil (vc-workfile-version file) file))
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
387 (unless (eq (vc-checkout-model file) 'implicit)
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
388 (if vc-cvs-use-edit
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
389 (vc-do-command nil 0 "cvs" file "unedit")
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
390 ;; Make the file read-only by switching off all w-bits
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
391 (set-file-modes file (logand (file-modes file) 3950)))))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
392
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
393 (defun vc-cvs-merge (file first-version &optional second-version)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
394 "Merge changes into current working copy of FILE.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
395 The changes are between FIRST-VERSION and SECOND-VERSION."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
396 (vc-do-command nil 0 "cvs" file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
397 "update" "-kk"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
398 (concat "-j" first-version)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
399 (concat "-j" second-version))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
400 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
401 (save-excursion
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
402 (set-buffer (get-buffer "*vc*"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
403 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
404 (if (re-search-forward "conflicts during merge" nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
405 1 ; signal error
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
406 0))) ; signal success
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
407
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
408 (defun vc-cvs-merge-news (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
409 "Merge in any new changes made to FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
410 (message "Merging changes into %s..." file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
411 (save-excursion
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
412 ;; (vc-file-setprop file 'vc-workfile-version nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
413 (vc-file-setprop file 'vc-checkout-time 0)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
414 (vc-do-command nil 0 "cvs" file "update")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
415 ;; Analyze the merge result reported by CVS, and set
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
416 ;; file properties accordingly.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
417 (set-buffer (get-buffer "*vc*"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
418 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
419 ;; get new workfile version
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
420 (if (re-search-forward (concat "^Merging differences between "
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
421 "[01234567890.]* and "
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
422 "\\([01234567890.]*\\) into")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
423 nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
424 (vc-file-setprop file 'vc-workfile-version (match-string 1))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
425 (vc-file-setprop file 'vc-workfile-version nil))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
426 ;; get file status
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
427 (prog1
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
428 (if (eq (buffer-size) 0)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
429 0 ;; there were no news; indicate success
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
430 (if (re-search-forward
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
431 (concat "^\\([CMUP] \\)?"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
432 (regexp-quote (file-name-nondirectory file))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
433 "\\( already contains the differences between \\)?")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
434 nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
435 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
436 ;; Merge successful, we are in sync with repository now
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
437 ((or (match-string 2)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
438 (string= (match-string 1) "U ")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
439 (string= (match-string 1) "P "))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
440 (vc-file-setprop file 'vc-state 'up-to-date)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
441 (vc-file-setprop file 'vc-checkout-time
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
442 (nth 5 (file-attributes file)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
443 0);; indicate success to the caller
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
444 ;; Merge successful, but our own changes are still in the file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
445 ((string= (match-string 1) "M ")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
446 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
447 0);; indicate success to the caller
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
448 ;; Conflicts detected!
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
449 (t
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
450 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
451 1);; signal the error to the caller
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
452 )
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
453 (pop-to-buffer "*vc*")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
454 (error "Couldn't analyze cvs update result")))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
455 (message "Merging changes into %s...done" file))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
456
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
457
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
458 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
459 ;;; History functions
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
460 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
461
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
462 (defun vc-cvs-print-log (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
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
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
468
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
469 (defun vc-cvs-show-log-entry (version)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
470 (when (re-search-forward
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
471 ;; also match some context, for safety
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
472 (concat "----\nrevision " version
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
473 "\\(\tlocked by:.*\n\\|\n\\)date: ") nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
474 ;; set the display window so that
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
475 ;; the whole log entry is displayed
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
476 (let (start end lines)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
477 (beginning-of-line) (forward-line -1) (setq start (point))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
478 (if (not (re-search-forward "^----*\nrevision" nil t))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
479 (setq end (point-max))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
480 (beginning-of-line) (forward-line -1) (setq end (point)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
481 (setq lines (count-lines start end))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
482 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
483 ;; if the global information and this log entry fit
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
484 ;; into the window, display from the beginning
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
485 ((< (count-lines (point-min) end) (window-height))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
486 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
487 (recenter 0)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
488 (goto-char start))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
489 ;; if the whole entry fits into the window,
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
490 ;; display it centered
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
491 ((< (1+ lines) (window-height))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
492 (goto-char start)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
493 (recenter (1- (- (/ (window-height) 2) (/ lines 2)))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
494 ;; otherwise (the entry is too large for the window),
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
495 ;; display from the start
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
496 (t
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
497 (goto-char start)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
498 (recenter 0))))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
499
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
500 (defun vc-cvs-diff (file &optional oldvers newvers)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
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
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
503 (if (string= (vc-workfile-version file) "0")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
504 ;; This file is added but not yet committed; there is no master file.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
505 (if (or oldvers newvers)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
506 (error "No revisions of %s exist" file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
507 ;; we regard this as "changed".
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
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
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
510 1 "diff" file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
511 (append diff-switches-list '("/dev/null"))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
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
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
518 "cvs" file "diff"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
519 (and oldvers (concat "-r" oldvers))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
520 (and newvers (concat "-r" newvers))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
521 diff-switches-list))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
522 (if (vc-cvs-stay-local-p file)
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
523 1 ;; async diff, pessimistic assumption
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
524 status))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
525
40125
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
526 (defun vc-cvs-diff-tree (dir &optional rev1 rev2)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
527 "Diff all files at and below DIR."
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
528 (with-current-buffer "*vc-diff*"
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
529 (setq default-directory dir)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
530 (if (vc-cvs-stay-local-p dir)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
531 ;; local diff: do it filewise, and only for files that are modified
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
532 (vc-file-tree-walk
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
533 dir
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
534 (lambda (f)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
535 (vc-exec-after
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
536 `(let ((coding-system-for-read (vc-coding-system-for-diff ',f)))
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
537 ;; possible optimization: fetch the state of all files
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
538 ;; in the tree via vc-cvs-dir-state-heuristic
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
539 (unless (vc-up-to-date-p ',f)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
540 (message "Looking at %s" ',f)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
541 (vc-diff-internal ',f ',rel1 ',rel2))))))
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
542 ;; cvs diff: use a single call for the entire tree
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
543 (let ((coding-system-for-read
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
544 (or coding-system-for-read 'undecided)))
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
545 (apply 'vc-do-command "*vc-diff*" 1 "cvs" nil "diff"
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
546 (and rel1 (concat "-r" rel1))
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
547 (and rel2 (concat "-r" rel2))
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
548 (vc-diff-switches-list cvs))))))
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
549
33545
5411250e7971 (vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents: 32959
diff changeset
550 (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
551 "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
552 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
553 (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
554 (concat "-r" version))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
556 (defun vc-cvs-annotate-current-time ()
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
557 "Return the current time, based at midnight of the current day, and
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
558 encoded as fractional days."
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
559 (vc-annotate-convert-time
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
560 (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time))))))
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
561
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
562 (defun vc-cvs-annotate-time ()
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
563 "Return the time of the next annotation (as fraction of days)
42206
0f4506820432 Doc fix.
Pavel Janík <Pavel@Janik.cz>
parents: 41707
diff changeset
564 systime, or nil if there is none."
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
565 (let ((time-stamp
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
566 "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): "))
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
567 (if (looking-at time-stamp)
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (progn
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (let* ((day (string-to-number (match-string 1)))
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
570 (month (cdr (assoc (match-string 2)
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
571 vc-cvs-local-month-numbers)))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 (year-tmp (string-to-number (match-string 3)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 ;; Years 0..68 are 2000..2068.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 ;; Years 69..99 are 1969..1999.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (year (+ (cond ((> 69 year-tmp) 2000)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 ((> 100 year-tmp) 1900)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (t 0))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 year-tmp)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (goto-char (match-end 0)) ; Position at end makes for nicer overlay result
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
580 (vc-annotate-convert-time (encode-time 0 0 0 day month year))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 ;; 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
582 ;; 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
583 ;; the very top of the buffer, for instance.
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
584 (if (re-search-forward time-stamp nil t)
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (progn
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (beginning-of-line nil)
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
587 (vc-cvs-annotate-time))))))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
588
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
589 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
590 ;;; Snapshot system
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
591 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
592
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
593 (defun vc-cvs-create-snapshot (dir name branchp)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
594 "Assign to DIR's current version a given NAME.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
595 If BRANCHP is non-nil, the name is created as a branch (and the current
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
596 workspace is immediately moved to that new branch)."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
597 (vc-do-command nil 0 "cvs" dir "tag" "-c" (if branchp "-b") name)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
598 (when branchp (vc-do-command nil 0 "cvs" dir "update" "-r" name)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
599
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
600 (defun vc-cvs-retrieve-snapshot (dir name update)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
601 "Retrieve a snapshot at and below DIR.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
602 NAME is the name of the snapshot; if it is empty, do a `cvs update'.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
603 If UPDATE is non-nil, then update (resynch) any affected buffers."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
604 (with-current-buffer (get-buffer-create "*vc*")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
605 (let ((default-directory dir))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
606 (erase-buffer)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
607 (if (or (not name) (string= name ""))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
608 (vc-do-command t 0 "cvs" nil "update")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
609 (vc-do-command t 0 "cvs" nil "update" "-r" name))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
610 (when update
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
611 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
612 (while (not (eobp))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
613 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
614 (let* ((file (expand-file-name (match-string 2) dir))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
615 (state (match-string 1))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
616 (buffer (find-buffer-visiting file)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
617 (when buffer
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
618 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
619 ((or (string= state "U")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
620 (string= state "P"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
621 (vc-file-setprop file 'vc-state 'up-to-date)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
622 (vc-file-setprop file 'vc-workfile-version nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
623 (vc-file-setprop file 'vc-checkout-time
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
624 (nth 5 (file-attributes file))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
625 ((or (string= state "M")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
626 (string= state "C"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
627 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
628 (vc-file-setprop file 'vc-workfile-version nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
629 (vc-file-setprop file 'vc-checkout-time 0)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
630 (vc-resynch-buffer file t t))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
631 (forward-line 1))))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
632
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
633
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
634 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
635 ;;; Miscellaneous
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
636 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
637
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
638 (defun vc-cvs-make-version-backups-p (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
639 "Return non-nil if version backups should be made for FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
640 (vc-cvs-stay-local-p file))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
641
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
642 (defun vc-cvs-check-headers ()
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
643 "Check if the current file has any headers in it."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
644 (save-excursion
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
645 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
646 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
647 \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
648
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
649
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
650 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
651 ;;; Internal functions
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
652 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
653
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
654 (defun vc-cvs-stay-local-p (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
655 "Return non-nil if VC should stay local when handling FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
656 (if vc-cvs-stay-local
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
657 (let* ((dirname (if (file-directory-p file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
658 (directory-file-name file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
659 (file-name-directory file)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
660 (prop
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
661 (or (vc-file-getprop dirname 'vc-cvs-stay-local-p)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
662 (let ((rootname (expand-file-name "CVS/Root" dirname)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
663 (vc-file-setprop
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
664 dirname 'vc-cvs-stay-local-p
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
665 (when (file-readable-p rootname)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
666 (with-temp-buffer
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
667 (vc-insert-file rootname)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
668 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
669 (if (looking-at "\\([^:]*\\):")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
670 (if (not (stringp vc-cvs-stay-local))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
671 'yes
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
672 (let ((hostname (match-string 1)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
673 (if (string-match vc-cvs-stay-local hostname)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
674 'yes
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
675 'no)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
676 'no))))))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
677 (if (eq prop 'yes) t nil))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
678
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
679 (defun vc-cvs-parse-status (&optional full)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
680 "Parse output of \"cvs status\" command in the current buffer.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
681 Set file properties accordingly. Unless FULL is t, parse only
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
682 essential information."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
683 (let (file status)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
684 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
685 (if (re-search-forward "^File: " nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
686 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
687 ((looking-at "no file") nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
688 ((re-search-forward "\\=\\([^ \t]+\\)" nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
689 (setq file (expand-file-name (match-string 1)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
690 (vc-file-setprop file 'vc-backend 'CVS)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
691 (if (not (re-search-forward "\\=[ \t]+Status: \\(.*\\)" nil t))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
692 (setq status "Unknown")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
693 (setq status (match-string 1)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
694 (if (and full
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
695 (re-search-forward
41707
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
696 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
697 \[\t ]+\\([0-9.]+\\)"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
698 nil t))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
699 (vc-file-setprop file 'vc-latest-version (match-string 2)))
41707
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
700 (vc-file-setprop
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
701 file 'vc-state
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
702 (cond
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
703 ((string-match "Up-to-date" status)
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
704 (vc-file-setprop file 'vc-checkout-time
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
705 (nth 5 (file-attributes file)))
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
706 'up-to-date)
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
707 ((string-match "Locally Modified" status) 'edited)
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
708 ((string-match "Needs Merge" status) 'needs-merge)
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
709 ((string-match "Needs \\(Checkout\\|Patch\\)" status) 'needs-patch)
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
710 (t 'edited))))))))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
711
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
712 (defun vc-cvs-dir-state-heuristic (dir)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
713 "Find the CVS state of all files in DIR, using only local information."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
714 (with-temp-buffer
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
715 (vc-insert-file (expand-file-name "CVS/Entries" dir))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
716 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
717 (while (not (eobp))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
718 (when (looking-at "/\\([^/]*\\)/")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
719 (let ((file (expand-file-name (match-string 1) dir)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
720 (unless (vc-file-getprop file 'vc-state)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
721 (vc-cvs-parse-entry file t))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
722 (forward-line 1))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
723
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
724 (defun vc-cvs-parse-entry (file &optional set-state)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
725 "Parse a line from CVS/Entries.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
726 Compare modification time to that of the FILE, set file properties
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
727 accordingly. However, `vc-state' is set only if optional arg SET-STATE
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
728 is non-nil."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
729 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
730 ;; entry for a "locally added" file (not yet committed)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
731 ((looking-at "/[^/]+/0/")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
732 (vc-file-setprop file 'vc-checkout-time 0)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
733 (vc-file-setprop file 'vc-workfile-version "0")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
734 (if set-state (vc-file-setprop file 'vc-state 'edited)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
735 ;; normal entry
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
736 ((looking-at
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
737 (concat "/[^/]+"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
738 ;; revision
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
739 "/\\([^/]*\\)"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
740 ;; timestamp
41520
143b4b27b6c9 (vc-cvs-parse-entry): Rewrite, comparing the string-
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40171
diff changeset
741 "/\\([^/]*\\)"))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
742 (vc-file-setprop file 'vc-workfile-version (match-string 1))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
743 ;; compare checkout time and modification time
41520
143b4b27b6c9 (vc-cvs-parse-entry): Rewrite, comparing the string-
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40171
diff changeset
744 (let ((mtime (nth 5 (file-attributes file)))
143b4b27b6c9 (vc-cvs-parse-entry): Rewrite, comparing the string-
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40171
diff changeset
745 (system-time-locale "C"))
143b4b27b6c9 (vc-cvs-parse-entry): Rewrite, comparing the string-
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40171
diff changeset
746 (cond ((equal (format-time-string "%c" mtime 'utc) (match-string 2))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
747 (vc-file-setprop file 'vc-checkout-time mtime)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
748 (if set-state (vc-file-setprop file 'vc-state 'up-to-date)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
749 (t
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
750 (vc-file-setprop file 'vc-checkout-time 0)
41520
143b4b27b6c9 (vc-cvs-parse-entry): Rewrite, comparing the string-
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40171
diff changeset
751 (if set-state (vc-file-setprop file 'vc-state 'edited))))))))
143b4b27b6c9 (vc-cvs-parse-entry): Rewrite, comparing the string-
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40171
diff changeset
752
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753 (provide 'vc-cvs)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 ;;; vc-cvs.el ends here