diff options
| author | Stefan Monnier | 2003-05-08 20:44:50 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2003-05-08 20:44:50 +0000 |
| commit | f153cb52f8a342e596e1fec0fb52e0a03a42be9e (patch) | |
| tree | 14815f3f039d377877b49a3a82459a7b2b96e9aa /lisp/vc-cvs.el | |
| parent | cc47c6c183f200c8a7a086ad82f521dd193e5d69 (diff) | |
| download | emacs-f153cb52f8a342e596e1fec0fb52e0a03a42be9e.tar.gz emacs-f153cb52f8a342e596e1fec0fb52e0a03a42be9e.zip | |
(vc-cvs-register, vc-cvs-checkin, vc-cvs-find-version, vc-cvs-diff)
(vc-cvs-diff-tree, vc-cvs-checkout): Use vc-switches.
(vc-cvs-revert): Undo patch committed 2003-05-08T20:08:12Z!monnier@iro.umontreal.ca.
Diffstat (limited to 'lisp/vc-cvs.el')
| -rw-r--r-- | lisp/vc-cvs.el | 138 |
1 files changed, 44 insertions, 94 deletions
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index 705db48bc30..6a4feb3f4c5 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: FSF (see vc.el for full credits) | 5 | ;; Author: FSF (see vc.el for full credits) |
| 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
| 7 | 7 | ||
| 8 | ;; $Id: vc-cvs.el,v 1.57 2003/05/08 18:23:53 monnier Exp $ | 8 | ;; $Id: vc-cvs.el,v 1.58 2003/05/08 20:08:12 monnier Exp $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -297,19 +297,11 @@ COMMENT can be used to provide an initial description of FILE. | |||
| 297 | 297 | ||
| 298 | `vc-register-switches' and `vc-cvs-register-switches' are passed to | 298 | `vc-register-switches' and `vc-cvs-register-switches' are passed to |
| 299 | the CVS command (in that order)." | 299 | the CVS command (in that order)." |
| 300 | (let ((switches (append | 300 | (apply 'vc-cvs-command nil 0 file |
| 301 | (if (stringp vc-register-switches) | 301 | "add" |
| 302 | (list vc-register-switches) | 302 | (and comment (string-match "[^\t\n ]" comment) |
| 303 | vc-register-switches) | 303 | (concat "-m" comment)) |
| 304 | (if (stringp vc-cvs-register-switches) | 304 | (vc-switches 'CVS 'register))) |
| 305 | (list vc-cvs-register-switches) | ||
| 306 | vc-cvs-register-switches)))) | ||
| 307 | |||
| 308 | (apply 'vc-cvs-command nil 0 file | ||
| 309 | "add" | ||
| 310 | (and comment (string-match "[^\t\n ]" comment) | ||
| 311 | (concat "-m" comment)) | ||
| 312 | switches))) | ||
| 313 | 305 | ||
| 314 | (defun vc-cvs-responsible-p (file) | 306 | (defun vc-cvs-responsible-p (file) |
| 315 | "Return non-nil if CVS thinks it is responsible for FILE." | 307 | "Return non-nil if CVS thinks it is responsible for FILE." |
| @@ -324,26 +316,18 @@ This is only possible if CVS is responsible for FILE's directory.") | |||
| 324 | 316 | ||
| 325 | (defun vc-cvs-checkin (file rev comment) | 317 | (defun vc-cvs-checkin (file rev comment) |
| 326 | "CVS-specific version of `vc-backend-checkin'." | 318 | "CVS-specific version of `vc-backend-checkin'." |
| 327 | (let ((switches (if (stringp vc-checkin-switches) | 319 | (unless (or (not rev) (vc-cvs-valid-version-number-p rev)) |
| 328 | (list vc-checkin-switches) | 320 | (if (not (vc-cvs-valid-symbolic-tag-name-p rev)) |
| 329 | vc-checkin-switches)) | 321 | (error "%s is not a valid symbolic tag name" rev) |
| 330 | status) | 322 | ;; If the input revison is a valid symbolic tag name, we create it |
| 331 | (if (or (not rev) (vc-cvs-valid-version-number-p rev)) | 323 | ;; as a branch, commit and switch to it. |
| 332 | (setq status (apply 'vc-cvs-command nil 1 file | 324 | (apply 'vc-cvs-command nil 0 file "tag" "-b" (list rev)) |
| 333 | "ci" (if rev (concat "-r" rev)) | 325 | (apply 'vc-cvs-command nil 0 file "update" "-r" (list rev)) |
| 334 | (concat "-m" comment) | 326 | (vc-file-setprop file 'vc-cvs-sticky-tag rev))) |
| 335 | switches)) | 327 | (let ((status (apply 'vc-cvs-command nil 1 file |
| 336 | (if (not (vc-cvs-valid-symbolic-tag-name-p rev)) | 328 | "ci" (if rev (concat "-r" rev)) |
| 337 | (error "%s is not a valid symbolic tag name" rev) | 329 | (concat "-m" comment) |
| 338 | ;; If the input revison is a valid symbolic tag name, we create it | 330 | (vc-switches 'CVS 'checkin)))) |
| 339 | ;; as a branch, commit and switch to it. | ||
| 340 | (apply 'vc-cvs-command nil 0 file "tag" "-b" (list rev)) | ||
| 341 | (apply 'vc-cvs-command nil 0 file "update" "-r" (list rev)) | ||
| 342 | (setq status (apply 'vc-cvs-command nil 1 file | ||
| 343 | "ci" | ||
| 344 | (concat "-m" comment) | ||
| 345 | switches)) | ||
| 346 | (vc-file-setprop file 'vc-cvs-sticky-tag rev))) | ||
| 347 | (set-buffer "*vc*") | 331 | (set-buffer "*vc*") |
| 348 | (goto-char (point-min)) | 332 | (goto-char (point-min)) |
| 349 | (when (not (zerop status)) | 333 | (when (not (zerop status)) |
| @@ -382,9 +366,7 @@ This is only possible if CVS is responsible for FILE's directory.") | |||
| 382 | (and rev (not (string= rev "")) | 366 | (and rev (not (string= rev "")) |
| 383 | (concat "-r" rev)) | 367 | (concat "-r" rev)) |
| 384 | "-p" | 368 | "-p" |
| 385 | (if (stringp vc-checkout-switches) | 369 | (vc-switches 'CVS 'checkout))) |
| 386 | (list vc-checkout-switches) | ||
| 387 | vc-checkout-switches))) | ||
| 388 | 370 | ||
| 389 | (defun vc-cvs-checkout (file &optional editable rev workfile) | 371 | (defun vc-cvs-checkout (file &optional editable rev workfile) |
| 390 | "Retrieve a revision of FILE into a WORKFILE. | 372 | "Retrieve a revision of FILE into a WORKFILE. |
| @@ -397,9 +379,7 @@ REV is the revision to check out into WORKFILE." | |||
| 397 | (save-excursion | 379 | (save-excursion |
| 398 | ;; Change buffers to get local value of vc-checkout-switches. | 380 | ;; Change buffers to get local value of vc-checkout-switches. |
| 399 | (if file-buffer (set-buffer file-buffer)) | 381 | (if file-buffer (set-buffer file-buffer)) |
| 400 | (setq switches (if (stringp vc-checkout-switches) | 382 | (setq switches (vc-switches 'CVS 'checkout)) |
| 401 | (list vc-checkout-switches) | ||
| 402 | vc-checkout-switches)) | ||
| 403 | ;; Save this buffer's default-directory | 383 | ;; Save this buffer's default-directory |
| 404 | ;; and use save-excursion to make sure it is restored | 384 | ;; and use save-excursion to make sure it is restored |
| 405 | ;; in the same buffer it was saved in. | 385 | ;; in the same buffer it was saved in. |
| @@ -445,7 +425,7 @@ REV is the revision to check out into WORKFILE." | |||
| 445 | (if (and (file-exists-p file) (not rev)) | 425 | (if (and (file-exists-p file) (not rev)) |
| 446 | ;; If no revision was specified, just make the file writable | 426 | ;; If no revision was specified, just make the file writable |
| 447 | ;; if necessary (using `cvs-edit' if requested). | 427 | ;; if necessary (using `cvs-edit' if requested). |
| 448 | (and editable (not (eq (vc-cvs-checkout-model file) 'implicit)) | 428 | (and editable (not (eq (vc-cvs-checkout-model file) 'implicit)) |
| 449 | (if vc-cvs-use-edit | 429 | (if vc-cvs-use-edit |
| 450 | (vc-cvs-command nil 0 file "edit") | 430 | (vc-cvs-command nil 0 file "edit") |
| 451 | (set-file-modes file (logior (file-modes file) 128)) | 431 | (set-file-modes file (logior (file-modes file) 128)) |
| @@ -473,30 +453,7 @@ REV is the revision to check out into WORKFILE." | |||
| 473 | (unless contents-done | 453 | (unless contents-done |
| 474 | ;; Check out via standard output (caused by the final argument | 454 | ;; Check out via standard output (caused by the final argument |
| 475 | ;; FILE below), so that no sticky tag is set. | 455 | ;; FILE below), so that no sticky tag is set. |
| 476 | ;; Change buffers to get local value of vc-checkout-switches. | 456 | (vc-cvs-checkout file nil (vc-workfile-version file) file)) |
| 477 | (with-current-buffer (or (get-file-buffer file) (current-buffer)) | ||
| 478 | (let ((failed t) | ||
| 479 | (backup-name (car (find-backup-file-name file)))) | ||
| 480 | (when backup-name | ||
| 481 | (copy-file file backup-name | ||
| 482 | 'ok-if-already-exists 'keep-date)) | ||
| 483 | (unless (file-writable-p file) | ||
| 484 | (set-file-modes file (logior (file-modes file) 128))) | ||
| 485 | (unwind-protect | ||
| 486 | (let ((buf (vc-find-version file (vc-workfile-version file)))) | ||
| 487 | (rename-file (with-current-buffer buf buffer-file-name) | ||
| 488 | file 'ok-if-already-exists) | ||
| 489 | (setq failed nil)) | ||
| 490 | (if failed | ||
| 491 | (if backup-name | ||
| 492 | (rename-file backup-name file | ||
| 493 | 'ok-if-already-exists) | ||
| 494 | (if (file-exists-p file) | ||
| 495 | (delete-file file))) | ||
| 496 | (and backup-name | ||
| 497 | (not vc-make-backup-files) | ||
| 498 | (delete-file backup-name))))))) | ||
| 499 | |||
| 500 | (unless (eq (vc-checkout-model file) 'implicit) | 457 | (unless (eq (vc-checkout-model file) 'implicit) |
| 501 | (if vc-cvs-use-edit | 458 | (if vc-cvs-use-edit |
| 502 | (vc-cvs-command nil 0 file "unedit") | 459 | (vc-cvs-command nil 0 file "unedit") |
| @@ -577,32 +534,26 @@ The changes are between FIRST-VERSION and SECOND-VERSION." | |||
| 577 | 534 | ||
| 578 | (defun vc-cvs-diff (file &optional oldvers newvers) | 535 | (defun vc-cvs-diff (file &optional oldvers newvers) |
| 579 | "Get a difference report using CVS between two versions of FILE." | 536 | "Get a difference report using CVS between two versions of FILE." |
| 580 | (let (status (diff-switches-list (vc-diff-switches-list 'CVS))) | 537 | (if (string= (vc-workfile-version file) "0") |
| 581 | (if (string= (vc-workfile-version file) "0") | 538 | ;; This file is added but not yet committed; there is no master file. |
| 582 | ;; This file is added but not yet committed; there is no master file. | 539 | (if (or oldvers newvers) |
| 583 | (if (or oldvers newvers) | 540 | (error "No revisions of %s exist" file) |
| 584 | (error "No revisions of %s exist" file) | 541 | ;; We regard this as "changed". |
| 585 | ;; We regard this as "changed". | 542 | ;; Diff it against /dev/null. |
| 586 | ;; Diff it against /dev/null. | 543 | ;; Note: this is NOT a "cvs diff". |
| 587 | ;; Note: this is NOT a "cvs diff". | 544 | (apply 'vc-do-command "*vc-diff*" |
| 588 | (apply 'vc-do-command "*vc-diff*" | 545 | 1 "diff" file |
| 589 | 1 "diff" file | 546 | (append (vc-switches nil 'diff) '("/dev/null"))) |
| 590 | (append diff-switches-list '("/dev/null"))) | 547 | ;; Even if it's empty, it's locally modified. |
| 591 | ;; Even if it's empty, it's locally modified. | 548 | 1) |
| 592 | 1) | 549 | (let* ((async (and (vc-cvs-stay-local-p file) (fboundp 'start-process))) |
| 593 | (setq status | 550 | (status (apply 'vc-cvs-command "*vc-diff*" |
| 594 | (apply 'vc-cvs-command "*vc-diff*" | 551 | (if async 'async 1) |
| 595 | (if (and (vc-cvs-stay-local-p file) | 552 | file "diff" |
| 596 | (fboundp 'start-process)) | 553 | (and oldvers (concat "-r" oldvers)) |
| 597 | 'async | 554 | (and newvers (concat "-r" newvers)) |
| 598 | 1) | 555 | (vc-switches 'CVS 'diff)))) |
| 599 | file "diff" | 556 | (if async 1 status)))) ; async diff, pessimistic assumption |
| 600 | (and oldvers (concat "-r" oldvers)) | ||
| 601 | (and newvers (concat "-r" newvers)) | ||
| 602 | diff-switches-list)) | ||
| 603 | (if (vc-cvs-stay-local-p file) | ||
| 604 | 1 ;; async diff, pessimistic assumption | ||
| 605 | status)))) | ||
| 606 | 557 | ||
| 607 | (defun vc-cvs-diff-tree (dir &optional rev1 rev2) | 558 | (defun vc-cvs-diff-tree (dir &optional rev1 rev2) |
| 608 | "Diff all files at and below DIR." | 559 | "Diff all files at and below DIR." |
| @@ -626,13 +577,12 @@ The changes are between FIRST-VERSION and SECOND-VERSION." | |||
| 626 | (apply 'vc-cvs-command "*vc-diff*" 1 nil "diff" | 577 | (apply 'vc-cvs-command "*vc-diff*" 1 nil "diff" |
| 627 | (and rev1 (concat "-r" rev1)) | 578 | (and rev1 (concat "-r" rev1)) |
| 628 | (and rev2 (concat "-r" rev2)) | 579 | (and rev2 (concat "-r" rev2)) |
| 629 | (vc-diff-switches-list 'CVS)))))) | 580 | (vc-switches 'CVS 'diff)))))) |
| 630 | 581 | ||
| 631 | (defun vc-cvs-annotate-command (file buffer &optional version) | 582 | (defun vc-cvs-annotate-command (file buffer &optional version) |
| 632 | "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. | 583 | "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. |
| 633 | Optional arg VERSION is a version to annotate from." | 584 | Optional arg VERSION is a version to annotate from." |
| 634 | (vc-cvs-command buffer 0 file "annotate" (if version | 585 | (vc-cvs-command buffer 0 file "annotate" (if version (concat "-r" version)))) |
| 635 | (concat "-r" version)))) | ||
| 636 | 586 | ||
| 637 | (defun vc-cvs-annotate-current-time () | 587 | (defun vc-cvs-annotate-current-time () |
| 638 | "Return the current time, based at midnight of the current day, and | 588 | "Return the current time, based at midnight of the current day, and |