annotate lisp/vc-svn.el @ 75230:b3af187429fb

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Sun, 14 Jan 2007 03:52:57 +0000
parents 299d3322c8be
children e52e99fc4ca5 dbe3f29e61d6
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
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67553
diff changeset
3 ;; Copyright (C) 2003, 2004, 2005, 2006 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
64091
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 59996
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
6fb026ad601f Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 59996
diff changeset
23 ;; Boston, MA 02110-1301, USA.
50818
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))
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59446
diff changeset
53 :version "22.1"
50818
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))
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59446
diff changeset
65 :version "22.1"
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))
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59446
diff changeset
79 :version "22.1"
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'."
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59446
diff changeset
84 :version "22.1"
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
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59446
diff changeset
94 ;; :version "22.1"
51732
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
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
98 (defvar vc-svn-admin-directory
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
99 (cond ((and (eq system-type 'windows-nt)
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
100 (getenv "SVN_ASP_DOT_NET_HACK"))
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
101 "_svn")
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
102 (t ".svn"))
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
103 "The name of the \".svn\" subdirectory or its equivalent.")
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
104
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
106 ;;; State-querying functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
109 ;;; vc-svn-admin-directory is generally not defined when the
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
110 ;;; autoloaded function is called.
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
111
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 ;;;###autoload (defun vc-svn-registered (f)
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
113 ;;;###autoload (let ((admin-dir (cond ((and (eq system-type 'windows-nt)
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
114 ;;;###autoload (getenv "SVN_ASP_DOT_NET_HACK"))
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
115 ;;;###autoload "_svn")
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
116 ;;;###autoload (t ".svn"))))
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
117 ;;;###autoload (when (file-readable-p (expand-file-name
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
118 ;;;###autoload (concat admin-dir "/entries")
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
119 ;;;###autoload (file-name-directory f)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
120 ;;;###autoload (load "vc-svn")
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
121 ;;;###autoload (vc-svn-registered f))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122
50999
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
123 ;;;###autoload
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
124 (add-to-list 'completion-ignored-extensions ".svn/")
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
125
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 (defun vc-svn-registered (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 "Check if FILE is SVN registered."
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
128 (when (file-readable-p (expand-file-name (concat vc-svn-admin-directory
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
129 "/entries")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130 (file-name-directory file)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 (with-temp-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132 (cd (file-name-directory file))
68651
3bd95f4f2941 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 67553
diff changeset
133 (let ((status
67553
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
134 (condition-case nil
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
135 ;; Ignore all errors.
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
136 (vc-svn-command t t file "status" "-v")
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
137 ;; Some problem happened. E.g. We can't find an `svn'
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
138 ;; executable. We used to only catch `file-error' but when
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
139 ;; the process is run on a remote host via Tramp, the error
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
140 ;; is only reported via the exit status which is turned into
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
141 ;; an `error' by vc-do-command.
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
142 (error nil))))
10707dfc70f3 (vc-svn-registered): Use it to avoid popping up a spurious
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 67547
diff changeset
143 (when (eq 0 status)
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
144 (vc-svn-parse-status file))))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 (defun vc-svn-state (file &optional localp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 "SVN-specific version of `vc-state'."
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
148 (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
149 (with-temp-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 (cd (file-name-directory file))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 (vc-svn-command t 0 file "status" (if localp "-v" "-u"))
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
152 (vc-svn-parse-status file)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 (defun vc-svn-state-heuristic (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 "SVN-specific state heuristic."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 (vc-svn-state file 'local))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 (defun vc-svn-dir-state (dir &optional localp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 "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
160 (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
161 (let ((default-directory dir))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 ;; 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
163 ;; enough. Otherwise it might fail with remote repositories.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164 (with-temp-buffer
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 (vc-svn-command t 0 nil "status" (if localp "-v" "-u"))
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
166 (vc-svn-parse-status))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 (defun vc-svn-workfile-version (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
169 "SVN-specific version of `vc-workfile-version'."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 ;; 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
171 ;; 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
172 ;; is registered in SVN.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 (vc-svn-registered file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 (vc-file-getprop file 'vc-workfile-version))
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 (defun vc-svn-checkout-model (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 "SVN-specific version of `vc-checkout-model'."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 ;; 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
179 'implicit)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180
51732
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
181 ;; 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
182 ;; works just fine.
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
183
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 (defun vc-svn-dired-state-info (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 "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
186 (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
187 (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
188 (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
189 "(added)" "(modified)"))
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
190 ((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
191 ((eq svn-state 'needs-merge) "(merge)"))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192
68653
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
193 (defun vc-svn-previous-version (file rev)
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
194 (let ((newrev (1- (string-to-number rev))))
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
195 (when (< 0 newrev)
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
196 (number-to-string newrev))))
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
197
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
198 (defun vc-svn-next-version (file rev)
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
199 (let ((newrev (1+ (string-to-number rev))))
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
200 ;; The "workfile version" is an uneasy conceptual fit under Subversion;
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
201 ;; we use it as the upper bound until a better idea comes along. If the
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
202 ;; workfile version W coincides with the tree's latest revision R, then
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
203 ;; this check prevents a "no such revision: R+1" error. Otherwise, it
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
204 ;; inhibits showing of W+1 through R, which could be considered anywhere
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
205 ;; from gracious to impolite.
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
206 (unless (< (string-to-number (vc-file-getprop file 'vc-workfile-version))
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
207 newrev)
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
208 (number-to-string newrev))))
61cc95860e05 (vc-svn-previous-version, vc-svn-next-version): New funcs.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 68651
diff changeset
209
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
212 ;;; State-changing functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
213 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 (defun vc-svn-register (file &optional rev comment)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
216 "Register FILE into the SVN version-control system.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 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
218
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 `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
220 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
221 (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
222
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 (defun vc-svn-responsible-p (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 "Return non-nil if SVN thinks it is responsible for FILE."
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
225 (file-directory-p (expand-file-name vc-svn-admin-directory
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 (if (file-directory-p file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 (file-name-directory file)))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 (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
231 "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
232 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
233
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 (defun vc-svn-checkin (file rev comment)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 "SVN-specific version of `vc-backend-checkin'."
55900
d8a2b8a11274 2004-06-03 Karl Fogel <kfogel@red-bean.com>
Karl Fogel <kfogel@red-bean.com>
parents: 55004
diff changeset
236 (let ((status (apply
d8a2b8a11274 2004-06-03 Karl Fogel <kfogel@red-bean.com>
Karl Fogel <kfogel@red-bean.com>
parents: 55004
diff changeset
237 'vc-svn-command nil 1 file "ci"
d8a2b8a11274 2004-06-03 Karl Fogel <kfogel@red-bean.com>
Karl Fogel <kfogel@red-bean.com>
parents: 55004
diff changeset
238 (nconc (list "-m" comment) (vc-switches 'SVN 'checkin)))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 (set-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 (unless (equal status 0)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 ;; Check checkin problem.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 (cond
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
244 ((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
245 (vc-file-setprop file 'vc-state 'needs-merge)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 (error (substitute-command-keys
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
247 (concat "Up-to-date check failed: "
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
248 "type \\[vc-next-action] to merge in changes"))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (t
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 (pop-to-buffer (current-buffer))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
252 (shrink-window-if-larger-than-buffer)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
253 (error "Check-in failed"))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
254 ;; Update file properties
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
255 ;; (vc-file-setprop
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
256 ;; file 'vc-workfile-version
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 ;; (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
258 ))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 (defun vc-svn-find-version (file rev buffer)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 (apply 'vc-svn-command
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 buffer 0 file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 "cat"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 (and rev (not (string= rev ""))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 (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
266 (vc-switches 'SVN 'checkout)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
267
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
268 (defun vc-svn-checkout (file &optional editable rev)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
269 (message "Checking out %s..." file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
270 (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
271 (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
272 (vc-mode-line file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273 (message "Checking out %s...done" file))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
275 (defun vc-svn-update (file editable rev switches)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
276 (if (and (file-exists-p file) (not rev))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
277 ;; 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
278 ;; if necessary (using `svn-edit' if requested).
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
279 (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
280 (if vc-svn-use-edit
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
281 (vc-svn-command nil 0 file "edit")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
282 (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
283 (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
284 ;; 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
285 (vc-file-setprop file 'vc-workfile-version nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
286 (apply 'vc-svn-command nil 0 file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
287 "update"
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
288 ;; 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
289 ;; 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
290 (cond
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
291 ((null rev) "-rBASE")
f43bd5204ab4 (vc-svn-use-edit): Make it into a const.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50999
diff changeset
292 ((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
293 (t (concat "-r" rev)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
294 switches)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
295
50999
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
296 (defun vc-svn-delete-file (file)
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
297 (vc-svn-command nil 0 file "remove"))
c09edac18f97 (completion-ignored-extensions): Add .svn.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50927
diff changeset
298
50922
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
299 (defun vc-svn-rename-file (old new)
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
300 (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
301
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
302 (defun vc-svn-revert (file &optional contents-done)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
303 "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
304 (unless contents-done
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
305 (vc-svn-command nil 0 file "revert"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
306 (unless (eq (vc-checkout-model file) 'implicit)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
307 (if vc-svn-use-edit
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
308 (vc-svn-command nil 0 file "unedit")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
309 ;; 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
310 (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
311
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
312 (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
313 "Merge changes into current working copy of FILE.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
314 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
315 (vc-svn-command nil 0 file
50822
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
316 "merge"
50823
83c8010f1eb2 (vc-svn-merge): Forgot quotes.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50822
diff changeset
317 "-r" (if second-version
50822
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
318 (concat first-version ":" second-version)
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
319 first-version))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
320 (vc-file-setprop file 'vc-state 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
321 (with-current-buffer (get-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
322 (goto-char (point-min))
50822
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
323 (if (looking-at "C ")
0be6233722ec (vc-svn-merge): First attempt.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50821
diff changeset
324 1 ; signal conflict
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
325 0))) ; signal success
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
326
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
327 (defun vc-svn-merge-news (file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
328 "Merge in any new changes made to FILE."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
329 (message "Merging changes into %s..." file)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
330 ;; (vc-file-setprop file 'vc-workfile-version nil)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
331 (vc-file-setprop file 'vc-checkout-time 0)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
332 (vc-svn-command nil 0 file "update")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
333 ;; 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
334 ;; file properties accordingly.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
335 (with-current-buffer (get-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
336 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
337 ;; get new workfile version
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
338 (if (re-search-forward
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
339 "^\\(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
340 (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
341 (vc-file-setprop file 'vc-workfile-version nil))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
342 ;; get file status
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
343 (goto-char (point-min))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
344 (prog1
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
345 (if (looking-at "At revision")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
346 0 ;; there were no news; indicate success
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
347 (if (re-search-forward
50821
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
348 (concat "^\\([CGDU] \\)?"
33e415a24bb5 (vc-svn-merge-news): Adjust for subversion.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50820
diff changeset
349 (regexp-quote (file-name-nondirectory file)))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
350 nil t)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
351 (cond
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
352 ;; 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
353 ((string= (match-string 1) "U ")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
354 (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
355 (vc-file-setprop file 'vc-checkout-time
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
356 (nth 5 (file-attributes file)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
357 0);; indicate success to the caller
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
358 ;; 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
359 ((string= (match-string 1) "G ")
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
360 (vc-file-setprop file 'vc-state 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
361 0);; indicate success to the caller
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
362 ;; Conflicts detected!
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
363 (t
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
364 (vc-file-setprop file 'vc-state 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
365 1);; signal the error to the caller
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
366 )
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
367 (pop-to-buffer "*vc*")
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
368 (error "Couldn't analyze svn update result")))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
369 (message "Merging changes into %s...done" file))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
370
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
371
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
372 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
373 ;;; History functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
374 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
375
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
376 (defun vc-svn-print-log (file &optional buffer)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
377 "Get change log associated with FILE."
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
378 (save-current-buffer
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
379 (vc-setup-buffer buffer)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
380 (let ((inhibit-read-only t))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
381 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
382 ;; 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
383 (insert "Working file: " (file-relative-name file) "\n"))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
384 (vc-svn-command
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
385 buffer
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
386 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
68740
0e55eddfde77 (vc-svn-print-log): Show recent commits as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68653
diff changeset
387 file "log"
0e55eddfde77 (vc-svn-print-log): Show recent commits as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68653
diff changeset
388 ;; By default Subversion only shows the log upto the working version,
0e55eddfde77 (vc-svn-print-log): Show recent commits as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68653
diff changeset
389 ;; whereas we also want the log of the subsequent commits. At least
0e55eddfde77 (vc-svn-print-log): Show recent commits as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68653
diff changeset
390 ;; that's what the vc-cvs.el code does.
0e55eddfde77 (vc-svn-print-log): Show recent commits as well.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68653
diff changeset
391 "-rHEAD:0")))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
392
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
393 (defun vc-svn-diff (file &optional oldvers newvers buffer)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
394 "Get a difference report using SVN between two versions of FILE."
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
395 (unless buffer (setq buffer "*vc-diff*"))
59317
d30f6c6ad0b5 (vc-svn-diff): Stay local if possible. From Karl Chen <quarl@cs.berkeley.edu>.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58929
diff changeset
396 (if (and oldvers (equal oldvers (vc-workfile-version file)))
d30f6c6ad0b5 (vc-svn-diff): Stay local if possible. From Karl Chen <quarl@cs.berkeley.edu>.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58929
diff changeset
397 ;; Use nil rather than the current revision because svn handles it
d30f6c6ad0b5 (vc-svn-diff): Stay local if possible. From Karl Chen <quarl@cs.berkeley.edu>.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58929
diff changeset
398 ;; better (i.e. locally).
d30f6c6ad0b5 (vc-svn-diff): Stay local if possible. From Karl Chen <quarl@cs.berkeley.edu>.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 58929
diff changeset
399 (setq oldvers nil))
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
400 (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
401 ;; 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
402 (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
403 (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
404 ;; 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
405 ;; 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
406 ;; Note: this is NOT a "svn diff".
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
407 (apply 'vc-do-command buffer
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
408 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
409 (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
410 ;; 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
411 1)
56777
332e641fe2b1 (vc-svn-diff): Treat options from vc-svn-diff-switches and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55900
diff changeset
412 (let* ((switches
332e641fe2b1 (vc-svn-diff): Treat options from vc-svn-diff-switches and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55900
diff changeset
413 (if vc-svn-diff-switches
332e641fe2b1 (vc-svn-diff): Treat options from vc-svn-diff-switches and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55900
diff changeset
414 (vc-switches 'SVN 'diff)
332e641fe2b1 (vc-svn-diff): Treat options from vc-svn-diff-switches and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55900
diff changeset
415 (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " "))))
59446
1ba18e657796 (vc-svn-diff): Don't diff asynchronously if vc-disable-async-diff is
André Spiegel <spiegel@gnu.org>
parents: 59317
diff changeset
416 (async (and (not vc-disable-async-diff)
1ba18e657796 (vc-svn-diff): Don't diff asynchronously if vc-disable-async-diff is
André Spiegel <spiegel@gnu.org>
parents: 59317
diff changeset
417 (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
418 (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
419 (fboundp 'start-process))))
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
420 (apply 'vc-svn-command buffer
50922
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
421 (if async 'async 0)
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
422 file "diff"
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
423 (append
56777
332e641fe2b1 (vc-svn-diff): Treat options from vc-svn-diff-switches and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55900
diff changeset
424 switches
50922
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
425 (when oldvers
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
426 (list "-r" (if newvers (concat oldvers ":" newvers)
bdc62a6694f7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50900
diff changeset
427 oldvers)))))
50900
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
428 (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
429 ;; 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
430 ;; status w.r.t whether the diff was empty or not.
55004
ae9b6f1e3bdf (vc-svn-print-log, vc-svn-diff): Add optional BUFFER arg.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
431 (buffer-size (get-buffer buffer))))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
432
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
433 (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
434 "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
435 (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
436
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
437 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
438 ;;; Snapshot system
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
439 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
440
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
441 (defun vc-svn-create-snapshot (dir name branchp)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
442 "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
443 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
444 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
445 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
446 (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
447 (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
448
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
449 (defun vc-svn-retrieve-snapshot (dir name update)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
450 "Retrieve a snapshot at and below DIR.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
451 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
452 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
453 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
454 (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
455 ;; 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
456 )
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
457
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
458 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
459 ;;; Miscellaneous
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
460 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
461
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
462 ;; 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
463 ;; (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
464 ;; "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
465
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
466 (defun vc-svn-check-headers ()
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
467 "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
468 (save-excursion
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
469 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
470 (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
471 \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
472
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
473
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
474 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
475 ;;; Internal functions
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
476 ;;;
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
477
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
478 (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
479 "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
480 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
481 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
482 (apply 'vc-do-command buffer okstatus "svn" file
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
483 (if (stringp vc-svn-global-switches)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
484 (cons vc-svn-global-switches flags)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
485 (append vc-svn-global-switches
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
486 flags))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
487
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
488 (defun vc-svn-repository-hostname (dirname)
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
489 (with-temp-buffer
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
490 (let ((coding-system-for-read
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
491 (or file-name-coding-system
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
492 default-file-name-coding-system)))
73848
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
493 (vc-insert-file (expand-file-name (concat vc-svn-admin-directory
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
494 "/entries")
299d3322c8be Fix typo in previous commit.
Chong Yidong <cyd@stupidchicken.com>
parents: 73847
diff changeset
495 dirname)))
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
496 (goto-char (point-min))
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
497 (when (re-search-forward
58929
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
498 ;; Old `svn' used name="svn:dir", newer use just name="".
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
499 (concat "name=\"\\(?:svn:this_dir\\)?\"[\n\t ]*"
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
500 "\\(?:[-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
50927
6f478e2878c7 (vc-svn-rename-file): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50922
diff changeset
501 "url=\"\\([^\"]+\\)\"") nil t)
58929
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
502 ;; This is not a hostname but a URL. This may actually be considered
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
503 ;; as a feature since it allows vc-svn-stay-local to specify different
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
504 ;; behavior for different modules on the same server.
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
505 (match-string 1))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
506
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
507 (defun vc-svn-parse-status (&optional filename)
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
508 "Parse output of \"svn status\" command in the current buffer.
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
509 Set file properties accordingly. Unless FILENAME is non-nil, parse only
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
510 information about FILENAME and return its status."
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
511 (let (file status)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
512 (goto-char (point-min))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
513 (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
514 "^[ 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
515 (setq file (expand-file-name
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
516 (buffer-substring (point) (line-end-position))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
517 (setq status (char-after (line-beginning-position)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
518 (unless (eq status ??)
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
519 ;; `vc-BACKEND-registered' must not set vc-backend,
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
520 ;; which is instead set in vc-registered.
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
521 (unless filename (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
522 ;; 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
523 ;; output works.
d853a98e1678 (vc-svn-dired-state-info): Use `added' for added files and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 50823
diff changeset
524 (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
525 (vc-file-setprop
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
526 file 'vc-state
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
527 (cond
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
528 ((eq status ?\ )
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
529 (if (eq (char-after (match-beginning 1)) ?*)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
530 'needs-patch
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
531 (vc-file-setprop file 'vc-checkout-time
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
532 (nth 5 (file-attributes file)))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
533 'up-to-date))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
534 ((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
535 ;; 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
536 (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
537 (vc-file-setprop file 'vc-checkout-time 0)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
538 'edited)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
539 ((memq status '(?M ?C))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
540 (if (eq (char-after (match-beginning 1)) ?*)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
541 'needs-merge
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
542 'edited))
73444
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
543 (t 'edited)))))
ee7eeb5732b2 (vc-svn-parse-status): Remove unused arg `localp'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68740
diff changeset
544 (if filename (vc-file-getprop filename 'vc-state))))
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
545
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
546 (defun vc-svn-dir-state-heuristic (dir)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
547 "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
548 (vc-svn-dir-state dir 'local))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
549
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
550 (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
551 "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
552 ;; 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
553 ;; 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
554 ;; lowercase letters, digits, `-', and `_'.
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
555 (and (string-match "^[a-zA-Z]" tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
556 (not (string-match "[^a-z0-9A-Z-_]" tag))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
557
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
558 (defun vc-svn-valid-version-number-p (tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
559 "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
560 (and (string-match "^[0-9]" tag)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
561 (not (string-match "[^0-9]" tag))))
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
562
58929
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
563 ;; Support for `svn annotate'
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
564
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
565 (defun vc-svn-annotate-command (file buf &optional rev)
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
566 (vc-svn-command buf 0 file "annotate" (if rev (concat "-r" rev))))
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
567
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
568 (defun vc-svn-annotate-time-of-rev (rev)
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
569 ;; Arbitrarily assume 10 commmits per day.
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
570 (/ (string-to-number rev) 10.0))
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
571
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
572 (defun vc-svn-annotate-current-time ()
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
573 (vc-svn-annotate-time-of-rev vc-annotate-parent-rev))
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
574
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
575 (defconst vc-svn-annotate-re "[ \t]*\\([0-9]+\\)[ \t]+[^\t ]+ ")
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
576
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
577 (defun vc-svn-annotate-time ()
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
578 (when (looking-at vc-svn-annotate-re)
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
579 (goto-char (match-end 0))
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
580 (vc-svn-annotate-time-of-rev (match-string 1))))
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
581
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
582 (defun vc-svn-annotate-extract-revision-at-line ()
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
583 (save-excursion
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
584 (beginning-of-line)
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
585 (if (looking-at vc-svn-annotate-re) (match-string 1))))
43248e1430b6 (vc-svn-repository-hostname): Adjust to new format.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 56777
diff changeset
586
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
587 (provide 'vc-svn)
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
588
56777
332e641fe2b1 (vc-svn-diff): Treat options from vc-svn-diff-switches and
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55900
diff changeset
589 ;; arch-tag: 02f10c68-2b4d-453a-90fc-1eee6cfb268d
50818
d3acfb11487e First cut at vc-svn.el.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
590 ;;; vc-svn.el ends here