diff options
| author | Richard M. Stallman | 1997-07-31 06:23:19 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-07-31 06:23:19 +0000 |
| commit | c0d66cb21bac57f5ec0378e8a04aac8f35c3eb5c (patch) | |
| tree | e04a726df40fc0e7708cdab50fafbdba9329c6cd | |
| parent | 403d549cb7cdf070291c6d3a39172661b21390e8 (diff) | |
| download | emacs-c0d66cb21bac57f5ec0378e8a04aac8f35c3eb5c.tar.gz emacs-c0d66cb21bac57f5ec0378e8a04aac8f35c3eb5c.zip | |
(vc-backend-checkin): For CVS, forget the checkout model after commit.
(vc-backend-checkout): Use "cvs edit" for files with manual checkout.
(vc-minor-part, vc-previous-version): New functions.
(vc-diff): Don't ask or guess version numbers.
(vc-version-diff): Suggest default versions based on the file state.
| -rw-r--r-- | lisp/vc.el | 108 |
1 files changed, 73 insertions, 35 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 900eae7aee8..bcee7f8ba0c 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -404,6 +404,26 @@ If nil, VC itself computes this value when it is first needed." | |||
| 404 | ;; return the branch part of a revision number REV | 404 | ;; return the branch part of a revision number REV |
| 405 | (substring rev 0 (string-match "\\.[0-9]+\\'" rev))) | 405 | (substring rev 0 (string-match "\\.[0-9]+\\'" rev))) |
| 406 | 406 | ||
| 407 | (defun vc-minor-part (rev) | ||
| 408 | ;; return the minor version number of a revision number REV | ||
| 409 | (string-match "[0-9]+\\'" rev) | ||
| 410 | (substring rev (match-beginning 0) (match-end 0))) | ||
| 411 | |||
| 412 | (defun vc-previous-version (rev) | ||
| 413 | ;; guess the previous version number | ||
| 414 | (let ((branch (vc-branch-part rev)) | ||
| 415 | (minor-num (string-to-number (vc-minor-part rev)))) | ||
| 416 | (if (> minor-num 1) | ||
| 417 | ;; version does probably not start a branch or release | ||
| 418 | (concat branch "." (number-to-string (1- minor-num))) | ||
| 419 | (if (vc-trunk-p rev) | ||
| 420 | ;; we are at the beginning of the trunk -- | ||
| 421 | ;; don't know anything to return here | ||
| 422 | "" | ||
| 423 | ;; we are at the beginning of a branch -- | ||
| 424 | ;; return version of starting point | ||
| 425 | (vc-branch-part branch))))) | ||
| 426 | |||
| 407 | ;; File property caching | 427 | ;; File property caching |
| 408 | 428 | ||
| 409 | (defun vc-clear-context () | 429 | (defun vc-clear-context () |
| @@ -1253,40 +1273,54 @@ and two version designators specifying which versions to compare." | |||
| 1253 | "There is no version-control master associated with this buffer")) | 1273 | "There is no version-control master associated with this buffer")) |
| 1254 | (let ((file buffer-file-name) | 1274 | (let ((file buffer-file-name) |
| 1255 | unchanged) | 1275 | unchanged) |
| 1256 | (if nil ;;; (not (vc-locking-user file)) | 1276 | (vc-buffer-sync not-urgent) |
| 1257 | ;; This seems like feeping creaturism -- rms. | 1277 | (setq unchanged (vc-workfile-unchanged-p buffer-file-name)) |
| 1258 | ;; if the file is not locked, ask for older version to compare with | 1278 | (if unchanged |
| 1259 | (let ((old (read-string | 1279 | (message "No changes to %s since latest version" file) |
| 1260 | "File is unchanged; version to compare with: "))) | 1280 | (vc-backend-diff file) |
| 1261 | (vc-version-diff file old "")) | 1281 | ;; Ideally, we'd like at this point to parse the diff so that |
| 1262 | (vc-buffer-sync not-urgent) | 1282 | ;; the buffer effectively goes into compilation mode and we |
| 1263 | (setq unchanged (vc-workfile-unchanged-p buffer-file-name)) | 1283 | ;; can visit the old and new change locations via next-error. |
| 1264 | (if unchanged | 1284 | ;; Unfortunately, this is just too painful to do. The basic |
| 1265 | (message "No changes to %s since latest version" file) | 1285 | ;; problem is that the `old' file doesn't exist to be |
| 1266 | (vc-backend-diff file) | 1286 | ;; visited. This plays hell with numerous assumptions in |
| 1267 | ;; Ideally, we'd like at this point to parse the diff so that | 1287 | ;; the diff.el and compile.el machinery. |
| 1268 | ;; the buffer effectively goes into compilation mode and we | 1288 | (set-buffer "*vc-diff*") |
| 1269 | ;; can visit the old and new change locations via next-error. | 1289 | (setq default-directory (file-name-directory file)) |
| 1270 | ;; Unfortunately, this is just too painful to do. The basic | 1290 | (if (= 0 (buffer-size)) |
| 1271 | ;; problem is that the `old' file doesn't exist to be | 1291 | (progn |
| 1272 | ;; visited. This plays hell with numerous assumptions in | 1292 | (setq unchanged t) |
| 1273 | ;; the diff.el and compile.el machinery. | 1293 | (message "No changes to %s since latest version" file)) |
| 1274 | (set-buffer "*vc-diff*") | 1294 | (pop-to-buffer "*vc-diff*") |
| 1275 | (setq default-directory (file-name-directory file)) | 1295 | (goto-char (point-min)) |
| 1276 | (if (= 0 (buffer-size)) | 1296 | (shrink-window-if-larger-than-buffer))) |
| 1277 | (progn | 1297 | (not unchanged)))) |
| 1278 | (setq unchanged t) | ||
| 1279 | (message "No changes to %s since latest version" file)) | ||
| 1280 | (pop-to-buffer "*vc-diff*") | ||
| 1281 | (goto-char (point-min)) | ||
| 1282 | (shrink-window-if-larger-than-buffer))) | ||
| 1283 | (not unchanged))))) | ||
| 1284 | 1298 | ||
| 1285 | (defun vc-version-diff (file rel1 rel2) | 1299 | (defun vc-version-diff (file rel1 rel2) |
| 1286 | "For FILE, report diffs between two stored versions REL1 and REL2 of it. | 1300 | "For FILE, report diffs between two stored versions REL1 and REL2 of it. |
| 1287 | If FILE is a directory, generate diffs between versions for all registered | 1301 | If FILE is a directory, generate diffs between versions for all registered |
| 1288 | files in or below it." | 1302 | files in or below it." |
| 1289 | (interactive "FFile or directory to diff: \nsOlder version: \nsNewer version: ") | 1303 | (interactive |
| 1304 | (let ((file (read-file-name "File or directory to diff: " | ||
| 1305 | default-directory buffer-file-name t | ||
| 1306 | (file-name-nondirectory buffer-file-name))) | ||
| 1307 | (rel1-default nil) (rel2-default nil)) | ||
| 1308 | ;; compute default versions based on the file state | ||
| 1309 | (cond | ||
| 1310 | ;; if it's a directory, don't supply any version defauolt | ||
| 1311 | ((file-directory-p file) | ||
| 1312 | nil) | ||
| 1313 | ;; if the file is locked, use current version as older version | ||
| 1314 | ((vc-locking-user file) | ||
| 1315 | (setq rel1-default (vc-workfile-version file))) | ||
| 1316 | ;; if the file is not locked, use last and previous version as default | ||
| 1317 | (t | ||
| 1318 | (setq rel1-default (vc-previous-version (vc-workfile-version file))) | ||
| 1319 | (setq rel2-default (vc-workfile-version file)))) | ||
| 1320 | ;; construct argument list | ||
| 1321 | (list file | ||
| 1322 | (read-string "Older version: " rel1-default) | ||
| 1323 | (read-string "Newer version: " rel2-default)))) | ||
| 1290 | (if (string-equal rel1 "") (setq rel1 nil)) | 1324 | (if (string-equal rel1 "") (setq rel1 nil)) |
| 1291 | (if (string-equal rel2 "") (setq rel2 nil)) | 1325 | (if (string-equal rel2 "") (setq rel2 nil)) |
| 1292 | (if (file-directory-p file) | 1326 | (if (file-directory-p file) |
| @@ -2401,12 +2435,11 @@ Return the first cons which CAR is not less than THRESHOLD, nil otherwise" | |||
| 2401 | (and rev (not (string= rev "")) | 2435 | (and rev (not (string= rev "")) |
| 2402 | (concat "-r" rev)) | 2436 | (concat "-r" rev)) |
| 2403 | switches) | 2437 | switches) |
| 2404 | ;; If no revision was specified, simply make the file writable. | 2438 | ;; If no revision was specified, call "cvs edit" to make |
| 2405 | (and writable | 2439 | ;; the file writeable. |
| 2406 | (or (eq (vc-checkout-model file) 'manual) | 2440 | (and writable (eq (vc-checkout-model file) 'manual) |
| 2407 | (zerop (logand 128 (file-modes file)))) | 2441 | (vc-do-command nil 0 "cvs" file 'WORKFILE "edit"))) |
| 2408 | (set-file-modes file (logior 128 (file-modes file))))) | 2442 | (if rev (vc-file-setprop file 'vc-workfile-version nil)))) |
| 2409 | (if rev (vc-file-setprop file 'vc-workfile-version nil)))) | ||
| 2410 | (cond | 2443 | (cond |
| 2411 | ((not workfile) | 2444 | ((not workfile) |
| 2412 | (vc-file-clear-masterprops file) | 2445 | (vc-file-clear-masterprops file) |
| @@ -2531,6 +2564,11 @@ Return the first cons which CAR is not less than THRESHOLD, nil otherwise" | |||
| 2531 | ;; if this was an explicit check-in, remove the sticky tag | 2564 | ;; if this was an explicit check-in, remove the sticky tag |
| 2532 | (if rev | 2565 | (if rev |
| 2533 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A")) | 2566 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A")) |
| 2567 | ;; Forget the checkout model, because we might have assumed | ||
| 2568 | ;; a wrong one when we found the file. After commit, we can | ||
| 2569 | ;; tell it from the permissions of the file | ||
| 2570 | ;; (see vc-checkout-model). | ||
| 2571 | (vc-file-setprop file 'vc-checkout-model nil) | ||
| 2534 | (vc-file-setprop file 'vc-locking-user 'none) | 2572 | (vc-file-setprop file 'vc-locking-user 'none) |
| 2535 | (vc-file-setprop file 'vc-checkout-time | 2573 | (vc-file-setprop file 'vc-checkout-time |
| 2536 | (nth 5 (file-attributes file))))))) | 2574 | (nth 5 (file-attributes file))))))) |