diff options
| author | André Spiegel | 1995-08-18 20:29:14 +0000 |
|---|---|---|
| committer | André Spiegel | 1995-08-18 20:29:14 +0000 |
| commit | 61dee1e7cf9449abbf65021979412cbaed02e467 (patch) | |
| tree | bd93ea1f15bf4c3f1a0ed0c699edf98748ebad7d | |
| parent | 04446ed0c2cd9c5e4cfcac0e3be5bb49090762fb (diff) | |
| download | emacs-61dee1e7cf9449abbf65021979412cbaed02e467.tar.gz emacs-61dee1e7cf9449abbf65021979412cbaed02e467.zip | |
(vc-next-action-on-file): Changed doc string, CVS case.
(vc-backend-checkin): Clear master properties before doing the
check-in. In the CVS case, catch error and display an appropriate
message in the echo area.
(vc-backend-revert): Clear master properties, because some might get
outdated by the operation.
(vc-backend-merge-news): Scan the output of "cvs update" and find out
whether conflicts have occurred.
(vc-finish-logentry): Delete the *VC-log* buffer *before* doing the
actual check-in. That leads to a better display in case the check-in
fails.
(vc-latest-on-branch-p): Defined it for CVS in the obvious way.
(vc-next-action-on-file): Removed special CVS cases. At this level,
CVS is now mostly handled like the other backends.
(vc-backend-checkout): CVS case: Clear sticky tag as default when
doing a verbose checkout. (This used to be done in
vc-next-action-on-file.)
| -rw-r--r-- | lisp/vc.el | 162 |
1 files changed, 84 insertions, 78 deletions
diff --git a/lisp/vc.el b/lisp/vc.el index 8698e302e14..729016d256d 100644 --- a/lisp/vc.el +++ b/lisp/vc.el | |||
| @@ -266,7 +266,7 @@ and that its contents match what the master file says.") | |||
| 266 | (kill-buffer (get-buffer "*vc-info*"))) | 266 | (kill-buffer (get-buffer "*vc-info*"))) |
| 267 | (string= tip-version workfile-version)))) | 267 | (string= tip-version workfile-version)))) |
| 268 | ;; CVS | 268 | ;; CVS |
| 269 | (error "vc-latest-on-branch-p is not defined for CVS files"))) | 269 | (string= (vc-workfile-version file) (vc-latest-version file)))) |
| 270 | 270 | ||
| 271 | (defun vc-registration-error (file) | 271 | (defun vc-registration-error (file) |
| 272 | (if file | 272 | (if file |
| @@ -503,9 +503,31 @@ to an optional list of FLAGS." | |||
| 503 | 'vc-checkout-writable-buffer-hook) | 503 | 'vc-checkout-writable-buffer-hook) |
| 504 | (vc-checkout-writable-buffer file))) | 504 | (vc-checkout-writable-buffer file))) |
| 505 | 505 | ||
| 506 | ;; CVS: changes to the master file need to be | ||
| 507 | ;; merged back into the working file | ||
| 508 | ((and (eq vc-type 'CVS) | ||
| 509 | (or (eq (vc-cvs-status file) 'needs-checkout) | ||
| 510 | (eq (vc-cvs-status file) 'needs-merge))) | ||
| 511 | (vc-buffer-sync) | ||
| 512 | (if (yes-or-no-p (format "%s is not up-to-date. Merge in changes now? " | ||
| 513 | (buffer-name))) | ||
| 514 | (progn | ||
| 515 | (if (and (buffer-modified-p) | ||
| 516 | (not (yes-or-no-p | ||
| 517 | "Buffer %s modified; merge file on disc anyhow? " | ||
| 518 | (buffer-name)))) | ||
| 519 | (error "Merge aborted")) | ||
| 520 | (if (not (zerop (vc-backend-merge-news file))) | ||
| 521 | ;; Overlaps detected - what now? Should use some | ||
| 522 | ;; fancy RCS conflict resolving package, or maybe | ||
| 523 | ;; emerge, but for now, simply warn the user with a | ||
| 524 | ;; message. | ||
| 525 | (message "Conflicts detected!")) | ||
| 526 | (vc-resynch-window file t (not (buffer-modified-p)))) | ||
| 527 | (error "%s needs update" (buffer-name)))) | ||
| 528 | |||
| 506 | ;; if there is no lock on the file, assert one and get it | 529 | ;; if there is no lock on the file, assert one and get it |
| 507 | ((and (not (eq vc-type 'CVS)) ;There are no locks in CVS. | 530 | ((not (setq owner (vc-locking-user file))) |
| 508 | (not (setq owner (vc-locking-user file)))) | ||
| 509 | (if (and vc-checkout-carefully | 531 | (if (and vc-checkout-carefully |
| 510 | (not (vc-workfile-unchanged-p file t))) | 532 | (not (vc-workfile-unchanged-p file t))) |
| 511 | (if (save-window-excursion | 533 | (if (save-window-excursion |
| @@ -540,7 +562,7 @@ to an optional list of FLAGS." | |||
| 540 | ))) | 562 | ))) |
| 541 | 563 | ||
| 542 | ;; a checked-out version exists, but the user may not own the lock | 564 | ;; a checked-out version exists, but the user may not own the lock |
| 543 | ((and (not (eq vc-type 'CVS)) ;There are no locks in CVS. | 565 | ((and (not (eq vc-type 'CVS)) |
| 544 | (not (string-equal owner (user-login-name)))) | 566 | (not (string-equal owner (user-login-name)))) |
| 545 | (if comment | 567 | (if comment |
| 546 | (error "Sorry, you can't steal the lock on %s this way" file)) | 568 | (error "Sorry, you can't steal the lock on %s this way" file)) |
| @@ -550,49 +572,6 @@ to an optional list of FLAGS." | |||
| 550 | (vc-workfile-version file)) | 572 | (vc-workfile-version file)) |
| 551 | owner)) | 573 | owner)) |
| 552 | 574 | ||
| 553 | ;; CVS: changes to the master file need to be | ||
| 554 | ;; merged back into the working file | ||
| 555 | ((and (eq vc-type 'CVS) | ||
| 556 | ;; "0" means "added, but not yet committed" | ||
| 557 | (not (string= (vc-workfile-version file) "0")) | ||
| 558 | (not (string= (vc-workfile-version file) | ||
| 559 | (vc-latest-version file)))) | ||
| 560 | (vc-buffer-sync) | ||
| 561 | (if (yes-or-no-p (format "%s is not up-to-date. Merge in changes now? " | ||
| 562 | (buffer-name))) | ||
| 563 | (progn | ||
| 564 | (if (and (buffer-modified-p) | ||
| 565 | (not (yes-or-no-p | ||
| 566 | "Buffer %s modified; merge file on disc anyhow? " | ||
| 567 | (buffer-name)))) | ||
| 568 | (error "Merge aborted")) | ||
| 569 | (if (not (zerop (vc-backend-merge-news file))) | ||
| 570 | ;; Overlaps detected - what now? Should use some | ||
| 571 | ;; fancy RCS conflict resolving package, or maybe | ||
| 572 | ;; emerge, but for now, simply warn the user with a | ||
| 573 | ;; message. | ||
| 574 | (message "Conflicts detected!")) | ||
| 575 | (vc-resynch-window file t (not (buffer-modified-p)))) | ||
| 576 | |||
| 577 | (error "%s needs update" (buffer-name)))) | ||
| 578 | |||
| 579 | ;; CVS: Buffer is read-only. Make the file "locked", i.e. | ||
| 580 | ;; make the buffer writable, and assert the user to be the locker | ||
| 581 | ((and (eq vc-type 'CVS) buffer-read-only) | ||
| 582 | (if verbose | ||
| 583 | (let ((rev (read-string "Trunk version to move to: "))) | ||
| 584 | (if (not (string= rev "")) | ||
| 585 | (vc-checkout file nil rev) | ||
| 586 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A") | ||
| 587 | (vc-checkout file))) | ||
| 588 | (setq buffer-read-only nil) | ||
| 589 | (vc-file-setprop file 'vc-locking-user (user-login-name)) | ||
| 590 | (vc-mode-line file) | ||
| 591 | ;; Sites who make link farms to a read-only gold tree (or | ||
| 592 | ;; something similar) can use the hook below to break the | ||
| 593 | ;; sym-link. | ||
| 594 | (run-hooks 'vc-make-buffer-writable-hook))) | ||
| 595 | |||
| 596 | ;; OK, user owns the lock on the file | 575 | ;; OK, user owns the lock on the file |
| 597 | (t | 576 | (t |
| 598 | (find-file file) | 577 | (find-file file) |
| @@ -670,8 +649,6 @@ For CVS files: | |||
| 670 | If the file is not already registered, this registers it for version | 649 | If the file is not already registered, this registers it for version |
| 671 | control. This does a \"cvs add\", but no \"cvs commit\". | 650 | control. This does a \"cvs add\", but no \"cvs commit\". |
| 672 | If the file is added but not committed, it is committed. | 651 | If the file is added but not committed, it is committed. |
| 673 | If the file has not been changed, neither in your working area or | ||
| 674 | in the repository, a message is printed and nothing is done. | ||
| 675 | If your working file is changed, but the repository file is | 652 | If your working file is changed, but the repository file is |
| 676 | unchanged, this pops up a buffer for entry of a log message; when the | 653 | unchanged, this pops up a buffer for entry of a log message; when the |
| 677 | message has been entered, it checks in the resulting changes along | 654 | message has been entered, it checks in the resulting changes along |
| @@ -923,21 +900,24 @@ If nil, uses `change-log-default-name'." | |||
| 923 | (set-buffer vc-parent-buffer) | 900 | (set-buffer vc-parent-buffer) |
| 924 | (or vc-dired-mode | 901 | (or vc-dired-mode |
| 925 | (vc-buffer-sync))) | 902 | (vc-buffer-sync))) |
| 926 | ;; OK, do it to it | 903 | (if (not vc-log-operation) (error "No log operation is pending")) |
| 927 | (if vc-log-operation | 904 | ;; save the parameters held in buffer-local variables |
| 928 | (save-excursion | 905 | (let ((log-operation vc-log-operation) |
| 929 | (funcall vc-log-operation | 906 | (log-file vc-log-file) |
| 930 | vc-log-file | 907 | (log-version vc-log-version) |
| 931 | vc-log-version | 908 | (log-entry (buffer-string)) |
| 932 | (buffer-string))) | 909 | (after-hook vc-log-after-operation-hook)) |
| 933 | (error "No log operation is pending")) | ||
| 934 | ;; save the vc-log-after-operation-hook of log buffer | ||
| 935 | (let ((after-hook vc-log-after-operation-hook)) | ||
| 936 | ;; Return to "parent" buffer of this checkin and remove checkin window | 910 | ;; Return to "parent" buffer of this checkin and remove checkin window |
| 937 | (pop-to-buffer vc-parent-buffer) | 911 | (pop-to-buffer vc-parent-buffer) |
| 938 | (let ((logbuf (get-buffer "*VC-log*"))) | 912 | (let ((logbuf (get-buffer "*VC-log*"))) |
| 939 | (delete-windows-on logbuf) | 913 | (delete-windows-on logbuf) |
| 940 | (kill-buffer logbuf)) | 914 | (kill-buffer logbuf)) |
| 915 | ;; OK, do it to it | ||
| 916 | (save-excursion | ||
| 917 | (funcall log-operation | ||
| 918 | log-file | ||
| 919 | log-version | ||
| 920 | log-entry)) | ||
| 941 | ;; Now make sure we see the expanded headers | 921 | ;; Now make sure we see the expanded headers |
| 942 | (if buffer-file-name | 922 | (if buffer-file-name |
| 943 | (vc-resynch-window buffer-file-name vc-keep-workfiles t)) | 923 | (vc-resynch-window buffer-file-name vc-keep-workfiles t)) |
| @@ -1768,6 +1748,11 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 1768 | vc-checkout-switches) | 1748 | vc-checkout-switches) |
| 1769 | (setq failed nil)) | 1749 | (setq failed nil)) |
| 1770 | (and failed (file-exists-p filename) (delete-file filename)))) | 1750 | (and failed (file-exists-p filename) (delete-file filename)))) |
| 1751 | ;; default for verbose checkout: clear the sticky tag | ||
| 1752 | ;; so that the actual update will go to the head of the trunk | ||
| 1753 | (and rev (string= rev "") | ||
| 1754 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A") | ||
| 1755 | (setq rev nil)) | ||
| 1771 | (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE | 1756 | (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE |
| 1772 | "update" | 1757 | "update" |
| 1773 | (and rev (concat "-r" rev)) | 1758 | (and rev (concat "-r" rev)) |
| @@ -1812,6 +1797,10 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 1812 | (save-excursion | 1797 | (save-excursion |
| 1813 | ;; Change buffers to get local value of vc-checkin-switches. | 1798 | ;; Change buffers to get local value of vc-checkin-switches. |
| 1814 | (set-buffer (or (get-file-buffer file) (current-buffer))) | 1799 | (set-buffer (or (get-file-buffer file) (current-buffer))) |
| 1800 | ;; Clear the master-properties. Do that here, not at the | ||
| 1801 | ;; end, because if the check-in fails we want them to get | ||
| 1802 | ;; re-computed before the next try. | ||
| 1803 | (vc-file-clear-masterprops file) | ||
| 1815 | (vc-backend-dispatch file | 1804 | (vc-backend-dispatch file |
| 1816 | ;; SCCS | 1805 | ;; SCCS |
| 1817 | (progn | 1806 | (progn |
| @@ -1862,14 +1851,20 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 1862 | (progn | 1851 | (progn |
| 1863 | ;; explicit check-in to the trunk requires a | 1852 | ;; explicit check-in to the trunk requires a |
| 1864 | ;; double check-in (first unexplicit) (CVS-1.3) | 1853 | ;; double check-in (first unexplicit) (CVS-1.3) |
| 1865 | (if (and rev (vc-trunk-p rev)) | 1854 | (condition-case nil |
| 1866 | (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE | 1855 | (progn |
| 1867 | "ci" "-m" "intermediate" | 1856 | (if (and rev (vc-trunk-p rev)) |
| 1868 | vc-checkin-switches)) | 1857 | (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE |
| 1869 | (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE | 1858 | "ci" "-m" "intermediate" |
| 1870 | "ci" (if rev (concat "-r" rev)) | 1859 | vc-checkin-switches)) |
| 1871 | (concat "-m" comment) | 1860 | (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE |
| 1872 | vc-checkin-switches) | 1861 | "ci" (if rev (concat "-r" rev)) |
| 1862 | (concat "-m" comment) | ||
| 1863 | vc-checkin-switches)) | ||
| 1864 | (error (if (eq (vc-cvs-status file) 'needs-merge) | ||
| 1865 | ;; The CVS output will be on top of this message. | ||
| 1866 | (error "Type C-x 0 C-x C-q to merge in changes.") | ||
| 1867 | (error "Check in FAILED.")))) | ||
| 1873 | ;; determine and store the new workfile version | 1868 | ;; determine and store the new workfile version |
| 1874 | (set-buffer "*vc*") | 1869 | (set-buffer "*vc*") |
| 1875 | (goto-char (point-min)) | 1870 | (goto-char (point-min)) |
| @@ -1885,13 +1880,13 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 1885 | (vc-file-setprop file 'vc-locking-user 'none) | 1880 | (vc-file-setprop file 'vc-locking-user 'none) |
| 1886 | (vc-file-setprop file 'vc-checkout-time | 1881 | (vc-file-setprop file 'vc-checkout-time |
| 1887 | (nth 5 (file-attributes file)))))) | 1882 | (nth 5 (file-attributes file)))))) |
| 1888 | (vc-file-clear-masterprops file) | ||
| 1889 | (message "Checking in %s...done" file)) | 1883 | (message "Checking in %s...done" file)) |
| 1890 | 1884 | ||
| 1891 | (defun vc-backend-revert (file) | 1885 | (defun vc-backend-revert (file) |
| 1892 | ;; Revert file to latest checked-in version. | 1886 | ;; Revert file to latest checked-in version. |
| 1893 | ;; (for RCS, to workfile version) | 1887 | ;; (for RCS, to workfile version) |
| 1894 | (message "Reverting %s..." file) | 1888 | (message "Reverting %s..." file) |
| 1889 | (vc-file-clear-masterprops file) | ||
| 1895 | (vc-backend-dispatch | 1890 | (vc-backend-dispatch |
| 1896 | file | 1891 | file |
| 1897 | ;; SCCS | 1892 | ;; SCCS |
| @@ -2011,16 +2006,27 @@ From a program, any arguments are passed to the `rcs2log' script." | |||
| 2011 | 2006 | ||
| 2012 | (defun vc-backend-merge-news (file) | 2007 | (defun vc-backend-merge-news (file) |
| 2013 | ;; Merge in any new changes made to FILE. | 2008 | ;; Merge in any new changes made to FILE. |
| 2014 | (vc-backend-dispatch | 2009 | (message "Merging changes into %s..." file) |
| 2015 | file | 2010 | (prog1 |
| 2016 | (error "vc-backend-merge-news not meaningful for SCCS files") ;SCCS | 2011 | (vc-backend-dispatch |
| 2017 | (error "vc-backend-merge-news not meaningful for RCS files") ;RCS | 2012 | file |
| 2018 | (progn ; CVS | 2013 | (error "vc-backend-merge-news not meaningful for SCCS files") ;SCCS |
| 2019 | (vc-file-clear-masterprops file) | 2014 | (error "vc-backend-merge-news not meaningful for RCS files") ;RCS |
| 2020 | (vc-file-setprop file 'vc-workfile-version nil) | 2015 | (save-excursion ; CVS |
| 2021 | (vc-file-setprop file 'vc-locking-user nil) | 2016 | (vc-file-clear-masterprops file) |
| 2022 | (vc-do-command nil 1 "cvs" file 'WORKFILE "update")) | 2017 | (vc-file-setprop file 'vc-workfile-version nil) |
| 2023 | )) | 2018 | (vc-file-setprop file 'vc-locking-user nil) |
| 2019 | (vc-do-command nil 0 "cvs" file 'WORKFILE "update") | ||
| 2020 | ;; CVS doesn't return an error code if conflicts are detected. | ||
| 2021 | ;; Since we want to warn the user about it (and possibly start | ||
| 2022 | ;; emerge later), scan the output and see if this occurred. | ||
| 2023 | (set-buffer (get-buffer "*vc*")) | ||
| 2024 | (goto-char (point-min)) | ||
| 2025 | (if (re-search-forward "^cvs update: conflicts found in .*" nil t) | ||
| 2026 | 1 ;; error code for caller | ||
| 2027 | 0 ;; no conflict detected | ||
| 2028 | ))) | ||
| 2029 | (message "Merging changes into %s...done" file))) | ||
| 2024 | 2030 | ||
| 2025 | (defun vc-check-headers () | 2031 | (defun vc-check-headers () |
| 2026 | "Check if the current file has any headers in it." | 2032 | "Check if the current file has any headers in it." |