Mercurial > emacs
comparison lisp/vc.el @ 91058:4b09bb044f38
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 899-900)
- Update from CVS
- Merge from emacs--rel--22
* emacs--rel--22 (patch 129-130)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 259-260)
- Merge from emacs--rel--22
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-272
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sat, 20 Oct 2007 02:22:59 +0000 |
parents | 1251cabc40b7 be5bf5efd2ed |
children | 4bc33ffdda1a |
comparison
equal
deleted
inserted
replaced
91057:5e056bb0109f | 91058:4b09bb044f38 |
---|---|
47 ;; with modern version-control systems that do commits by fileset | 47 ;; with modern version-control systems that do commits by fileset |
48 ;; rather than per individual file. | 48 ;; rather than per individual file. |
49 ;; | 49 ;; |
50 ;; Features in the new version: | 50 ;; Features in the new version: |
51 ;; * Key commands (vc-next-action = C-x v v, vc-print-log = C-x v l, vc-revert | 51 ;; * Key commands (vc-next-action = C-x v v, vc-print-log = C-x v l, vc-revert |
52 ;; = C-x v u, vc-rollback = C-x v c, vc-diff = C-x v =, vc-update = C-x v +) | 52 ;; = C-x v u, vc-rollback = C-x v c, vc-diff = C-x v =, vc-update = C-x v +) |
53 ;; now operate on filesets rather than individual files. | 53 ;; now operate on filesets rather than individual files. |
54 ;; * The fileset for a command is either (a) all marked files in VC-dired | 54 ;; * The fileset for a command is either (a) all marked files in VC-dired |
55 ;; mode, (b) the currently visited file if it's under version control, | 55 ;; mode, (b) the currently visited file if it's under version control, |
56 ;; or (c) the current directory if the visited buffer is not under | 56 ;; or (c) the current directory if the visited buffer is not under |
57 ;; version control and a wildcarding-enable flag has been set. | 57 ;; version control and a wildcarding-enable flag has been set. |
58 ;; | 58 ;; |
59 ;; If you maintain a client of the mode or customize it in your .emacs, | 59 ;; If you maintain a client of the mode or customize it in your .emacs, |
60 ;; note that some backend functions which formerly took single file arguments | 60 ;; note that some backend functions which formerly took single file arguments |
61 ;; now take a list of files. These include: register, checkin, print-log, | 61 ;; now take a list of files. These include: register, checkin, print-log, |
62 ;; rollback, and diff. | 62 ;; rollback, and diff. |
63 | 63 |
64 ;;; Commentary: | 64 ;;; Commentary: |
65 | 65 |
127 ;; | 127 ;; |
128 ;; Takes no arguments. Returns either 'file or 'repository. Backends | 128 ;; Takes no arguments. Returns either 'file or 'repository. Backends |
129 ;; that return 'file have per-file revision numbering; backends | 129 ;; that return 'file have per-file revision numbering; backends |
130 ;; that return 'repository have per-repository revision numbering, | 130 ;; that return 'repository have per-repository revision numbering, |
131 ;; so a revision level implicitly identifies a changeset | 131 ;; so a revision level implicitly identifies a changeset |
132 ;; | 132 ;; |
133 ;; STATE-QUERYING FUNCTIONS | 133 ;; STATE-QUERYING FUNCTIONS |
134 ;; | 134 ;; |
135 ;; * registered (file) | 135 ;; * registered (file) |
136 ;; | 136 ;; |
137 ;; Return non-nil if FILE is registered in this backend. Both this | 137 ;; Return non-nil if FILE is registered in this backend. Both this |
166 ;; | 166 ;; |
167 ;; * working-revision (file) | 167 ;; * working-revision (file) |
168 ;; | 168 ;; |
169 ;; Return the working revision of FILE. This is the revision fetched | 169 ;; Return the working revision of FILE. This is the revision fetched |
170 ;; by the last checkout or upate, not necessarily the same thing as the | 170 ;; by the last checkout or upate, not necessarily the same thing as the |
171 ;; head or tip revision. Should return "0" for a file added but not yet | 171 ;; head or tip revision. Should return "0" for a file added but not yet |
172 ;; committed. | 172 ;; committed. |
173 ;; | 173 ;; |
174 ;; - latest-on-branch-p (file) | 174 ;; - latest-on-branch-p (file) |
175 ;; | 175 ;; |
176 ;; Return non-nil if the working revision of FILE is the latest revision | 176 ;; Return non-nil if the working revision of FILE is the latest revision |
195 ;; `vc-disable-async-diff'.) | 195 ;; `vc-disable-async-diff'.) |
196 ;; | 196 ;; |
197 ;; - mode-line-string (file) | 197 ;; - mode-line-string (file) |
198 ;; | 198 ;; |
199 ;; If provided, this function should return the VC-specific mode | 199 ;; If provided, this function should return the VC-specific mode |
200 ;; line string for FILE. The returned string should have a | 200 ;; line string for FILE. The returned string should have a |
201 ;; `help-echo' property which is the text to be displayed as a | 201 ;; `help-echo' property which is the text to be displayed as a |
202 ;; tooltip when the mouse hovers over the VC entry on the mode-line. | 202 ;; tooltip when the mouse hovers over the VC entry on the mode-line. |
203 ;; The default implementation deals well with all states that | 203 ;; The default implementation deals well with all states that |
204 ;; `vc-state' can return. | 204 ;; `vc-state' can return. |
205 ;; | 205 ;; |
211 ;; | 211 ;; |
212 ;; STATE-CHANGING FUNCTIONS | 212 ;; STATE-CHANGING FUNCTIONS |
213 ;; | 213 ;; |
214 ;; * create-repo (backend) | 214 ;; * create-repo (backend) |
215 ;; | 215 ;; |
216 ;; Create an empty repository in the current directory and initialize | 216 ;; Create an empty repository in the current directory and initialize |
217 ;; it so VC mode can add files to it. For file-oriented systems, this | 217 ;; it so VC mode can add files to it. For file-oriented systems, this |
218 ;; need do no more than create a subdirectory with the right name. | 218 ;; need do no more than create a subdirectory with the right name. |
219 ;; | 219 ;; |
220 ;; * register (files &optional rev comment) | 220 ;; * register (files &optional rev comment) |
221 ;; | 221 ;; |
222 ;; Register FILES in this backend. Optionally, an initial revision REV | 222 ;; Register FILES in this backend. Optionally, an initial revision REV |
223 ;; and an initial description of the file, COMMENT, may be specified, | 223 ;; and an initial description of the file, COMMENT, may be specified, |
224 ;; but it is not guaranteed that the backend will do anything with this. | 224 ;; but it is not guaranteed that the backend will do anything with this. |
225 ;; The implementation should pass the value of vc-register-switches | 225 ;; The implementation should pass the value of vc-register-switches |
226 ;; to the backend command. (Note: in older versions of VC, this | 226 ;; to the backend command. (Note: in older versions of VC, this |
227 ;; command took a single file argument and not a list.) | 227 ;; command took a single file argument and not a list.) |
228 ;; | 228 ;; |
229 ;; - init-revision (file) | 229 ;; - init-revision (file) |
230 ;; | 230 ;; |
231 ;; The initial revision to use when registering FILE if one is not | 231 ;; The initial revision to use when registering FILE if one is not |
262 ;; | 262 ;; |
263 ;; Commit changes in FILES to this backend. If REV is non-nil, that | 263 ;; Commit changes in FILES to this backend. If REV is non-nil, that |
264 ;; should become the new revision number (not all backends do | 264 ;; should become the new revision number (not all backends do |
265 ;; anything with it). COMMENT is used as a check-in comment. The | 265 ;; anything with it). COMMENT is used as a check-in comment. The |
266 ;; implementation should pass the value of vc-checkin-switches to | 266 ;; implementation should pass the value of vc-checkin-switches to |
267 ;; the backend command. (Note: in older versions of VC, this | 267 ;; the backend command. (Note: in older versions of VC, this |
268 ;; command took a single file argument and not a list.) | 268 ;; command took a single file argument and not a list.) |
269 ;; | 269 ;; |
270 ;; * find-revision (file rev buffer) | 270 ;; * find-revision (file rev buffer) |
271 ;; | 271 ;; |
272 ;; Fetch revision REV of file FILE and put it into BUFFER. | 272 ;; Fetch revision REV of file FILE and put it into BUFFER. |
372 ;; function should pass the value of (vc-switches BACKEND 'diff) to | 372 ;; function should pass the value of (vc-switches BACKEND 'diff) to |
373 ;; the backend command. It should return a status of either 0 (no | 373 ;; the backend command. It should return a status of either 0 (no |
374 ;; differences found), or 1 (either non-empty diff or the diff is | 374 ;; differences found), or 1 (either non-empty diff or the diff is |
375 ;; run asynchronously). | 375 ;; run asynchronously). |
376 ;; | 376 ;; |
377 ;; - revision-completion-table (file) | 377 ;; - revision-completion-table (files) |
378 ;; | 378 ;; |
379 ;; Return a completion table for existing revisions of FILE. | 379 ;; Return a completion table for existing revisions of FILES. |
380 ;; The default is to not use any completion table. | 380 ;; The default is to not use any completion table. |
381 ;; | |
382 ;; - diff-tree (dir &optional rev1 rev2) | |
383 ;; | |
384 ;; Insert the diff for all files at and below DIR into the *vc-diff* | |
385 ;; buffer. The meaning of REV1 and REV2 is the same as for | |
386 ;; vc-BACKEND-diff. The default implementation does an explicit tree | |
387 ;; walk, calling vc-BACKEND-diff for each individual file. | |
388 ;; | 381 ;; |
389 ;; - annotate-command (file buf &optional rev) | 382 ;; - annotate-command (file buf &optional rev) |
390 ;; | 383 ;; |
391 ;; If this function is provided, it should produce an annotated display | 384 ;; If this function is provided, it should produce an annotated display |
392 ;; of FILE in BUF, relative to revision REV. Annotation means each line | 385 ;; of FILE in BUF, relative to revision REV. Annotation means each line |
618 "If non-nil, show only locked or locally modified files in VC Dired." | 611 "If non-nil, show only locked or locally modified files in VC Dired." |
619 :type 'boolean | 612 :type 'boolean |
620 :group 'vc | 613 :group 'vc |
621 :version "20.3") | 614 :version "20.3") |
622 | 615 |
623 (defcustom vc-directory-exclusion-list '("SCCS" "RCS" "CVS" "MCVS" ".svn" | 616 (defcustom vc-directory-exclusion-list '("SCCS" "RCS" "CVS" "MCVS" ".svn" |
624 ".git" ".hg" ".bzr" "{arch}") | 617 ".git" ".hg" ".bzr" "{arch}") |
625 "List of directory names to be ignored when walking directory trees." | 618 "List of directory names to be ignored when walking directory trees." |
626 :type '(repeat string) | 619 :type '(repeat string) |
627 :group 'vc) | 620 :group 'vc) |
628 | 621 |
857 been updated to their corresponding values." | 850 been updated to their corresponding values." |
858 (declare (debug t)) | 851 (declare (debug t)) |
859 `(let ((vc-touched-properties (list t))) | 852 `(let ((vc-touched-properties (list t))) |
860 ,form | 853 ,form |
861 (dolist (file ,files) | 854 (dolist (file ,files) |
862 (mapc (lambda (setting) | 855 (dolist (setting ,settings) |
863 (let ((property (car setting))) | 856 (let ((property (car setting))) |
864 (unless (memq property vc-touched-properties) | 857 (unless (memq property vc-touched-properties) |
865 (put (intern file vc-file-prop-obarray) | 858 (put (intern file vc-file-prop-obarray) |
866 property (cdr setting))))) | 859 property (cdr setting)))))))) |
867 ,settings)))) | |
868 | 860 |
869 ;; Two macros for elisp programming | 861 ;; Two macros for elisp programming |
870 | 862 |
871 ;;;###autoload | 863 ;;;###autoload |
872 (defmacro with-vc-file (file comment &rest body) | 864 (defmacro with-vc-file (file comment &rest body) |
873 "Check out a writable copy of FILE if necessary, then execute BODY. | 865 "Check out a writable copy of FILE if necessary, then execute BODY. |
874 Check in FILE with COMMENT (a string) after BODY has been executed. | 866 Check in FILE with COMMENT (a string) after BODY has been executed. |
875 FILE is passed through `expand-file-name'; BODY executed within | 867 FILE is passed through `expand-file-name'; BODY executed within |
876 `save-excursion'. If FILE is not under version control, or you are | 868 `save-excursion'. If FILE is not under version control, or you are |
877 using a locking version-control system and the file is locked by | 869 using a locking version-control system and the file is locked by |
878 somebody else, signal error." | 870 somebody else, signal error." |
879 (declare (debug t) (indent 2)) | 871 (declare (debug t) (indent 2)) |
880 (let ((filevar (make-symbol "file"))) | 872 (let ((filevar (make-symbol "file"))) |
881 `(let ((,filevar (expand-file-name ,file))) | 873 `(let ((,filevar (expand-file-name ,file))) |
882 (or (vc-backend ,filevar) | 874 (or (vc-backend ,filevar) |
1008 already current, set it up properly and erase it. The command is | 1000 already current, set it up properly and erase it. The command is |
1009 considered successful if its exit status does not exceed OKSTATUS (if | 1001 considered successful if its exit status does not exceed OKSTATUS (if |
1010 OKSTATUS is nil, that means to ignore error status, if it is `async', that | 1002 OKSTATUS is nil, that means to ignore error status, if it is `async', that |
1011 means not to wait for termination of the subprocess; if it is t it means to | 1003 means not to wait for termination of the subprocess; if it is t it means to |
1012 ignore all execution errors). FILE-OR-LIST is the name of a working file; | 1004 ignore all execution errors). FILE-OR-LIST is the name of a working file; |
1013 it may be a list of files or be nil (to execute commands that don't expect | 1005 it may be a list of files or be nil (to execute commands that don't expect |
1014 a file name or set of files). If an optional list of FLAGS is present, | 1006 a file name or set of files). If an optional list of FLAGS is present, |
1015 that is inserted into the command line before the filename." | 1007 that is inserted into the command line before the filename." |
1016 ;; FIXME: file-relative-name can return a bogus result because | 1008 ;; FIXME: file-relative-name can return a bogus result because |
1017 ;; it doesn't look at the actual file-system to see if symlinks | 1009 ;; it doesn't look at the actual file-system to see if symlinks |
1018 ;; come into play. | 1010 ;; come into play. |
1019 (let* ((files | 1011 (let* ((files |
1020 (mapcar (lambda (f) (file-relative-name (expand-file-name f))) | 1012 (mapcar (lambda (f) (file-relative-name (expand-file-name f))) |
1021 (if (listp file-or-list) file-or-list (list file-or-list)))) | 1013 (if (listp file-or-list) file-or-list (list file-or-list)))) |
1022 (full-command | 1014 (full-command |
1023 ;; What we're doing here is preparing a version of the command | 1015 ;; What we're doing here is preparing a version of the command |
1024 ;; for display in a debug-progess message. If it's fewer than | 1016 ;; for display in a debug-progess message. If it's fewer than |
1025 ;; 20 characters display the entire command (without trailing | 1017 ;; 20 characters display the entire command (without trailing |
1026 ;; newline). Otherwise display the first 20 followed by an ellipsis. | 1018 ;; newline). Otherwise display the first 20 followed by an ellipsis. |
1027 (concat (if (string= (substring command -1) "\n") | 1019 (concat (if (string= (substring command -1) "\n") |
1028 (substring command 0 -1) | 1020 (substring command 0 -1) |
1029 command) | 1021 command) |
1030 " " | 1022 " " |
1031 (vc-delistify (mapcar (lambda (s) (if (> (length s) 20) (concat (substring s 0 2) "...") s)) flags)) | 1023 (vc-delistify (mapcar (lambda (s) (if (> (length s) 20) (concat (substring s 0 2) "...") s)) flags)) |
1032 " " (vc-delistify files)))) | 1024 " " (vc-delistify files)))) |
1033 (save-current-buffer | 1025 (save-current-buffer |
1034 (unless (or (eq buffer t) | 1026 (unless (or (eq buffer t) |
1035 (and (stringp buffer) | 1027 (and (stringp buffer) |
1036 (string= (buffer-name) buffer)) | 1028 (string= (buffer-name) buffer)) |
1080 (if (integerp status) (format "status %d" status) status)))) | 1072 (if (integerp status) (format "status %d" status) status)))) |
1081 ;; We're done | 1073 ;; We're done |
1082 (if vc-command-messages | 1074 (if vc-command-messages |
1083 (message "Running %s...OK = %d" full-command status))) | 1075 (message "Running %s...OK = %d" full-command status))) |
1084 (vc-exec-after | 1076 (vc-exec-after |
1085 `(run-hook-with-args 'vc-post-command-functions | 1077 `(run-hook-with-args 'vc-post-command-functions |
1086 ',command ',file-or-list ',flags)) | 1078 ',command ',file-or-list ',flags)) |
1087 status)))) | 1079 status)))) |
1088 | 1080 |
1089 (defun vc-position-context (posn) | 1081 (defun vc-position-context (posn) |
1090 "Save a bit of the text around POSN in the current buffer. | 1082 "Save a bit of the text around POSN in the current buffer. |
1166 (defun vc-restore-buffer-context (context) | 1158 (defun vc-restore-buffer-context (context) |
1167 "Restore point/mark, and reparse any affected compilation buffers. | 1159 "Restore point/mark, and reparse any affected compilation buffers. |
1168 CONTEXT is that which `vc-buffer-context' returns." | 1160 CONTEXT is that which `vc-buffer-context' returns." |
1169 (let ((point-context (nth 0 context)) | 1161 (let ((point-context (nth 0 context)) |
1170 (mark-context (nth 1 context)) | 1162 (mark-context (nth 1 context)) |
1171 (reparse (nth 2 context))) | 1163 ;; (reparse (nth 2 context)) |
1164 ) | |
1172 ;; The new compilation code does not use compilation-error-list any | 1165 ;; The new compilation code does not use compilation-error-list any |
1173 ;; more, so the code below is now ineffective and might as well | 1166 ;; more, so the code below is now ineffective and might as well |
1174 ;; be disabled. -- Stef | 1167 ;; be disabled. -- Stef |
1175 ;; ;; Reparse affected compilation buffers. | 1168 ;; ;; Reparse affected compilation buffers. |
1176 ;; (while reparse | 1169 ;; (while reparse |
1249 (vc-file-tree-walk | 1242 (vc-file-tree-walk |
1250 node (lambda (f) (if (vc-backend f) (push f flattened))))) | 1243 node (lambda (f) (if (vc-backend f) (push f flattened))))) |
1251 (nreverse flattened))) | 1244 (nreverse flattened))) |
1252 | 1245 |
1253 (defun vc-deduce-fileset (&optional allow-directory-wildcard) | 1246 (defun vc-deduce-fileset (&optional allow-directory-wildcard) |
1254 "Deduce a set of files and a backend to apply an operation to. | 1247 "Deduce a set of files and a backend to which to apply an operation. |
1255 | 1248 |
1256 If we're in VC-dired-mode, the fileset is the list of marked | 1249 If we're in VC-dired mode, the fileset is the list of marked files. |
1257 files. Otherwise, if we're looking at a buffer visiting a | 1250 Otherwise, if we're looking at a buffer visiting a version-controlled file, |
1258 version-controlled file. the fileset is a singleton containing | 1251 the fileset is a singleton containing this file. |
1259 the relative filename, throw an error. | 1252 If neither of these things is true, but ALLOW-DIRECTORY-WILDCARD is on |
1260 | 1253 and we're in a dired buffer, select the current directory. |
1261 If neither of these things is true, but allow-directory-wildcard is on, | 1254 Otherwise, throw an error." |
1262 select all files under version control at and below the current | 1255 (cond (vc-dired-mode |
1263 directory. | 1256 (let ((marked (dired-map-over-marks (dired-get-filename) nil))) |
1264 | |
1265 Otherwise, throw an error. | |
1266 " | |
1267 (cond (vc-dired-mode | |
1268 (let ((regexp (dired-marker-regexp)) | |
1269 (marked (dired-map-over-marks (dired-get-filename) nil))) | |
1270 (unless marked | 1257 (unless marked |
1271 (error "No files have been selected.")) | 1258 (error "No files have been selected.")) |
1272 ;; All members of the fileset must have the same backend | 1259 ;; All members of the fileset must have the same backend |
1273 (let ((firstbackend (vc-backend (car marked)))) | 1260 (let ((firstbackend (vc-backend (car marked)))) |
1274 (mapc (lambda (f) (unless (eq (vc-backend f) firstbackend) | 1261 (dolist (f (cdr marked)) |
1275 (error "All members of a fileset must be under the same version-control system."))) | 1262 (unless (eq (vc-backend f) firstbackend) |
1276 (cdr marked))) | 1263 (error "All members of a fileset must be under the same version-control system.")))) |
1277 marked)) | 1264 marked)) |
1278 ((vc-backend buffer-file-name) | 1265 ((vc-backend buffer-file-name) |
1279 (list buffer-file-name)) | 1266 (list buffer-file-name)) |
1280 ((and vc-parent-buffer (buffer-file-name vc-parent-buffer)) | 1267 ((and vc-parent-buffer (buffer-file-name vc-parent-buffer)) |
1281 (progn | 1268 (progn |
1282 (set-buffer vc-parent-buffer) | 1269 (set-buffer vc-parent-buffer) |
1283 (vc-deduce-fileset))) | 1270 (vc-deduce-fileset))) |
1284 ;; This is guarded by an enabling arg so users won't potentially | 1271 ;; This is guarded by an enabling arg so users won't potentially |
1285 ;; shoot themselves in the foot by modifying a fileset they can't | 1272 ;; shoot themselves in the foot by modifying a fileset they can't |
1286 ;; verify by eyeball. Allow it for nondestructive commands like | 1273 ;; verify by eyeball. Allow it for nondestructive commands like |
1287 ;; making diffs, or possibly for destructive ones that have | 1274 ;; making diffs, or possibly for destructive ones that have |
1288 ;; confirmation prompts. | 1275 ;; confirmation prompts. |
1289 (allow-directory-wildcard | 1276 ((and allow-directory-wildcard |
1277 ;; I think this is a misfeature. For now, I'll leave it in, but | |
1278 ;; I'll disable it anywhere else than in dired buffers. --Stef | |
1279 (and (derived-mode-p 'dired-mode) | |
1280 (equal buffer-file-name nil) | |
1281 (equal list-buffers-directory default-directory))) | |
1290 (progn | 1282 (progn |
1291 (message "All version-controlled files below %s selected." | 1283 (message "All version-controlled files below %s selected." |
1292 default-directory) | 1284 default-directory) |
1293 (list default-directory))) | 1285 (list default-directory))) |
1294 (t (error "No fileset is available here.")))) | 1286 (t (error "No fileset is available here.")))) |
1375 with the logmessage as change commentary. A writable file is retained. | 1367 with the logmessage as change commentary. A writable file is retained. |
1376 If the repository file is changed, you are asked if you want to | 1368 If the repository file is changed, you are asked if you want to |
1377 merge in the changes into your working copy." | 1369 merge in the changes into your working copy." |
1378 (interactive "P") | 1370 (interactive "P") |
1379 (let* ((files (vc-deduce-fileset)) | 1371 (let* ((files (vc-deduce-fileset)) |
1380 (backend (vc-backend (car files))) | |
1381 (state (vc-state (car files))) | 1372 (state (vc-state (car files))) |
1382 (model (vc-checkout-model (car files))) | 1373 (model (vc-checkout-model (car files))) |
1383 revision) | 1374 revision) |
1384 ;; Verify that the fileset is homogenous | 1375 ;; Verify that the fileset is homogenous |
1385 (dolist (file (cdr files)) | 1376 (dolist (file (cdr files)) |
1409 (vc-buffer-sync t) | 1400 (vc-buffer-sync t) |
1410 (if (buffer-modified-p) | 1401 (if (buffer-modified-p) |
1411 (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file)) | 1402 (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file)) |
1412 (error "Aborted"))))))) | 1403 (error "Aborted"))))))) |
1413 ;; Do the right thing | 1404 ;; Do the right thing |
1414 (cond | 1405 (cond |
1415 ;; Files aren't registered | 1406 ;; Files aren't registered |
1416 ((not state) | 1407 ((not state) |
1417 (mapc 'vc-register files)) | 1408 (mapc 'vc-register files)) |
1418 ;; Files are up-to-date, or need a merge and user specified a revision | 1409 ;; Files are up-to-date, or need a merge and user specified a revision |
1419 ((or (eq state 'up-to-date) (and verbose (eq state 'needs-patch))) | 1410 ((or (eq state 'up-to-date) (and verbose (eq state 'needs-patch))) |
1421 (verbose | 1412 (verbose |
1422 ;; go to a different revision | 1413 ;; go to a different revision |
1423 (setq revision (read-string "Branch, revision, or backend to move to: ")) | 1414 (setq revision (read-string "Branch, revision, or backend to move to: ")) |
1424 (let ((vsym (intern-soft (upcase revision)))) | 1415 (let ((vsym (intern-soft (upcase revision)))) |
1425 (if (member vsym vc-handled-backends) | 1416 (if (member vsym vc-handled-backends) |
1426 (mapc (lambda (file) (vc-transfer-file file vsym)) files) | 1417 (dolist (file files) (vc-transfer-file file vsym)) |
1427 (mapc (lambda (file) | 1418 (dolist (file files) |
1428 (vc-checkout file (eq model 'implicit) revision)))))) | 1419 (vc-checkout file (eq model 'implicit) revision))))) |
1429 ((not (eq model 'implicit)) | 1420 ((not (eq model 'implicit)) |
1430 ;; check the files out | 1421 ;; check the files out |
1431 (mapc (lambda (file) (vc-checkout file t)) files)) | 1422 (dolist (file files) (vc-checkout file t))) |
1432 (t | 1423 (t |
1433 ;; do nothing | 1424 ;; do nothing |
1434 (message "Fileset is up-to-date")))) | 1425 (message "Fileset is up-to-date")))) |
1435 ;; Files have local changes | 1426 ;; Files have local changes |
1436 ((eq state 'edited) | 1427 ((eq state 'edited) |
1437 (let ((ready-for-commit files)) | 1428 (let ((ready-for-commit files)) |
1438 ;; If files are edited but read-only, give user a chance to correct | 1429 ;; If files are edited but read-only, give user a chance to correct |
1439 (dolist (file files) | 1430 (dolist (file files) |
1440 (if (not (file-writable-p file)) | 1431 (if (not (file-writable-p file)) |
1442 ;; Make the file+buffer read-write. | 1433 ;; Make the file+buffer read-write. |
1443 (unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue?" file)) | 1434 (unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue?" file)) |
1444 (error "Aborted")) | 1435 (error "Aborted")) |
1445 (set-file-modes file (logior (file-modes file) 128)) | 1436 (set-file-modes file (logior (file-modes file) 128)) |
1446 (let ((visited (get-file-buffer file))) | 1437 (let ((visited (get-file-buffer file))) |
1447 (if visited | 1438 (if visited |
1448 (save-excursion | 1439 (with-current-buffer visited |
1449 (set-buffer visited) | |
1450 (toggle-read-only -1))))))) | 1440 (toggle-read-only -1))))))) |
1451 ;; Allow user to revert files with no changes | 1441 ;; Allow user to revert files with no changes |
1452 (save-excursion | 1442 (save-excursion |
1453 (let ((revertlist '())) | 1443 (dolist (file files) |
1454 (dolist (file files) | 1444 (let ((visited (get-file-buffer file))) |
1455 (let ((visited (get-file-buffer file))) | 1445 ;; For files with locking, if the file does not contain |
1456 ;; For files with locking, if the file does not contain | 1446 ;; any changes, just let go of the lock, i.e. revert. |
1457 ;; any changes, just let go of the lock, i.e. revert. | 1447 (if (and (not (eq model 'implicit)) |
1458 (if (and (not (eq model 'implicit)) | 1448 (vc-workfile-unchanged-p file) |
1459 (vc-workfile-unchanged-p file) | 1449 ;; If buffer is modified, that means the user just |
1460 ;; If buffer is modified, that means the user just | 1450 ;; said no to saving it; in that case, don't revert, |
1461 ;; said no to saving it; in that case, don't revert, | 1451 ;; because the user might intend to save after |
1462 ;; because the user might intend to save after | 1452 ;; finishing the log entry and committing. |
1463 ;; finishing the log entry and committing. | 1453 (not (and visited (buffer-modified-p)))) |
1464 (not (and visited (buffer-modified-p)))) | 1454 (progn |
1465 (progn | 1455 (vc-revert-file file) |
1466 (vc-revert-file file) | 1456 (delete file ready-for-commit)))))) |
1467 (delete file ready-for-commit))))))) | |
1468 ;; Remaining files need to be committed | 1457 ;; Remaining files need to be committed |
1469 (if (not ready-for-commit) | 1458 (if (not ready-for-commit) |
1470 (message "No files remain to be committed") | 1459 (message "No files remain to be committed") |
1471 (if (not verbose) | 1460 (if (not verbose) |
1472 (vc-checkin ready-for-commit) | 1461 (vc-checkin ready-for-commit) |
1476 (if (member vsym vc-handled-backends) | 1465 (if (member vsym vc-handled-backends) |
1477 (vc-transfer-file file vsym) | 1466 (vc-transfer-file file vsym) |
1478 (vc-checkin ready-for-commit revision)))))))) | 1467 (vc-checkin ready-for-commit revision)))))))) |
1479 ;; locked by somebody else (locking VCSes only) | 1468 ;; locked by somebody else (locking VCSes only) |
1480 ((stringp state) | 1469 ((stringp state) |
1481 (let ((revision | 1470 (let ((revision |
1482 (if verbose | 1471 (if verbose |
1483 (read-string "Revision to steal: ") | 1472 (read-string "Revision to steal: ") |
1484 (vc-working-revision file)))) | 1473 (vc-working-revision file)))) |
1485 (mapc (lambda (file) (vc-steal-lock file revision state) files)))) | 1474 (dolist (file files) (vc-steal-lock file revision state)))) |
1486 ;; needs-patch | 1475 ;; needs-patch |
1487 ((eq state 'needs-patch) | 1476 ((eq state 'needs-patch) |
1488 (dolist (file files) | 1477 (dolist (file files) |
1489 (if (yes-or-no-p (format | 1478 (if (yes-or-no-p (format |
1490 "%s is not up-to-date. Get latest revision? " | 1479 "%s is not up-to-date. Get latest revision? " |
1491 (file-name-nondirectory file))) | 1480 (file-name-nondirectory file))) |
1502 (vc-maybe-resolve-conflicts file (vc-call merge-news file))))) | 1491 (vc-maybe-resolve-conflicts file (vc-call merge-news file))))) |
1503 | 1492 |
1504 ;; unlocked-changes | 1493 ;; unlocked-changes |
1505 ((eq state 'unlocked-changes) | 1494 ((eq state 'unlocked-changes) |
1506 (dolist (file files) | 1495 (dolist (file files) |
1507 (if (not (equal buffer-file-name file)) | 1496 (if (not (equal buffer-file-name file)) |
1508 (find-file-other-window file)) | 1497 (find-file-other-window file)) |
1509 (if (save-window-excursion | 1498 (if (save-window-excursion |
1510 (vc-diff-internal | 1499 (vc-diff-internal nil (list file) (vc-working-revision file) nil) |
1511 (vc-backend file) nil (list file) | |
1512 (vc-working-revision file) nil) | |
1513 (goto-char (point-min)) | 1500 (goto-char (point-min)) |
1514 (let ((inhibit-read-only t)) | 1501 (let ((inhibit-read-only t)) |
1515 (insert | 1502 (insert |
1516 (format "Changes to %s since last lock:\n\n" file))) | 1503 (format "Changes to %s since last lock:\n\n" file))) |
1517 (not (beep)) | 1504 (not (beep)) |
1642 INITIAL-CONTENTS is nil, do action immediately as if the user had | 1629 INITIAL-CONTENTS is nil, do action immediately as if the user had |
1643 entered COMMENT. If COMMENT is t, also do action immediately with an | 1630 entered COMMENT. If COMMENT is t, also do action immediately with an |
1644 empty comment. Remember the file's buffer in `vc-parent-buffer' | 1631 empty comment. Remember the file's buffer in `vc-parent-buffer' |
1645 \(current one if no file). AFTER-HOOK specifies the local value | 1632 \(current one if no file). AFTER-HOOK specifies the local value |
1646 for vc-log-operation-hook." | 1633 for vc-log-operation-hook." |
1647 (let ((parent | 1634 (let ((parent |
1648 (if (and files (equal (length files) 1)) | 1635 (if (and files (equal (length files) 1)) |
1649 (get-file-buffer (car files)) | 1636 (get-file-buffer (car files)) |
1650 (current-buffer)))) | 1637 (current-buffer)))) |
1651 (if vc-before-checkin-hook | 1638 (if vc-before-checkin-hook |
1652 (if files | 1639 (if files |
1653 (with-current-buffer parent | 1640 (with-current-buffer parent |
1654 (run-hooks 'vc-before-checkin-hook)) | 1641 (run-hooks 'vc-before-checkin-hook)) |
1772 the buffer contents as a comment." | 1759 the buffer contents as a comment." |
1773 (interactive) | 1760 (interactive) |
1774 ;; Check and record the comment, if any. | 1761 ;; Check and record the comment, if any. |
1775 (unless nocomment | 1762 (unless nocomment |
1776 ;; Comment too long? | 1763 ;; Comment too long? |
1777 (vc-call-backend (or (and vc-log-fileset (vc-backend (car vc-log-fileset))) | 1764 (vc-call-backend (or (if vc-log-fileset (vc-backend vc-log-fileset)) |
1778 (vc-responsible-backend default-directory)) | 1765 (vc-responsible-backend default-directory)) |
1779 'logentry-check) | 1766 'logentry-check) |
1780 (run-hooks 'vc-logentry-check-hook)) | 1767 (run-hooks 'vc-logentry-check-hook)) |
1781 ;; Sync parent buffer in case the user modified it while editing the comment. | 1768 ;; Sync parent buffer in case the user modified it while editing the comment. |
1782 ;; But not if it is a vc-dired buffer. | 1769 ;; But not if it is a vc-dired buffer. |
1808 (logbuf (pop-to-buffer "*VC-log*") | 1795 (logbuf (pop-to-buffer "*VC-log*") |
1809 (bury-buffer) | 1796 (bury-buffer) |
1810 (pop-to-buffer tmp-vc-parent-buffer)))) | 1797 (pop-to-buffer tmp-vc-parent-buffer)))) |
1811 ;; Now make sure we see the expanded headers | 1798 ;; Now make sure we see the expanded headers |
1812 (if log-fileset | 1799 (if log-fileset |
1813 (mapc | 1800 (mapc |
1814 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t)) | 1801 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t)) |
1815 log-fileset)) | 1802 log-fileset)) |
1816 (if vc-dired-mode | 1803 (if vc-dired-mode |
1817 (dired-move-to-filename)) | 1804 (dired-move-to-filename)) |
1818 (run-hooks after-hook 'vc-finish-logentry-hook))) | 1805 (run-hooks after-hook 'vc-finish-logentry-hook))) |
1819 | 1806 |
1820 ;;; Additional entry points for examining version histories | 1807 ;;; Additional entry points for examining version histories |
1821 | 1808 |
1822 (defun vc-default-diff-tree (backend dir rev1 rev2) | 1809 ;; (defun vc-default-diff-tree (backend dir rev1 rev2) |
1823 "List differences for all registered files at and below DIR. | 1810 ;; "List differences for all registered files at and below DIR. |
1824 The meaning of REV1 and REV2 is the same as for `vc-revision-diff'." | 1811 ;; The meaning of REV1 and REV2 is the same as for `vc-revision-diff'." |
1825 ;; This implementation does an explicit tree walk, and calls | 1812 ;; ;; This implementation does an explicit tree walk, and calls |
1826 ;; vc-BACKEND-diff directly for each file. An optimization | 1813 ;; ;; vc-BACKEND-diff directly for each file. An optimization |
1827 ;; would be to use `vc-diff-internal', so that diffs can be local, | 1814 ;; ;; would be to use `vc-diff-internal', so that diffs can be local, |
1828 ;; and to call it only for files that are actually changed. | 1815 ;; ;; and to call it only for files that are actually changed. |
1829 ;; However, this is expensive for some backends, and so it is left | 1816 ;; ;; However, this is expensive for some backends, and so it is left |
1830 ;; to backend-specific implementations. | 1817 ;; ;; to backend-specific implementations. |
1831 (setq default-directory dir) | 1818 ;; (setq default-directory dir) |
1832 (vc-file-tree-walk | 1819 ;; (vc-file-tree-walk |
1833 default-directory | 1820 ;; default-directory |
1834 (lambda (f) | 1821 ;; (lambda (f) |
1835 (vc-exec-after | 1822 ;; (vc-exec-after |
1836 `(let ((coding-system-for-read (vc-coding-system-for-diff ',f))) | 1823 ;; `(let ((coding-system-for-read (vc-coding-system-for-diff ',f))) |
1837 (message "Looking at %s" ',f) | 1824 ;; (message "Looking at %s" ',f) |
1838 (vc-call-backend ',(vc-backend f) | 1825 ;; (vc-call-backend ',(vc-backend f) |
1839 'diff (list ',f) ',rev1 ',rev2)))))) | 1826 ;; 'diff (list ',f) ',rev1 ',rev2)))))) |
1840 | 1827 |
1841 (defun vc-coding-system-for-diff (file) | 1828 (defun vc-coding-system-for-diff (file) |
1842 "Return the coding system for reading diff output for FILE." | 1829 "Return the coding system for reading diff output for FILE." |
1843 (or coding-system-for-read | 1830 (or coding-system-for-read |
1844 ;; if we already have this file open, | 1831 ;; if we already have this file open, |
1883 (insert "No differences found.\n") | 1870 (insert "No differences found.\n") |
1884 (insert (format "\n\nDiffs between %s and %s end here." rev1-name rev2-name))))) | 1871 (insert (format "\n\nDiffs between %s and %s end here." rev1-name rev2-name))))) |
1885 (goto-char (point-min)) | 1872 (goto-char (point-min)) |
1886 (shrink-window-if-larger-than-buffer)) | 1873 (shrink-window-if-larger-than-buffer)) |
1887 | 1874 |
1888 (defun vc-diff-internal (backend async files rev1 rev2 &optional verbose) | 1875 (defvar vc-diff-added-files nil |
1876 "If non-nil, diff added files by comparing them to /dev/null.") | |
1877 | |
1878 (defun vc-diff-internal (async files rev1 rev2 &optional verbose) | |
1889 "Report diffs between two revisions of a fileset. | 1879 "Report diffs between two revisions of a fileset. |
1890 Diff output goes to the *vc-diff* buffer. The function | 1880 Diff output goes to the *vc-diff* buffer. The function |
1891 returns t if the buffer had changes, nil otherwise." | 1881 returns t if the buffer had changes, nil otherwise." |
1892 (let* ((filenames (vc-delistify files)) | 1882 (let* ((filenames (vc-delistify files)) |
1893 (rev1-name (or rev1 "working revision")) | 1883 (rev1-name (or rev1 "working revision")) |
1894 (rev2-name (or rev2 "workfile")) | 1884 (rev2-name (or rev2 "workfile")) |
1895 ;; Set coding system based on the first file. It's a kluge, | 1885 ;; Set coding system based on the first file. It's a kluge, |
1896 ;; but the only way to set it for each file included would | 1886 ;; but the only way to set it for each file included would |
1897 ;; be to call the back end separately for each file. | 1887 ;; be to call the back end separately for each file. |
1898 (coding-system-for-read | 1888 (coding-system-for-read |
1899 (if files (vc-coding-system-for-diff (car files)) 'undecided))) | 1889 (if files (vc-coding-system-for-diff (car files)) 'undecided))) |
1900 (vc-setup-buffer "*vc-diff*") | 1890 (vc-setup-buffer "*vc-diff*") |
1901 (message "Finding changes in %s..." filenames) | 1891 (message "Finding changes in %s..." filenames) |
1902 ;; Many backends don't handle well the case of a file that has been | 1892 ;; Many backends don't handle well the case of a file that has been |
1903 ;; added but not yet committed to the repo (notably CVS and Subversion). | 1893 ;; added but not yet committed to the repo (notably CVS and Subversion). |
1904 ;; Do that work here so the backends don't have to futz with it. | 1894 ;; Do that work here so the backends don't have to futz with it. --ESR |
1905 (let ((filtered '())) | 1895 ;; |
1906 (dolist (file files) | 1896 ;; Actually most backends (including CVS) have options to control the |
1907 (cond ((and (not (file-directory-p file)) (string= (vc-working-revision file) "0")) | 1897 ;; behavior since which one is better depends on the user and on the |
1908 (progn | 1898 ;; situation). Worse yet: this code does not handle the case where |
1909 ;; This file is added but not yet committed; | 1899 ;; `file' is a directory which contains added files. |
1910 ;; there is no master file to diff against. | 1900 ;; I made it conditional on vc-diff-added-files but it should probably |
1911 (if (or rev1 rev2) | 1901 ;; just be removed (or copied/moved to specific backends). --Stef. |
1912 (error "No revisions of %s exist" file) | 1902 (when vc-diff-added-files |
1913 ;; We regard this as "changed". | 1903 (let ((filtered '())) |
1914 ;; Diff it against /dev/null. | 1904 (dolist (file files) |
1915 (apply 'vc-do-command "*vc-diff*" | 1905 (if (or (file-directory-p file) |
1916 1 "diff" file | 1906 (not (string= (vc-working-revision file) "0"))) |
1917 (append (vc-switches nil 'diff) '("/dev/null")))))) | 1907 (push file filtered) |
1918 (t | 1908 ;; This file is added but not yet committed; |
1919 (add-to-list 'filtered file t)))) | 1909 ;; there is no master file to diff against. |
1920 (let ((vc-disable-async-diff (not async))) | 1910 (if (or rev1 rev2) |
1921 (vc-call-backend backend 'diff filtered rev1 rev2 "*vc-diff*"))) | 1911 (error "No revisions of %s exist" file) |
1912 ;; We regard this as "changed". | |
1913 ;; Diff it against /dev/null. | |
1914 (apply 'vc-do-command "*vc-diff*" | |
1915 1 "diff" file | |
1916 (append (vc-switches nil 'diff) '("/dev/null")))))) | |
1917 (setq files (nreverse filtered)))) | |
1918 (let ((vc-disable-async-diff (not async))) | |
1919 (vc-call diff files rev1 rev2 "*vc-diff*")) | |
1922 (set-buffer "*vc-diff*") | 1920 (set-buffer "*vc-diff*") |
1923 (if (and (zerop (buffer-size)) | 1921 (if (and (zerop (buffer-size)) |
1924 (not (get-buffer-process (current-buffer)))) | 1922 (not (get-buffer-process (current-buffer)))) |
1925 ;; Treat this case specially so as not to pop the buffer. | 1923 ;; Treat this case specially so as not to pop the buffer. |
1926 (progn | 1924 (progn |
1934 ;; In the async case, we return t even if there are no differences | 1932 ;; In the async case, we return t even if there are no differences |
1935 ;; because we don't know that yet. | 1933 ;; because we don't know that yet. |
1936 t))) | 1934 t))) |
1937 | 1935 |
1938 ;;;###autoload | 1936 ;;;###autoload |
1939 (defun vc-history-diff (backend files rev1 rev2) | 1937 (defun vc-version-diff (files rev1 rev2) |
1940 "Report diffs between revisions of the fileset in the repository history." | 1938 "Report diffs between revisions of the fileset in the repository history." |
1941 (interactive | 1939 (interactive |
1942 (let* ((files (vc-deduce-fileset t)) | 1940 (let* ((files (vc-deduce-fileset t)) |
1943 (first (car files)) | 1941 (first (car files)) |
1944 (backend (vc-backend first)) | |
1945 (completion-table | 1942 (completion-table |
1946 (vc-call-backend backend 'revision-completion-table first)) | 1943 (vc-call revision-completion-table files)) |
1947 (rev1-default nil) | 1944 (rev1-default nil) |
1948 (rev2-default nil)) | 1945 (rev2-default nil)) |
1949 (cond | 1946 (cond |
1950 ;; someday we may be able to do revision completion on non-singleton | 1947 ;; someday we may be able to do revision completion on non-singleton |
1951 ;; filesets, but not yet. | 1948 ;; filesets, but not yet. |
1978 (completing-read rev2-prompt completion-table | 1975 (completing-read rev2-prompt completion-table |
1979 nil nil nil nil rev2-default) | 1976 nil nil nil nil rev2-default) |
1980 (read-string rev2-prompt nil nil rev2-default)))) | 1977 (read-string rev2-prompt nil nil rev2-default)))) |
1981 (if (string= rev1 "") (setq rev1 nil)) | 1978 (if (string= rev1 "") (setq rev1 nil)) |
1982 (if (string= rev2 "") (setq rev2 nil)) | 1979 (if (string= rev2 "") (setq rev2 nil)) |
1983 (list backend files rev1 rev2)))) | 1980 (list files rev1 rev2)))) |
1984 (if (and (not rev1) rev2) | 1981 (if (and (not rev1) rev2) |
1985 (error "Not a valid revision range.")) | 1982 (error "Not a valid revision range.")) |
1986 (vc-diff-internal backend t files rev1 rev2 (interactive-p))) | 1983 (vc-diff-internal t files rev1 rev2 (interactive-p))) |
1987 | 1984 |
1988 (defun vc-contains-version-controlled-file (dir) | 1985 ;; (defun vc-contains-version-controlled-file (dir) |
1989 "Return t if DIR contains a version-controlled file, nil otherwise." | 1986 ;; "Return t if DIR contains a version-controlled file, nil otherwise." |
1990 (catch 'found | 1987 ;; (catch 'found |
1991 (mapc (lambda (f) (and (not (file-directory-p f)) (vc-backend f) (throw 'found 't))) (directory-files dir)) | 1988 ;; (mapc (lambda (f) (and (not (file-directory-p f)) (vc-backend f) (throw 'found 't))) (directory-files dir)) |
1992 nil)) | 1989 ;; nil)) |
1993 | 1990 |
1994 ;;;###autoload | 1991 ;;;###autoload |
1995 (defun vc-diff (historic) | 1992 (defun vc-diff (historic &optional not-urgent) |
1996 "Display diffs between file revisions. | 1993 "Display diffs between file revisions. |
1997 Normally this compares the currently selected fileset with their | 1994 Normally this compares the currently selected fileset with their |
1998 working revisions. With a prefix argument HISTORIC, it reads two revision | 1995 working revisions. With a prefix argument HISTORIC, it reads two revision |
1999 designators specifying which revisions to compare. | 1996 designators specifying which revisions to compare. |
2000 | 1997 |
2001 If no current fileset is available (that is, we are not in | 1998 If no current fileset is available (that is, we are not in |
2002 VC-Dired mode and the visited file of the current buffer is not | 1999 VC-Dired mode and the visited file of the current buffer is not |
2003 under version control) behave specially; if there are | 2000 under version control) and we're in a Dired buffer, use |
2004 version-controlled files in the current directory, treat all | 2001 the current directory. |
2005 version-controlled files recursively beneath the current | 2002 The optional argument NOT-URGENT non-nil means it is ok to say no to |
2006 directory as the selected fileset. | 2003 saving the buffer." |
2007 " | 2004 (interactive (list current-prefix-arg t)) |
2008 | 2005 (if historic |
2009 (interactive "P") | 2006 (call-interactively 'vc-version-diff) |
2010 (cond | 2007 (let* ((files (vc-deduce-fileset t))) |
2011 ;;((not (vc-contains-version-controlled-file default-directory)) | 2008 (if buffer-file-name (vc-buffer-sync not-urgent)) |
2012 ;;(error "No version-controlled files directly beneath default directory")) | 2009 (vc-diff-internal t files nil nil (interactive-p))))) |
2013 (historic | 2010 |
2014 (call-interactively 'vc-history-diff)) | |
2015 (t | |
2016 (let* ((files (vc-deduce-fileset t)) | |
2017 (first (car files)) | |
2018 (backend | |
2019 (cond ((file-directory-p first) | |
2020 (vc-responsible-backend first)) | |
2021 (t | |
2022 (vc-backend first))))) | |
2023 (vc-diff-internal backend t files nil nil (interactive-p)))))) | |
2024 | 2011 |
2025 ;;;###autoload | 2012 ;;;###autoload |
2026 (defun vc-revision-other-window (rev) | 2013 (defun vc-revision-other-window (rev) |
2027 "Visit revision REV of the current file in another window. | 2014 "Visit revision REV of the current file in another window. |
2028 If the current file is named `F', the revision is named `F.~REV~'. | 2015 If the current file is named `F', the revision is named `F.~REV~'. |
2250 (let ((backend-name (symbol-name (vc-responsible-backend | 2237 (let ((backend-name (symbol-name (vc-responsible-backend |
2251 default-directory)))) | 2238 default-directory)))) |
2252 (setq mode-name (concat mode-name backend-name)) | 2239 (setq mode-name (concat mode-name backend-name)) |
2253 ;; Add menu after `vc-dired-mode-map' has `dired-mode-map' as the parent. | 2240 ;; Add menu after `vc-dired-mode-map' has `dired-mode-map' as the parent. |
2254 (let ((vc-dire-menu-map (copy-keymap vc-menu-map))) | 2241 (let ((vc-dire-menu-map (copy-keymap vc-menu-map))) |
2255 (define-key-after (lookup-key vc-dired-mode-map [menu-bar]) [vc] | 2242 (define-key-after (lookup-key vc-dired-mode-map [menu-bar]) [vc] |
2256 (cons backend-name vc-dire-menu-map) 'subdir))) | 2243 (cons backend-name vc-dire-menu-map) 'subdir))) |
2257 (setq vc-dired-mode t)) | 2244 (setq vc-dired-mode t)) |
2258 | 2245 |
2259 (defun vc-dired-toggle-terse-mode () | 2246 (defun vc-dired-toggle-terse-mode () |
2260 "Toggle terse display in VC Dired." | 2247 "Toggle terse display in VC Dired." |
2375 (defun vc-dired-buffers-for-dir (dir) | 2362 (defun vc-dired-buffers-for-dir (dir) |
2376 "Return a list of all vc-dired buffers that currently display DIR." | 2363 "Return a list of all vc-dired buffers that currently display DIR." |
2377 (let (result) | 2364 (let (result) |
2378 ;; Check whether dired is loaded. | 2365 ;; Check whether dired is loaded. |
2379 (when (fboundp 'dired-buffers-for-dir) | 2366 (when (fboundp 'dired-buffers-for-dir) |
2380 (mapc (lambda (buffer) | 2367 (dolist (buffer (dired-buffers-for-dir dir)) |
2381 (with-current-buffer buffer | 2368 (with-current-buffer buffer |
2382 (if vc-dired-mode | 2369 (if vc-dired-mode |
2383 (setq result (append result (list buffer)))))) | 2370 (push buffer result))))) |
2384 (dired-buffers-for-dir dir))) | 2371 (nreverse result))) |
2385 result)) | |
2386 | 2372 |
2387 (defun vc-dired-resynch-file (file) | 2373 (defun vc-dired-resynch-file (file) |
2388 "Update the entries for FILE in any VC Dired buffers that list it." | 2374 "Update the entries for FILE in any VC Dired buffers that list it." |
2389 (let ((buffers (vc-dired-buffers-for-dir (file-name-directory file)))) | 2375 (let ((buffers (vc-dired-buffers-for-dir (file-name-directory file)))) |
2390 (when buffers | 2376 (when buffers |
2482 (defun vc-print-log (&optional working-revision) | 2468 (defun vc-print-log (&optional working-revision) |
2483 "List the change log of the current fileset in a window. | 2469 "List the change log of the current fileset in a window. |
2484 If WORKING-REVISION is non-nil, leave the point at that revision." | 2470 If WORKING-REVISION is non-nil, leave the point at that revision." |
2485 (interactive) | 2471 (interactive) |
2486 (let* ((files (vc-deduce-fileset)) | 2472 (let* ((files (vc-deduce-fileset)) |
2487 (backend (vc-backend (car files))) | 2473 (backend (vc-backend files)) |
2488 (working-revision (or working-revision (vc-working-revision (car files))))) | 2474 (working-revision (or working-revision (vc-working-revision (car files))))) |
2489 ;; Don't switch to the output buffer before running the command, | 2475 ;; Don't switch to the output buffer before running the command, |
2490 ;; so that any buffer-local settings in the vc-controlled | 2476 ;; so that any buffer-local settings in the vc-controlled |
2491 ;; buffer can be accessed by the command. | 2477 ;; buffer can be accessed by the command. |
2492 (vc-call-backend backend 'print-log files "*vc-change-log*") | 2478 (vc-call-backend backend 'print-log files "*vc-change-log*") |
2511 (defun vc-revert () | 2497 (defun vc-revert () |
2512 "Revert working copies of the selected fileset to their repository contents. | 2498 "Revert working copies of the selected fileset to their repository contents. |
2513 This asks for confirmation if the buffer contents are not identical | 2499 This asks for confirmation if the buffer contents are not identical |
2514 to the working revision (except for keyword expansion)." | 2500 to the working revision (except for keyword expansion)." |
2515 (interactive) | 2501 (interactive) |
2516 (let* ((files (vc-deduce-fileset)) | 2502 (let* ((files (vc-deduce-fileset))) |
2517 (backend (vc-backend (car files)))) | |
2518 ;; If any of the files is visited by the current buffer, make | 2503 ;; If any of the files is visited by the current buffer, make |
2519 ;; sure buffer is saved. If the user says `no', abort since | 2504 ;; sure buffer is saved. If the user says `no', abort since |
2520 ;; we cannot show the changes and ask for confirmation to | 2505 ;; we cannot show the changes and ask for confirmation to |
2521 ;; discard them. | 2506 ;; discard them. |
2522 (if (or (not files) (memq (buffer-file-name) files)) | 2507 (if (or (not files) (memq (buffer-file-name) files)) |
2523 (vc-buffer-sync nil)) | 2508 (vc-buffer-sync nil)) |
2524 (dolist (file files) | 2509 (dolist (file files) |
2525 (let (buf (get-file-buffer file)) | 2510 (let ((buf (get-file-buffer file))) |
2526 (if (and buf (buffer-modified-p buf)) | 2511 (if (and buf (buffer-modified-p buf)) |
2527 (error "Please kill or save all modified buffers before reverting."))) | 2512 (error "Please kill or save all modified buffers before reverting."))) |
2528 (if (vc-up-to-date-p file) | 2513 (if (vc-up-to-date-p file) |
2529 (unless (yes-or-no-p (format "%s seems up-to-date. Revert anyway? " file)) | 2514 (unless (yes-or-no-p (format "%s seems up-to-date. Revert anyway? " file)) |
2530 (error "Revert canceled")))) | 2515 (error "Revert canceled")))) |
2531 (if (vc-diff-internal backend vc-allow-async-revert files nil nil) | 2516 (if (vc-diff-internal vc-allow-async-revert files nil nil) |
2532 (progn | 2517 (progn |
2533 (unless (yes-or-no-p (format "Discard changes in %s? " (vc-delistify files))) | 2518 (unless (yes-or-no-p (format "Discard changes in %s? " (vc-delistify files))) |
2534 (error "Revert canceled")) | 2519 (error "Revert canceled")) |
2535 (delete-windows-on "*vc-diff*") | 2520 (delete-windows-on "*vc-diff*") |
2536 (kill-buffer "*vc-diff*"))) | 2521 (kill-buffer "*vc-diff*"))) |
2545 "Roll back (remove) the most recent changeset committed to the repository. | 2530 "Roll back (remove) the most recent changeset committed to the repository. |
2546 This may be either a file-level or a repository-level operation, | 2531 This may be either a file-level or a repository-level operation, |
2547 depending on the underlying version-control system." | 2532 depending on the underlying version-control system." |
2548 (interactive) | 2533 (interactive) |
2549 (let* ((files (vc-deduce-fileset)) | 2534 (let* ((files (vc-deduce-fileset)) |
2550 (backend (vc-backend (car files))) | 2535 (backend (vc-backend files)) |
2551 (granularity (vc-call-backend backend 'revision-granularity))) | 2536 (granularity (vc-call-backend backend 'revision-granularity))) |
2552 (unless (vc-find-backend-function backend 'rollback) | 2537 (unless (vc-find-backend-function backend 'rollback) |
2553 (error "Rollback is not supported in %s" backend)) | 2538 (error "Rollback is not supported in %s" backend)) |
2554 (if (and (not (eq granularity 'repository)) (/= (length files) 1)) | 2539 (if (and (not (eq granularity 'repository)) (/= (length files) 1)) |
2555 (error "Rollback requires a singleton fileset or repository versioning")) | 2540 (error "Rollback requires a singleton fileset or repository versioning")) |
2570 (vc-setup-buffer "*vc-diff*") | 2555 (vc-setup-buffer "*vc-diff*") |
2571 (not-modified) | 2556 (not-modified) |
2572 (message "Finding changes...") | 2557 (message "Finding changes...") |
2573 (let* ((tip (vc-working-revision (car files))) | 2558 (let* ((tip (vc-working-revision (car files))) |
2574 (previous (vc-call previous-revision (car files) tip))) | 2559 (previous (vc-call previous-revision (car files) tip))) |
2575 (vc-diff-internal backend nil files previous tip)) | 2560 (vc-diff-internal nil files previous tip)) |
2576 ;; Display changes | 2561 ;; Display changes |
2577 (unless (yes-or-no-p "Discard these revisions? ") | 2562 (unless (yes-or-no-p "Discard these revisions? ") |
2578 (error "Rollback canceled")) | 2563 (error "Rollback canceled")) |
2579 (delete-windows-on "*vc-diff*") | 2564 (delete-windows-on "*vc-diff*") |
2580 (kill-buffer"*vc-diff*") | 2565 (kill-buffer"*vc-diff*") |
2581 ;; Do the actual reversions | 2566 ;; Do the actual reversions |
2584 files | 2569 files |
2585 (vc-call-backend backend 'rollback files) | 2570 (vc-call-backend backend 'rollback files) |
2586 `((vc-state . ,'up-to-date) | 2571 `((vc-state . ,'up-to-date) |
2587 (vc-checkout-time . , (nth 5 (file-attributes file))) | 2572 (vc-checkout-time . , (nth 5 (file-attributes file))) |
2588 (vc-working-revision . nil))) | 2573 (vc-working-revision . nil))) |
2589 (mapc (lambda (f) (vc-resynch-buffer f t t)) files) | 2574 (dolist (f files) (vc-resynch-buffer f t t)) |
2590 (message "Rolling back %s...done" (vc-delistify files)))) | 2575 (message "Rolling back %s...done" (vc-delistify files)))) |
2591 | 2576 |
2592 ;;;###autoload | 2577 ;;;###autoload |
2593 (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1") | 2578 (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1") |
2594 | 2579 |
2595 ;;;###autoload | 2580 ;;;###autoload |
2596 (defun vc-update () | 2581 (defun vc-update () |
2597 "Update the current fileset's files to their tip revisions. | 2582 "Update the current fileset's files to their tip revisions. |
2598 For each one that contains no changes, and is not locked, then this simply | 2583 For each one that contains no changes, and is not locked, then this simply |
2599 replaces the work file with the latest revision on its branch. If the file | 2584 replaces the work file with the latest revision on its branch. If the file |
2600 contains changes, and the backend supports merging news, then any recent | 2585 contains changes, and the backend supports merging news, then any recent |
2601 changes from the current branch are merged into the working file." | 2586 changes from the current branch are merged into the working file." |
2602 (interactive) | 2587 (interactive) |
2603 (dolist (file (vc-deduce-fileset)) | 2588 (dolist (file (vc-deduce-fileset)) |
2604 (if (buffer-modified-p (get-file-buffer file)) | 2589 (if (buffer-modified-p (get-file-buffer file)) |
2605 (error "Please kill or save all modified buffers before updating.")) | 2590 (error "Please kill or save all modified buffers before updating.")) |
2621 (vc-resynch-buffer file t t)))))) | 2606 (vc-resynch-buffer file t t)))))) |
2622 | 2607 |
2623 (defun vc-version-backup-file (file &optional rev) | 2608 (defun vc-version-backup-file (file &optional rev) |
2624 "Return name of backup file for revision REV of FILE. | 2609 "Return name of backup file for revision REV of FILE. |
2625 If version backups should be used for FILE, and there exists | 2610 If version backups should be used for FILE, and there exists |
2626 such a backup for REV or the working revision of file, return | 2611 such a backup for REV or the working revision of file, return |
2627 its name; otherwise return nil." | 2612 its name; otherwise return nil." |
2628 (when (vc-call make-version-backups-p file) | 2613 (when (vc-call make-version-backups-p file) |
2629 (let ((backup-file (vc-version-backup-file-name file rev))) | 2614 (let ((backup-file (vc-version-backup-file-name file rev))) |
2630 (if (file-exists-p backup-file) | 2615 (if (file-exists-p backup-file) |
2631 backup-file | 2616 backup-file |
3046 (with-current-buffer "*vc*" | 3031 (with-current-buffer "*vc*" |
3047 (vc-call print-log (list file)) | 3032 (vc-call print-log (list file)) |
3048 (vc-call-backend backend 'wash-log) | 3033 (vc-call-backend backend 'wash-log) |
3049 (buffer-string)))) | 3034 (buffer-string)))) |
3050 | 3035 |
3051 (defun vc-default-unregister (backend file) | |
3052 "Default implementation of `vc-unregister', signals an error." | |
3053 (error "Unregistering files is not supported for %s" backend)) | |
3054 | |
3055 (defun vc-default-receive-file (backend file rev) | 3036 (defun vc-default-receive-file (backend file rev) |
3056 "Let BACKEND receive FILE from another version control system." | 3037 "Let BACKEND receive FILE from another version control system." |
3057 (vc-call-backend backend 'register file rev "")) | 3038 (vc-call-backend backend 'register file rev "")) |
3058 | 3039 |
3059 (defun vc-default-create-snapshot (backend dir name branchp) | 3040 (defun vc-default-create-snapshot (backend dir name branchp) |
3281 age, and everything that is older than that is shown in blue. | 3262 age, and everything that is older than that is shown in blue. |
3282 | 3263 |
3283 Customization variables: | 3264 Customization variables: |
3284 | 3265 |
3285 `vc-annotate-menu-elements' customizes the menu elements of the | 3266 `vc-annotate-menu-elements' customizes the menu elements of the |
3286 mode-specific menu. `vc-annotate-color-map' and | 3267 mode-specific menu. `vc-annotate-color-map' and |
3287 `vc-annotate-very-old-color' defines the mapping of time to | 3268 `vc-annotate-very-old-color' define the mapping of time to colors. |
3288 colors. `vc-annotate-background' specifies the background color." | 3269 `vc-annotate-background' specifies the background color." |
3289 (interactive | 3270 (interactive |
3290 (save-current-buffer | 3271 (save-current-buffer |
3291 (vc-ensure-vc-buffer) | 3272 (vc-ensure-vc-buffer) |
3292 (list buffer-file-name | 3273 (list buffer-file-name |
3293 (let ((def (vc-working-revision buffer-file-name))) | 3274 (let ((def (vc-working-revision buffer-file-name))) |
3420 (setq prev-rev | 3401 (setq prev-rev |
3421 (vc-call previous-revision vc-annotate-parent-file rev-at-line)) | 3402 (vc-call previous-revision vc-annotate-parent-file rev-at-line)) |
3422 (if (not prev-rev) | 3403 (if (not prev-rev) |
3423 (message "Cannot diff from any revision prior to %s" rev-at-line) | 3404 (message "Cannot diff from any revision prior to %s" rev-at-line) |
3424 (save-window-excursion | 3405 (save-window-excursion |
3425 (vc-diff-internal | 3406 (vc-diff-internal nil (list vc-annotate-parent-file) |
3426 (vc-backend vc-annotate-parent-file) | 3407 prev-rev rev-at-line)) |
3427 nil | |
3428 (list vc-annotate-parent-file) | |
3429 prev-rev rev-at-line)) | |
3430 (switch-to-buffer "*vc-diff*")))))) | 3408 (switch-to-buffer "*vc-diff*")))))) |
3431 | 3409 |
3432 (defun vc-annotate-warp-revision (revspec) | 3410 (defun vc-annotate-warp-revision (revspec) |
3433 "Annotate the revision described by REVSPEC. | 3411 "Annotate the revision described by REVSPEC. |
3434 | 3412 |