comparison lisp/vc.el @ 12885:5c1941d38daa

(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.)
author André Spiegel <spiegel@gnu.org>
date Fri, 18 Aug 1995 20:29:14 +0000
parents fedbe59f374e
children ee3f21f562b8
comparison
equal deleted inserted replaced
12884:f47248851f26 12885:5c1941d38daa
264 "\\.[0-9]+\\)\ndate[ \t]+\\([0-9.]+\\);") 1 2))))) 264 "\\.[0-9]+\\)\ndate[ \t]+\\([0-9.]+\\);") 1 2)))))
265 (if (get-buffer "*vc-info*") 265 (if (get-buffer "*vc-info*")
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
273 (error "File %s is not under version control" file) 273 (error "File %s is not under version control" file)
274 (error "Buffer %s is not associated with a file" (buffer-name)))) 274 (error "Buffer %s is not associated with a file" (buffer-name))))
501 (if vc-initial-comment 501 (if vc-initial-comment
502 (setq vc-log-after-operation-hook 502 (setq vc-log-after-operation-hook
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
512 (pop-to-buffer "*vc-diff*") 534 (pop-to-buffer "*vc-diff*")
513 (goto-char (point-min)) 535 (goto-char (point-min))
538 (vc-checkout-writable-buffer file 560 (vc-checkout-writable-buffer file
539 (vc-branch-part (vc-workfile-version file)))))) 561 (vc-branch-part (vc-workfile-version file))))))
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))
547 (vc-steal-lock 569 (vc-steal-lock
548 file 570 file
549 (if verbose (read-string "Version to steal: ") 571 (if verbose (read-string "Version to steal: ")
550 (vc-workfile-version file)) 572 (vc-workfile-version file))
551 owner)) 573 owner))
552
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 574
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)
599 578
668 647
669 For CVS files: 648 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
678 with the logmessage as change commentary. A writable file is retained. 655 with the logmessage as change commentary. A writable file is retained.
679 If the repository file is changed, you are asked if you want to 656 If the repository file is changed, you are asked if you want to
921 ;; But not if it is a vc-dired buffer. 898 ;; But not if it is a vc-dired buffer.
922 (save-excursion 899 (save-excursion
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))
944 (run-hooks after-hook))) 924 (run-hooks after-hook)))
945 925
1766 (concat "-r" rev) 1746 (concat "-r" rev)
1767 "-p" 1747 "-p"
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))
1774 vc-checkout-switches) 1759 vc-checkout-switches)
1775 (vc-file-setprop file 'vc-workfile-version nil)) 1760 (vc-file-setprop file 'vc-workfile-version nil))
1810 (or (and comment (string-match "[^\t\n ]" comment)) 1795 (or (and comment (string-match "[^\t\n ]" comment))
1811 (setq comment "*** empty log message ***")) 1796 (setq comment "*** empty log message ***"))
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
1818 (apply 'vc-do-command nil 0 "delta" file 'MASTER 1807 (apply 'vc-do-command nil 0 "delta" file 'MASTER
1819 (if rev (concat "-r" rev)) 1808 (if rev (concat "-r" rev))
1860 (concat "-u" old-version))))) 1849 (concat "-u" old-version)))))
1861 ;; CVS 1850 ;; CVS
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))
1876 (if (re-search-forward 1871 (if (re-search-forward
1877 "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" nil t) 1872 "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" nil t)
1883 (if rev 1878 (if rev
1884 (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A")) 1879 (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A"))
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
1898 (progn 1893 (progn
1899 (vc-do-command nil 0 "unget" file 'MASTER nil) 1894 (vc-do-command nil 0 "unget" file 'MASTER nil)
2009 (t 2004 (t
2010 (vc-registration-error file))))) 2005 (vc-registration-error file)))))
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."
2027 (interactive) 2033 (interactive)
2028 (save-excursion 2034 (save-excursion