Mercurial > emacs
comparison lisp/vc.el @ 32054:fef29341db1c
(vc-next-action-on-file): Update mode line only if file is visited.
(vc-start-entry): New argument initial-contents. Don't visit the file
if it isn't already visited. Brought documentation up-to-date.
(vc-next-action, vc-register): Updated calls to vc-start-entry.
(vc-checkin): New optional arg initial-contents, which is passed to
vc-start-entry.
(vc-finish-logentry): Make sure to bury log buffer only if there
really is one. Call `vc-resynch-buffer' on log-file, not
buffer-file-name.
(vc-default-comment-history, vc-default-wash-log): New functions.
(vc-index-of): Removed.
(vc-transfer-file): Make do without the above.
(vc-default-receive-file): Call comment-history unconditionally. Pass
the resulting string to vc-checkin, instead of inserting it into the
comment ring.
author | André Spiegel <spiegel@gnu.org> |
---|---|
date | Sun, 01 Oct 2000 12:06:15 +0000 |
parents | 69ccb7fbb1c1 |
children | 4196f89984ce |
comparison
equal
deleted
inserted
replaced
32053:0216f8dcf1d4 | 32054:fef29341db1c |
---|---|
834 | 834 |
835 ;; Do the right thing | 835 ;; Do the right thing |
836 (if (not (vc-registered file)) | 836 (if (not (vc-registered file)) |
837 (vc-register verbose comment) | 837 (vc-register verbose comment) |
838 (vc-recompute-state file) | 838 (vc-recompute-state file) |
839 (vc-mode-line file) | 839 (if visited (vc-mode-line file)) |
840 (setq state (vc-state file)) | 840 (setq state (vc-state file)) |
841 (cond | 841 (cond |
842 ;; up-to-date | 842 ;; up-to-date |
843 ((or (eq state 'up-to-date) | 843 ((or (eq state 'up-to-date) |
844 (and verbose (eq state 'needs-patch))) | 844 (and verbose (eq state 'needs-patch))) |
1015 (mapconcat | 1015 (mapconcat |
1016 (lambda (f) | 1016 (lambda (f) |
1017 (if (not (vc-up-to-date-p f)) "@" "")) | 1017 (if (not (vc-up-to-date-p f)) "@" "")) |
1018 files "")) | 1018 files "")) |
1019 (vc-next-action-dired nil nil "dummy") | 1019 (vc-next-action-dired nil nil "dummy") |
1020 (vc-start-entry nil nil nil | 1020 (vc-start-entry nil nil nil nil |
1021 "Enter a change comment for the marked files." | 1021 "Enter a change comment for the marked files." |
1022 'vc-next-action-dired)) | 1022 'vc-next-action-dired)) |
1023 (throw 'nogo nil))) | 1023 (throw 'nogo nil))) |
1024 (while vc-parent-buffer | 1024 (while vc-parent-buffer |
1025 (pop-to-buffer vc-parent-buffer)) | 1025 (pop-to-buffer vc-parent-buffer)) |
1061 (read-string (format "Initial version level for %s: " | 1061 (read-string (format "Initial version level for %s: " |
1062 (buffer-name))) | 1062 (buffer-name))) |
1063 ;; TODO: Use backend-specific init version. | 1063 ;; TODO: Use backend-specific init version. |
1064 vc-default-init-version) | 1064 vc-default-init-version) |
1065 (or comment (not vc-initial-comment)) | 1065 (or comment (not vc-initial-comment)) |
1066 nil | |
1066 "Enter initial comment." | 1067 "Enter initial comment." |
1067 (lambda (file rev comment) | 1068 (lambda (file rev comment) |
1068 (message "Registering %s... " file) | 1069 (message "Registering %s... " file) |
1069 (let ((backend (vc-responsible-backend file))) | 1070 (let ((backend (vc-responsible-backend file))) |
1070 (vc-file-clearprops file) | 1071 (vc-file-clearprops file) |
1149 (if buffer | 1150 (if buffer |
1150 (with-current-buffer buffer | 1151 (with-current-buffer buffer |
1151 (vc-resynch-window file keep noquery))))) | 1152 (vc-resynch-window file keep noquery))))) |
1152 (vc-dired-resynch-file file)) | 1153 (vc-dired-resynch-file file)) |
1153 | 1154 |
1154 (defun vc-start-entry (file rev comment msg action &optional after-hook) | 1155 (defun vc-start-entry (file rev comment initial-contents msg action &optional after-hook) |
1155 "Accept a comment for an operation on FILE revision REV. | 1156 "Accept a comment for an operation on FILE revision REV. |
1156 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the | 1157 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the |
1157 action on close to ACTION; otherwise, do action immediately. Remember | 1158 action on close to ACTION. If COMMENT is a string and |
1158 the file's buffer in `vc-parent-buffer' (current one if no file). | 1159 INITIAL-CONTENTS is non-nil, then COMMENT is used as the initial |
1159 AFTER-HOOK specifies the local value for vc-log-operation-hook." | 1160 contents of the log entry buffer. If COMMENT is a string and |
1160 (let ((parent (if file (find-file-noselect file) (current-buffer)))) | 1161 INITIAL-CONTENTS is nil, do action immediately as if the user had |
1162 entered COMMENT. If COMMENT is t, also do action immediately with an | |
1163 empty comment. Remember the file's buffer in `vc-parent-buffer' | |
1164 \(current one if no file). AFTER-HOOK specifies the local value | |
1165 for vc-log-operation-hook." | |
1166 (let ((parent (or (and file (get-file-buffer file)) (current-buffer)))) | |
1161 (if vc-before-checkin-hook | 1167 (if vc-before-checkin-hook |
1162 (if file | 1168 (if file |
1163 (with-current-buffer parent | 1169 (with-current-buffer parent |
1164 (run-hooks 'vc-before-checkin-hook)) | 1170 (run-hooks 'vc-before-checkin-hook)) |
1165 (run-hooks 'vc-before-checkin-hook))) | 1171 (run-hooks 'vc-before-checkin-hook))) |
1166 (if comment | 1172 (if (and comment (not initial-contents)) |
1167 (set-buffer (get-buffer-create "*VC-log*")) | 1173 (set-buffer (get-buffer-create "*VC-log*")) |
1168 (pop-to-buffer (get-buffer-create "*VC-log*"))) | 1174 (pop-to-buffer (get-buffer-create "*VC-log*"))) |
1169 (set (make-local-variable 'vc-parent-buffer) parent) | 1175 (set (make-local-variable 'vc-parent-buffer) parent) |
1170 (set (make-local-variable 'vc-parent-buffer-name) | 1176 (set (make-local-variable 'vc-parent-buffer-name) |
1171 (concat " from " (buffer-name vc-parent-buffer))) | 1177 (concat " from " (buffer-name vc-parent-buffer))) |
1174 (make-local-variable 'vc-log-after-operation-hook) | 1180 (make-local-variable 'vc-log-after-operation-hook) |
1175 (if after-hook | 1181 (if after-hook |
1176 (setq vc-log-after-operation-hook after-hook)) | 1182 (setq vc-log-after-operation-hook after-hook)) |
1177 (setq vc-log-operation action) | 1183 (setq vc-log-operation action) |
1178 (setq vc-log-version rev) | 1184 (setq vc-log-version rev) |
1179 (if comment | 1185 (erase-buffer) |
1180 (progn | 1186 (if (eq comment t) |
1181 (erase-buffer) | 1187 (vc-finish-logentry t) |
1182 (if (eq comment t) | 1188 (if comment |
1183 (vc-finish-logentry t) | 1189 (insert comment)) |
1184 (insert comment) | 1190 (if (and comment (not initial-contents)) |
1185 (vc-finish-logentry nil))) | 1191 (vc-finish-logentry nil) |
1186 (message "%s Type C-c C-c when done" msg)))) | 1192 (message "%s Type C-c C-c when done" msg))))) |
1187 | 1193 |
1188 (defun vc-checkout (file &optional writable rev) | 1194 (defun vc-checkout (file &optional writable rev) |
1189 "Retrieve a copy of the revision REV of FILE. | 1195 "Retrieve a copy of the revision REV of FILE. |
1190 If WRITABLE is non-nil, make sure the retrieved file is writable. | 1196 If WRITABLE is non-nil, make sure the retrieved file is writable. |
1191 REV defaults to the latest revision." | 1197 REV defaults to the latest revision." |
1236 (vc-call steal-lock file version) | 1242 (vc-call steal-lock file version) |
1237 `((vc-state edited))) | 1243 `((vc-state edited))) |
1238 (vc-resynch-buffer file t t) | 1244 (vc-resynch-buffer file t t) |
1239 (message "Stealing lock on %s...done" file)) | 1245 (message "Stealing lock on %s...done" file)) |
1240 | 1246 |
1241 (defun vc-checkin (file &optional rev comment) | 1247 (defun vc-checkin (file &optional rev comment initial-contents) |
1242 "Check in FILE. | 1248 "Check in FILE. |
1243 The optional argument REV may be a string specifying the new version | 1249 The optional argument REV may be a string specifying the new version |
1244 level (if nil increment the current level). COMMENT is a comment | 1250 level (if nil increment the current level). COMMENT is a comment |
1245 string; if omitted, a buffer is popped up to accept a comment. | 1251 string; if omitted, a buffer is popped up to accept a comment. If |
1252 INITIAL-CONTENTS is non-nil, then COMMENT is used as the initial contents | |
1253 of the log entry buffer. | |
1246 | 1254 |
1247 If `vc-keep-workfiles' is nil, FILE is deleted afterwards, provided | 1255 If `vc-keep-workfiles' is nil, FILE is deleted afterwards, provided |
1248 that the version control system supports this mode of operation. | 1256 that the version control system supports this mode of operation. |
1249 | 1257 |
1250 Runs the normal hook `vc-checkin-hook'." | 1258 Runs the normal hook `vc-checkin-hook'." |
1251 (vc-start-entry | 1259 (vc-start-entry |
1252 file rev comment | 1260 file rev comment initial-contents |
1253 "Enter a change comment." | 1261 "Enter a change comment." |
1254 (lambda (file rev comment) | 1262 (lambda (file rev comment) |
1255 (message "Checking in %s..." file) | 1263 (message "Checking in %s..." file) |
1256 ;; "This log message intentionally left almost blank". | 1264 ;; "This log message intentionally left almost blank". |
1257 ;; RCS 5.7 gripes about white-space-only comments too. | 1265 ;; RCS 5.7 gripes about white-space-only comments too. |
1355 (let ((logbuf (get-buffer "*VC-log*"))) | 1363 (let ((logbuf (get-buffer "*VC-log*"))) |
1356 (cond ((and logbuf vc-delete-logbuf-window) | 1364 (cond ((and logbuf vc-delete-logbuf-window) |
1357 (delete-windows-on logbuf (selected-frame)) | 1365 (delete-windows-on logbuf (selected-frame)) |
1358 ;; Kill buffer and delete any other dedicated windows/frames. | 1366 ;; Kill buffer and delete any other dedicated windows/frames. |
1359 (kill-buffer logbuf)) | 1367 (kill-buffer logbuf)) |
1360 (t (pop-to-buffer "*VC-log*") | 1368 (logbuf (pop-to-buffer "*VC-log*") |
1361 (bury-buffer) | 1369 (bury-buffer) |
1362 (pop-to-buffer tmp-vc-parent-buffer)))) | 1370 (pop-to-buffer tmp-vc-parent-buffer)))) |
1363 ;; Now make sure we see the expanded headers | 1371 ;; Now make sure we see the expanded headers |
1364 (if buffer-file-name | 1372 (if log-file |
1365 (vc-resynch-buffer buffer-file-name vc-keep-workfiles t)) | 1373 (vc-resynch-buffer log-file vc-keep-workfiles t)) |
1366 (if vc-dired-mode | 1374 (if vc-dired-mode |
1367 (dired-move-to-filename)) | 1375 (dired-move-to-filename)) |
1368 (run-hooks after-hook 'vc-finish-logentry-hook))) | 1376 (run-hooks after-hook 'vc-finish-logentry-hook))) |
1369 | 1377 |
1370 ;; Code for access to the comment ring | 1378 ;; Code for access to the comment ring |
1371 | 1379 |
1372 (defun vc-new-comment-index (stride len) | 1380 (defun vc-new-comment-index (stride len) |
2096 (if (vc-find-backend-function ',(vc-backend file) 'show-log-entry) | 2104 (if (vc-find-backend-function ',(vc-backend file) 'show-log-entry) |
2097 (vc-call-backend ',(vc-backend file) | 2105 (vc-call-backend ',(vc-backend file) |
2098 'show-log-entry | 2106 'show-log-entry |
2099 ',(vc-workfile-version file)))))))) | 2107 ',(vc-workfile-version file)))))))) |
2100 | 2108 |
2109 (defun vc-default-comment-history (backend file) | |
2110 "Return a string with all log entries that were made under BACKEND for FILE." | |
2111 (if (vc-find-backend-function backend 'print-log) | |
2112 (with-temp-buffer | |
2113 (vc-call print-log file) | |
2114 (vc-call wash-log file) | |
2115 (buffer-string)))) | |
2116 | |
2117 (defun vc-default-wash-log (backend file) | |
2118 "Remove all non-comment information from log output. | |
2119 This default implementation works for RCS logs; backends should override | |
2120 it if their logs are not in RCS format." | |
2121 (let ((separator (concat "^-+\nrevision [0-9.]+\ndate: .*\n" | |
2122 "\\(branches: .*;\n\\)?" | |
2123 "\\(\\*\\*\\* empty log message \\*\\*\\*\n\\)?"))) | |
2124 (goto-char (point-max)) (forward-line -1) | |
2125 (while (looking-at "=*\n") | |
2126 (delete-char (- (match-end 0) (match-beginning 0))) | |
2127 (forward-line -1)) | |
2128 (goto-char (point-min)) | |
2129 (if (looking-at "[\b\t\n\v\f\r ]+") | |
2130 (delete-char (- (match-end 0) (match-beginning 0)))) | |
2131 (goto-char (point-min)) | |
2132 (re-search-forward separator nil t) | |
2133 (delete-region (point-min) (point)) | |
2134 (while (re-search-forward separator nil t) | |
2135 (delete-region (match-beginning 0) (match-end 0))))) | |
2136 | |
2101 ;;;###autoload | 2137 ;;;###autoload |
2102 (defun vc-revert-buffer () | 2138 (defun vc-revert-buffer () |
2103 "Revert the current buffer's file back to the version it was based on. | 2139 "Revert the current buffer's file back to the version it was based on. |
2104 This asks for confirmation if the buffer contents are not identical | 2140 This asks for confirmation if the buffer contents are not identical |
2105 to that version. Note that for RCS and CVS, this function does not | 2141 to that version. Note that for RCS and CVS, this function does not |
2194 (error "%s is not registered in %s" file backend)) | 2230 (error "%s is not registered in %s" file backend)) |
2195 (vc-file-clearprops file) | 2231 (vc-file-clearprops file) |
2196 (vc-file-setprop file 'vc-backend backend) | 2232 (vc-file-setprop file 'vc-backend backend) |
2197 (vc-resynch-buffer file t t)) | 2233 (vc-resynch-buffer file t t)) |
2198 | 2234 |
2199 (defun vc-index-of (backend) | |
2200 "Return the index of BACKEND in vc-handled-backends." | |
2201 (- (length vc-handled-backends) | |
2202 (length (memq backend vc-handled-backends)))) | |
2203 | |
2204 ;;;autoload | 2235 ;;;autoload |
2205 (defun vc-transfer-file (file new-backend) | 2236 (defun vc-transfer-file (file new-backend) |
2206 "Transfer FILE to another version control system NEW-BACKEND. | 2237 "Transfer FILE to another version control system NEW-BACKEND. |
2207 If NEW-BACKEND has a higher precedence than FILE's current backend | 2238 If NEW-BACKEND has a higher precedence than FILE's current backend |
2208 \(i.e. it comes earlier in vc-handled-backends), then register FILE in | 2239 \(i.e. it comes earlier in vc-handled-backends), then register FILE in |
2216 (error "%s is the current backend of %s" | 2247 (error "%s is the current backend of %s" |
2217 new-backend file) | 2248 new-backend file) |
2218 (with-vc-properties | 2249 (with-vc-properties |
2219 file | 2250 file |
2220 (vc-call-backend new-backend 'receive-file file | 2251 (vc-call-backend new-backend 'receive-file file |
2221 (< (vc-index-of old-backend) | 2252 ;; set MOVE argument if new-backend |
2222 (vc-index-of new-backend))) | 2253 ;; comes later in vc-handled-backends |
2254 (memq new-backend | |
2255 (memq old-backend vc-handled-backends))) | |
2223 `((vc-backend ,new-backend)))) | 2256 `((vc-backend ,new-backend)))) |
2224 (vc-resynch-buffer file t t))) | 2257 (vc-resynch-buffer file t t))) |
2225 | 2258 |
2226 (defun vc-default-receive-file (backend file move) | 2259 (defun vc-default-receive-file (backend file move) |
2227 "Let BACKEND receive FILE from another version control system. | 2260 "Let BACKEND receive FILE from another version control system. |
2229 backend and its comment history is used as the initial contents | 2262 backend and its comment history is used as the initial contents |
2230 of the log entry buffer." | 2263 of the log entry buffer." |
2231 (let ((old-backend (vc-backend file)) | 2264 (let ((old-backend (vc-backend file)) |
2232 (rev (vc-workfile-version file)) | 2265 (rev (vc-workfile-version file)) |
2233 (state (vc-state file)) | 2266 (state (vc-state file)) |
2234 (comment (and move | 2267 (comment (and move (vc-call comment-history file)))) |
2235 (vc-find-backend-function old-backend 'comment-history) | |
2236 (vc-call 'comment-history file)))) | |
2237 (if move (vc-unregister file old-backend)) | 2268 (if move (vc-unregister file old-backend)) |
2238 (vc-file-clearprops file) | 2269 (vc-file-clearprops file) |
2239 (if (not (vc-call-backend backend 'registered file)) | 2270 (if (not (vc-call-backend backend 'registered file)) |
2240 (with-vc-properties | 2271 (with-vc-properties |
2241 file | 2272 file |
2248 (vc-file-setprop file 'vc-state 'edited) | 2279 (vc-file-setprop file 'vc-state 'edited) |
2249 (set-file-modes file | 2280 (set-file-modes file |
2250 (logior (file-modes file) 128))) | 2281 (logior (file-modes file) 128))) |
2251 (when (or move (eq state 'edited)) | 2282 (when (or move (eq state 'edited)) |
2252 (vc-file-setprop file 'vc-state 'edited) | 2283 (vc-file-setprop file 'vc-state 'edited) |
2253 ;; TODO: The comment history should actually become the | 2284 (vc-checkin file nil comment (stringp comment))))) |
2254 ;; initial contents of the log entry buffer. | |
2255 (and comment (ring-insert vc-comment-ring comment)) | |
2256 (vc-checkin file)))) | |
2257 | 2285 |
2258 (defun vc-rename-master (oldmaster newfile templates) | 2286 (defun vc-rename-master (oldmaster newfile templates) |
2259 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." | 2287 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." |
2260 (let* ((dir (file-name-directory (expand-file-name oldmaster))) | 2288 (let* ((dir (file-name-directory (expand-file-name oldmaster))) |
2261 (newdir (or (file-name-directory newfile) "")) | 2289 (newdir (or (file-name-directory newfile) "")) |