Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / vc / vc-dav.el
blob9b67d74c779511453c6c43df62d71c4d4185d46a
1 ;;; vc-dav.el --- vc.el support for WebDAV
3 ;; Copyright (C) 2001, 2004-2014 Free Software Foundation, Inc.
5 ;; Author: Bill Perry <wmperry@gnu.org>
6 ;; Maintainer: Bill Perry <wmperry@gnu.org>
7 ;; Keywords: url, vc
8 ;; Package: vc
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;;; Commentary:
27 ;;; Todo:
29 ;; - Some methods need to be updated to match the current vc.el.
30 ;; - rename "version" -> "revision"
31 ;; - some methods need to take a fileset as a parameter instead of a
32 ;; single file.
34 ;;; Code:
36 (require 'url)
37 (require 'url-dav)
39 ;;; Required functions for a vc backend
40 (defun vc-dav-registered (url)
41 "Return t if URL is registered with a DAV aware server."
42 (url-dav-vc-registered url))
44 (defun vc-dav-state (url)
45 "Return the current version control state of URL.
46 For a list of possible values, see `vc-state'."
47 ;; Things we can support for WebDAV
49 ;; up-to-date - use lockdiscovery
50 ;; edited - check for an active lock by us
51 ;; USER - use lockdiscovery + owner
53 ;; These don't make sense for WebDAV
54 ;; needs-patch
55 ;; needs-merge
56 ;; unlocked-changes
57 (let ((locks (url-dav-active-locks url)))
58 (cond
59 ((null locks) 'up-to-date)
60 ((assoc url locks)
61 ;; SOMEBODY has a lock... let's find out who.
62 (setq locks (cdr (assoc url locks)))
63 (if (rassoc url-dav-lock-identifier locks)
64 ;; _WE_ have a lock
65 'edited
66 (cdr (car locks)))))))
68 (defun vc-dav-checkout-model (url)
69 "Indicate whether URL needs to be \"checked out\" before it can be edited.
70 See `vc-checkout-model' for a list of possible values."
71 ;; The only thing we can support with webdav is 'locking
72 'locking)
74 ;; This should figure out the version # of the file somehow. What is
75 ;; the most appropriate property in WebDAV to look at for this?
76 (defun vc-dav-workfile-version (url)
77 "Return the current workfile version of URL."
78 "Unknown")
80 (defun vc-dav-register (url &optional rev comment)
81 "Register URL in the DAV backend."
82 ;; Do we need to do anything here? FIXME?
85 (defun vc-dav-checkin (url rev comment)
86 "Commit changes in URL to WebDAV.
87 If REV is non-nil, that should become the new revision number.
88 COMMENT is used as a check-in comment."
89 ;; This should PUT the resource and release any locks that we hold.
92 (defun vc-dav-checkout (url &optional editable rev destfile)
93 "Check out revision REV of URL into the working area.
95 If EDITABLE is non-nil URL should be writable by the user and if
96 locking is used for URL, a lock should also be set.
98 If REV is non-nil, that is the revision to check out. If REV is the
99 empty string, that means to check ou tht ehead of the trunk.
101 If optional arg DESTFILE is given, it is an alternate filename to
102 write the contents to.
104 ;; This should LOCK the resource.
107 (defun vc-dav-revert (url &optional contents-done)
108 "Revert URL back to the current workfile version.
110 If optional arg CONTENTS-DONE is non-nil, then the contents of FILE
111 have already been reverted from a version backup, and this function
112 only needs to update the status of URL within the backend.
114 ;; Should do a GET if !contents_done
115 ;; Should UNLOCK the file.
118 (defun vc-dav-print-log (url)
119 "Insert the revision log of URL into the *vc* buffer."
122 (defun vc-dav-diff (url &optional rev1 rev2)
123 "Insert the diff for URL into the *vc-diff* buffer.
124 If REV1 and REV2 are non-nil report differences from REV1 to REV2.
125 If REV1 is nil, use the current workfile version as the older version.
126 If REV2 is nil, use the current workfile contents as the nwer version.
128 It should return a status of either 0 (no differences found), or
129 1 (either non-empty diff or the diff is run asynchronously).
131 ;; We should do this asynchronously...
132 ;; How would we do it at all, that is the question!
137 ;;; Optional functions
138 ;; Should be faster than vc-dav-state - but how?
139 (defun vc-dav-state-heuristic (url)
140 "Estimate the version control state of URL at visiting time."
141 (vc-dav-state url))
143 ;; This should use url-dav-get-properties with a depth of `1' to get
144 ;; all the properties.
145 (defun vc-dav-dir-state (url)
146 "find the version control state of all files in DIR in a fast way."
149 (defun vc-dav-workfile-unchanged-p (url)
150 "Return non-nil if URL is unchanged from its current workfile version."
151 ;; Probably impossible with webdav
154 (defun vc-dav-responsible-p (url)
155 "Return non-nil if DAV considers itself `responsible' for URL."
156 ;; Check for DAV support on the web server.
159 (defun vc-dav-could-register (url)
160 "Return non-nil if URL could be registered under this backend."
161 ;; Check for DAV support on the web server.
164 ;;; Unimplemented functions
166 ;; vc-dav-latest-on-branch-p(URL)
167 ;; Return non-nil if the current workfile version of FILE is the
168 ;; latest on its branch. There are no branches in webdav yet.
170 ;; vc-dav-mode-line-string(url)
171 ;; Return a dav-specific mode line string for URL. Are there any
172 ;; specific states that we want exposed?
174 ;; vc-dir support
176 ;; vc-dav-receive-file(url rev)
177 ;; Let this backend `receive' a file that is already registered
178 ;; under another backend. The default just calls `register', which
179 ;; should be sufficient for WebDAV.
181 ;; vc-dav-unregister(url)
182 ;; Unregister URL. Not possible with WebDAV, other than by
183 ;; deleting the resource.
185 (provide 'vc-dav)
187 ;;; vc-dav.el ends here