annotate lisp/vc-svn.el @ 54998:a9da0517d087

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Tue, 20 Apr 2004 07:15:39 +0000
parents 695cf19ef79e
children ae9b6f1e3bdf 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; vc-svn.el --- non-resident support for Subversion version-control
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
2
50999
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
3 ;; Copyright (C) 1995,98,99,2000,2001,02,2003 Free Software Foundation, Inc.
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
4
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
5 ;; Author: FSF (see vc.el for full credits)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Maintainer: Stefan Monnier <monnier@gnu.org>
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
9
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
13 ;; any later version.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
14
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
18 ;; GNU General Public License for more details.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
19
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
24
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
25 ;;; Commentary:
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 ;; This is preliminary support for Subversion (http://subversion.tigris.org/).
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 ;; It started as `sed s/cvs/svn/ vc.cvs.el' (from version 1.56)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 ;; and hasn't been completely fixed since.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 ;; Sync'd with Subversion's vc-svn.el as of revision 5801.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 ;;; Bugs:
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
35 ;; - VC-dired is (really) slow.
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 ;;; Code:
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 (eval-when-compile
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 (require 'vc))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43 ;;; Customization options
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 (defcustom vc-svn-global-switches nil
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 "*Global switches to pass to any SVN command."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 :type '(choice (const :tag "None" nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (string :tag "Argument String")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (repeat :tag "Argument List"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 :value ("")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 string))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 :version "21.4"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 :group 'vc)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (defcustom vc-svn-register-switches nil
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 "*Extra switches for registering a file into SVN.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 A string or list of strings passed to the checkin program by
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 \\[vc-register]."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 :type '(choice (const :tag "None" nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (string :tag "Argument String")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (repeat :tag "Argument List"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 :value ("")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 string))
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
65 :version "21.4"
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 :group 'vc)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67
52033
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
68 (defcustom vc-svn-diff-switches
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
69 t ;`svn' doesn't support common args like -c or -b.
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
70 "String or list of strings specifying extra switches for svn diff under VC.
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
71 If nil, use the value of `vc-diff-switches'.
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
72 If you want to force an empty list of arguments, use t."
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
73 :type '(choice (const :tag "Unspecified" nil)
9b5f3940a1ef (vc-svn-diff-switches): Don't default to vc-diff-switches.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 51732
diff changeset
74 (const :tag "None" t)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 (string :tag "Argument String")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76 (repeat :tag "Argument List"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 :value ("")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 string))
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
79 :version "21.4"
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 :group 'vc)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 (defcustom vc-svn-header (or (cdr (assoc 'SVN vc-header-alist)) '("\$Id\$"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 "*Header keywords to be inserted by `vc-insert-headers'."
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
84 :version "21.4"
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 :type '(repeat string)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 :group 'vc)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
88 (defconst vc-svn-use-edit nil
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
89 ;; Subversion does not provide this feature (yet).
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 "*Non-nil means to use `svn edit' to \"check out\" a file.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 This is only meaningful if you don't use the implicit checkout model
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 \(i.e. if you have $SVNREAD set)."
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
93 ;; :type 'boolean
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
94 ;; :version "21.4"
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
95 ;; :group 'vc
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
96 )
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 ;;; State-querying functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
101
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 ;;;###autoload (defun vc-svn-registered (f)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 ;;;###autoload (when (file-readable-p (expand-file-name
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104 ;;;###autoload ".svn/entries" (file-name-directory f)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 ;;;###autoload (load "vc-svn")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 ;;;###autoload (vc-svn-registered f)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107
50999
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
108 ;;;###autoload
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
109 (add-to-list 'completion-ignored-extensions ".svn/")
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
110
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 (defun vc-svn-registered (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 "Check if FILE is SVN registered."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 (when (file-readable-p (expand-file-name ".svn/entries"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 (file-name-directory file)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 (with-temp-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 (cd (file-name-directory file))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 (condition-case nil
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 (vc-svn-command t 0 file "status" "-v")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
119 ;; We can't find an `svn' executable. We could also deregister SVN.
50820
fc3f65557bc8 (vc-svn-registered): Missing paren.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50818
diff changeset
120 (file-error nil))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 (vc-svn-parse-status t)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 (eq 'SVN (vc-file-getprop file 'vc-backend)))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 (defun vc-svn-state (file &optional localp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 "SVN-specific version of `vc-state'."
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
126 (setq localp (or localp (vc-stay-local-p file)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 (with-temp-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 (cd (file-name-directory file))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 (vc-svn-command t 0 file "status" (if localp "-v" "-u"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 (vc-svn-parse-status localp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 (vc-file-getprop file 'vc-state)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 (defun vc-svn-state-heuristic (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 "SVN-specific state heuristic."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 (vc-svn-state file 'local))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 (defun vc-svn-dir-state (dir &optional localp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 "Find the SVN state of all files in DIR."
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
139 (setq localp (or localp (vc-stay-local-p dir)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140 (let ((default-directory dir))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 ;; Don't specify DIR in this command, the default-directory is
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 ;; enough. Otherwise it might fail with remote repositories.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 (with-temp-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 (vc-svn-command t 0 nil "status" (if localp "-v" "-u"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 (vc-svn-parse-status localp))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 (defun vc-svn-workfile-version (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 "SVN-specific version of `vc-workfile-version'."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 ;; There is no need to consult RCS headers under SVN, because we
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 ;; get the workfile version for free when we recognize that a file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 ;; is registered in SVN.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 (vc-svn-registered file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 (vc-file-getprop file 'vc-workfile-version))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 (defun vc-svn-checkout-model (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 "SVN-specific version of `vc-checkout-model'."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 ;; It looks like Subversion has no equivalent of CVSREAD.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 'implicit)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
160 ;; vc-svn-mode-line-string doesn't exist because the default implementation
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
161 ;; works just fine.
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
162
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 (defun vc-svn-dired-state-info (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 "SVN-specific version of `vc-dired-state-info'."
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
165 (let ((svn-state (vc-state file)))
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
166 (cond ((eq svn-state 'edited)
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
167 (if (equal (vc-workfile-version file) "0")
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
168 "(added)" "(modified)"))
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
169 ((eq svn-state 'needs-patch) "(patch)")
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
170 ((eq svn-state 'needs-merge) "(merge)"))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 ;;; State-changing functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 (defun vc-svn-register (file &optional rev comment)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 "Register FILE into the SVN version-control system.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 COMMENT can be used to provide an initial description of FILE.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181 `vc-register-switches' and `vc-svn-register-switches' are passed to
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 the SVN command (in that order)."
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
183 (apply 'vc-svn-command nil 0 file "add" (vc-switches 'SVN 'register)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 (defun vc-svn-responsible-p (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 "Return non-nil if SVN thinks it is responsible for FILE."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
187 (file-directory-p (expand-file-name ".svn"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
188 (if (file-directory-p file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 (file-name-directory file)))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 (defalias 'vc-svn-could-register 'vc-svn-responsible-p
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 "Return non-nil if FILE could be registered in SVN.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 This is only possible if SVN is responsible for FILE's directory.")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 (defun vc-svn-checkin (file rev comment)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 "SVN-specific version of `vc-backend-checkin'."
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
198 (let ((status (apply 'vc-svn-command nil 1 file
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
199 "ci" (list* "-m" comment (vc-switches 'SVN 'checkin)))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200 (set-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 (unless (equal status 0)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 ;; Check checkin problem.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 (cond
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
205 ((search-forward "Transaction is out of date" nil t)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 (vc-file-setprop file 'vc-state 'needs-merge)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207 (error (substitute-command-keys
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 (concat "Up-to-date check failed: "
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 "type \\[vc-next-action] to merge in changes"))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 (t
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 (pop-to-buffer (current-buffer))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 (shrink-window-if-larger-than-buffer)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 (error "Check-in failed"))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 ;; Update file properties
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 ;; (vc-file-setprop
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 ;; file 'vc-workfile-version
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 ;; (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 ))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 (defun vc-svn-find-version (file rev buffer)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 (apply 'vc-svn-command
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 buffer 0 file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 "cat"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 (and rev (not (string= rev ""))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 (concat "-r" rev))
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
227 (vc-switches 'SVN 'checkout)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229 (defun vc-svn-checkout (file &optional editable rev)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 (message "Checking out %s..." file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 (with-current-buffer (or (get-file-buffer file) (current-buffer))
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
232 (vc-call update file editable rev (vc-switches 'SVN 'checkout)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 (vc-mode-line file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 (message "Checking out %s...done" file))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236 (defun vc-svn-update (file editable rev switches)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 (if (and (file-exists-p file) (not rev))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 ;; If no revision was specified, just make the file writable
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 ;; if necessary (using `svn-edit' if requested).
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 (and editable (not (eq (vc-svn-checkout-model file) 'implicit))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 (if vc-svn-use-edit
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 (vc-svn-command nil 0 file "edit")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 (set-file-modes file (logior (file-modes file) 128))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 (if (equal file buffer-file-name) (toggle-read-only -1))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 ;; Check out a particular version (or recreate the file).
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 (vc-file-setprop file 'vc-workfile-version nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 (apply 'vc-svn-command nil 0 file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 "update"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 ;; default for verbose checkout: clear the sticky tag so
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 ;; that the actual update will get the head of the trunk
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
251 (cond
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
252 ((null rev) "-rBASE")
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
253 ((or (eq rev t) (equal rev "")) nil)
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
254 (t (concat "-r" rev)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 switches)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256
50999
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
257 (defun vc-svn-delete-file (file)
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
258 (vc-svn-command nil 0 file "remove"))
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
259
50922
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
260 (defun vc-svn-rename-file (old new)
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
261 (vc-svn-command nil 0 new "move" (file-relative-name old)))
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
262
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 (defun vc-svn-revert (file &optional contents-done)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 "Revert FILE to the version it was based on."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 (unless contents-done
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
266 (vc-svn-command nil 0 file "revert"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267 (unless (eq (vc-checkout-model file) 'implicit)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 (if vc-svn-use-edit
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 (vc-svn-command nil 0 file "unedit")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 ;; Make the file read-only by switching off all w-bits
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
271 (set-file-modes file (logand (file-modes file) 3950)))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 (defun vc-svn-merge (file first-version &optional second-version)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 "Merge changes into current working copy of FILE.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 The changes are between FIRST-VERSION and SECOND-VERSION."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (vc-svn-command nil 0 file
50822
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
277 "merge"
50823
83c8010f1eb2 (vc-svn-merge): Forgot quotes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50822
diff changeset
278 "-r" (if second-version
50822
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
279 (concat first-version ":" second-version)
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
280 first-version))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 (vc-file-setprop file 'vc-state 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 (with-current-buffer (get-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
283 (goto-char (point-min))
50822
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
284 (if (looking-at "C ")
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
285 1 ; signal conflict
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 0))) ; signal success
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 (defun vc-svn-merge-news (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
289 "Merge in any new changes made to FILE."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
290 (message "Merging changes into %s..." file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
291 ;; (vc-file-setprop file 'vc-workfile-version nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
292 (vc-file-setprop file 'vc-checkout-time 0)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
293 (vc-svn-command nil 0 file "update")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 ;; Analyze the merge result reported by SVN, and set
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295 ;; file properties accordingly.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
296 (with-current-buffer (get-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
297 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
298 ;; get new workfile version
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
299 (if (re-search-forward
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
300 "^\\(Updated to\\|At\\) revision \\([0-9]+\\)" nil t)
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
301 (vc-file-setprop file 'vc-workfile-version (match-string 2))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 (vc-file-setprop file 'vc-workfile-version nil))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 ;; get file status
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
304 (goto-char (point-min))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 (prog1
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
306 (if (looking-at "At revision")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 0 ;; there were no news; indicate success
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 (if (re-search-forward
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
309 (concat "^\\([CGDU] \\)?"
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
310 (regexp-quote (file-name-nondirectory file)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
311 nil t)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 (cond
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
313 ;; Merge successful, we are in sync with repository now
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
314 ((string= (match-string 1) "U ")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
315 (vc-file-setprop file 'vc-state 'up-to-date)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
316 (vc-file-setprop file 'vc-checkout-time
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
317 (nth 5 (file-attributes file)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
318 0);; indicate success to the caller
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
319 ;; Merge successful, but our own changes are still in the file
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
320 ((string= (match-string 1) "G ")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 (vc-file-setprop file 'vc-state 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 0);; indicate success to the caller
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
323 ;; Conflicts detected!
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
324 (t
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 (vc-file-setprop file 'vc-state 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326 1);; signal the error to the caller
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327 )
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 (pop-to-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 (error "Couldn't analyze svn update result")))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 (message "Merging changes into %s...done" file))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
334 ;;; History functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 (defun vc-svn-print-log (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 "Get change log associated with FILE."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
339 (save-current-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
340 (vc-setup-buffer nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
341 (let ((inhibit-read-only t))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
343 ;; Add a line to tell log-view-mode what file this is.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 (insert "Working file: " (file-relative-name file) "\n"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
345 (vc-svn-command
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 t
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
347 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
348 file "log")))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
349
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350 (defun vc-svn-diff (file &optional oldvers newvers)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 "Get a difference report using SVN between two versions of FILE."
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
352 (if (string= (vc-workfile-version file) "0")
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
353 ;; This file is added but not yet committed; there is no master file.
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
354 (if (or oldvers newvers)
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
355 (error "No revisions of %s exist" file)
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
356 ;; We regard this as "changed".
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
357 ;; Diff it against /dev/null.
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
358 ;; Note: this is NOT a "svn diff".
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
359 (apply 'vc-do-command "*vc-diff*"
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
360 1 "diff" file
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
361 (append (vc-switches nil 'diff) '("/dev/null")))
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
362 ;; Even if it's empty, it's locally modified.
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
363 1)
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
364 (let* ((switches (vc-switches 'SVN 'diff))
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
365 (async (and (vc-stay-local-p file)
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
366 (or oldvers newvers) ; Svn diffs those locally.
50922
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
367 (fboundp 'start-process))))
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
368 (apply 'vc-svn-command "*vc-diff*"
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
369 (if async 'async 0)
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
370 file "diff"
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
371 (append
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
372 (when switches
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
373 (list "-x" (mapconcat 'identity switches " ")))
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
374 (when oldvers
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
375 (list "-r" (if newvers (concat oldvers ":" newvers)
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
376 oldvers)))))
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
377 (if async 1 ; async diff => pessimistic assumption
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
378 ;; For some reason `svn diff' does not return a useful
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
379 ;; status w.r.t whether the diff was empty or not.
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
380 (buffer-size (get-buffer "*vc-diff*"))))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 (defun vc-svn-diff-tree (dir &optional rev1 rev2)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
383 "Diff all files at and below DIR."
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
384 (vc-svn-diff (file-name-as-directory dir) rev1 rev2))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
385
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
386 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
387 ;;; Snapshot system
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
388 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
389
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
390 (defun vc-svn-create-snapshot (dir name branchp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
391 "Assign to DIR's current version a given NAME.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392 If BRANCHP is non-nil, the name is created as a branch (and the current
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
393 workspace is immediately moved to that new branch).
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
394 NAME is assumed to be a URL."
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
395 (vc-svn-command nil 0 dir "copy" name)
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
396 (when branchp (vc-svn-retrieve-snapshot dir name nil)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
397
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
398 (defun vc-svn-retrieve-snapshot (dir name update)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
399 "Retrieve a snapshot at and below DIR.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
400 NAME is the name of the snapshot; if it is empty, do a `svn update'.
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
401 If UPDATE is non-nil, then update (resynch) any affected buffers.
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
402 NAME is assumed to be a URL."
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
403 (vc-svn-command nil 0 dir "switch" name)
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
404 ;; FIXME: parse the output and obey `update'.
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
405 )
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
406
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
407 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
408 ;;; Miscellaneous
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
409 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
410
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
411 ;; Subversion makes backups for us, so don't bother.
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
412 ;; (defalias 'vc-svn-make-version-backups-p 'vc-stay-local-p
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
413 ;; "Return non-nil if version backups should be made for FILE.")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
414
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
415 (defun vc-svn-check-headers ()
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
416 "Check if the current file has any headers in it."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
417 (save-excursion
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
418 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
419 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
420 \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
421
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
422
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
423 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
424 ;;; Internal functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
425 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
426
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
427 (defun vc-svn-command (buffer okstatus file &rest flags)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
428 "A wrapper around `vc-do-command' for use in vc-svn.el.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
429 The difference to vc-do-command is that this function always invokes `svn',
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
430 and that it passes `vc-svn-global-switches' to it before FLAGS."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
431 (apply 'vc-do-command buffer okstatus "svn" file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432 (if (stringp vc-svn-global-switches)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 (cons vc-svn-global-switches flags)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
434 (append vc-svn-global-switches
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
435 flags))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
436
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
437 (defun vc-svn-repository-hostname (dirname)
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
438 (with-temp-buffer
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
439 (let ((coding-system-for-read
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
440 (or file-name-coding-system
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
441 default-file-name-coding-system)))
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
442 (vc-insert-file (expand-file-name ".svn/entries" dirname)))
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
443 (goto-char (point-min))
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
444 (when (re-search-forward
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
445 (concat "name=\"svn:this_dir\"[\n\t ]*"
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
446 "\\([-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
447 "url=\"\\([^\"]+\\)\"") nil t)
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
448 (match-string 2))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 (defun vc-svn-parse-status (localp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 "Parse output of \"svn status\" command in the current buffer.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
452 Set file properties accordingly. Unless FULL is t, parse only
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
453 essential information."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
454 (let (file status)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
455 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
456 (while (re-search-forward
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
457 "^[ ADMCI?!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 (setq file (expand-file-name
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 (buffer-substring (point) (line-end-position))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 (setq status (char-after (line-beginning-position)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461 (unless (eq status ??)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462 (vc-file-setprop file 'vc-backend 'SVN)
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
463 ;; Use the last-modified revision, so that searching in vc-print-log
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
464 ;; output works.
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
465 (vc-file-setprop file 'vc-workfile-version (match-string 3))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 (vc-file-setprop
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 file 'vc-state
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
468 (cond
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 ((eq status ?\ )
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 (if (eq (char-after (match-beginning 1)) ?*)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
471 'needs-patch
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472 (vc-file-setprop file 'vc-checkout-time
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473 (nth 5 (file-attributes file)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 'up-to-date))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 ((eq status ?A)
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
476 ;; If the file was actually copied, (match-string 2) is "-".
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
477 (vc-file-setprop file 'vc-workfile-version "0")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (vc-file-setprop file 'vc-checkout-time 0)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
479 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
480 ((memq status '(?M ?C))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
481 (if (eq (char-after (match-beginning 1)) ?*)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
482 'needs-merge
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 'edited))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 (t 'edited)))))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 (defun vc-svn-dir-state-heuristic (dir)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487 "Find the SVN state of all files in DIR, using only local information."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
488 (vc-svn-dir-state dir 'local))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
489
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
490 (defun vc-svn-valid-symbolic-tag-name-p (tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
491 "Return non-nil if TAG is a valid symbolic tag name."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
492 ;; According to the SVN manual, a valid symbolic tag must start with
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
493 ;; an uppercase or lowercase letter and can contain uppercase and
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
494 ;; lowercase letters, digits, `-', and `_'.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
495 (and (string-match "^[a-zA-Z]" tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
496 (not (string-match "[^a-z0-9A-Z-_]" tag))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
497
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
498 (defun vc-svn-valid-version-number-p (tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
499 "Return non-nil if TAG is a valid version number."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
500 (and (string-match "^[0-9]" tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
501 (not (string-match "[^0-9]" tag))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
502
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
503 (provide 'vc-svn)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
504
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52033
diff changeset
505 ;;; arch-tag: 02f10c68-2b4d-453a-90fc-1eee6cfb268d
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506 ;;; vc-svn.el ends here