comparison lisp/vc-rcs.el @ 32094:027fb880735d

(vc-rcs-fetch-master-state): Parse and remember default branch unconditionally. (vc-rcs-set-default-branch): New function. (vc-rcs-cancel-version, vc-rcs-checkin, vc-rcs-checkout): Use it. (vc-rcs-checkin): If an appropriate default branch has been set, force creation of that branch.
author André Spiegel <spiegel@gnu.org>
date Tue, 03 Oct 2000 11:33:59 +0000
parents 4196f89984ce
children e7f273d850bf
comparison
equal deleted inserted replaced
32093:5c36fa51ee96 32094:027fb880735d
3 ;; Copyright (C) 1992,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc. 3 ;; Copyright (C) 1992,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
4 4
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-rcs.el,v 1.8 2000/10/01 11:17:42 spiegel Exp $ 8 ;; $Id: vc-rcs.el,v 1.9 2000/10/01 19:35:24 monnier Exp $
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by 13 ;; it under the terms of the GNU General Public License as published by
213 This function sets the properties `vc-workfile-version' and 213 This function sets the properties `vc-workfile-version' and
214 `vc-checkout-model' to their correct values, based on the master 214 `vc-checkout-model' to their correct values, based on the master
215 file." 215 file."
216 (with-temp-buffer 216 (with-temp-buffer
217 (vc-insert-file (vc-name file) "^[0-9]") 217 (vc-insert-file (vc-name file) "^[0-9]")
218 (let ((workfile-is-latest nil)) 218 (let ((workfile-is-latest nil)
219 (default-branch (vc-parse-buffer "^branch[ \t\n]+\\([^;]*\\);" 1)))
220 (vc-file-setprop file 'vc-rcs-default-branch default-branch)
219 (unless workfile-version 221 (unless workfile-version
220 (let ((default-branch (vc-parse-buffer "^branch[ \t\n]+\\([^;]*\\);" 1))) 222 ;; Workfile version not known yet. Determine that first. It
221 ;; Workfile version not known yet. Determine that first. It 223 ;; is either the head of the trunk, the head of the default
222 ;; is either the head of the trunk, the head of the default 224 ;; branch, or the "default branch" itself, if that is a full
223 ;; branch, or the "default branch" itself, if that is a full 225 ;; revision number.
224 ;; revision number. 226 (cond
225 (cond 227 ;; no default branch
226 ;; no default branch 228 ((or (not default-branch) (string= "" default-branch))
227 ((or (not default-branch) (string= "" default-branch)) 229 (setq workfile-version
230 (vc-parse-buffer "^head[ \t\n]+\\([^;]+\\);" 1))
231 (setq workfile-is-latest t))
232 ;; default branch is actually a revision
233 ((string-match "^[0-9]+\\.[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*$"
234 default-branch)
235 (setq workfile-version default-branch))
236 ;; else, search for the head of the default branch
237 (t (vc-insert-file (vc-name file) "^desc")
228 (setq workfile-version 238 (setq workfile-version
229 (vc-parse-buffer "^head[ \t\n]+\\([^;]+\\);" 1)) 239 (vc-rcs-find-most-recent-rev default-branch))
230 (setq workfile-is-latest t)) 240 (setq workfile-is-latest t)))
231 ;; default branch is actually a revision 241 (vc-file-setprop file 'vc-workfile-version workfile-version))
232 ((string-match "^[0-9]+\\.[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*$"
233 default-branch)
234 (setq workfile-version default-branch))
235 ;; else, search for the head of the default branch
236 (t (vc-insert-file (vc-name file) "^desc")
237 (setq workfile-version
238 (vc-rcs-find-most-recent-rev default-branch))
239 (setq workfile-is-latest t)))
240 (vc-file-setprop file 'vc-workfile-version workfile-version)))
241 ;; Check strict locking 242 ;; Check strict locking
242 (goto-char (point-min)) 243 (goto-char (point-min))
243 (vc-file-setprop file 'vc-checkout-model 244 (vc-file-setprop file 'vc-checkout-model
244 (if (re-search-forward ";[ \t\n]*strict;" nil t) 245 (if (re-search-forward ";[ \t\n]*strict;" nil t)
245 'locking 'implicit)) 246 'locking 'implicit))
526 (setq done t)) 527 (setq done t))
527 (error (set-buffer "*vc*") 528 (error (set-buffer "*vc*")
528 (goto-char (point-min)) 529 (goto-char (point-min))
529 (if (search-forward "no side branches present for" nil t) 530 (if (search-forward "no side branches present for" nil t)
530 (progn (setq previous (vc-branch-part previous)) 531 (progn (setq previous (vc-branch-part previous))
531 (vc-do-command nil 0 "rcs" (vc-name file) 532 (vc-rcs-set-default-branch file previous)
532 (concat "-b" previous))
533 ;; vc-do-command popped up a window with 533 ;; vc-do-command popped up a window with
534 ;; the error message. Get rid of it, by 534 ;; the error message. Get rid of it, by
535 ;; restoring the old window configuration. 535 ;; restoring the old window configuration.
536 (set-window-configuration config)) 536 (set-window-configuration config))
537 ;; No, it was some other error: re-signal it. 537 ;; No, it was some other error: re-signal it.
584 (defun vc-rcs-checkin (file rev comment) 584 (defun vc-rcs-checkin (file rev comment)
585 "RCS-specific version of `vc-backend-checkin'." 585 "RCS-specific version of `vc-backend-checkin'."
586 (let ((switches (if (stringp vc-checkin-switches) 586 (let ((switches (if (stringp vc-checkin-switches)
587 (list vc-checkin-switches) 587 (list vc-checkin-switches)
588 vc-checkin-switches))) 588 vc-checkin-switches)))
589 (let ((old-version (vc-workfile-version file)) new-version) 589 (let ((old-version (vc-workfile-version file)) new-version
590 (default-branch (vc-file-getprop file 'vc-rcs-default-branch)))
591 ;; Force branch creation if an appropriate
592 ;; default branch has been set.
593 (and (not rev)
594 default-branch
595 (string-match (concat "^" (regexp-quote old-version) "\\.")
596 default-branch)
597 (setq rev default-branch)
598 (setq switches (cons "-f" switches)))
590 (apply 'vc-do-command nil 0 "ci" (vc-name file) 599 (apply 'vc-do-command nil 0 "ci" (vc-name file)
591 ;; if available, use the secure check-in option 600 ;; if available, use the secure check-in option
592 (and (vc-rcs-release-p "5.6.4") "-j") 601 (and (vc-rcs-release-p "5.6.4") "-j")
593 (concat (if vc-keep-workfiles "-u" "-r") rev) 602 (concat (if vc-keep-workfiles "-u" "-r") rev)
594 (concat "-m" comment) 603 (concat "-m" comment)
595 ;; allow creation of branches with no changes;
596 ;; this is used by vc-rcs-receive-file if the
597 ;; base version cannot be found
598 (if (and (stringp rev) (string-match ".1.1$" rev)) "-f")
599 switches) 604 switches)
600 (vc-file-setprop file 'vc-workfile-version nil) 605 (vc-file-setprop file 'vc-workfile-version nil)
601 606
602 ;; determine the new workfile version 607 ;; determine the new workfile version
603 (set-buffer "*vc*") 608 (set-buffer "*vc*")
613 ;; branch accordingly 618 ;; branch accordingly
614 (cond 619 (cond
615 ((and old-version new-version 620 ((and old-version new-version
616 (not (string= (vc-rcs-branch-part old-version) 621 (not (string= (vc-rcs-branch-part old-version)
617 (vc-rcs-branch-part new-version)))) 622 (vc-rcs-branch-part new-version))))
618 (vc-do-command nil 0 "rcs" (vc-name file) 623 (vc-rcs-set-default-branch file
619 (if (vc-rcs-trunk-p new-version) "-b" 624 (if (vc-rcs-trunk-p new-version) nil
620 (concat "-b" (vc-rcs-branch-part new-version)))) 625 (vc-rcs-branch-part new-version)))
621 ;; If this is an old RCS release, we might have 626 ;; If this is an old RCS release, we might have
622 ;; to remove a remaining lock. 627 ;; to remove a remaining lock.
623 (if (not (vc-rcs-release-p "5.6.2")) 628 (if (not (vc-rcs-release-p "5.6.2"))
624 ;; exit status of 1 is also accepted. 629 ;; exit status of 1 is also accepted.
625 ;; It means that the lock was removed before. 630 ;; It means that the lock was removed before.
764 769
765 (defun vc-rcs-set-non-strict-locking (file) 770 (defun vc-rcs-set-non-strict-locking (file)
766 (vc-do-command nil 0 "rcs" file "-U") 771 (vc-do-command nil 0 "rcs" file "-U")
767 (vc-file-setprop file 'vc-checkout-model 'implicit) 772 (vc-file-setprop file 'vc-checkout-model 'implicit)
768 (set-file-modes file (logior (file-modes file) 128))) 773 (set-file-modes file (logior (file-modes file) 128)))
774
775 (defun vc-rcs-set-default-branch (file branch)
776 (vc-do-command nil 0 "rcs" (vc-name file) (concat "-b" branch))
777 (vc-file-setprop file 'vc-rcs-default-branch branch))
769 778
770 (defun vc-rcs-checkout (file &optional writable rev workfile) 779 (defun vc-rcs-checkout (file &optional writable rev workfile)
771 "Retrieve a copy of a saved version of FILE into a workfile." 780 "Retrieve a copy of a saved version of FILE into a workfile."
772 (let ((filename (or workfile file)) 781 (let ((filename (or workfile file))
773 (file-buffer (get-file-buffer file)) 782 (file-buffer (get-file-buffer file))
812 (delete-file filename)))) 821 (delete-file filename))))
813 (let (new-version) 822 (let (new-version)
814 ;; if we should go to the head of the trunk, 823 ;; if we should go to the head of the trunk,
815 ;; clear the default branch first 824 ;; clear the default branch first
816 (and rev (string= rev "") 825 (and rev (string= rev "")
817 (vc-do-command nil 0 "rcs" (vc-name file) "-b")) 826 (vc-rcs-set-default-branch file nil))
818 ;; now do the checkout 827 ;; now do the checkout
819 (apply 'vc-do-command 828 (apply 'vc-do-command
820 nil 0 "co" (vc-name file) 829 nil 0 "co" (vc-name file)
821 ;; If locking is not strict, force to overwrite 830 ;; If locking is not strict, force to overwrite
822 ;; the writable workfile. 831 ;; the writable workfile.
834 (setq new-version 843 (setq new-version
835 (vc-parse-buffer "^revision \\([0-9.]+\\).*\n" 1))) 844 (vc-parse-buffer "^revision \\([0-9.]+\\).*\n" 1)))
836 (vc-file-setprop file 'vc-workfile-version new-version) 845 (vc-file-setprop file 'vc-workfile-version new-version)
837 ;; if necessary, adjust the default branch 846 ;; if necessary, adjust the default branch
838 (and rev (not (string= rev "")) 847 (and rev (not (string= rev ""))
839 (vc-do-command 848 (vc-rcs-set-default-branch
840 nil 0 "rcs" (vc-name file) 849 file
841 (concat "-b" 850 (if (vc-rcs-latest-on-branch-p file new-version)
842 (if (vc-rcs-latest-on-branch-p file new-version) 851 (if (vc-rcs-trunk-p new-version) nil
843 (if (vc-rcs-trunk-p new-version) nil 852 (vc-rcs-branch-part new-version))
844 (vc-rcs-branch-part new-version)) 853 new-version))))))
845 new-version)))))))
846 (message "Checking out %s...done" filename))))) 854 (message "Checking out %s...done" filename)))))
847 855
848 (provide 'vc-rcs) 856 (provide 'vc-rcs)
849 857
850 ;;; vc-rcs.el ends here 858 ;;; vc-rcs.el ends here