aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Spiegel2001-01-10 14:42:53 +0000
committerAndré Spiegel2001-01-10 14:42:53 +0000
commitfcb500ea434e48278dc790ce1b581ce8381f7649 (patch)
tree814f3fec49cfdfb2eed2ae38fde5cec8cd6360d6
parent8726e79b75b0b8d515b12a762e85552268ef14a9 (diff)
downloademacs-fcb500ea434e48278dc790ce1b581ce8381f7649.tar.gz
emacs-fcb500ea434e48278dc790ce1b581ce8381f7649.zip
Added documentation for backend interface.
-rw-r--r--lisp/vc.el350
1 files changed, 256 insertions, 94 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index be57709bfd7..11675a724d3 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -5,7 +5,7 @@
5;; Author: FSF (see below for full credits) 5;; Author: FSF (see below for full credits)
6;; Maintainer: Andre Spiegel <spiegel@gnu.org> 6;; Maintainer: Andre Spiegel <spiegel@gnu.org>
7 7
8;; $Id: vc.el,v 1.292 2000/11/20 14:01:35 spiegel Exp $ 8;; $Id: vc.el,v 1.293 2001/01/08 16:23:33 spiegel Exp $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -69,115 +69,293 @@
69;; 69;;
70;; Developer's notes on some concurrency issues are included at the end of 70;; Developer's notes on some concurrency issues are included at the end of
71;; the file. 71;; the file.
72
73;;; Code:
74
75;;;;;;;;;;;;;;;;; Backend-specific functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
76;; 72;;
77;; For each operation FUN, the backend should provide a function 73;; ADDING SUPPORT FOR OTHER BACKENDS
78;; vc-BACKEND-FUN. Operations marked with a `-' instead of a `*' 74;;
79;; are optional. 75;; VC can use arbitrary version control systems as a backend. To add
80 76;; support for a new backend named SYS, write a library vc-sys.el that
81;;; 77;; contains functions of the form `vc-sys-...' (note that SYS is in lower
82;;; State-querying functions 78;; case for the function and library names). VC will use that library if
83;;; 79;; you put the symbol SYS somewhere into the list of
84 80;; `vc-handled-backends'. Then, for example, if `vc-sys-registered'
81;; returns non-nil for a file, all SYS-specific versions of VC commands
82;; will be available for that file.
83;;
84;; VC keeps some per-file information in the form of properties (see
85;; vc-file-set/getprop in vc-hooks.el). The backend-specific functions
86;; do not generally need to be aware of these properties. For example,
87;; `vc-sys-workfile-version' should compute the workfile version and
88;; return it; it should not look it up in the property, and it needn't
89;; store it there either. However, if a backend-specific function does
90;; store a value in a property, that value takes precedence over any
91;; value that the generic code might want to set (check for uses of
92;; the macro `with-vc-properties' in vc.el).
93;;
94;; In the list of functions below, each identifier needs to be prepended
95;; with `vc-sys-'. Some of the functions are mandatory (marked with a
96;; `*'), others are optional (`-').
97;;
98;; STATE-QUERYING FUNCTIONS
99;;
85;; * registered (file) 100;; * registered (file)
86;; * state (file) 101;;
102;; Return non-nil if FILE is registered in this backend.
103;;
104;; * state (file)
105;;
106;; Return the current version control state of FILE. For a list of
107;; possible values, see `vc-state'. This function should do a full and
108;; reliable state computation; it is usually called immediately after
109;; C-x v v. If you want to use a faster heuristic when visiting a
110;; file, put that into `state-heuristic' below.
111;;
87;; - state-heuristic (file) 112;; - state-heuristic (file)
88;; The default behavior delegates to `state'. 113;;
114;; If provided, this function is used to estimate the version control
115;; state of FILE at visiting time. It should be considerably faster
116;; than the implementation of `state'. For a list of possible values,
117;; see the doc string of `vc-state'.
118;;
89;; - dir-state (dir) 119;; - dir-state (dir)
120;;
121;; If provided, this function is used to find the version control state
122;; of all files in DIR in a fast way. The function should not return
123;; anything, but rather store the files' states into the corresponding
124;; `vc-state' properties.
125;;
90;; * workfile-version (file) 126;; * workfile-version (file)
91;; * latest-on-branch-p (file) 127;;
128;; Return the current workfile version of FILE.
129;;
130;; - latest-on-branch-p (file)
131;;
132;; Return non-nil if the current workfile version of FILE is the latest
133;; on its branch. The default implementation always returns t, which
134;; means that working with non-current versions is not supported by
135;; default.
136;;
92;; * checkout-model (file) 137;; * checkout-model (file)
138;;
139;; Indicate whether FILE needs to be "checked out" before it can be
140;; edited. See `vc-checkout-model' for a list of possible values.
141;;
93;; - workfile-unchanged-p (file) 142;; - workfile-unchanged-p (file)
94;; Return non-nil if FILE is unchanged from its current workfile version. 143;;
95;; This function should do a brief comparison of FILE's contents 144;; Return non-nil if FILE is unchanged from its current workfile
96;; with those of the master version. If the backend does not have 145;; version. This function should do a brief comparison of FILE's
97;; such a brief-comparison feature, the default implementation of this 146;; contents with those of the master version. If the backend does not
98;; function can be used, which delegates to a full vc-BACKEND-diff. 147;; have such a brief-comparison feature, the default implementation of
148;; this function can be used, which delegates to a full
149;; vc-BACKEND-diff.
150;;
99;; - mode-line-string (file) 151;; - mode-line-string (file)
152;;
153;; If provided, this function should return the VC-specific mode line
154;; string for FILE. The default implementation deals well with all
155;; states that `vc-state' can return.
156;;
100;; - dired-state-info (file) 157;; - dired-state-info (file)
101 158;;
102;;; 159;; Translate the `vc-state' property of FILE into a string that can be
103;;; State-changing functions 160;; used in a vc-dired buffer. The default implementation deals well
104;;; 161;; with all states that `vc-state' can return.
105 162;;
106;; * register (file rev comment) 163;; STATE-CHANGING FUNCTIONS
164;;
165;; * register (file &optional rev comment)
166;;
167;; Register FILE in this backend. Optionally, an initial revision REV
168;; and an initial description of the file, COMMENT, may be specified.
169;;
107;; - responsible-p (file) 170;; - responsible-p (file)
108;; Should also work if FILE is a directory (ends with a slash). 171;;
172;; Return non-nil if this backend considers itself "responsible" for
173;; FILE, which can also be a directory. This function is used to find
174;; out what backend to use for registration of new files and for things
175;; like change log generation. The default implementation always
176;; returns nil.
177;;
109;; - could-register (file) 178;; - could-register (file)
179;;
180;; Return non-nil if FILE could be registered under this backend. The
181;; default implementation always returns t.
182;;
110;; - receive-file (file rev) 183;; - receive-file (file rev)
111;; - unregister (file backend) 184;;
185;; Let this backend "receive" a file that is already registered under
186;; another backend. The default implementation simply calls `register'
187;; for FILE, but it can be overridden to do something more specific,
188;; e.g. keep revision numbers consistent or choose editing modes for
189;; FILE that resemble those of the other backend.
190;;
191;; - unregister (file)
192;;
193;; Unregister FILE from this backend. This is only needed if this
194;; backend may be used as a "more local" backend for temporary editing.
195;;
112;; * checkin (file rev comment) 196;; * checkin (file rev comment)
113;; * checkout (file writable &optional rev destfile) 197;;
114;; Checkout revision REV of FILE into DESTFILE. 198;; Commit changes in FILE to this backend. If REV is non-nil, that
115;; DESTFILE defaults to FILE. 199;; should become the new revision number. COMMENT is used as a
116;; The file should be made writable if WRITABLE is non-nil. 200;; check-in comment.
117;; REV can be nil (BASE) or "" (HEAD) or any other revision. 201;;
202;; * checkout (file &optional editable rev destfile)
203;;
204;; Check out revision REV of FILE into the working area. If EDITABLE
205;; is non-nil, FILE should be writable by the user and if locking is
206;; used for FILE, a lock should also be set. If REV is non-nil, that
207;; is the revision to check out (default is current workfile version);
208;; if REV is the empty string, that means to check out the head of the
209;; trunk. If optional arg DESTFILE is given, it is an alternate
210;; filename to write the contents to.
211;;
118;; * revert (file) 212;; * revert (file)
119;; - cancel-version (file writable) 213;;
214;; Revert FILE back to the current workfile version.
215;;
216;; - cancel-version (file editable)
217;;
218;; Cancel the current workfile version of FILE, i.e. remove it from the
219;; master. EDITABLE non-nil means that FILE should be writable
220;; afterwards, and if locking is used for FILE, then a lock should also
221;; be set. If this function is not provided, trying to cancel a
222;; version is caught as an error.
223;;
120;; - merge (file rev1 rev2) 224;; - merge (file rev1 rev2)
225;;
226;; Merge the changes between REV1 and REV2 into the current working file.
227;;
121;; - merge-news (file) 228;; - merge-news (file)
122;; Only needed if state `needs-merge' is possible. 229;;
230;; Merge recent changes from the current branch into FILE.
231;;
123;; - steal-lock (file &optional version) 232;; - steal-lock (file &optional version)
124;; Only required if files can be locked by somebody else. 233;;
125 234;; Steal any lock on the current workfile version of FILE, or on
126;;; 235;; VERSION if that is provided. This function is only needed if
127;;; History functions 236;; locking is used for files under this backend, and if files can
128;;; 237;; indeed be locked by other users.
129 238;;
239;; HISTORY FUNCTIONS
240;;
130;; * print-log (file) 241;; * print-log (file)
131;; Insert the revision log of FILE into the current buffer. 242;;
243;; Insert the revision log of FILE into the current buffer.
244;;
132;; - show-log-entry (version) 245;; - show-log-entry (version)
246;;
247;; If provided, search the log entry for VERSION in the current buffer,
248;; and make sure it is displayed in the buffer's window. The default
249;; implementation of this function works for RCS-style logs.
250;;
133;; - wash-log (file) 251;; - wash-log (file)
134;; Remove all non-comment information from the output of print-log 252;;
253;; Remove all non-comment information from the output of print-log. The
254;; default implementation of this function works for RCS-style logs.
255;;
135;; - logentry-check () 256;; - logentry-check ()
257;;
258;; If defined, this function is run to find out whether the user
259;; entered a valid log entry for check-in. The log entry is in the
260;; current buffer, and if it is not a valid one, the function should
261;; throw an error.
262;;
136;; - comment-history (file) 263;; - comment-history (file)
264;;
265;; Return a string containing all log entries that were made for FILE.
266;; This is used for transferring a file from one backend to another,
267;; retaining comment information. The default implementation of this
268;; function does this by calling print-log and then wash-log, and
269;; returning the resulting buffer contents as a string.
270;;
137;; - update-changelog (files) 271;; - update-changelog (files)
138;; Find changelog entries for FILES, or for all files at or below 272;;
139;; the default-directory if FILES is nil. 273;; Using recent log entries, create ChangeLog entries for FILES, or for
274;; all files at or below the default-directory if FILES is nil. The
275;; default implementation runs rcs2log, which handles RCS- and
276;; CVS-style logs.
277;;
140;; * diff (file &optional rev1 rev2) 278;; * diff (file &optional rev1 rev2)
141;; Insert the diff for FILE into the current buffer. 279;;
142;; REV1 should default to workfile-version. 280;; Insert the diff for FILE into the current buffer. If REV1 and REV2
143;; REV2 should default to the current workfile 281;; are non-nil, report differences from REV1 to REV2. If REV1 is nil,
144;; Return a status of either 0 (i.e. no diff) or 1 (i.e. either non-empty 282;; use the current workfile version (as found in the repository) as the
145;; diff or the diff is run asynchronously). 283;; older version; if REV2 is nil, use the current workfile contents as
284;; the newer version. This function should return a status of either 0
285;; (no differences found), or 1 (either non-empty diff or the diff is
286;; run asynchronously).
287;;
146;; - annotate-command (file buf rev) 288;; - annotate-command (file buf rev)
147;; - annotate-difference (pos) 289;;
148;; Only required if `annotate-command' is defined for the backend. 290;; If this function is provided, it should produce an annotated version
149 291;; of FILE in BUF, relative to version REV. This is currently only
150;;; 292;; implemented for CVS, using the `cvs annotate' command.
151;;; Snapshot system 293;;
152;;; 294;; - annotate-difference (point)
153 295;;
296;; Only required if `annotate-command' is defined for the backend.
297;; Return the difference between the age of the line at point and the
298;; current time. Return NIL if there is no more comparison to be made
299;; in the buffer. Return value as defined for `current-time'. You can
300;; safely assume that point is placed at the beginning of each line,
301;; starting at `point-min'. The buffer that point is placed in is the
302;; Annotate output, as defined by the relevant backend.
303;;
304;; SNAPSHOT SYSTEM
305;;
154;; - create-snapshot (dir name branchp) 306;; - create-snapshot (dir name branchp)
155;; Take a snapshot of the current state of files under DIR and 307;;
156;; name it NAME. This should make sure that files are up-to-date 308;; Take a snapshot of the current state of files under DIR and name it
157;; before proceeding with the action. DIR can also be a file and 309;; NAME. This should make sure that files are up-to-date before
158;; if BRANCHP is specified, NAME should be created as a branch and 310;; proceeding with the action. DIR can also be a file and if BRANCHP
159;; DIR should be checked out under this new branch. The default 311;; is specified, NAME should be created as a branch and DIR should be
160;; behavior does not support branches but does a sanity check, a 312;; checked out under this new branch. The default implementation does
161;; tree traversal and for each file calls `assign-name'. 313;; not support branches but does a sanity check, a tree traversal and
162;; * assign-name (file name) 314;; for each file calls `assign-name'.
163;; Give name NAME to the current version of FILE, assuming it is 315;;
164;; up-to-date. Only used by the default version of `create-snapshot'. 316;; - assign-name (file name)
317;;
318;; Give name NAME to the current version of FILE, assuming it is
319;; up-to-date. Only used by the default version of `create-snapshot'.
320;;
165;; - retrieve-snapshot (dir name update) 321;; - retrieve-snapshot (dir name update)
166;; Retrieve a named snapshot of all registered files at or below DIR. 322;;
167;; If UPDATE is non-nil, then update buffers of any files in the snapshot 323;; Retrieve a named snapshot of all registered files at or below DIR.
168;; that are currently visited. 324;; If UPDATE is non-nil, then update buffers of any files in the
169 325;; snapshot that are currently visited. The default implementation
170;;; 326;; does a sanity check whether there aren't any uncommitted changes at
171;;; Miscellaneous 327;; or below DIR, and then performs a tree walk, using the `checkout'
172;;; 328;; function to retrieve the corresponding versions.
173 329;;
330;; MISCELLANEOUS
331;;
174;; - make-version-backups-p (file) 332;; - make-version-backups-p (file)
333;;
334;; Return non-nil if unmodified repository versions of FILE should be
335;; backed up locally. If this is done, VC can perform `diff' and
336;; `revert' operations itself, without calling the backend system. The
337;; default implementation always returns nil.
338;;
175;; - check-headers () 339;; - check-headers ()
340;;
341;; Return non-nil if the current buffer contains any version headers.
342;;
176;; - clear-headers () 343;; - clear-headers ()
344;;
345;; In the current buffer, reset all version headers to their unexpanded
346;; form. This function should be provided if the state-querying code
347;; for this backend uses the version headers to determine the state of
348;; a file. This function will then be called whenever VC changes the
349;; version control state in such a way that the headers would give
350;; wrong information.
351;;
177;; - rename-file (old new) 352;; - rename-file (old new)
353;;
354;; Rename file OLD to NEW, both in the working area and in the
355;; repository. If this function is not provided, the command
356;; `vc-rename-file' will signal an error.
178 357
179 358;;; Code:
180;;;;;;;;;;;;;;; End of backend-specific functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
181 359
182(require 'vc-hooks) 360(require 'vc-hooks)
183(require 'ring) 361(require 'ring)
@@ -2462,12 +2640,6 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
2462(defun vc-rename-file (old new) 2640(defun vc-rename-file (old new)
2463 "Rename file OLD to NEW, and rename its master file likewise." 2641 "Rename file OLD to NEW, and rename its master file likewise."
2464 (interactive "fVC rename file: \nFRename to: ") 2642 (interactive "fVC rename file: \nFRename to: ")
2465 ;; There are several ways of renaming files under CVS 1.3, but they all
2466 ;; have serious disadvantages. See the FAQ (available from think.com in
2467 ;; pub/cvs/). I'd rather send the user an error, than do something he might
2468 ;; consider to be wrong. When the famous, long-awaited rename database is
2469 ;; implemented things might change for the better. This is unlikely to occur
2470 ;; until CVS 2.0 is released. --ceder 1994-01-23 21:27:51
2471 (let ((oldbuf (get-file-buffer old)) 2643 (let ((oldbuf (get-file-buffer old))
2472 (backend (vc-backend old))) 2644 (backend (vc-backend old)))
2473 (unless (or (null backend) (vc-find-backend-function backend 'rename-file)) 2645 (unless (or (null backend) (vc-find-backend-function backend 'rename-file))
@@ -2724,16 +2896,6 @@ nil otherwise"
2724 tmp-cons)) ; Return the appropriate value 2896 tmp-cons)) ; Return the appropriate value
2725 2897
2726 2898
2727;;;; (defun vc-BACKEND-annotate-difference (point) ...)
2728;;;;
2729;;;; Return the difference between the age of the line at point and
2730;;;; the current time. Return NIL if there is no more comparison to
2731;;;; be made in the buffer. Return value as defined for
2732;;;; `current-time'. You can safely assume that point is placed at
2733;;;; the beginning of each line, starting at `point-min'. The buffer
2734;;;; that point is placed in is the Annotate output, as defined by
2735;;;; the relevant backend.
2736
2737(defun vc-annotate-display (buffer &optional color-map backend) 2899(defun vc-annotate-display (buffer &optional color-map backend)
2738 "Do the VC-Annotate display in BUFFER using COLOR-MAP. 2900 "Do the VC-Annotate display in BUFFER using COLOR-MAP.
2739The original annotating file is supposed to be handled by BACKEND. 2901The original annotating file is supposed to be handled by BACKEND.