diff options
| author | Dan Nicolaescu | 2007-10-05 04:35:37 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-10-05 04:35:37 +0000 |
| commit | 2765044b397542096d9c66c48eaa32e28fd9cce2 (patch) | |
| tree | ff6a8b38a0c447ae2fe1431a26e71b0e01668dd9 | |
| parent | 258800f85f19157263bfdbb96c526f108009364c (diff) | |
| download | emacs-2765044b397542096d9c66c48eaa32e28fd9cce2.tar.gz emacs-2765044b397542096d9c66c48eaa32e28fd9cce2.zip | |
Reorder functions, no code changes.
| -rw-r--r-- | lisp/ChangeLog | 4 | ||||
| -rw-r--r-- | lisp/vc.el | 1002 |
2 files changed, 504 insertions, 502 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4abf79b3457..47484498836 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2007-10-05 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc.el: Reorder functions, no code changes. | ||
| 4 | |||
| 1 | 2007-10-04 Michael Albinus <michael.albinus@gmx.de> | 5 | 2007-10-04 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 6 | ||
| 3 | * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el. | 7 | * net/tramp.el (tramp-make-temp-file): Move to tramp-compat.el. |
diff --git a/lisp/vc.el b/lisp/vc.el index 6c06f9a9032..874213698ca 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -817,59 +817,6 @@ in their implementation of vc-BACKEND-diff.") | |||
| 817 | (defvar vc-dired-mode nil) | 817 | (defvar vc-dired-mode nil) |
| 818 | (make-variable-buffer-local 'vc-dired-mode) | 818 | (make-variable-buffer-local 'vc-dired-mode) |
| 819 | 819 | ||
| 820 | ;; functions that operate on RCS revision numbers. This code should | ||
| 821 | ;; also be moved into the backends. It stays for now, however, since | ||
| 822 | ;; it is used in code below. | ||
| 823 | ;;;###autoload | ||
| 824 | (defun vc-trunk-p (rev) | ||
| 825 | "Return t if REV is a revision on the trunk." | ||
| 826 | (not (eq nil (string-match "\\`[0-9]+\\.[0-9]+\\'" rev)))) | ||
| 827 | |||
| 828 | (defun vc-branch-p (rev) | ||
| 829 | "Return t if REV is a branch revision." | ||
| 830 | (not (eq nil (string-match "\\`[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*\\'" rev)))) | ||
| 831 | |||
| 832 | ;;;###autoload | ||
| 833 | (defun vc-branch-part (rev) | ||
| 834 | "Return the branch part of a revision number REV." | ||
| 835 | (let ((index (string-match "\\.[0-9]+\\'" rev))) | ||
| 836 | (if index | ||
| 837 | (substring rev 0 index)))) | ||
| 838 | |||
| 839 | (defun vc-minor-part (rev) | ||
| 840 | "Return the minor version number of a revision number REV." | ||
| 841 | (string-match "[0-9]+\\'" rev) | ||
| 842 | (substring rev (match-beginning 0) (match-end 0))) | ||
| 843 | |||
| 844 | (defun vc-default-previous-version (backend file rev) | ||
| 845 | "Return the version number immediately preceding REV for FILE, | ||
| 846 | or nil if there is no previous version. This default | ||
| 847 | implementation works for MAJOR.MINOR-style version numbers as | ||
| 848 | used by RCS and CVS." | ||
| 849 | (let ((branch (vc-branch-part rev)) | ||
| 850 | (minor-num (string-to-number (vc-minor-part rev)))) | ||
| 851 | (when branch | ||
| 852 | (if (> minor-num 1) | ||
| 853 | ;; version does probably not start a branch or release | ||
| 854 | (concat branch "." (number-to-string (1- minor-num))) | ||
| 855 | (if (vc-trunk-p rev) | ||
| 856 | ;; we are at the beginning of the trunk -- | ||
| 857 | ;; don't know anything to return here | ||
| 858 | nil | ||
| 859 | ;; we are at the beginning of a branch -- | ||
| 860 | ;; return version of starting point | ||
| 861 | (vc-branch-part branch)))))) | ||
| 862 | |||
| 863 | (defun vc-default-next-version (backend file rev) | ||
| 864 | "Return the version number immediately following REV for FILE, | ||
| 865 | or nil if there is no next version. This default implementation | ||
| 866 | works for MAJOR.MINOR-style version numbers as used by RCS | ||
| 867 | and CVS." | ||
| 868 | (when (not (string= rev (vc-workfile-version file))) | ||
| 869 | (let ((branch (vc-branch-part rev)) | ||
| 870 | (minor-num (string-to-number (vc-minor-part rev)))) | ||
| 871 | (concat branch "." (number-to-string (1+ minor-num)))))) | ||
| 872 | |||
| 873 | ;; File property caching | 820 | ;; File property caching |
| 874 | 821 | ||
| 875 | (defun vc-clear-context () | 822 | (defun vc-clear-context () |
| @@ -894,11 +841,6 @@ been updated to their corresponding values." | |||
| 894 | 841 | ||
| 895 | ;; Random helper functions | 842 | ;; Random helper functions |
| 896 | 843 | ||
| 897 | (defsubst vc-editable-p (file) | ||
| 898 | "Return non-nil if FILE can be edited." | ||
| 899 | (or (eq (vc-checkout-model file) 'implicit) | ||
| 900 | (memq (vc-state file) '(edited needs-merge)))) | ||
| 901 | |||
| 902 | ;; Two macros for elisp programming | 844 | ;; Two macros for elisp programming |
| 903 | ;;;###autoload | 845 | ;;;###autoload |
| 904 | (defmacro with-vc-file (file comment &rest body) | 846 | (defmacro with-vc-file (file comment &rest body) |
| @@ -936,17 +878,6 @@ However, before executing BODY, find FILE, and after BODY, save buffer." | |||
| 936 | ,@body | 878 | ,@body |
| 937 | (save-buffer))))) | 879 | (save-buffer))))) |
| 938 | 880 | ||
| 939 | (defun vc-ensure-vc-buffer () | ||
| 940 | "Make sure that the current buffer visits a version-controlled file." | ||
| 941 | (if vc-dired-mode | ||
| 942 | (set-buffer (find-file-noselect (dired-get-filename))) | ||
| 943 | (while vc-parent-buffer | ||
| 944 | (set-buffer vc-parent-buffer)) | ||
| 945 | (if (not buffer-file-name) | ||
| 946 | (error "Buffer %s is not associated with a file" (buffer-name)) | ||
| 947 | (if (not (vc-backend buffer-file-name)) | ||
| 948 | (error "File %s is not under version control" buffer-file-name))))) | ||
| 949 | |||
| 950 | (defun vc-process-filter (p s) | 881 | (defun vc-process-filter (p s) |
| 951 | "An alternative output filter for async process P. | 882 | "An alternative output filter for async process P. |
| 952 | One difference with the default filter is that this inserts S after markers. | 883 | One difference with the default filter is that this inserts S after markers. |
| @@ -1033,12 +964,13 @@ Else, add CODE to the process' sentinel." | |||
| 1033 | Each function is called inside the buffer in which the command was run | 964 | Each function is called inside the buffer in which the command was run |
| 1034 | and is passed 3 arguments: the COMMAND, the FILE and the FLAGS.") | 965 | and is passed 3 arguments: the COMMAND, the FILE and the FLAGS.") |
| 1035 | 966 | ||
| 1036 | ;; FIXME what about file names with spaces? | 967 | (defvar w32-quote-process-args) |
| 968 | |||
| 1037 | (defun vc-delistify (filelist) | 969 | (defun vc-delistify (filelist) |
| 1038 | "Smash a FILELIST into a file list string suitable for info messages." | 970 | "Smash a FILELIST into a file list string suitable for info messages." |
| 971 | ;; FIXME what about file names with spaces? | ||
| 1039 | (if (not filelist) "." (mapconcat 'identity filelist " "))) | 972 | (if (not filelist) "." (mapconcat 'identity filelist " "))) |
| 1040 | 973 | ||
| 1041 | (defvar w32-quote-process-args) | ||
| 1042 | ;;;###autoload | 974 | ;;;###autoload |
| 1043 | (defun vc-do-command (buffer okstatus command file-or-list &rest flags) | 975 | (defun vc-do-command (buffer okstatus command file-or-list &rest flags) |
| 1044 | "Execute a VC command, notifying user and checking for errors. | 976 | "Execute a VC command, notifying user and checking for errors. |
| @@ -1227,6 +1159,70 @@ CONTEXT is that which `vc-buffer-context' returns." | |||
| 1227 | (let ((new-mark (vc-find-position-by-context mark-context))) | 1159 | (let ((new-mark (vc-find-position-by-context mark-context))) |
| 1228 | (if new-mark (set-mark new-mark)))))) | 1160 | (if new-mark (set-mark new-mark)))))) |
| 1229 | 1161 | ||
| 1162 | (defun vc-responsible-backend (file &optional register) | ||
| 1163 | "Return the name of a backend system that is responsible for FILE. | ||
| 1164 | The optional argument REGISTER means that a backend suitable for | ||
| 1165 | registration should be found. | ||
| 1166 | |||
| 1167 | If REGISTER is nil, then if FILE is already registered, return the | ||
| 1168 | backend of FILE. If FILE is not registered, or a directory, then the | ||
| 1169 | first backend in `vc-handled-backends' that declares itself | ||
| 1170 | responsible for FILE is returned. If no backend declares itself | ||
| 1171 | responsible, return the first backend. | ||
| 1172 | |||
| 1173 | If REGISTER is non-nil, return the first responsible backend under | ||
| 1174 | which FILE is not yet registered. If there is no such backend, return | ||
| 1175 | the first backend under which FILE is not yet registered, but could | ||
| 1176 | be registered." | ||
| 1177 | (if (not vc-handled-backends) | ||
| 1178 | (error "No handled backends")) | ||
| 1179 | (or (and (not (file-directory-p file)) (not register) (vc-backend file)) | ||
| 1180 | (catch 'found | ||
| 1181 | ;; First try: find a responsible backend. If this is for registration, | ||
| 1182 | ;; it must be a backend under which FILE is not yet registered. | ||
| 1183 | (dolist (backend vc-handled-backends) | ||
| 1184 | (and (or (not register) | ||
| 1185 | (not (vc-call-backend backend 'registered file))) | ||
| 1186 | (vc-call-backend backend 'responsible-p file) | ||
| 1187 | (throw 'found backend))) | ||
| 1188 | ;; no responsible backend | ||
| 1189 | (if (not register) | ||
| 1190 | ;; if this is not for registration, the first backend must do | ||
| 1191 | (car vc-handled-backends) | ||
| 1192 | ;; for registration, we need to find a new backend that | ||
| 1193 | ;; could register FILE | ||
| 1194 | (dolist (backend vc-handled-backends) | ||
| 1195 | (and (not (vc-call-backend backend 'registered file)) | ||
| 1196 | (vc-call-backend backend 'could-register file) | ||
| 1197 | (throw 'found backend))) | ||
| 1198 | (error "No backend that could register"))))) | ||
| 1199 | |||
| 1200 | (defun vc-expand-dirs (file-or-dir-list) | ||
| 1201 | "Expands directories in a file list specification. | ||
| 1202 | Only files already under version control are noticed." | ||
| 1203 | ;; FIXME: Kill this function. | ||
| 1204 | (let ((flattened '())) | ||
| 1205 | (dolist (node file-or-dir-list) | ||
| 1206 | (vc-file-tree-walk | ||
| 1207 | node (lambda (f) (if (vc-backend f) (push f flattened))))) | ||
| 1208 | (nreverse flattened))) | ||
| 1209 | |||
| 1210 | (defun vc-ensure-vc-buffer () | ||
| 1211 | "Make sure that the current buffer visits a version-controlled file." | ||
| 1212 | (if vc-dired-mode | ||
| 1213 | (set-buffer (find-file-noselect (dired-get-filename))) | ||
| 1214 | (while vc-parent-buffer | ||
| 1215 | (set-buffer vc-parent-buffer)) | ||
| 1216 | (if (not buffer-file-name) | ||
| 1217 | (error "Buffer %s is not associated with a file" (buffer-name)) | ||
| 1218 | (if (not (vc-backend buffer-file-name)) | ||
| 1219 | (error "File %s is not under version control" buffer-file-name))))) | ||
| 1220 | |||
| 1221 | (defsubst vc-editable-p (file) | ||
| 1222 | "Return non-nil if FILE can be edited." | ||
| 1223 | (or (eq (vc-checkout-model file) 'implicit) | ||
| 1224 | (memq (vc-state file) '(edited needs-merge)))) | ||
| 1225 | |||
| 1230 | (defun vc-revert-buffer1 (&optional arg no-confirm) | 1226 | (defun vc-revert-buffer1 (&optional arg no-confirm) |
| 1231 | "Revert buffer, keeping point and mark where user expects them. | 1227 | "Revert buffer, keeping point and mark where user expects them. |
| 1232 | Try to be clever in the face of changes due to expanded version control | 1228 | Try to be clever in the face of changes due to expanded version control |
| @@ -1245,7 +1241,6 @@ ARG and NO-CONFIRM are passed on to `revert-buffer'." | |||
| 1245 | (revert-buffer arg no-confirm t)) | 1241 | (revert-buffer arg no-confirm t)) |
| 1246 | (vc-restore-buffer-context context))) | 1242 | (vc-restore-buffer-context context))) |
| 1247 | 1243 | ||
| 1248 | |||
| 1249 | (defun vc-buffer-sync (&optional not-urgent) | 1244 | (defun vc-buffer-sync (&optional not-urgent) |
| 1250 | "Make sure the current buffer and its working file are in sync. | 1245 | "Make sure the current buffer and its working file are in sync. |
| 1251 | NOT-URGENT means it is ok to continue if the user says not to save." | 1246 | NOT-URGENT means it is ok to continue if the user says not to save." |
| @@ -1256,11 +1251,75 @@ NOT-URGENT means it is ok to continue if the user says not to save." | |||
| 1256 | (unless not-urgent | 1251 | (unless not-urgent |
| 1257 | (error "Aborted"))))) | 1252 | (error "Aborted"))))) |
| 1258 | 1253 | ||
| 1259 | (defun vc-default-latest-on-branch-p (backend file) | 1254 | (defvar vc-dired-window-configuration) |
| 1260 | "Return non-nil if FILE is the latest on its branch. | 1255 | |
| 1261 | This default implementation always returns non-nil, which means that | 1256 | ;; Here's the major entry point. |
| 1262 | editing non-current versions is not supported by default." | 1257 | |
| 1263 | t) | 1258 | ;;;###autoload |
| 1259 | (defun vc-next-action (verbose) | ||
| 1260 | "Do the next logical version control operation on the current file. | ||
| 1261 | |||
| 1262 | If you call this from within a VC dired buffer with no files marked, | ||
| 1263 | it will operate on the file in the current line. | ||
| 1264 | |||
| 1265 | If you call this from within a VC dired buffer, and one or more | ||
| 1266 | files are marked, it will accept a log message and then operate on | ||
| 1267 | each one. The log message will be used as a comment for any register | ||
| 1268 | or checkin operations, but ignored when doing checkouts. Attempted | ||
| 1269 | lock steals will raise an error. | ||
| 1270 | |||
| 1271 | A prefix argument lets you specify the version number to use. | ||
| 1272 | |||
| 1273 | For RCS and SCCS files: | ||
| 1274 | If the file is not already registered, this registers it for version | ||
| 1275 | control. | ||
| 1276 | If the file is registered and not locked by anyone, this checks out | ||
| 1277 | a writable and locked file ready for editing. | ||
| 1278 | If the file is checked out and locked by the calling user, this | ||
| 1279 | first checks to see if the file has changed since checkout. If not, | ||
| 1280 | it performs a revert. | ||
| 1281 | If the file has been changed, this pops up a buffer for entry | ||
| 1282 | of a log message; when the message has been entered, it checks in the | ||
| 1283 | resulting changes along with the log message as change commentary. If | ||
| 1284 | the variable `vc-keep-workfiles' is non-nil (which is its default), a | ||
| 1285 | read-only copy of the changed file is left in place afterwards. | ||
| 1286 | If the file is registered and locked by someone else, you are given | ||
| 1287 | the option to steal the lock. | ||
| 1288 | |||
| 1289 | For CVS files: | ||
| 1290 | If the file is not already registered, this registers it for version | ||
| 1291 | control. This does a \"cvs add\", but no \"cvs commit\". | ||
| 1292 | If the file is added but not committed, it is committed. | ||
| 1293 | If your working file is changed, but the repository file is | ||
| 1294 | unchanged, this pops up a buffer for entry of a log message; when the | ||
| 1295 | message has been entered, it checks in the resulting changes along | ||
| 1296 | with the logmessage as change commentary. A writable file is retained. | ||
| 1297 | If the repository file is changed, you are asked if you want to | ||
| 1298 | merge in the changes into your working copy." | ||
| 1299 | |||
| 1300 | (interactive "P") | ||
| 1301 | (catch 'nogo | ||
| 1302 | (if vc-dired-mode | ||
| 1303 | (let ((files (dired-get-marked-files))) | ||
| 1304 | (set (make-local-variable 'vc-dired-window-configuration) | ||
| 1305 | (current-window-configuration)) | ||
| 1306 | (if (string= "" | ||
| 1307 | (mapconcat | ||
| 1308 | (lambda (f) | ||
| 1309 | (if (not (vc-up-to-date-p f)) "@" "")) | ||
| 1310 | files "")) | ||
| 1311 | (vc-next-action-dired nil nil "dummy") | ||
| 1312 | (vc-start-entry nil nil nil nil | ||
| 1313 | "Enter a change comment for the marked files." | ||
| 1314 | 'vc-next-action-dired)) | ||
| 1315 | (throw 'nogo nil))) | ||
| 1316 | (while vc-parent-buffer | ||
| 1317 | (pop-to-buffer vc-parent-buffer)) | ||
| 1318 | (if buffer-file-name | ||
| 1319 | (vc-next-action-on-file buffer-file-name verbose) | ||
| 1320 | (error "Buffer %s is not associated with a file" (buffer-name))))) | ||
| 1321 | |||
| 1322 | ;; These functions help the vc-next-action entry point | ||
| 1264 | 1323 | ||
| 1265 | (defun vc-next-action-on-file (file verbose &optional comment) | 1324 | (defun vc-next-action-on-file (file verbose &optional comment) |
| 1266 | "Do The Right Thing for a given FILE under version control. | 1325 | "Do The Right Thing for a given FILE under version control. |
| @@ -1405,8 +1464,6 @@ If VERBOSE is non-nil, query the user rather than using default parameters." | |||
| 1405 | (vc-revert-buffer1 t t) | 1464 | (vc-revert-buffer1 t t) |
| 1406 | (vc-checkout file t)))))))) | 1465 | (vc-checkout file t)))))))) |
| 1407 | 1466 | ||
| 1408 | (defvar vc-dired-window-configuration) | ||
| 1409 | |||
| 1410 | (defun vc-next-action-dired (file rev comment) | 1467 | (defun vc-next-action-dired (file rev comment) |
| 1411 | "Call `vc-next-action-on-file' on all the marked files. | 1468 | "Call `vc-next-action-on-file' on all the marked files. |
| 1412 | Ignores FILE and REV, but passes on COMMENT." | 1469 | Ignores FILE and REV, but passes on COMMENT." |
| @@ -1421,76 +1478,6 @@ Ignores FILE and REV, but passes on COMMENT." | |||
| 1421 | nil t)) | 1478 | nil t)) |
| 1422 | (dired-move-to-filename)) | 1479 | (dired-move-to-filename)) |
| 1423 | 1480 | ||
| 1424 | ;; Here's the major entry point. | ||
| 1425 | |||
| 1426 | ;;;###autoload | ||
| 1427 | (defun vc-next-action (verbose) | ||
| 1428 | "Do the next logical version control operation on the current file. | ||
| 1429 | |||
| 1430 | If you call this from within a VC dired buffer with no files marked, | ||
| 1431 | it will operate on the file in the current line. | ||
| 1432 | |||
| 1433 | If you call this from within a VC dired buffer, and one or more | ||
| 1434 | files are marked, it will accept a log message and then operate on | ||
| 1435 | each one. The log message will be used as a comment for any register | ||
| 1436 | or checkin operations, but ignored when doing checkouts. Attempted | ||
| 1437 | lock steals will raise an error. | ||
| 1438 | |||
| 1439 | A prefix argument lets you specify the version number to use. | ||
| 1440 | |||
| 1441 | For RCS and SCCS files: | ||
| 1442 | If the file is not already registered, this registers it for version | ||
| 1443 | control. | ||
| 1444 | If the file is registered and not locked by anyone, this checks out | ||
| 1445 | a writable and locked file ready for editing. | ||
| 1446 | If the file is checked out and locked by the calling user, this | ||
| 1447 | first checks to see if the file has changed since checkout. If not, | ||
| 1448 | it performs a revert. | ||
| 1449 | If the file has been changed, this pops up a buffer for entry | ||
| 1450 | of a log message; when the message has been entered, it checks in the | ||
| 1451 | resulting changes along with the log message as change commentary. If | ||
| 1452 | the variable `vc-keep-workfiles' is non-nil (which is its default), a | ||
| 1453 | read-only copy of the changed file is left in place afterwards. | ||
| 1454 | If the file is registered and locked by someone else, you are given | ||
| 1455 | the option to steal the lock. | ||
| 1456 | |||
| 1457 | For CVS files: | ||
| 1458 | If the file is not already registered, this registers it for version | ||
| 1459 | control. This does a \"cvs add\", but no \"cvs commit\". | ||
| 1460 | If the file is added but not committed, it is committed. | ||
| 1461 | If your working file is changed, but the repository file is | ||
| 1462 | unchanged, this pops up a buffer for entry of a log message; when the | ||
| 1463 | message has been entered, it checks in the resulting changes along | ||
| 1464 | with the logmessage as change commentary. A writable file is retained. | ||
| 1465 | If the repository file is changed, you are asked if you want to | ||
| 1466 | merge in the changes into your working copy." | ||
| 1467 | |||
| 1468 | (interactive "P") | ||
| 1469 | (catch 'nogo | ||
| 1470 | (if vc-dired-mode | ||
| 1471 | (let ((files (dired-get-marked-files))) | ||
| 1472 | (set (make-local-variable 'vc-dired-window-configuration) | ||
| 1473 | (current-window-configuration)) | ||
| 1474 | (if (string= "" | ||
| 1475 | (mapconcat | ||
| 1476 | (lambda (f) | ||
| 1477 | (if (not (vc-up-to-date-p f)) "@" "")) | ||
| 1478 | files "")) | ||
| 1479 | (vc-next-action-dired nil nil "dummy") | ||
| 1480 | (vc-start-entry nil nil nil nil | ||
| 1481 | "Enter a change comment for the marked files." | ||
| 1482 | 'vc-next-action-dired)) | ||
| 1483 | (throw 'nogo nil))) | ||
| 1484 | (while vc-parent-buffer | ||
| 1485 | (pop-to-buffer vc-parent-buffer)) | ||
| 1486 | (if buffer-file-name | ||
| 1487 | (vc-next-action-on-file buffer-file-name verbose) | ||
| 1488 | (error "Buffer %s is not associated with a file" (buffer-name))))) | ||
| 1489 | |||
| 1490 | ;; These functions help the vc-next-action entry point | ||
| 1491 | |||
| 1492 | (defun vc-default-init-version (backend) vc-default-init-version) | ||
| 1493 | |||
| 1494 | ;;;###autoload | 1481 | ;;;###autoload |
| 1495 | (defun vc-register (&optional set-version comment) | 1482 | (defun vc-register (&optional set-version comment) |
| 1496 | "Register the current file into a version control system. | 1483 | "Register the current file into a version control system. |
| @@ -1539,64 +1526,6 @@ first backend that could register the file is used." | |||
| 1539 | (message "Registering %s... done" file)))) | 1526 | (message "Registering %s... done" file)))) |
| 1540 | 1527 | ||
| 1541 | 1528 | ||
| 1542 | (defun vc-responsible-backend (file &optional register) | ||
| 1543 | "Return the name of a backend system that is responsible for FILE. | ||
| 1544 | The optional argument REGISTER means that a backend suitable for | ||
| 1545 | registration should be found. | ||
| 1546 | |||
| 1547 | If REGISTER is nil, then if FILE is already registered, return the | ||
| 1548 | backend of FILE. If FILE is not registered, or a directory, then the | ||
| 1549 | first backend in `vc-handled-backends' that declares itself | ||
| 1550 | responsible for FILE is returned. If no backend declares itself | ||
| 1551 | responsible, return the first backend. | ||
| 1552 | |||
| 1553 | If REGISTER is non-nil, return the first responsible backend under | ||
| 1554 | which FILE is not yet registered. If there is no such backend, return | ||
| 1555 | the first backend under which FILE is not yet registered, but could | ||
| 1556 | be registered." | ||
| 1557 | (if (not vc-handled-backends) | ||
| 1558 | (error "No handled backends")) | ||
| 1559 | (or (and (not (file-directory-p file)) (not register) (vc-backend file)) | ||
| 1560 | (catch 'found | ||
| 1561 | ;; First try: find a responsible backend. If this is for registration, | ||
| 1562 | ;; it must be a backend under which FILE is not yet registered. | ||
| 1563 | (dolist (backend vc-handled-backends) | ||
| 1564 | (and (or (not register) | ||
| 1565 | (not (vc-call-backend backend 'registered file))) | ||
| 1566 | (vc-call-backend backend 'responsible-p file) | ||
| 1567 | (throw 'found backend))) | ||
| 1568 | ;; no responsible backend | ||
| 1569 | (if (not register) | ||
| 1570 | ;; if this is not for registration, the first backend must do | ||
| 1571 | (car vc-handled-backends) | ||
| 1572 | ;; for registration, we need to find a new backend that | ||
| 1573 | ;; could register FILE | ||
| 1574 | (dolist (backend vc-handled-backends) | ||
| 1575 | (and (not (vc-call-backend backend 'registered file)) | ||
| 1576 | (vc-call-backend backend 'could-register file) | ||
| 1577 | (throw 'found backend))) | ||
| 1578 | (error "No backend that could register"))))) | ||
| 1579 | |||
| 1580 | (defun vc-default-responsible-p (backend file) | ||
| 1581 | "Indicate whether BACKEND is reponsible for FILE. | ||
| 1582 | The default is to return nil always." | ||
| 1583 | nil) | ||
| 1584 | |||
| 1585 | (defun vc-default-could-register (backend file) | ||
| 1586 | "Return non-nil if BACKEND could be used to register FILE. | ||
| 1587 | The default implementation returns t for all files." | ||
| 1588 | t) | ||
| 1589 | |||
| 1590 | (defun vc-expand-dirs (file-or-dir-list) | ||
| 1591 | "Expands directories in a file list specification. | ||
| 1592 | Only files already under version control are noticed." | ||
| 1593 | ;; FIXME: Kill this function. | ||
| 1594 | (let ((flattened '())) | ||
| 1595 | (dolist (node file-or-dir-list) | ||
| 1596 | (vc-file-tree-walk | ||
| 1597 | node (lambda (f) (if (vc-backend f) (push f flattened))))) | ||
| 1598 | (nreverse flattened))) | ||
| 1599 | |||
| 1600 | (defun vc-resynch-window (file &optional keep noquery) | 1529 | (defun vc-resynch-window (file &optional keep noquery) |
| 1601 | "If FILE is in the current buffer, either revert or unvisit it. | 1530 | "If FILE is in the current buffer, either revert or unvisit it. |
| 1602 | The choice between revert (to see expanded keywords) and unvisit depends on | 1531 | The choice between revert (to see expanded keywords) and unvisit depends on |
| @@ -1761,6 +1690,8 @@ Runs the normal hook `vc-checkin-hook'." | |||
| 1761 | (message "Checking in %s...done" file)) | 1690 | (message "Checking in %s...done" file)) |
| 1762 | 'vc-checkin-hook)) | 1691 | 'vc-checkin-hook)) |
| 1763 | 1692 | ||
| 1693 | ;; Code for access to the comment ring | ||
| 1694 | |||
| 1764 | (defun vc-finish-logentry (&optional nocomment) | 1695 | (defun vc-finish-logentry (&optional nocomment) |
| 1765 | "Complete the operation implied by the current log entry. | 1696 | "Complete the operation implied by the current log entry. |
| 1766 | Use the contents of the current buffer as a check-in or registration | 1697 | Use the contents of the current buffer as a check-in or registration |
| @@ -1810,9 +1741,108 @@ the buffer contents as a comment." | |||
| 1810 | (dired-move-to-filename)) | 1741 | (dired-move-to-filename)) |
| 1811 | (run-hooks after-hook 'vc-finish-logentry-hook))) | 1742 | (run-hooks after-hook 'vc-finish-logentry-hook))) |
| 1812 | 1743 | ||
| 1813 | ;; Code for access to the comment ring | 1744 | ;;; Additional entry points for examining version histories |
| 1745 | |||
| 1746 | (defun vc-default-diff-tree (backend dir rev1 rev2) | ||
| 1747 | "List differences for all registered files at and below DIR. | ||
| 1748 | The meaning of REV1 and REV2 is the same as for `vc-version-diff'." | ||
| 1749 | ;; This implementation does an explicit tree walk, and calls | ||
| 1750 | ;; vc-BACKEND-diff directly for each file. An optimization | ||
| 1751 | ;; would be to use `vc-diff-internal', so that diffs can be local, | ||
| 1752 | ;; and to call it only for files that are actually changed. | ||
| 1753 | ;; However, this is expensive for some backends, and so it is left | ||
| 1754 | ;; to backend-specific implementations. | ||
| 1755 | (setq default-directory dir) | ||
| 1756 | (vc-file-tree-walk | ||
| 1757 | default-directory | ||
| 1758 | (lambda (f) | ||
| 1759 | (vc-exec-after | ||
| 1760 | `(let ((coding-system-for-read (vc-coding-system-for-diff ',f))) | ||
| 1761 | (message "Looking at %s" ',f) | ||
| 1762 | (vc-call-backend ',(vc-backend f) | ||
| 1763 | 'diff (list ',f) ',rev1 ',rev2)))))) | ||
| 1764 | |||
| 1765 | (defun vc-coding-system-for-diff (file) | ||
| 1766 | "Return the coding system for reading diff output for FILE." | ||
| 1767 | (or coding-system-for-read | ||
| 1768 | ;; if we already have this file open, | ||
| 1769 | ;; use the buffer's coding system | ||
| 1770 | (let ((buf (find-buffer-visiting file))) | ||
| 1771 | (if buf (with-current-buffer buf | ||
| 1772 | buffer-file-coding-system))) | ||
| 1773 | ;; otherwise, try to find one based on the file name | ||
| 1774 | (car (find-operation-coding-system 'insert-file-contents file)) | ||
| 1775 | ;; and a final fallback | ||
| 1776 | 'undecided)) | ||
| 1814 | 1777 | ||
| 1815 | ;; Additional entry points for examining version histories | 1778 | (defun vc-switches (backend op) |
| 1779 | (let ((switches | ||
| 1780 | (or (if backend | ||
| 1781 | (let ((sym (vc-make-backend-sym | ||
| 1782 | backend (intern (concat (symbol-name op) | ||
| 1783 | "-switches"))))) | ||
| 1784 | (if (boundp sym) (symbol-value sym)))) | ||
| 1785 | (let ((sym (intern (format "vc-%s-switches" (symbol-name op))))) | ||
| 1786 | (if (boundp sym) (symbol-value sym))) | ||
| 1787 | (cond | ||
| 1788 | ((eq op 'diff) diff-switches))))) | ||
| 1789 | (if (stringp switches) (list switches) | ||
| 1790 | ;; If not a list, return nil. | ||
| 1791 | ;; This is so we can set vc-diff-switches to t to override | ||
| 1792 | ;; any switches in diff-switches. | ||
| 1793 | (if (listp switches) switches)))) | ||
| 1794 | |||
| 1795 | ;; Old def for compatibility with Emacs-21.[123]. | ||
| 1796 | (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff)) | ||
| 1797 | (make-obsolete 'vc-diff-switches-list 'vc-switches "22.1") | ||
| 1798 | |||
| 1799 | (defun vc-diff-internal (file rev1 rev2) | ||
| 1800 | "Run diff to compare FILE's revisions REV1 and REV2. | ||
| 1801 | Diff output goes to the *vc-diff* buffer. The exit status of the diff | ||
| 1802 | command is returned. | ||
| 1803 | |||
| 1804 | This function takes care to set up a proper coding system for diff output. | ||
| 1805 | If both revisions are available as local files, then it also does not | ||
| 1806 | actually call the backend, but performs a local diff." | ||
| 1807 | (if (or (not rev1) (string-equal rev1 "")) | ||
| 1808 | (setq rev1 (vc-workfile-version file))) | ||
| 1809 | (if (string-equal rev2 "") | ||
| 1810 | (setq rev2 nil)) | ||
| 1811 | (let ((file-rev1 (vc-version-backup-file file rev1)) | ||
| 1812 | (file-rev2 (if (not rev2) | ||
| 1813 | file | ||
| 1814 | (vc-version-backup-file file rev2))) | ||
| 1815 | (coding-system-for-read (vc-coding-system-for-diff file))) | ||
| 1816 | (if (and file-rev1 file-rev2) | ||
| 1817 | (let ((status | ||
| 1818 | (if (eq vc-diff-knows-L 'no) | ||
| 1819 | (apply 'vc-do-command "*vc-diff*" 1 "diff" nil | ||
| 1820 | (append (vc-switches nil 'diff) | ||
| 1821 | (list (file-relative-name file-rev1) | ||
| 1822 | (file-relative-name file-rev2)))) | ||
| 1823 | (apply 'vc-do-command "*vc-diff*" 2 "diff" nil | ||
| 1824 | (append (vc-switches nil 'diff) | ||
| 1825 | ;; Provide explicit labels like RCS or | ||
| 1826 | ;; CVS would do so diff-mode refers to | ||
| 1827 | ;; `file' rather than to `file-rev1' | ||
| 1828 | ;; when trying to find/apply/undo | ||
| 1829 | ;; hunks. | ||
| 1830 | (list "-L" (vc-diff-label file file-rev1 rev1) | ||
| 1831 | "-L" (vc-diff-label file file-rev2 rev2) | ||
| 1832 | (file-relative-name file-rev1) | ||
| 1833 | (file-relative-name file-rev2))))))) | ||
| 1834 | (if (eq status 2) | ||
| 1835 | (if (not vc-diff-knows-L) | ||
| 1836 | (setq vc-diff-knows-L 'no | ||
| 1837 | status (apply 'vc-do-command "*vc-diff*" 1 "diff" nil | ||
| 1838 | (append | ||
| 1839 | (vc-switches nil 'diff) | ||
| 1840 | (list (file-relative-name file-rev1) | ||
| 1841 | (file-relative-name file-rev2))))) | ||
| 1842 | (error "diff failed")) | ||
| 1843 | (if (not vc-diff-knows-L) (setq vc-diff-knows-L 'yes))) | ||
| 1844 | status) | ||
| 1845 | (vc-call diff (list file) rev1 rev2 "*vc-diff*")))) | ||
| 1816 | 1846 | ||
| 1817 | ;;;###autoload | 1847 | ;;;###autoload |
| 1818 | (defun vc-diff (historic &optional not-urgent) | 1848 | (defun vc-diff (historic &optional not-urgent) |
| @@ -1833,8 +1863,6 @@ saving the buffer." | |||
| 1833 | (message "No changes to %s since latest version" file) | 1863 | (message "No changes to %s since latest version" file) |
| 1834 | (vc-version-diff file nil nil))))) | 1864 | (vc-version-diff file nil nil))))) |
| 1835 | 1865 | ||
| 1836 | (defun vc-default-revision-completion-table (backend file) nil) | ||
| 1837 | |||
| 1838 | (defun vc-version-diff (file rev1 rev2) | 1866 | (defun vc-version-diff (file rev1 rev2) |
| 1839 | "List the differences between FILE's versions REV1 and REV2. | 1867 | "List the differences between FILE's versions REV1 and REV2. |
| 1840 | If REV1 is empty or nil it means to use the current workfile version; | 1868 | If REV1 is empty or nil it means to use the current workfile version; |
| @@ -1927,107 +1955,6 @@ versions of all registered files in or below it." | |||
| 1927 | (nth 5 (file-attributes file-rev))) | 1955 | (nth 5 (file-attributes file-rev))) |
| 1928 | rev)) | 1956 | rev)) |
| 1929 | 1957 | ||
| 1930 | (defun vc-diff-internal (file rev1 rev2) | ||
| 1931 | "Run diff to compare FILE's revisions REV1 and REV2. | ||
| 1932 | Diff output goes to the *vc-diff* buffer. The exit status of the diff | ||
| 1933 | command is returned. | ||
| 1934 | |||
| 1935 | This function takes care to set up a proper coding system for diff output. | ||
| 1936 | If both revisions are available as local files, then it also does not | ||
| 1937 | actually call the backend, but performs a local diff." | ||
| 1938 | (if (or (not rev1) (string-equal rev1 "")) | ||
| 1939 | (setq rev1 (vc-workfile-version file))) | ||
| 1940 | (if (string-equal rev2 "") | ||
| 1941 | (setq rev2 nil)) | ||
| 1942 | (let ((file-rev1 (vc-version-backup-file file rev1)) | ||
| 1943 | (file-rev2 (if (not rev2) | ||
| 1944 | file | ||
| 1945 | (vc-version-backup-file file rev2))) | ||
| 1946 | (coding-system-for-read (vc-coding-system-for-diff file))) | ||
| 1947 | (if (and file-rev1 file-rev2) | ||
| 1948 | (let ((status | ||
| 1949 | (if (eq vc-diff-knows-L 'no) | ||
| 1950 | (apply 'vc-do-command "*vc-diff*" 1 "diff" nil | ||
| 1951 | (append (vc-switches nil 'diff) | ||
| 1952 | (list (file-relative-name file-rev1) | ||
| 1953 | (file-relative-name file-rev2)))) | ||
| 1954 | (apply 'vc-do-command "*vc-diff*" 2 "diff" nil | ||
| 1955 | (append (vc-switches nil 'diff) | ||
| 1956 | ;; Provide explicit labels like RCS or | ||
| 1957 | ;; CVS would do so diff-mode refers to | ||
| 1958 | ;; `file' rather than to `file-rev1' | ||
| 1959 | ;; when trying to find/apply/undo | ||
| 1960 | ;; hunks. | ||
| 1961 | (list "-L" (vc-diff-label file file-rev1 rev1) | ||
| 1962 | "-L" (vc-diff-label file file-rev2 rev2) | ||
| 1963 | (file-relative-name file-rev1) | ||
| 1964 | (file-relative-name file-rev2))))))) | ||
| 1965 | (if (eq status 2) | ||
| 1966 | (if (not vc-diff-knows-L) | ||
| 1967 | (setq vc-diff-knows-L 'no | ||
| 1968 | status (apply 'vc-do-command "*vc-diff*" 1 "diff" nil | ||
| 1969 | (append | ||
| 1970 | (vc-switches nil 'diff) | ||
| 1971 | (list (file-relative-name file-rev1) | ||
| 1972 | (file-relative-name file-rev2))))) | ||
| 1973 | (error "diff failed")) | ||
| 1974 | (if (not vc-diff-knows-L) (setq vc-diff-knows-L 'yes))) | ||
| 1975 | status) | ||
| 1976 | (vc-call diff (list file) rev1 rev2 "*vc-diff*")))) | ||
| 1977 | |||
| 1978 | (defun vc-switches (backend op) | ||
| 1979 | (let ((switches | ||
| 1980 | (or (if backend | ||
| 1981 | (let ((sym (vc-make-backend-sym | ||
| 1982 | backend (intern (concat (symbol-name op) | ||
| 1983 | "-switches"))))) | ||
| 1984 | (if (boundp sym) (symbol-value sym)))) | ||
| 1985 | (let ((sym (intern (format "vc-%s-switches" (symbol-name op))))) | ||
| 1986 | (if (boundp sym) (symbol-value sym))) | ||
| 1987 | (cond | ||
| 1988 | ((eq op 'diff) diff-switches))))) | ||
| 1989 | (if (stringp switches) (list switches) | ||
| 1990 | ;; If not a list, return nil. | ||
| 1991 | ;; This is so we can set vc-diff-switches to t to override | ||
| 1992 | ;; any switches in diff-switches. | ||
| 1993 | (if (listp switches) switches)))) | ||
| 1994 | |||
| 1995 | ;; Old def for compatibility with Emacs-21.[123]. | ||
| 1996 | (defmacro vc-diff-switches-list (backend) `(vc-switches ',backend 'diff)) | ||
| 1997 | (make-obsolete 'vc-diff-switches-list 'vc-switches "22.1") | ||
| 1998 | |||
| 1999 | (defun vc-default-diff-tree (backend dir rev1 rev2) | ||
| 2000 | "List differences for all registered files at and below DIR. | ||
| 2001 | The meaning of REV1 and REV2 is the same as for `vc-version-diff'." | ||
| 2002 | ;; This implementation does an explicit tree walk, and calls | ||
| 2003 | ;; vc-BACKEND-diff directly for each file. An optimization | ||
| 2004 | ;; would be to use `vc-diff-internal', so that diffs can be local, | ||
| 2005 | ;; and to call it only for files that are actually changed. | ||
| 2006 | ;; However, this is expensive for some backends, and so it is left | ||
| 2007 | ;; to backend-specific implementations. | ||
| 2008 | (setq default-directory dir) | ||
| 2009 | (vc-file-tree-walk | ||
| 2010 | default-directory | ||
| 2011 | (lambda (f) | ||
| 2012 | (vc-exec-after | ||
| 2013 | `(let ((coding-system-for-read (vc-coding-system-for-diff ',f))) | ||
| 2014 | (message "Looking at %s" ',f) | ||
| 2015 | (vc-call-backend ',(vc-backend f) | ||
| 2016 | 'diff (list ',f) ',rev1 ',rev2)))))) | ||
| 2017 | |||
| 2018 | (defun vc-coding-system-for-diff (file) | ||
| 2019 | "Return the coding system for reading diff output for FILE." | ||
| 2020 | (or coding-system-for-read | ||
| 2021 | ;; if we already have this file open, | ||
| 2022 | ;; use the buffer's coding system | ||
| 2023 | (let ((buf (find-buffer-visiting file))) | ||
| 2024 | (if buf (with-current-buffer buf | ||
| 2025 | buffer-file-coding-system))) | ||
| 2026 | ;; otherwise, try to find one based on the file name | ||
| 2027 | (car (find-operation-coding-system 'insert-file-contents file)) | ||
| 2028 | ;; and a final fallback | ||
| 2029 | 'undecided)) | ||
| 2030 | |||
| 2031 | ;;;###autoload | 1958 | ;;;###autoload |
| 2032 | (defun vc-version-other-window (rev) | 1959 | (defun vc-version-other-window (rev) |
| 2033 | "Visit version REV of the current file in another window. | 1960 | "Visit version REV of the current file in another window. |
| @@ -2077,18 +2004,6 @@ If `F.~REV~' already exists, use it instead of checking it out again." | |||
| 2077 | (message "Checking out %s...done" filename))) | 2004 | (message "Checking out %s...done" filename))) |
| 2078 | (find-file-noselect filename))) | 2005 | (find-file-noselect filename))) |
| 2079 | 2006 | ||
| 2080 | (defun vc-default-find-version (backend file rev buffer) | ||
| 2081 | "Provide the new `find-version' op based on the old `checkout' op. | ||
| 2082 | This is only for compatibility with old backends. They should be updated | ||
| 2083 | to provide the `find-version' operation instead." | ||
| 2084 | (let ((tmpfile (make-temp-file (expand-file-name file)))) | ||
| 2085 | (unwind-protect | ||
| 2086 | (progn | ||
| 2087 | (vc-call-backend backend 'checkout file nil rev tmpfile) | ||
| 2088 | (with-current-buffer buffer | ||
| 2089 | (insert-file-contents-literally tmpfile))) | ||
| 2090 | (delete-file tmpfile)))) | ||
| 2091 | |||
| 2092 | ;; Header-insertion code | 2007 | ;; Header-insertion code |
| 2093 | 2008 | ||
| 2094 | ;;;###autoload | 2009 | ;;;###autoload |
| @@ -2295,15 +2210,6 @@ There is a special command, `*l', to mark all files currently locked." | |||
| 2295 | 2210 | ||
| 2296 | (define-key vc-dired-mode-map "*l" 'vc-dired-mark-locked) | 2211 | (define-key vc-dired-mode-map "*l" 'vc-dired-mark-locked) |
| 2297 | 2212 | ||
| 2298 | (defun vc-default-dired-state-info (backend file) | ||
| 2299 | (let ((state (vc-state file))) | ||
| 2300 | (cond | ||
| 2301 | ((stringp state) (concat "(" state ")")) | ||
| 2302 | ((eq state 'edited) (concat "(" (vc-user-login-name file) ")")) | ||
| 2303 | ((eq state 'needs-merge) "(merge)") | ||
| 2304 | ((eq state 'needs-patch) "(patch)") | ||
| 2305 | ((eq state 'unlocked-changes) "(stale)")))) | ||
| 2306 | |||
| 2307 | (defun vc-dired-reformat-line (vc-info) | 2213 | (defun vc-dired-reformat-line (vc-info) |
| 2308 | "Reformat a directory-listing line. | 2214 | "Reformat a directory-listing line. |
| 2309 | Replace various columns with version control information, VC-INFO. | 2215 | Replace various columns with version control information, VC-INFO. |
| @@ -2483,17 +2389,6 @@ are checked out in that new branch." | |||
| 2483 | 'create-snapshot dir name branchp) | 2389 | 'create-snapshot dir name branchp) |
| 2484 | (message "Making %s... done" (if branchp "branch" "snapshot"))) | 2390 | (message "Making %s... done" (if branchp "branch" "snapshot"))) |
| 2485 | 2391 | ||
| 2486 | (defun vc-default-create-snapshot (backend dir name branchp) | ||
| 2487 | (when branchp | ||
| 2488 | (error "VC backend %s does not support module branches" backend)) | ||
| 2489 | (let ((result (vc-snapshot-precondition dir))) | ||
| 2490 | (if (stringp result) | ||
| 2491 | (error "File %s is not up-to-date" result) | ||
| 2492 | (vc-file-tree-walk | ||
| 2493 | dir | ||
| 2494 | (lambda (f) | ||
| 2495 | (vc-call assign-name f name)))))) | ||
| 2496 | |||
| 2497 | ;;;###autoload | 2392 | ;;;###autoload |
| 2498 | (defun vc-retrieve-snapshot (dir name) | 2393 | (defun vc-retrieve-snapshot (dir name) |
| 2499 | "Descending recursively from DIR, retrieve the snapshot called NAME. | 2394 | "Descending recursively from DIR, retrieve the snapshot called NAME. |
| @@ -2514,26 +2409,6 @@ allowed and simply skipped)." | |||
| 2514 | 'retrieve-snapshot dir name update) | 2409 | 'retrieve-snapshot dir name update) |
| 2515 | (message "%s" (concat msg "done")))) | 2410 | (message "%s" (concat msg "done")))) |
| 2516 | 2411 | ||
| 2517 | (defun vc-default-retrieve-snapshot (backend dir name update) | ||
| 2518 | (if (string= name "") | ||
| 2519 | (progn | ||
| 2520 | (vc-file-tree-walk | ||
| 2521 | dir | ||
| 2522 | (lambda (f) (and | ||
| 2523 | (vc-up-to-date-p f) | ||
| 2524 | (vc-error-occurred | ||
| 2525 | (vc-call checkout f nil "") | ||
| 2526 | (if update (vc-resynch-buffer f t t))))))) | ||
| 2527 | (let ((result (vc-snapshot-precondition dir))) | ||
| 2528 | (if (stringp result) | ||
| 2529 | (error "File %s is locked" result) | ||
| 2530 | (setq update (and (eq result 'visited) update)) | ||
| 2531 | (vc-file-tree-walk | ||
| 2532 | dir | ||
| 2533 | (lambda (f) (vc-error-occurred | ||
| 2534 | (vc-call checkout f nil name) | ||
| 2535 | (if update (vc-resynch-buffer f t t))))))))) | ||
| 2536 | |||
| 2537 | ;; Miscellaneous other entry points | 2412 | ;; Miscellaneous other entry points |
| 2538 | 2413 | ||
| 2539 | ;;;###autoload | 2414 | ;;;###autoload |
| @@ -2583,39 +2458,6 @@ If FOCUS-REV is non-nil, leave the point at that revision." | |||
| 2583 | (setq vc-sentinel-movepoint (point)) | 2458 | (setq vc-sentinel-movepoint (point)) |
| 2584 | (set-buffer-modified-p nil))))) | 2459 | (set-buffer-modified-p nil))))) |
| 2585 | 2460 | ||
| 2586 | (defun vc-default-log-view-mode (backend) (log-view-mode)) | ||
| 2587 | (defun vc-default-show-log-entry (backend rev) | ||
| 2588 | (with-no-warnings | ||
| 2589 | (log-view-goto-rev rev))) | ||
| 2590 | |||
| 2591 | (defun vc-default-comment-history (backend file) | ||
| 2592 | "Return a string with all log entries stored in BACKEND for FILE." | ||
| 2593 | (if (vc-find-backend-function backend 'print-log) | ||
| 2594 | (with-current-buffer "*vc*" | ||
| 2595 | (vc-call print-log (list file)) | ||
| 2596 | (vc-call wash-log file) | ||
| 2597 | (buffer-string)))) | ||
| 2598 | |||
| 2599 | (defun vc-default-wash-log (backend file) | ||
| 2600 | "Remove all non-comment information from log output. | ||
| 2601 | This default implementation works for RCS logs; backends should override | ||
| 2602 | it if their logs are not in RCS format." | ||
| 2603 | (let ((separator (concat "^-+\nrevision [0-9.]+\ndate: .*\n" | ||
| 2604 | "\\(branches: .*;\n\\)?" | ||
| 2605 | "\\(\\*\\*\\* empty log message \\*\\*\\*\n\\)?"))) | ||
| 2606 | (goto-char (point-max)) (forward-line -1) | ||
| 2607 | (while (looking-at "=*\n") | ||
| 2608 | (delete-char (- (match-end 0) (match-beginning 0))) | ||
| 2609 | (forward-line -1)) | ||
| 2610 | (goto-char (point-min)) | ||
| 2611 | (if (looking-at "[\b\t\n\v\f\r ]+") | ||
| 2612 | (delete-char (- (match-end 0) (match-beginning 0)))) | ||
| 2613 | (goto-char (point-min)) | ||
| 2614 | (re-search-forward separator nil t) | ||
| 2615 | (delete-region (point-min) (point)) | ||
| 2616 | (while (re-search-forward separator nil t) | ||
| 2617 | (delete-region (match-beginning 0) (match-end 0))))) | ||
| 2618 | |||
| 2619 | ;;;###autoload | 2461 | ;;;###autoload |
| 2620 | (defun vc-revert () | 2462 | (defun vc-revert () |
| 2621 | "Revert the current buffer's file to the version it was based on. | 2463 | "Revert the current buffer's file to the version it was based on. |
| @@ -2660,6 +2502,53 @@ changes found in the master file; use \\[universal-argument] \\[vc-next-action] | |||
| 2660 | (message "Reverting %s...done" file))) | 2502 | (message "Reverting %s...done" file))) |
| 2661 | 2503 | ||
| 2662 | ;;;###autoload | 2504 | ;;;###autoload |
| 2505 | (defun vc-rollback (&optional norevert) | ||
| 2506 | "Get rid of most recently checked in version of this file. | ||
| 2507 | A prefix argument NOREVERT means do not revert the buffer afterwards." | ||
| 2508 | (interactive "P") | ||
| 2509 | (vc-ensure-vc-buffer) | ||
| 2510 | (let* ((file buffer-file-name) | ||
| 2511 | (backend (vc-backend file)) | ||
| 2512 | (target (vc-workfile-version file))) | ||
| 2513 | (cond | ||
| 2514 | ((not (vc-find-backend-function backend 'rollback)) | ||
| 2515 | (error "Sorry, canceling versions is not supported under %s" backend)) | ||
| 2516 | ((not (vc-call latest-on-branch-p file)) | ||
| 2517 | (error "This is not the latest version; VC cannot cancel it")) | ||
| 2518 | ((not (vc-up-to-date-p file)) | ||
| 2519 | (error "%s" (substitute-command-keys "File is not up to date; use \\[vc-revert] to discard changes")))) | ||
| 2520 | (if (null (yes-or-no-p (format "Remove version %s from master? " target))) | ||
| 2521 | (error "Aborted") | ||
| 2522 | (setq norevert (or norevert (not | ||
| 2523 | (yes-or-no-p "Revert buffer to most recent remaining version? ")))) | ||
| 2524 | |||
| 2525 | (message "Removing last change from %s..." file) | ||
| 2526 | (with-vc-properties | ||
| 2527 | file | ||
| 2528 | (vc-call rollback (list file)) | ||
| 2529 | `((vc-state . ,(if norevert 'edited 'up-to-date)) | ||
| 2530 | (vc-checkout-time . ,(if norevert | ||
| 2531 | 0 | ||
| 2532 | (nth 5 (file-attributes file)))) | ||
| 2533 | (vc-workfile-version . nil))) | ||
| 2534 | (message "Removing last change from %s...done" file) | ||
| 2535 | |||
| 2536 | (cond | ||
| 2537 | (norevert ;; clear version headers and mark the buffer modified | ||
| 2538 | (set-visited-file-name file) | ||
| 2539 | (when (not vc-make-backup-files) | ||
| 2540 | ;; inhibit backup for this buffer | ||
| 2541 | (make-local-variable 'backup-inhibited) | ||
| 2542 | (setq backup-inhibited t)) | ||
| 2543 | (setq buffer-read-only nil) | ||
| 2544 | (vc-clear-headers) | ||
| 2545 | (vc-mode-line file) | ||
| 2546 | (vc-dired-resynch-file file)) | ||
| 2547 | (t ;; revert buffer to file on disk | ||
| 2548 | (vc-resynch-buffer file t t))) | ||
| 2549 | (message "Version %s has been removed from the master" target)))) | ||
| 2550 | |||
| 2551 | ;;;###autoload | ||
| 2663 | (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1") | 2552 | (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1") |
| 2664 | 2553 | ||
| 2665 | ;;;###autoload | 2554 | ;;;###autoload |
| @@ -2704,33 +2593,6 @@ return its name; otherwise return nil." | |||
| 2704 | (if (file-exists-p backup-file) | 2593 | (if (file-exists-p backup-file) |
| 2705 | backup-file))))) | 2594 | backup-file))))) |
| 2706 | 2595 | ||
| 2707 | (defun vc-default-revert (backend file contents-done) | ||
| 2708 | (unless contents-done | ||
| 2709 | (let ((rev (vc-workfile-version file)) | ||
| 2710 | (file-buffer (or (get-file-buffer file) (current-buffer)))) | ||
| 2711 | (message "Checking out %s..." file) | ||
| 2712 | (let ((failed t) | ||
| 2713 | (backup-name (car (find-backup-file-name file)))) | ||
| 2714 | (when backup-name | ||
| 2715 | (copy-file file backup-name 'ok-if-already-exists 'keep-date) | ||
| 2716 | (unless (file-writable-p file) | ||
| 2717 | (set-file-modes file (logior (file-modes file) 128)))) | ||
| 2718 | (unwind-protect | ||
| 2719 | (let ((coding-system-for-read 'no-conversion) | ||
| 2720 | (coding-system-for-write 'no-conversion)) | ||
| 2721 | (with-temp-file file | ||
| 2722 | (let ((outbuf (current-buffer))) | ||
| 2723 | ;; Change buffer to get local value of vc-checkout-switches. | ||
| 2724 | (with-current-buffer file-buffer | ||
| 2725 | (let ((default-directory (file-name-directory file))) | ||
| 2726 | (vc-call find-version file rev outbuf))))) | ||
| 2727 | (setq failed nil)) | ||
| 2728 | (when backup-name | ||
| 2729 | (if failed | ||
| 2730 | (rename-file backup-name file 'ok-if-already-exists) | ||
| 2731 | (and (not vc-make-backup-files) (delete-file backup-name)))))) | ||
| 2732 | (message "Checking out %s...done" file)))) | ||
| 2733 | |||
| 2734 | (defun vc-revert-file (file) | 2596 | (defun vc-revert-file (file) |
| 2735 | "Revert FILE back to the version it was based on." | 2597 | "Revert FILE back to the version it was based on." |
| 2736 | (with-vc-properties | 2598 | (with-vc-properties |
| @@ -2745,53 +2607,6 @@ return its name; otherwise return nil." | |||
| 2745 | (vc-resynch-buffer file t t)) | 2607 | (vc-resynch-buffer file t t)) |
| 2746 | 2608 | ||
| 2747 | ;;;###autoload | 2609 | ;;;###autoload |
| 2748 | (defun vc-rollback (&optional norevert) | ||
| 2749 | "Get rid of most recently checked in version of this file. | ||
| 2750 | A prefix argument NOREVERT means do not revert the buffer afterwards." | ||
| 2751 | (interactive "P") | ||
| 2752 | (vc-ensure-vc-buffer) | ||
| 2753 | (let* ((file buffer-file-name) | ||
| 2754 | (backend (vc-backend file)) | ||
| 2755 | (target (vc-workfile-version file))) | ||
| 2756 | (cond | ||
| 2757 | ((not (vc-find-backend-function backend 'rollback)) | ||
| 2758 | (error "Sorry, canceling versions is not supported under %s" backend)) | ||
| 2759 | ((not (vc-call latest-on-branch-p file)) | ||
| 2760 | (error "This is not the latest version; VC cannot cancel it")) | ||
| 2761 | ((not (vc-up-to-date-p file)) | ||
| 2762 | (error "%s" (substitute-command-keys "File is not up to date; use \\[vc-revert] to discard changes")))) | ||
| 2763 | (if (null (yes-or-no-p (format "Remove version %s from master? " target))) | ||
| 2764 | (error "Aborted") | ||
| 2765 | (setq norevert (or norevert (not | ||
| 2766 | (yes-or-no-p "Revert buffer to most recent remaining version? ")))) | ||
| 2767 | |||
| 2768 | (message "Removing last change from %s..." file) | ||
| 2769 | (with-vc-properties | ||
| 2770 | file | ||
| 2771 | (vc-call rollback (list file)) | ||
| 2772 | `((vc-state . ,(if norevert 'edited 'up-to-date)) | ||
| 2773 | (vc-checkout-time . ,(if norevert | ||
| 2774 | 0 | ||
| 2775 | (nth 5 (file-attributes file)))) | ||
| 2776 | (vc-workfile-version . nil))) | ||
| 2777 | (message "Removing last change from %s...done" file) | ||
| 2778 | |||
| 2779 | (cond | ||
| 2780 | (norevert ;; clear version headers and mark the buffer modified | ||
| 2781 | (set-visited-file-name file) | ||
| 2782 | (when (not vc-make-backup-files) | ||
| 2783 | ;; inhibit backup for this buffer | ||
| 2784 | (make-local-variable 'backup-inhibited) | ||
| 2785 | (setq backup-inhibited t)) | ||
| 2786 | (setq buffer-read-only nil) | ||
| 2787 | (vc-clear-headers) | ||
| 2788 | (vc-mode-line file) | ||
| 2789 | (vc-dired-resynch-file file)) | ||
| 2790 | (t ;; revert buffer to file on disk | ||
| 2791 | (vc-resynch-buffer file t t))) | ||
| 2792 | (message "Version %s has been removed from the master" target)))) | ||
| 2793 | |||
| 2794 | ;;;###autoload | ||
| 2795 | (defun vc-switch-backend (file backend) | 2610 | (defun vc-switch-backend (file backend) |
| 2796 | "Make BACKEND the current version control system for FILE. | 2611 | "Make BACKEND the current version control system for FILE. |
| 2797 | FILE must already be registered in BACKEND. The change is not | 2612 | FILE must already be registered in BACKEND. The change is not |
| @@ -2898,14 +2713,6 @@ backend to NEW-BACKEND, and unregister FILE from the current backend. | |||
| 2898 | (vc-mode-line file) | 2713 | (vc-mode-line file) |
| 2899 | (vc-checkin file nil comment (stringp comment))))) | 2714 | (vc-checkin file nil comment (stringp comment))))) |
| 2900 | 2715 | ||
| 2901 | (defun vc-default-unregister (backend file) | ||
| 2902 | "Default implementation of `vc-unregister', signals an error." | ||
| 2903 | (error "Unregistering files is not supported for %s" backend)) | ||
| 2904 | |||
| 2905 | (defun vc-default-receive-file (backend file rev) | ||
| 2906 | "Let BACKEND receive FILE from another version control system." | ||
| 2907 | (vc-call-backend backend 'register file rev "")) | ||
| 2908 | |||
| 2909 | (defun vc-rename-master (oldmaster newfile templates) | 2716 | (defun vc-rename-master (oldmaster newfile templates) |
| 2910 | "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." | 2717 | "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." |
| 2911 | (let* ((dir (file-name-directory (expand-file-name oldmaster))) | 2718 | (let* ((dir (file-name-directory (expand-file-name oldmaster))) |
| @@ -2956,14 +2763,6 @@ backend to NEW-BACKEND, and unregister FILE from the current backend. | |||
| 2956 | ;; If the backend hasn't deleted the file itself, let's do it for him. | 2763 | ;; If the backend hasn't deleted the file itself, let's do it for him. |
| 2957 | (if (file-exists-p file) (delete-file file)))) | 2764 | (if (file-exists-p file) (delete-file file)))) |
| 2958 | 2765 | ||
| 2959 | (defun vc-default-rename-file (backend old new) | ||
| 2960 | (condition-case nil | ||
| 2961 | (add-name-to-file old new) | ||
| 2962 | (error (rename-file old new))) | ||
| 2963 | (vc-delete-file old) | ||
| 2964 | (with-current-buffer (find-file-noselect new) | ||
| 2965 | (vc-register))) | ||
| 2966 | |||
| 2967 | ;;;###autoload | 2766 | ;;;###autoload |
| 2968 | (defun vc-rename-file (old new) | 2767 | (defun vc-rename-file (old new) |
| 2969 | "Rename file OLD to NEW, and rename its master file likewise." | 2768 | "Rename file OLD to NEW, and rename its master file likewise." |
| @@ -3032,6 +2831,77 @@ log entries should be gathered." | |||
| 3032 | (vc-call-backend (vc-responsible-backend default-directory) | 2831 | (vc-call-backend (vc-responsible-backend default-directory) |
| 3033 | 'update-changelog args)) | 2832 | 'update-changelog args)) |
| 3034 | 2833 | ||
| 2834 | ;; functions that operate on RCS revision numbers. This code should | ||
| 2835 | ;; also be moved into the backends. It stays for now, however, since | ||
| 2836 | ;; it is used in code below. | ||
| 2837 | ;;;###autoload | ||
| 2838 | (defun vc-trunk-p (rev) | ||
| 2839 | "Return t if REV is a revision on the trunk." | ||
| 2840 | (not (eq nil (string-match "\\`[0-9]+\\.[0-9]+\\'" rev)))) | ||
| 2841 | |||
| 2842 | (defun vc-branch-p (rev) | ||
| 2843 | "Return t if REV is a branch revision." | ||
| 2844 | (not (eq nil (string-match "\\`[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*\\'" rev)))) | ||
| 2845 | |||
| 2846 | ;;;###autoload | ||
| 2847 | (defun vc-branch-part (rev) | ||
| 2848 | "Return the branch part of a revision number REV." | ||
| 2849 | (let ((index (string-match "\\.[0-9]+\\'" rev))) | ||
| 2850 | (if index | ||
| 2851 | (substring rev 0 index)))) | ||
| 2852 | |||
| 2853 | (defun vc-minor-part (rev) | ||
| 2854 | "Return the minor version number of a revision number REV." | ||
| 2855 | (string-match "[0-9]+\\'" rev) | ||
| 2856 | (substring rev (match-beginning 0) (match-end 0))) | ||
| 2857 | |||
| 2858 | (defun vc-default-previous-version (backend file rev) | ||
| 2859 | "Return the version number immediately preceding REV for FILE, | ||
| 2860 | or nil if there is no previous version. This default | ||
| 2861 | implementation works for MAJOR.MINOR-style version numbers as | ||
| 2862 | used by RCS and CVS." | ||
| 2863 | (let ((branch (vc-branch-part rev)) | ||
| 2864 | (minor-num (string-to-number (vc-minor-part rev)))) | ||
| 2865 | (when branch | ||
| 2866 | (if (> minor-num 1) | ||
| 2867 | ;; version does probably not start a branch or release | ||
| 2868 | (concat branch "." (number-to-string (1- minor-num))) | ||
| 2869 | (if (vc-trunk-p rev) | ||
| 2870 | ;; we are at the beginning of the trunk -- | ||
| 2871 | ;; don't know anything to return here | ||
| 2872 | nil | ||
| 2873 | ;; we are at the beginning of a branch -- | ||
| 2874 | ;; return version of starting point | ||
| 2875 | (vc-branch-part branch)))))) | ||
| 2876 | |||
| 2877 | (defun vc-default-next-version (backend file rev) | ||
| 2878 | "Return the version number immediately following REV for FILE, | ||
| 2879 | or nil if there is no next version. This default implementation | ||
| 2880 | works for MAJOR.MINOR-style version numbers as used by RCS | ||
| 2881 | and CVS." | ||
| 2882 | (when (not (string= rev (vc-workfile-version file))) | ||
| 2883 | (let ((branch (vc-branch-part rev)) | ||
| 2884 | (minor-num (string-to-number (vc-minor-part rev)))) | ||
| 2885 | (concat branch "." (number-to-string (1+ minor-num)))))) | ||
| 2886 | |||
| 2887 | (defun vc-default-responsible-p (backend file) | ||
| 2888 | "Indicate whether BACKEND is reponsible for FILE. | ||
| 2889 | The default is to return nil always." | ||
| 2890 | nil) | ||
| 2891 | |||
| 2892 | (defun vc-default-could-register (backend file) | ||
| 2893 | "Return non-nil if BACKEND could be used to register FILE. | ||
| 2894 | The default implementation returns t for all files." | ||
| 2895 | t) | ||
| 2896 | |||
| 2897 | (defun vc-default-latest-on-branch-p (backend file) | ||
| 2898 | "Return non-nil if FILE is the latest on its branch. | ||
| 2899 | This default implementation always returns non-nil, which means that | ||
| 2900 | editing non-current versions is not supported by default." | ||
| 2901 | t) | ||
| 2902 | |||
| 2903 | (defun vc-default-init-version (backend) vc-default-init-version) | ||
| 2904 | |||
| 3035 | (defalias 'vc-cvs-update-changelog 'vc-update-changelog-rcs2log) | 2905 | (defalias 'vc-cvs-update-changelog 'vc-update-changelog-rcs2log) |
| 3036 | (defalias 'vc-rcs-update-changelog 'vc-update-changelog-rcs2log) | 2906 | (defalias 'vc-rcs-update-changelog 'vc-update-changelog-rcs2log) |
| 3037 | ;; FIXME: This should probably be moved to vc-rcs.el and replaced in | 2907 | ;; FIXME: This should probably be moved to vc-rcs.el and replaced in |
| @@ -3087,7 +2957,149 @@ Uses `rcs2log' which only works for RCS and CVS." | |||
| 3087 | (setq default-directory (file-name-directory changelog)) | 2957 | (setq default-directory (file-name-directory changelog)) |
| 3088 | (delete-file tempfile))))) | 2958 | (delete-file tempfile))))) |
| 3089 | 2959 | ||
| 3090 | ;; Annotate functionality | 2960 | (defun vc-default-find-version (backend file rev buffer) |
| 2961 | "Provide the new `find-version' op based on the old `checkout' op. | ||
| 2962 | This is only for compatibility with old backends. They should be updated | ||
| 2963 | to provide the `find-version' operation instead." | ||
| 2964 | (let ((tmpfile (make-temp-file (expand-file-name file)))) | ||
| 2965 | (unwind-protect | ||
| 2966 | (progn | ||
| 2967 | (vc-call-backend backend 'checkout file nil rev tmpfile) | ||
| 2968 | (with-current-buffer buffer | ||
| 2969 | (insert-file-contents-literally tmpfile))) | ||
| 2970 | (delete-file tmpfile)))) | ||
| 2971 | |||
| 2972 | (defun vc-default-dired-state-info (backend file) | ||
| 2973 | (let ((state (vc-state file))) | ||
| 2974 | (cond | ||
| 2975 | ((stringp state) (concat "(" state ")")) | ||
| 2976 | ((eq state 'edited) (concat "(" (vc-user-login-name file) ")")) | ||
| 2977 | ((eq state 'needs-merge) "(merge)") | ||
| 2978 | ((eq state 'needs-patch) "(patch)") | ||
| 2979 | ((eq state 'unlocked-changes) "(stale)")))) | ||
| 2980 | |||
| 2981 | (defun vc-default-rename-file (backend old new) | ||
| 2982 | (condition-case nil | ||
| 2983 | (add-name-to-file old new) | ||
| 2984 | (error (rename-file old new))) | ||
| 2985 | (vc-delete-file old) | ||
| 2986 | (with-current-buffer (find-file-noselect new) | ||
| 2987 | (vc-register))) | ||
| 2988 | |||
| 2989 | (defalias 'vc-default-logentry-check 'ignore) | ||
| 2990 | |||
| 2991 | (defun vc-default-check-headers (backend) | ||
| 2992 | "Default implementation of check-headers; always returns nil." | ||
| 2993 | nil) | ||
| 2994 | |||
| 2995 | (defun vc-default-log-view-mode (backend) (log-view-mode)) | ||
| 2996 | |||
| 2997 | (defun vc-default-show-log-entry (backend rev) | ||
| 2998 | (with-no-warnings | ||
| 2999 | (log-view-goto-rev rev))) | ||
| 3000 | |||
| 3001 | (defun vc-default-comment-history (backend file) | ||
| 3002 | "Return a string with all log entries stored in BACKEND for FILE." | ||
| 3003 | (if (vc-find-backend-function backend 'print-log) | ||
| 3004 | (with-current-buffer "*vc*" | ||
| 3005 | (vc-call print-log (list file)) | ||
| 3006 | (vc-call wash-log file) | ||
| 3007 | (buffer-string)))) | ||
| 3008 | |||
| 3009 | (defun vc-default-unregister (backend file) | ||
| 3010 | "Default implementation of `vc-unregister', signals an error." | ||
| 3011 | (error "Unregistering files is not supported for %s" backend)) | ||
| 3012 | |||
| 3013 | (defun vc-default-receive-file (backend file rev) | ||
| 3014 | "Let BACKEND receive FILE from another version control system." | ||
| 3015 | (vc-call-backend backend 'register file rev "")) | ||
| 3016 | |||
| 3017 | (defun vc-default-create-snapshot (backend dir name branchp) | ||
| 3018 | (when branchp | ||
| 3019 | (error "VC backend %s does not support module branches" backend)) | ||
| 3020 | (let ((result (vc-snapshot-precondition dir))) | ||
| 3021 | (if (stringp result) | ||
| 3022 | (error "File %s is not up-to-date" result) | ||
| 3023 | (vc-file-tree-walk | ||
| 3024 | dir | ||
| 3025 | (lambda (f) | ||
| 3026 | (vc-call assign-name f name)))))) | ||
| 3027 | |||
| 3028 | (defun vc-default-retrieve-snapshot (backend dir name update) | ||
| 3029 | (if (string= name "") | ||
| 3030 | (progn | ||
| 3031 | (vc-file-tree-walk | ||
| 3032 | dir | ||
| 3033 | (lambda (f) (and | ||
| 3034 | (vc-up-to-date-p f) | ||
| 3035 | (vc-error-occurred | ||
| 3036 | (vc-call checkout f nil "") | ||
| 3037 | (if update (vc-resynch-buffer f t t))))))) | ||
| 3038 | (let ((result (vc-snapshot-precondition dir))) | ||
| 3039 | (if (stringp result) | ||
| 3040 | (error "File %s is locked" result) | ||
| 3041 | (setq update (and (eq result 'visited) update)) | ||
| 3042 | (vc-file-tree-walk | ||
| 3043 | dir | ||
| 3044 | (lambda (f) (vc-error-occurred | ||
| 3045 | (vc-call checkout f nil name) | ||
| 3046 | (if update (vc-resynch-buffer f t t))))))))) | ||
| 3047 | |||
| 3048 | (defun vc-default-revert (backend file contents-done) | ||
| 3049 | (unless contents-done | ||
| 3050 | (let ((rev (vc-workfile-version file)) | ||
| 3051 | (file-buffer (or (get-file-buffer file) (current-buffer)))) | ||
| 3052 | (message "Checking out %s..." file) | ||
| 3053 | (let ((failed t) | ||
| 3054 | (backup-name (car (find-backup-file-name file)))) | ||
| 3055 | (when backup-name | ||
| 3056 | (copy-file file backup-name 'ok-if-already-exists 'keep-date) | ||
| 3057 | (unless (file-writable-p file) | ||
| 3058 | (set-file-modes file (logior (file-modes file) 128)))) | ||
| 3059 | (unwind-protect | ||
| 3060 | (let ((coding-system-for-read 'no-conversion) | ||
| 3061 | (coding-system-for-write 'no-conversion)) | ||
| 3062 | (with-temp-file file | ||
| 3063 | (let ((outbuf (current-buffer))) | ||
| 3064 | ;; Change buffer to get local value of vc-checkout-switches. | ||
| 3065 | (with-current-buffer file-buffer | ||
| 3066 | (let ((default-directory (file-name-directory file))) | ||
| 3067 | (vc-call find-version file rev outbuf))))) | ||
| 3068 | (setq failed nil)) | ||
| 3069 | (when backup-name | ||
| 3070 | (if failed | ||
| 3071 | (rename-file backup-name file 'ok-if-already-exists) | ||
| 3072 | (and (not vc-make-backup-files) (delete-file backup-name)))))) | ||
| 3073 | (message "Checking out %s...done" file)))) | ||
| 3074 | |||
| 3075 | (defun vc-default-wash-log (backend file) | ||
| 3076 | "Remove all non-comment information from log output. | ||
| 3077 | This default implementation works for RCS logs; backends should override | ||
| 3078 | it if their logs are not in RCS format." | ||
| 3079 | (let ((separator (concat "^-+\nrevision [0-9.]+\ndate: .*\n" | ||
| 3080 | "\\(branches: .*;\n\\)?" | ||
| 3081 | "\\(\\*\\*\\* empty log message \\*\\*\\*\n\\)?"))) | ||
| 3082 | (goto-char (point-max)) (forward-line -1) | ||
| 3083 | (while (looking-at "=*\n") | ||
| 3084 | (delete-char (- (match-end 0) (match-beginning 0))) | ||
| 3085 | (forward-line -1)) | ||
| 3086 | (goto-char (point-min)) | ||
| 3087 | (if (looking-at "[\b\t\n\v\f\r ]+") | ||
| 3088 | (delete-char (- (match-end 0) (match-beginning 0)))) | ||
| 3089 | (goto-char (point-min)) | ||
| 3090 | (re-search-forward separator nil t) | ||
| 3091 | (delete-region (point-min) (point)) | ||
| 3092 | (while (re-search-forward separator nil t) | ||
| 3093 | (delete-region (match-beginning 0) (match-end 0))))) | ||
| 3094 | |||
| 3095 | (defun vc-default-revision-completion-table (backend file) nil) | ||
| 3096 | |||
| 3097 | (defun vc-check-headers () | ||
| 3098 | "Check if the current file has any headers in it." | ||
| 3099 | (interactive) | ||
| 3100 | (vc-call-backend (vc-backend buffer-file-name) 'check-headers)) | ||
| 3101 | |||
| 3102 | ;;; Annotate functionality | ||
| 3091 | 3103 | ||
| 3092 | ;; Declare globally instead of additional parameter to | 3104 | ;; Declare globally instead of additional parameter to |
| 3093 | ;; temp-buffer-show-function (not possible to pass more than one | 3105 | ;; temp-buffer-show-function (not possible to pass more than one |
| @@ -3506,20 +3518,6 @@ The annotations are relative to the current time, unless overridden by OFFSET." | |||
| 3506 | ;; Pretend to font-lock there were no matches. | 3518 | ;; Pretend to font-lock there were no matches. |
| 3507 | nil) | 3519 | nil) |
| 3508 | 3520 | ||
| 3509 | ;; Collect back-end-dependent stuff here | ||
| 3510 | |||
| 3511 | (defalias 'vc-default-logentry-check 'ignore) | ||
| 3512 | |||
| 3513 | (defun vc-check-headers () | ||
| 3514 | "Check if the current file has any headers in it." | ||
| 3515 | (interactive) | ||
| 3516 | (vc-call-backend (vc-backend buffer-file-name) 'check-headers)) | ||
| 3517 | |||
| 3518 | (defun vc-default-check-headers (backend) | ||
| 3519 | "Default implementation of check-headers; always returns nil." | ||
| 3520 | nil) | ||
| 3521 | |||
| 3522 | ;; Back-end-dependent stuff ends here. | ||
| 3523 | 3521 | ||
| 3524 | ;; Set up key bindings for use while editing log messages | 3522 | ;; Set up key bindings for use while editing log messages |
| 3525 | 3523 | ||