54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; vc-dav.el --- vc.el support for WebDAV
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Author: Bill Perry <wmperry@gnu.org>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Maintainer: Bill Perry <wmperry@gnu.org>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7 ;; Keywords: url, vc
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 ;; it under the terms of the GNU General Public License as published by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; any later version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; GNU Emacs is distributed in the hope that it will be useful,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; GNU General Public License for more details.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; You should have received a copy of the GNU General Public License
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; Boston, MA 02111-1307, USA.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 (require 'url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 (require 'url-dav)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27 ;;; Required functions for a vc backend
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28 (defun vc-dav-registered (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 "Return t iff URL is registered with a DAV aware server."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30 (url-dav-vc-registered url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 (defun vc-dav-state (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 "Return the current version control state of URL.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 For a list of possible values, see `vc-state'."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; Things we can support for WebDAV
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;; up-to-date - use lockdiscovery
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; edited - check for an active lock by us
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 ;; USER - use lockdiscovery + owner
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41 ;; These don't make sense for WebDAV
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 ;; needs-patch
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
43 ;; needs-merge
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
44 ;; unlocked-changes
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 (let ((locks (url-dav-active-locks url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
46 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47 ((null locks) 'up-to-date)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 ((assoc url locks)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 ;; SOMEBODY has a lock... let's find out who.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50 (setq locks (cdr (assoc url locks)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 (if (rassoc url-dav-lock-identifier locks)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52 ;; _WE_ have a lock
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 'edited
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 (cdr (car locks)))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 (defun vc-dav-checkout-model (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 "Indicate whether URL needs to be \"checked out\" before it can be edited.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 See `vc-checkout-model' for a list of possible values."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 ;; The only thing we can support with webdav is 'locking
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 'locking)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 ;; This should figure out the version # of the file somehow. What is
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 ;; the most appropriate property in WebDAV to look at for this?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (defun vc-dav-workfile-version (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 "Return the current workfile version of URL."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 "Unknown")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 (defun vc-dav-register (url &optional rev comment)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 "Register URL in the DAV backend."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 ;; Do we need to do anything here? FIXME?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 (defun vc-dav-checkin (url rev comment)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 "Commit changes in URL to WebDAV.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 If REV is non-nil, that should become the new revision number.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 COMMENT is used as a check-in comment."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 ;; This should PUT the resource and release any locks that we hold.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 (defun vc-dav-checkout (url &optional editable rev destfile)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 "Check out revision REV of URL into the working area.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 If EDITABLE is non-nil URL should be writable by the user and if
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 locking is used for URL, a lock should also be set.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 If REV is non-nil, that is the revision to check out. If REV is the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 empty string, that means to check ou tht ehead of the trunk.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 If optional arg DESTFILE is given, it is an alternate filename to
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 write the contents to.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 ;; This should LOCK the resource.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (defun vc-dav-revert (url &optional contents-done)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 "Revert URL back to the current workfile version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 If optional arg CONTENTS-DONE is non-nil, then the contents of FILE
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 have already been reverted from a version backup, and this function
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 only needs to update the status of URL within the backend.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 ;; Should do a GET if !contents_done
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 ;; Should UNLOCK the file.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 (defun vc-dav-print-log (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 "Insert the revision log of URL into the *vc* buffer."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (defun vc-dav-diff (url &optional rev1 rev2)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 "Insert the diff for URL into the *vc-diff* buffer.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 If REV1 and REV2 are non-nil report differences from REV1 to REV2.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 If REV1 is nil, use the current workfile version as the older version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 If REV2 is nil, use the current workfile contents as the nwer version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 It should return a status of either 0 (no differences found), or
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 1 (either non-empty diff or the diff is run asynchronously).
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 ;; We should do this asynchronously...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 ;; How would we do it at all, that is the question!
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 ;;; Optional functions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 ;; Should be faster than vc-dav-state - but how?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 (defun vc-dav-state-heuristic (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 "Estimate the version control state of URL at visiting time."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 (vc-dav-state url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 ;; This should use url-dav-get-properties with a depth of `1' to get
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 ;; all the properties.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 (defun vc-dav-dir-state (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 "find the version control state of all files in DIR in a fast way."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 (defun vc-dav-workfile-unchanged-p (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138 "Return non-nil if URL is unchanged from its current workfile version."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 ;; Probably impossible with webdav
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 (defun vc-dav-responsible-p (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 "Return non-nil if DAV considers itself `responsible' for URL."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144 ;; Check for DAV support on the web server.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (defun vc-dav-could-register (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 "Return non-nil if URL could be registered under this backend."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 ;; Check for DAV support on the web server.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150 t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 ;;; Unimplemented functions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 ;; vc-dav-latest-on-branch-p(URL)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
155 ;; Return non-nil if the current workfile version of FILE is the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 ;; latest on its branch. There are no branches in webdav yet.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
158 ;; vc-dav-mode-line-string(url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 ;; Return a dav-specific mode line string for URL. Are there any
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 ;; specific states that we want exposed?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 ;; vc-dav-dired-state-info(url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 ;; Translate the `vc-state' property of URL into a string that can
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 ;; be used in a vc-dired buffer. Are there any extra states that
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 ;; we want exposed?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 ;; vc-dav-receive-file(url rev)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 ;; Let this backend `receive' a file that is already registered
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 ;; under another backend. The default just calls `register', which
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 ;; should be sufficient for WebDAV.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
172 ;; vc-dav-unregister(url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 ;; Unregister URL. Not possible with WebDAV, other than by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 ;; deleting the resource.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 (provide 'vc-dav)
|
54699
|
177
|
|
178 ;;; arch-tag: 0a0fb9fe-8190-4c0a-a179-5c291d3a467e
|