annotate lisp/vc-cvs.el @ 50531:42265835091c

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Thu, 10 Apr 2003 12:02:31 +0000
parents e499daf7fb22
children 4b6925d144de
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
47840
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
3 ;; Copyright (C) 1995,98,99,2000,2001,2002 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
50453
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
8 ;; $Id: vc-cvs.el,v 1.52 2003/03/27 22:38:38 schwab 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
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
38 (defcustom vc-cvs-global-switches nil
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
39 "*Global switches to pass to any CVS command."
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
40 :type '(choice (const :tag "None" nil)
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
41 (string :tag "Argument String")
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
42 (repeat :tag "Argument List"
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
43 :value ("")
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
44 string))
45255
20c79f08a7da Change all post-21.1 :version attributes to 21.4.
Eli Zaretskii <eliz@gnu.org>
parents: 44462
diff changeset
45 :version "21.4"
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
46 :group 'vc)
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
47
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 (defcustom vc-cvs-register-switches nil
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 "*Extra switches for registering a file into CVS.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 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
51 \\[vc-register]."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 :type '(choice (const :tag "None" nil)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (string :tag "Argument String")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 (repeat :tag "Argument List"
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 :value ("")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 string))
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
57 :version "21.1"
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 :group 'vc)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59
35821
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
60 (defcustom vc-cvs-diff-switches nil
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
61 "*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
62 :type '(choice (const :tag "None" nil)
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
63 (string :tag "Argument String")
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
64 (repeat :tag "Argument List"
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
65 :value ("")
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
66 string))
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
67 :version "21.1"
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
68 :group 'vc)
6b1ff979e045 (vc-cvs-diff-switches): New customization option.
André Spiegel <spiegel@gnu.org>
parents: 35702
diff changeset
69
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 (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
71 "*Header keywords to be inserted by `vc-insert-headers'."
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
72 :version "21.1"
35177
f7c511463b68 (vc-cvs-header): Fix :type.
Dave Love <fx@gnu.org>
parents: 35132
diff changeset
73 :type '(repeat string)
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 :group 'vc)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (defcustom vc-cvs-use-edit t
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 "*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
78 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
79 \(i.e. if you have $CVSREAD set)."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 :type 'boolean
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
81 :version "21.1"
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 :group 'vc)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 (defcustom vc-cvs-stay-local t
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
85 "*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
86 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
87 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
88 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
89 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
90 :type '(choice (const :tag "Always stay local" t)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (string :tag "Host regexp")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (const :tag "Don't stay local" nil))
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
93 :version "21.1"
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 :group 'vc)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
96 (defcustom vc-cvs-sticky-date-format-string "%c"
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
97 "*Format string for mode-line display of sticky date.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
98 Format is according to `format-time-string'. Only used if
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
99 `vc-cvs-sticky-tag-display' is t."
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
100 :type '(string)
45255
20c79f08a7da Change all post-21.1 :version attributes to 21.4.
Eli Zaretskii <eliz@gnu.org>
parents: 44462
diff changeset
101 :version "21.4"
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
102 :group 'vc)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
103
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
104 (defcustom vc-cvs-sticky-tag-display t
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
105 "*Specify the mode-line display of sticky tags.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
106 Value t means default display, nil means no display at all. If the
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
107 value is a function or macro, it is called with the sticky tag and
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
108 its' type as parameters, in that order. TYPE can have three different
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
109 values: `symbolic-name' (TAG is a string), `revision-number' (TAG is a
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
110 string) and `date' (TAG is a date as returned by `encode-time'). The
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
111 return value of the function or macro will be displayed as a string.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
112
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
113 Here's an example that will display the formatted date for sticky
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
114 dates and the word \"Sticky\" for sticky tag names and revisions.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
115
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
116 (lambda (tag type)
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
117 (cond ((eq type 'date) (format-time-string
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
118 vc-cvs-sticky-date-format-string tag))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
119 ((eq type 'revision-number) \"Sticky\")
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
120 ((eq type 'symbolic-name) \"Sticky\")))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
121
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
122 Here's an example that will abbreviate to the first character only,
47917
ca7641fe56ba (vc-cvs-sticky-tag-display): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 47840
diff changeset
123 any text before the first occurrence of `-' for sticky symbolic tags.
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
124 If the sticky tag is a revision number, the word \"Sticky\" is
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
125 displayed. Date and time is displayed for sticky dates.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
126
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
127 (lambda (tag type)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
128 (cond ((eq type 'date) (format-time-string \"%Y%m%d %H:%M\" tag))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
129 ((eq type 'revision-number) \"Sticky\")
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
130 ((eq type 'symbolic-name)
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
131 (condition-case nil
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
132 (progn
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
133 (string-match \"\\\\([^-]*\\\\)\\\\(.*\\\\)\" tag)
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
134 (concat (substring (match-string 1 tag) 0 1) \":\"
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
135 (substring (match-string 2 tag) 1 nil)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
136 (error tag))))) ; Fall-back to given tag name.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
137
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
138 See also variable `vc-cvs-sticky-date-format-string'."
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
139 :type '(choice boolean function)
45255
20c79f08a7da Change all post-21.1 :version attributes to 21.4.
Eli Zaretskii <eliz@gnu.org>
parents: 44462
diff changeset
140 :version "21.4"
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
141 :group 'vc)
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
142
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
143 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
144 ;;; Internal variables
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
145 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
146
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
147 (defvar vc-cvs-local-month-numbers
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
148 '(("Jan" . 1) ("Feb" . 2) ("Mar" . 3) ("Apr" . 4)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
149 ("May" . 5) ("Jun" . 6) ("Jul" . 7) ("Aug" . 8)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
150 ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
151 "Local association list of month numbers.")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
152
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
153
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
154 ;;;
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
155 ;;; State-querying functions
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
156 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
157
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 ;;;###autoload (defun vc-cvs-registered (f)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 ;;;###autoload (when (file-readable-p (expand-file-name
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 ;;;###autoload "CVS/Entries" (file-name-directory f)))
47811
8b1c72f30fea (vc-cvs-registered): In the autoload version use load instead of
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47807
diff changeset
161 ;;;###autoload (load "vc-cvs")
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 ;;;###autoload (vc-cvs-registered f)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 (defun vc-cvs-registered (file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 "Check if FILE is CVS registered."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (let ((dirname (or (file-name-directory file) ""))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (basename (file-name-nondirectory file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 ;; 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
169 (case-fold-search nil))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 (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
171 (with-temp-buffer
50453
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
172 (vc-cvs-get-entries dirname)
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (goto-char (point-min))
31475
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
174 (cond
b25e22223eb9 DOc fixes.
Dave Love <fx@gnu.org>
parents: 31404
diff changeset
175 ((re-search-forward
44104
985526b08270 (vc-cvs-registered, vc-cvs-dir-state-heuristic):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44005
diff changeset
176 ;; CVS-removed files are not taken under VC control.
985526b08270 (vc-cvs-registered, vc-cvs-dir-state-heuristic):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44005
diff changeset
177 (concat "^/" (regexp-quote basename) "/[^/-]") nil t)
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 (beginning-of-line)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (vc-cvs-parse-entry file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 t)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 (t nil)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 nil)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 (defun vc-cvs-state (file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 "CVS-specific version of `vc-state'."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 (if (vc-cvs-stay-local-p file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 (let ((state (vc-file-getprop file 'vc-state)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 ;; 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
189 ;; 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
190 (if (memq state '(up-to-date edited))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (vc-cvs-state-heuristic file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 state))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 (with-temp-buffer
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 (cd (file-name-directory file))
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
195 (vc-cvs-command t 0 file "status")
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 (vc-cvs-parse-status t))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (defun vc-cvs-state-heuristic (file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 "CVS-specific state heuristic."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 ;; 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
201 ;; Otherwise consider it `edited'.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (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
203 (lastmod (nth 5 (file-attributes file))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 (if (equal checkout-time lastmod)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 'up-to-date
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 'edited)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
208 (defun vc-cvs-dir-state (dir)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
209 "Find the CVS state of all files in DIR."
49822
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
210 ;; if DIR is not under CVS control, don't do anything
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
211 (if (file-readable-p (expand-file-name "CVS/Entries" dir))
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
212 (if (vc-cvs-stay-local-p dir)
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
213 (vc-cvs-dir-state-heuristic dir)
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
214 (let ((default-directory dir))
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
215 ;; Don't specify DIR in this command, the default-directory is
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
216 ;; enough. Otherwise it might fail with remote repositories.
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
217 (with-temp-buffer
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
218 (vc-do-command t 0 "cvs" nil "status" "-l")
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
219 (goto-char (point-min))
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
220 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
221 (narrow-to-region (match-beginning 0) (match-end 0))
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
222 (vc-cvs-parse-status)
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
223 (goto-char (point-max))
02529e3b1f2c (vc-cvs-dir-state): Protect against DIR not being under CVS control.
André Spiegel <spiegel@gnu.org>
parents: 48965
diff changeset
224 (widen)))))))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
225
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
226 (defun vc-cvs-workfile-version (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
227 "CVS-specific version of `vc-workfile-version'."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
228 ;; There is no need to consult RCS headers under CVS, because we
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
229 ;; get the workfile version for free when we recognize that a file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
230 ;; is registered in CVS.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
231 (vc-cvs-registered file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
232 (vc-file-getprop file 'vc-workfile-version))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
233
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
234 (defun vc-cvs-checkout-model (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
235 "CVS-specific version of `vc-checkout-model'."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
236 (if (or (getenv "CVSREAD")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
237 ;; If the file is not writable (despite CVSREAD being
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
238 ;; undefined), this is probably because the file is being
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
239 ;; "watched" by other developers.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
240 ;; (If vc-mistrust-permissions was t, we actually shouldn't
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
241 ;; 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
242 ;; at the moment (version 1.9).)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
243 (string-match "r-..-..-." (nth 8 (file-attributes file))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
244 'announce
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
245 'implicit))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
246
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
247 (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
248 "Return string for placement into the modeline for FILE.
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
249 Compared to the default implementation, this function does two things:
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
250 Handle the special case of a CVS file that is added but not yet
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
251 committed and support display of sticky tags."
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
252 (let* ((state (vc-state file))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
253 (rev (vc-workfile-version file))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
254 (sticky-tag (vc-file-getprop file 'vc-cvs-sticky-tag))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
255 (sticky-tag-printable (and sticky-tag
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
256 (not (string= sticky-tag ""))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
257 (concat "[" sticky-tag "]"))))
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
258 (cond ((string= rev "0")
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
259 ;; 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
260 "CVS @@")
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
261 ((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
262 (eq state 'needs-patch))
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
263 (concat "CVS-" rev sticky-tag-printable))
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
264 ((stringp state)
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
265 (concat "CVS:" state ":" rev sticky-tag-printable))
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
266 (t
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
267 ;; 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
268 ;; 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
269 ;; for 'needs-patch and 'needs-merge.
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
270 (concat "CVS:" rev sticky-tag-printable)))))
31404
f2ab9420390f 2000-09-05 Stefan Monnier <monnier@cs.yale.edu>
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 31384
diff changeset
271
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
272 (defun vc-cvs-dired-state-info (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
273 "CVS-specific version of `vc-dired-state-info'."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
274 (let* ((cvs-state (vc-state file))
38288
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
275 (state (cond ((eq cvs-state 'edited) "modified")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
276 ((eq cvs-state 'needs-patch) "patch")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
277 ((eq cvs-state 'needs-merge) "merge")
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
278 ;; 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
279 ((eq cvs-state 'unlocked-changes) "conflict")
6934c28c6bc5 (vc-cvs-stay-local): doc fix.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37358
diff changeset
280 ((eq cvs-state 'locally-added) "added")
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
281 )))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
282 (if state (concat "(" state ")"))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
284
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
285 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
286 ;;; State-changing functions
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
287 ;;;
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
289 (defun vc-cvs-register (file &optional rev comment)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
290 "Register FILE into the CVS version-control system.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
291 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
292
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
293 `vc-register-switches' and `vc-cvs-register-switches' are passed to
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
294 the CVS command (in that order)."
44005
0d10b436b5d5 (vc-cvs-register): Fix handling of vc-[cvs-]register-switches.
André Spiegel <spiegel@gnu.org>
parents: 43727
diff changeset
295 (let ((switches (append
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
296 (if (stringp vc-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
297 (list vc-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
298 vc-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
299 (if (stringp vc-cvs-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
300 (list vc-cvs-register-switches)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
301 vc-cvs-register-switches))))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
302
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
303 (apply 'vc-cvs-command nil 0 file
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
304 "add"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
305 (and comment (string-match "[^\t\n ]" comment)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
306 (concat "-m" comment))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
307 switches)))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
309 (defun vc-cvs-responsible-p (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
310 "Return non-nil if CVS thinks it is responsible for FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
311 (file-directory-p (expand-file-name "CVS"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
312 (if (file-directory-p file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
313 file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
314 (file-name-directory file)))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
316 (defun vc-cvs-could-register (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
317 "Return non-nil if FILE could be registered in CVS.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
318 This is only possible if CVS is responsible for FILE's directory."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
319 (vc-cvs-responsible-p file))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (defun vc-cvs-checkin (file rev comment)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 "CVS-specific version of `vc-backend-checkin'."
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 (let ((switches (if (stringp vc-checkin-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (list vc-checkin-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 vc-checkin-switches))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 status)
44462
6eb10924e77f (vc-cvs-valid-version-number-p): New function.
Sam Steingold <sds@gnu.org>
parents: 44436
diff changeset
327 (if (or (not rev) (vc-cvs-valid-version-number-p rev))
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
328 (setq status (apply 'vc-cvs-command nil 1 file
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
329 "ci" (if rev (concat "-r" rev))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
330 (concat "-m" comment)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
331 switches))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
332 (if (not (vc-cvs-valid-symbolic-tag-name-p rev))
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
333 (error "%s is not a valid symbolic tag name" rev)
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
334 ;; If the input revison is a valid symbolic tag name, we create it
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
335 ;; as a branch, commit and switch to it.
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
336 (apply 'vc-cvs-command nil 0 file "tag" "-b" (list rev))
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
337 (apply 'vc-cvs-command nil 0 file "update" "-r" (list rev))
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
338 (setq status (apply 'vc-cvs-command nil 1 file
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
339 "ci"
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
340 (concat "-m" comment)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
341 switches))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
342 (vc-file-setprop file 'vc-cvs-sticky-tag rev)))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (set-buffer "*vc*")
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 (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
345 (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
346 ;; Check checkin problem.
3c95af2888f6 (vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents: 32747
diff changeset
347 (cond
3c95af2888f6 (vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents: 32747
diff changeset
348 ((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
349 (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
350 (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
351 (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
352 "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
353 (t
3c95af2888f6 (vc-cvs-checkin): Check both status and error message after command.
André Spiegel <spiegel@gnu.org>
parents: 32747
diff changeset
354 (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
355 (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
356 (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
357 (error "Check-in failed"))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 ;; Update file properties
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (vc-file-setprop
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 file 'vc-workfile-version
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (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
362 ;; 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
363 ;; 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
364 ;; 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
365 ;; vc-cvs-checkout-model).
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (vc-file-setprop file 'vc-checkout-model nil)
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
367
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
368 ;; if this was an explicit check-in (does not include creation of
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
369 ;; a branch), remove the sticky tag.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
370 (if (and rev (not (vc-cvs-valid-symbolic-tag-name-p rev)))
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
371 (vc-cvs-command nil 0 file "update" "-A"))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372
47799
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
373 (defun vc-cvs-find-version (file rev buffer)
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
374 (apply 'vc-cvs-command
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
375 buffer 0 file
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
376 "-Q" ; suppress diagnostic output
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
377 "update"
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
378 (and rev (not (string= rev ""))
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
379 (concat "-r" rev))
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
380 "-p"
47807
b5920ffc1070 (vc-cvs-find-version): Fix vc-checkout-switches use.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47799
diff changeset
381 (if (stringp vc-checkout-switches)
b5920ffc1070 (vc-cvs-find-version): Fix vc-checkout-switches use.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47799
diff changeset
382 (list vc-checkout-switches)
b5920ffc1070 (vc-cvs-find-version): Fix vc-checkout-switches use.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47799
diff changeset
383 vc-checkout-switches)))
47799
0d2f83a91144 (vc-cvs-find-version): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47758
diff changeset
384
35132
78bce41f17c5 (vc-cvs-latest-on-branch-p): Removed.
André Spiegel <spiegel@gnu.org>
parents: 33637
diff changeset
385 (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
386 "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
387 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
388 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
389 (let ((filename (or workfile file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (file-buffer (get-file-buffer file))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (message "Checking out %s..." filename)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 (save-excursion
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 ;; 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
395 (if file-buffer (set-buffer file-buffer))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (setq switches (if (stringp vc-checkout-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (list vc-checkout-switches)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 vc-checkout-switches))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 ;; Save this buffer's default-directory
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ;; 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
401 ;; in the same buffer it was saved in.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 (let ((default-directory default-directory))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 (save-excursion
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 ;; 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
405 ;; the file in the right place.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (setq default-directory (file-name-directory filename))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (if workfile
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
408 (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
409 (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
410 (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
411 (when backup-name
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
412 (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
413 '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
414 (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
415 (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
416 (logior (file-modes filename) 128))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (unwind-protect
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (progn
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (let ((coding-system-for-read 'no-conversion)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (coding-system-for-write 'no-conversion))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (with-temp-file filename
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
422 (apply 'vc-cvs-command
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
423 (current-buffer) 0 file
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 "-Q" ; suppress diagnostic output
43727
1163adb21e5d (vc-cvs-diff-tree): Fix typo in parameter names.
André Spiegel <spiegel@gnu.org>
parents: 43533
diff changeset
425 "update"
48965
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
426 (and (stringp rev)
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
427 (not (string= rev ""))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (concat "-r" rev))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 "-p"
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 switches)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 (setq failed nil))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
432 (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
433 (if backup-name
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
434 (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
435 '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
436 (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
437 (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
438 (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
439 (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
440 (delete-file backup-name)))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (if (and (file-exists-p file) (not rev))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 ;; 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
443 ;; if necessary (using `cvs-edit' if requested).
48965
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
444 (and editable (not (eq (vc-cvs-checkout-model file) 'implicit))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
445 (if vc-cvs-use-edit
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
446 (vc-cvs-command nil 0 file "edit")
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
447 (set-file-modes file (logior (file-modes file) 128))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
448 (if file-buffer (toggle-read-only -1))))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
449 ;; Check out a particular version (or recreate the file).
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
450 (vc-file-setprop file 'vc-workfile-version nil)
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
451 (apply 'vc-cvs-command nil 0 file
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
452 (and editable
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
453 (or (not (file-exists-p file))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
454 (not (eq (vc-cvs-checkout-model file)
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
455 'implicit)))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
456 "-w")
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
457 "update"
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
458 ;; default for verbose checkout: clear the sticky tag so
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
459 ;; that the actual update will get the head of the trunk
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
460 (if (or (not rev) (eq rev t) (string= rev ""))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
461 "-A"
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
462 (concat "-r" rev))
322a31d667aa (vc-cvs-checkout): Handle t argument for REV.
André Spiegel <spiegel@gnu.org>
parents: 47917
diff changeset
463 switches))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (vc-mode-line file)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (message "Checking out %s...done" filename)))))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466
39001
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
467 (defun vc-cvs-revert (file &optional contents-done)
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
468 "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
469 (unless contents-done
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
470 ;; 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
471 ;; 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
472 (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
473 (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
474 (if vc-cvs-use-edit
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
475 (vc-cvs-command nil 0 file "unedit")
39001
d13c2139752b (vc-*-revert-file): Handle new optional arg CONTENTS-DONE.
André Spiegel <spiegel@gnu.org>
parents: 38288
diff changeset
476 ;; 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
477 (set-file-modes file (logand (file-modes file) 3950)))))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
478
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
479 (defun vc-cvs-merge (file first-version &optional second-version)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
480 "Merge changes into current working copy of FILE.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
481 The changes are between FIRST-VERSION and SECOND-VERSION."
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
482 (vc-cvs-command nil 0 file
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
483 "update" "-kk"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
484 (concat "-j" first-version)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
485 (concat "-j" second-version))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
486 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
487 (save-excursion
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
488 (set-buffer (get-buffer "*vc*"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
489 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
490 (if (re-search-forward "conflicts during merge" nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
491 1 ; signal error
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
492 0))) ; signal success
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
493
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
494 (defun vc-cvs-merge-news (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
495 "Merge in any new changes made to FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
496 (message "Merging changes into %s..." file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
497 (save-excursion
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
498 ;; (vc-file-setprop file 'vc-workfile-version nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
499 (vc-file-setprop file 'vc-checkout-time 0)
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
500 (vc-cvs-command nil 0 file "update")
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
501 ;; Analyze the merge result reported by CVS, and set
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
502 ;; file properties accordingly.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
503 (set-buffer (get-buffer "*vc*"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
504 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
505 ;; get new workfile version
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
506 (if (re-search-forward (concat "^Merging differences between "
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
507 "[01234567890.]* and "
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
508 "\\([01234567890.]*\\) into")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
509 nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
510 (vc-file-setprop file 'vc-workfile-version (match-string 1))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
511 (vc-file-setprop file 'vc-workfile-version nil))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
512 ;; get file status
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
513 (prog1
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
514 (if (eq (buffer-size) 0)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
515 0 ;; there were no news; indicate success
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
516 (if (re-search-forward
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
517 (concat "^\\([CMUP] \\)?"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
518 (regexp-quote (file-name-nondirectory file))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
519 "\\( already contains the differences between \\)?")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
520 nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
521 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
522 ;; Merge successful, we are in sync with repository now
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
523 ((or (match-string 2)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
524 (string= (match-string 1) "U ")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
525 (string= (match-string 1) "P "))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
526 (vc-file-setprop file 'vc-state 'up-to-date)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
527 (vc-file-setprop file 'vc-checkout-time
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
528 (nth 5 (file-attributes file)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
529 0);; indicate success to the caller
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
530 ;; Merge successful, but our own changes are still in the file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
531 ((string= (match-string 1) "M ")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
532 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
533 0);; indicate success to the caller
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
534 ;; Conflicts detected!
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
535 (t
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
536 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
537 1);; signal the error to the caller
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
538 )
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
539 (pop-to-buffer "*vc*")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
540 (error "Couldn't analyze cvs update result")))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
541 (message "Merging changes into %s...done" file))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
542
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
543
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
544 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
545 ;;; History functions
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
546 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
547
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
548 (defun vc-cvs-print-log (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
549 "Get change log associated with FILE."
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
550 (vc-cvs-command
37358
ae55f4048b3b (vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents: 36711
diff changeset
551 nil
ae55f4048b3b (vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents: 36711
diff changeset
552 (if (and (vc-cvs-stay-local-p file) (fboundp 'start-process)) 'async 0)
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
553 file "log"))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
554
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
555 (defun vc-cvs-diff (file &optional oldvers newvers)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
556 "Get a difference report using CVS between two versions of FILE."
43533
d4dab5e8395f (vc-cvs-diff, vc-cvs-diff-tree): Use consistent parameter format for
André Spiegel <spiegel@gnu.org>
parents: 43447
diff changeset
557 (let (options status (diff-switches-list (vc-diff-switches-list 'CVS)))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
558 (if (string= (vc-workfile-version file) "0")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
559 ;; 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
560 (if (or oldvers newvers)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
561 (error "No revisions of %s exist" file)
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
562 ;; We regard this as "changed".
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
563 ;; Diff it against /dev/null.
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
564 ;; Note: this is NOT a "cvs diff".
36711
22fd463447c3 (vc-cvs-checkin): When removing the sticky tag, make output go to
André Spiegel <spiegel@gnu.org>
parents: 35839
diff changeset
565 (apply 'vc-do-command "*vc-diff*"
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
566 1 "diff" file
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
567 (append diff-switches-list '("/dev/null"))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
568 (setq status
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
569 (apply 'vc-cvs-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
570 (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
571 (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
572 'async
ae55f4048b3b (vc-cvs-print-log, vc-cvs-diff): Don't invoke CVS as
Eli Zaretskii <eliz@gnu.org>
parents: 36711
diff changeset
573 1)
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
574 file "diff"
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
575 (and oldvers (concat "-r" oldvers))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
576 (and newvers (concat "-r" newvers))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
577 diff-switches-list))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
578 (if (vc-cvs-stay-local-p file)
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
579 1 ;; async diff, pessimistic assumption
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
580 status))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
581
40125
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
582 (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
583 "Diff all files at and below DIR."
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
584 (with-current-buffer "*vc-diff*"
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
585 (setq default-directory dir)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
586 (if (vc-cvs-stay-local-p dir)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
587 ;; 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
588 (vc-file-tree-walk
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
589 dir
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
590 (lambda (f)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
591 (vc-exec-after
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
592 `(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
593 ;; possible optimization: fetch the state of all files
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
594 ;; 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
595 (unless (vc-up-to-date-p ',f)
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
596 (message "Looking at %s" ',f)
43727
1163adb21e5d (vc-cvs-diff-tree): Fix typo in parameter names.
André Spiegel <spiegel@gnu.org>
parents: 43533
diff changeset
597 (vc-diff-internal ',f ',rev1 ',rev2))))))
40125
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
598 ;; 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
599 (let ((coding-system-for-read
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
600 (or coding-system-for-read 'undecided)))
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
601 (apply 'vc-cvs-command "*vc-diff*" 1 nil "diff"
43727
1163adb21e5d (vc-cvs-diff-tree): Fix typo in parameter names.
André Spiegel <spiegel@gnu.org>
parents: 43533
diff changeset
602 (and rev1 (concat "-r" rev1))
1163adb21e5d (vc-cvs-diff-tree): Fix typo in parameter names.
André Spiegel <spiegel@gnu.org>
parents: 43533
diff changeset
603 (and rev2 (concat "-r" rev2))
43533
d4dab5e8395f (vc-cvs-diff, vc-cvs-diff-tree): Use consistent parameter format for
André Spiegel <spiegel@gnu.org>
parents: 43447
diff changeset
604 (vc-diff-switches-list 'CVS))))))
40125
b2e4b1a5315a (vc-cvs-diff-tree): New function.
André Spiegel <spiegel@gnu.org>
parents: 39001
diff changeset
605
33545
5411250e7971 (vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents: 32959
diff changeset
606 (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
607 "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
608 Optional arg VERSION is a version to annotate from."
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
609 (vc-cvs-command buffer 0 file "annotate" (if version
33545
5411250e7971 (vc-cvs-annotate-command): New optional arg VERSION. Use
André Spiegel <spiegel@gnu.org>
parents: 32959
diff changeset
610 (concat "-r" version))))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
612 (defun vc-cvs-annotate-current-time ()
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
613 "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
614 encoded as fractional days."
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
615 (vc-annotate-convert-time
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
616 (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
617
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
618 (defun vc-cvs-annotate-time ()
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
619 "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
620 systime, or nil if there is none."
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
621 (let ((time-stamp
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
622 "^\\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
623 (if (looking-at time-stamp)
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 (progn
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 (let* ((day (string-to-number (match-string 1)))
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
626 (month (cdr (assoc (match-string 2)
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
627 vc-cvs-local-month-numbers)))
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 (year-tmp (string-to-number (match-string 3)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 ;; Years 0..68 are 2000..2068.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 ;; Years 69..99 are 1969..1999.
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 (year (+ (cond ((> 69 year-tmp) 2000)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 ((> 100 year-tmp) 1900)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 (t 0))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 year-tmp)))
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 (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
636 (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
637 ;; 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
638 ;; 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
639 ;; 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
640 (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
641 (progn
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 (beginning-of-line nil)
40171
91eda91380cb New scaling algorithm for vc-annotate.
André Spiegel <spiegel@gnu.org>
parents: 40125
diff changeset
643 (vc-cvs-annotate-time))))))
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
644
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
645 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
646 ;;; Snapshot system
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
647 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
648
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
649 (defun vc-cvs-create-snapshot (dir name branchp)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
650 "Assign to DIR's current version a given NAME.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
651 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
652 workspace is immediately moved to that new branch)."
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
653 (vc-cvs-command nil 0 dir "tag" "-c" (if branchp "-b") name)
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
654 (when branchp (vc-cvs-command nil 0 dir "update" "-r" name)))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
655
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
656 (defun vc-cvs-retrieve-snapshot (dir name update)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
657 "Retrieve a snapshot at and below DIR.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
658 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
659 If UPDATE is non-nil, then update (resynch) any affected buffers."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
660 (with-current-buffer (get-buffer-create "*vc*")
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
661 (let ((default-directory dir)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
662 (sticky-tag))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
663 (erase-buffer)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
664 (if (or (not name) (string= name ""))
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
665 (vc-cvs-command t 0 nil "update")
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
666 (vc-cvs-command t 0 nil "update" "-r" name)
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
667 (setq sticky-tag name))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
668 (when update
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
669 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
670 (while (not (eobp))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
671 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
672 (let* ((file (expand-file-name (match-string 2) dir))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
673 (state (match-string 1))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
674 (buffer (find-buffer-visiting file)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
675 (when buffer
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
676 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
677 ((or (string= state "U")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
678 (string= state "P"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
679 (vc-file-setprop file 'vc-state 'up-to-date)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
680 (vc-file-setprop file 'vc-workfile-version nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
681 (vc-file-setprop file 'vc-checkout-time
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
682 (nth 5 (file-attributes file))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
683 ((or (string= state "M")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
684 (string= state "C"))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
685 (vc-file-setprop file 'vc-state 'edited)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
686 (vc-file-setprop file 'vc-workfile-version nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
687 (vc-file-setprop file 'vc-checkout-time 0)))
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
688 (vc-file-setprop file 'vc-cvs-sticky-tag sticky-tag)
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
689 (vc-resynch-buffer file t t))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
690 (forward-line 1))))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
691
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
692
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
693 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
694 ;;; Miscellaneous
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
695 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
696
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
697 (defun vc-cvs-make-version-backups-p (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
698 "Return non-nil if version backups should be made for FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
699 (vc-cvs-stay-local-p file))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
700
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
701 (defun vc-cvs-check-headers ()
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
702 "Check if the current file has any headers in it."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
703 (save-excursion
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
704 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
705 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
706 \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
707
35569
5cd8ebba5a94 doc&comment fix
Sam Steingold <sds@gnu.org>
parents: 35177
diff changeset
708
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
709 ;;;
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
710 ;;; Internal functions
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
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
713 (defun vc-cvs-command (buffer okstatus file &rest flags)
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
714 "A wrapper around `vc-do-command' for use in vc-cvs.el.
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
715 The difference to vc-do-command is that this function always invokes `cvs',
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
716 and that it passes `vc-cvs-global-switches' to it before FLAGS."
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
717 (apply 'vc-do-command buffer okstatus "cvs" file
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
718 (if (stringp vc-cvs-global-switches)
44197
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
719 (cons vc-cvs-global-switches flags)
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
720 (append vc-cvs-global-switches
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
721 flags))))
e255f8fa4f62 (vc-cvs-global-switches): New user option.
André Spiegel <spiegel@gnu.org>
parents: 44104
diff changeset
722
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
723 (defun vc-cvs-stay-local-p (file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
724 "Return non-nil if VC should stay local when handling FILE."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
725 (if vc-cvs-stay-local
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
726 (let* ((dirname (if (file-directory-p file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
727 (directory-file-name file)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
728 (file-name-directory file)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
729 (prop
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
730 (or (vc-file-getprop dirname 'vc-cvs-stay-local-p)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
731 (let ((rootname (expand-file-name "CVS/Root" dirname)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
732 (vc-file-setprop
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
733 dirname 'vc-cvs-stay-local-p
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
734 (when (file-readable-p rootname)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
735 (with-temp-buffer
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
736 (vc-insert-file rootname)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
737 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
738 (if (looking-at "\\([^:]*\\):")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
739 (if (not (stringp vc-cvs-stay-local))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
740 'yes
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
741 (let ((hostname (match-string 1)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
742 (if (string-match vc-cvs-stay-local hostname)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
743 'yes
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
744 'no)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
745 'no))))))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
746 (if (eq prop 'yes) t nil))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
747
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
748 (defun vc-cvs-parse-status (&optional full)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
749 "Parse output of \"cvs status\" command in the current buffer.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
750 Set file properties accordingly. Unless FULL is t, parse only
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
751 essential information."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
752 (let (file status)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
753 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
754 (if (re-search-forward "^File: " nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
755 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
756 ((looking-at "no file") nil)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
757 ((re-search-forward "\\=\\([^ \t]+\\)" nil t)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
758 (setq file (expand-file-name (match-string 1)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
759 (vc-file-setprop file 'vc-backend 'CVS)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
760 (if (not (re-search-forward "\\=[ \t]+Status: \\(.*\\)" nil t))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
761 (setq status "Unknown")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
762 (setq status (match-string 1)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
763 (if (and full
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
764 (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
765 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
766 \[\t ]+\\([0-9.]+\\)"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
767 nil t))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
768 (vc-file-setprop file 'vc-latest-version (match-string 2)))
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
769 (vc-file-setprop
41707
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
770 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
771 (cond
94df6eb103b3 (vc-cvs-parse-status): Store file state in property, don't just return
André Spiegel <spiegel@gnu.org>
parents: 41520
diff changeset
772 ((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
773 (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
774 (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
775 '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
776 ((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
777 ((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
778 ((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
779 (t 'edited))))))))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
780
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
781 (defun vc-cvs-dir-state-heuristic (dir)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
782 "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
783 (with-temp-buffer
50453
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
784 (vc-cvs-get-entries dir)
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
785 (goto-char (point-min))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
786 (while (not (eobp))
44104
985526b08270 (vc-cvs-registered, vc-cvs-dir-state-heuristic):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44005
diff changeset
787 ;; CVS-removed files are not taken under VC control.
985526b08270 (vc-cvs-registered, vc-cvs-dir-state-heuristic):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44005
diff changeset
788 (when (looking-at "/\\([^/]*\\)/[^/-]")
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
789 (let ((file (expand-file-name (match-string 1) dir)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
790 (unless (vc-file-getprop file 'vc-state)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
791 (vc-cvs-parse-entry file t))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
792 (forward-line 1))))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
793
50453
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
794 (defun vc-cvs-get-entries (dir)
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
795 "Insert the CVS/Entries file from below DIR into the current buffer.
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
796 This function ensures that the correct coding system is used for that,
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
797 which may not be the one that is used for the files' contents.
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
798 CVS/Entries should only be accessed through this function."
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
799 (let ((coding-system-for-read (or file-name-coding-system
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
800 default-file-name-coding-system)))
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
801 (vc-insert-file (expand-file-name "CVS/Entries" dir))))
e499daf7fb22 (vc-cvs-get-entries): New function that uses the right coding system for
André Spiegel <spiegel@gnu.org>
parents: 50321
diff changeset
802
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
803 (defun vc-cvs-valid-symbolic-tag-name-p (tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
804 "Return non-nil if TAG is a valid symbolic tag name."
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
805 ;; According to the CVS manual, a valid symbolic tag must start with
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
806 ;; an uppercase or lowercase letter and can contain uppercase and
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
807 ;; lowercase letters, digits, `-', and `_'.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
808 (and (string-match "^[a-zA-Z]" tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
809 (not (string-match "[^a-z0-9A-Z-_]" tag))))
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
810
44462
6eb10924e77f (vc-cvs-valid-version-number-p): New function.
Sam Steingold <sds@gnu.org>
parents: 44436
diff changeset
811 (defun vc-cvs-valid-version-number-p (tag)
6eb10924e77f (vc-cvs-valid-version-number-p): New function.
Sam Steingold <sds@gnu.org>
parents: 44436
diff changeset
812 "Return non-nil if TAG is a valid version number."
6eb10924e77f (vc-cvs-valid-version-number-p): New function.
Sam Steingold <sds@gnu.org>
parents: 44436
diff changeset
813 (and (string-match "^[0-9]" tag)
6eb10924e77f (vc-cvs-valid-version-number-p): New function.
Sam Steingold <sds@gnu.org>
parents: 44436
diff changeset
814 (not (string-match "[^0-9.]" tag))))
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
815
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
816 (defun vc-cvs-parse-sticky-tag (match-type match-tag)
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
817 "Parse and return the sticky tag as a string.
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
818 `match-data' is protected."
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
819 (let ((data (match-data))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
820 (tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
821 (type (cond ((string= match-type "D") 'date)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
822 ((string= match-type "T")
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
823 (if (vc-cvs-valid-symbolic-tag-name-p match-tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
824 'symbolic-name
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
825 'revision-number))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
826 (t nil))))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
827 (unwind-protect
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
828 (progn
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
829 (cond
46163
426c8cf1a3df Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 45255
diff changeset
830 ;; Sticky Date tag. Convert to a proper date value (`encode-time')
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
831 ((eq type 'date)
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
832 (string-match
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
833 "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)"
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
834 match-tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
835 (let* ((year-tmp (string-to-number (match-string 1 match-tag)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
836 (month (string-to-number (match-string 2 match-tag)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
837 (day (string-to-number (match-string 3 match-tag)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
838 (hour (string-to-number (match-string 4 match-tag)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
839 (min (string-to-number (match-string 5 match-tag)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
840 (sec (string-to-number (match-string 6 match-tag)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
841 ;; Years 0..68 are 2000..2068.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
842 ;; Years 69..99 are 1969..1999.
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
843 (year (+ (cond ((> 69 year-tmp) 2000)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
844 ((> 100 year-tmp) 1900)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
845 (t 0))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
846 year-tmp)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
847 (setq tag (encode-time sec min hour day month year))))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
848 ;; Sticky Tag name or revision number
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
849 ((eq type 'symbolic-name) (setq tag match-tag))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
850 ((eq type 'revision-number) (setq tag match-tag))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
851 ;; Default is no sticky tag at all
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
852 (t nil))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
853 (cond ((eq vc-cvs-sticky-tag-display nil) nil)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
854 ((eq vc-cvs-sticky-tag-display t)
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
855 (cond ((eq type 'date) (format-time-string
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
856 vc-cvs-sticky-date-format-string
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
857 tag))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
858 ((eq type 'symbolic-name) tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
859 ((eq type 'revision-number) tag)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
860 (t nil)))
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
861 ((functionp vc-cvs-sticky-tag-display)
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
862 (funcall vc-cvs-sticky-tag-display tag type))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
863 (t nil)))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
864
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
865 (set-match-data data))))
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
866
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
867 (defun vc-cvs-parse-entry (file &optional set-state)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
868 "Parse a line from CVS/Entries.
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
869 Compare modification time to that of the FILE, set file properties
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
870 accordingly. However, `vc-state' is set only if optional arg SET-STATE
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
871 is non-nil."
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
872 (cond
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
873 ;; entry for a "locally added" file (not yet committed)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
874 ((looking-at "/[^/]+/0/")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
875 (vc-file-setprop file 'vc-checkout-time 0)
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
876 (vc-file-setprop file 'vc-workfile-version "0")
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
877 (if set-state (vc-file-setprop file 'vc-state 'edited)))
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
878 ;; normal entry
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
879 ((looking-at
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
880 (concat "/[^/]+"
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
881 ;; revision
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
882 "/\\([^/]*\\)"
50321
17ff9d10125f (vc-cvs-parse-entry): Make sure a file with conflicts
Andreas Schwab <schwab@suse.de>
parents: 49822
diff changeset
883 ;; timestamp and optional conflict field
17ff9d10125f (vc-cvs-parse-entry): Make sure a file with conflicts
Andreas Schwab <schwab@suse.de>
parents: 49822
diff changeset
884 "/\\([^/]*\\)/"
43447
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
885 ;; options
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
886 "\\([^/]*\\)/"
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
887 ;; sticky tag
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
888 "\\(.\\|\\)" ;Sticky tag type (date or tag name, could be empty)
79cf46e34420 Patch by Martin.Lorentzson@telia.com.
André Spiegel <spiegel@gnu.org>
parents: 42657
diff changeset
889 "\\(.*\\)")) ;Sticky tag
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
890 (vc-file-setprop file 'vc-workfile-version (match-string 1))
44104
985526b08270 (vc-cvs-registered, vc-cvs-dir-state-heuristic):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44005
diff changeset
891 (vc-file-setprop file 'vc-cvs-sticky-tag
50321
17ff9d10125f (vc-cvs-parse-entry): Make sure a file with conflicts
Andreas Schwab <schwab@suse.de>
parents: 49822
diff changeset
892 (vc-cvs-parse-sticky-tag (match-string 4) (match-string 5)))
33560
da206bbad86b Functions reordered.
André Spiegel <spiegel@gnu.org>
parents: 33554
diff changeset
893 ;; compare checkout time and modification time
47819
677f4ca67bbe (vc-cvs-parse-entry): Parse the time stamp found in CVS/Entries,
André Spiegel <spiegel@gnu.org>
parents: 47811
diff changeset
894 (let ((mtime (nth 5 (file-attributes file))))
677f4ca67bbe (vc-cvs-parse-entry): Parse the time stamp found in CVS/Entries,
André Spiegel <spiegel@gnu.org>
parents: 47811
diff changeset
895 (require 'parse-time)
47840
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
896 (let ((parsed-time
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
897 (parse-time-string (concat (match-string 2) " +0000"))))
50321
17ff9d10125f (vc-cvs-parse-entry): Make sure a file with conflicts
Andreas Schwab <schwab@suse.de>
parents: 49822
diff changeset
898 (cond ((and (not (string-match "\\+" (match-string 2)))
17ff9d10125f (vc-cvs-parse-entry): Make sure a file with conflicts
Andreas Schwab <schwab@suse.de>
parents: 49822
diff changeset
899 (car parsed-time)
47840
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
900 (equal mtime (apply 'encode-time parsed-time)))
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
901 (vc-file-setprop file 'vc-checkout-time mtime)
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
902 (if set-state (vc-file-setprop file 'vc-state 'up-to-date)))
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
903 (t
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
904 (vc-file-setprop file 'vc-checkout-time 0)
868ca431eff1 (vc-cvs-parse-entry): Don't barf when an `Entries' files contains an
Miles Bader <miles@gnu.org>
parents: 47819
diff changeset
905 (if set-state (vc-file-setprop file 'vc-state 'edited)))))))))
44436
f9db51bb423b (vc-cvs-checkin): Pass the required argument to `error'.
Sam Steingold <sds@gnu.org>
parents: 44197
diff changeset
906
31384
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
907 (provide 'vc-cvs)
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
908
f6cb7dfe5e7c (vc-cvs-show-log-entry): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
909 ;;; vc-cvs.el ends here