Mercurial > emacs
comparison lisp/vc-cvs.el @ 44436:f9db51bb423b
(vc-cvs-checkin): Pass the required argument to `error'.
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Mon, 08 Apr 2002 13:38:48 +0000 |
parents | e255f8fa4f62 |
children | 6eb10924e77f |
comparison
equal
deleted
inserted
replaced
44435:343a3a52107d | 44436:f9db51bb423b |
---|---|
3 ;; Copyright (C) 1995,98,99,2000,2001 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995,98,99,2000,2001 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-cvs.el,v 1.37 2002/03/22 23:10:01 monnier Exp $ | 8 ;; $Id: vc-cvs.el,v 1.38 2002/03/28 14:27:30 spiegel 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 |
112 | 112 |
113 Here's an example that will display the formatted date for sticky | 113 Here's an example that will display the formatted date for sticky |
114 dates and the word \"Sticky\" for sticky tag names and revisions. | 114 dates and the word \"Sticky\" for sticky tag names and revisions. |
115 | 115 |
116 (lambda (tag type) | 116 (lambda (tag type) |
117 (cond ((eq type 'date) (format-time-string | 117 (cond ((eq type 'date) (format-time-string |
118 vc-cvs-sticky-date-format-string tag)) | 118 vc-cvs-sticky-date-format-string tag)) |
119 ((eq type 'revision-number) \"Sticky\") | 119 ((eq type 'revision-number) \"Sticky\") |
120 ((eq type 'symbolic-name) \"Sticky\"))) | 120 ((eq type 'symbolic-name) \"Sticky\"))) |
121 | 121 |
122 Here's an example that will abbreviate to the first character only, | 122 Here's an example that will abbreviate to the first character only, |
125 displayed. Date and time is displayed for sticky dates. | 125 displayed. Date and time is displayed for sticky dates. |
126 | 126 |
127 (lambda (tag type) | 127 (lambda (tag type) |
128 (cond ((eq type 'date) (format-time-string \"%Y%m%d %H:%M\" tag)) | 128 (cond ((eq type 'date) (format-time-string \"%Y%m%d %H:%M\" tag)) |
129 ((eq type 'revision-number) \"Sticky\") | 129 ((eq type 'revision-number) \"Sticky\") |
130 ((eq type 'symbolic-name) | 130 ((eq type 'symbolic-name) |
131 (condition-case nil | 131 (condition-case nil |
132 (progn | 132 (progn |
133 (string-match \"\\\\([^-]*\\\\)\\\\(.*\\\\)\" tag) | 133 (string-match \"\\\\([^-]*\\\\)\\\\(.*\\\\)\" tag) |
134 (concat (substring (match-string 1 tag) 0 1) \":\" | 134 (concat (substring (match-string 1 tag) 0 1) \":\" |
135 (substring (match-string 2 tag) 1 nil))) | 135 (substring (match-string 2 tag) 1 nil))) |
136 (error tag))))) ; Fall-back to given tag name. | 136 (error tag))))) ; Fall-back to given tag name. |
137 | 137 |
138 See also variable `vc-cvs-sticky-date-format-string'." | 138 See also variable `vc-cvs-sticky-date-format-string'." |
139 :type '(choice boolean function) | 139 :type '(choice boolean function) |
326 (setq status (apply 'vc-cvs-command nil 1 file | 326 (setq status (apply 'vc-cvs-command nil 1 file |
327 "ci" (if rev (concat "-r" rev)) | 327 "ci" (if rev (concat "-r" rev)) |
328 (concat "-m" comment) | 328 (concat "-m" comment) |
329 switches)) | 329 switches)) |
330 (if (not (vc-cvs-valid-symbolic-tag-name-p rev)) | 330 (if (not (vc-cvs-valid-symbolic-tag-name-p rev)) |
331 (error "%s is not a valid symbolic tag name") | 331 (error "%s is not a valid symbolic tag name" rev) |
332 ;; If the input revison is a valid symbolic tag name, we create it | 332 ;; If the input revison is a valid symbolic tag name, we create it |
333 ;; as a branch, commit and switch to it. | 333 ;; as a branch, commit and switch to it. |
334 (apply 'vc-cvs-command nil 0 file "tag" "-b" (list rev)) | 334 (apply 'vc-cvs-command nil 0 file "tag" "-b" (list rev)) |
335 (apply 'vc-cvs-command nil 0 file "update" "-r" (list rev)) | 335 (apply 'vc-cvs-command nil 0 file "update" "-r" (list rev)) |
336 (setq status (apply 'vc-cvs-command nil 1 file | 336 (setq status (apply 'vc-cvs-command nil 1 file |
337 "ci" | 337 "ci" |
338 (concat "-m" comment) | 338 (concat "-m" comment) |
339 switches)) | 339 switches)) |
340 (vc-file-setprop file 'vc-cvs-sticky-tag rev))) | 340 (vc-file-setprop file 'vc-cvs-sticky-tag rev))) |
341 (set-buffer "*vc*") | 341 (set-buffer "*vc*") |
342 (goto-char (point-min)) | 342 (goto-char (point-min)) |
632 (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time)))))) | 632 (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time (current-time)))))) |
633 | 633 |
634 (defun vc-cvs-annotate-time () | 634 (defun vc-cvs-annotate-time () |
635 "Return the time of the next annotation (as fraction of days) | 635 "Return the time of the next annotation (as fraction of days) |
636 systime, or nil if there is none." | 636 systime, or nil if there is none." |
637 (let ((time-stamp | 637 (let ((time-stamp |
638 "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): ")) | 638 "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): ")) |
639 (if (looking-at time-stamp) | 639 (if (looking-at time-stamp) |
640 (progn | 640 (progn |
641 (let* ((day (string-to-number (match-string 1))) | 641 (let* ((day (string-to-number (match-string 1))) |
642 (month (cdr (assoc (match-string 2) | 642 (month (cdr (assoc (match-string 2) |
643 vc-cvs-local-month-numbers))) | 643 vc-cvs-local-month-numbers))) |
644 (year-tmp (string-to-number (match-string 3))) | 644 (year-tmp (string-to-number (match-string 3))) |
645 ;; Years 0..68 are 2000..2068. | 645 ;; Years 0..68 are 2000..2068. |
646 ;; Years 69..99 are 1969..1999. | 646 ;; Years 69..99 are 1969..1999. |
647 (year (+ (cond ((> 69 year-tmp) 2000) | 647 (year (+ (cond ((> 69 year-tmp) 2000) |
729 (defun vc-cvs-command (buffer okstatus file &rest flags) | 729 (defun vc-cvs-command (buffer okstatus file &rest flags) |
730 "A wrapper around `vc-do-command' for use in vc-cvs.el. | 730 "A wrapper around `vc-do-command' for use in vc-cvs.el. |
731 The difference to vc-do-command is that this function always invokes `cvs', | 731 The difference to vc-do-command is that this function always invokes `cvs', |
732 and that it passes `vc-cvs-global-switches' to it before FLAGS." | 732 and that it passes `vc-cvs-global-switches' to it before FLAGS." |
733 (apply 'vc-do-command buffer okstatus "cvs" file | 733 (apply 'vc-do-command buffer okstatus "cvs" file |
734 (if (stringp vc-cvs-global-switches) | 734 (if (stringp vc-cvs-global-switches) |
735 (cons vc-cvs-global-switches flags) | 735 (cons vc-cvs-global-switches flags) |
736 (append vc-cvs-global-switches | 736 (append vc-cvs-global-switches |
737 flags)))) | 737 flags)))) |
738 | 738 |
739 (defun vc-cvs-stay-local-p (file) | 739 (defun vc-cvs-stay-local-p (file) |
780 (re-search-forward | 780 (re-search-forward |
781 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\ | 781 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\ |
782 \[\t ]+\\([0-9.]+\\)" | 782 \[\t ]+\\([0-9.]+\\)" |
783 nil t)) | 783 nil t)) |
784 (vc-file-setprop file 'vc-latest-version (match-string 2))) | 784 (vc-file-setprop file 'vc-latest-version (match-string 2))) |
785 (vc-file-setprop | 785 (vc-file-setprop |
786 file 'vc-state | 786 file 'vc-state |
787 (cond | 787 (cond |
788 ((string-match "Up-to-date" status) | 788 ((string-match "Up-to-date" status) |
789 (vc-file-setprop file 'vc-checkout-time | 789 (vc-file-setprop file 'vc-checkout-time |
790 (nth 5 (file-attributes file))) | 790 (nth 5 (file-attributes file))) |
813 ;; According to the CVS manual, a valid symbolic tag must start with | 813 ;; According to the CVS manual, a valid symbolic tag must start with |
814 ;; an uppercase or lowercase letter and can contain uppercase and | 814 ;; an uppercase or lowercase letter and can contain uppercase and |
815 ;; lowercase letters, digits, `-', and `_'. | 815 ;; lowercase letters, digits, `-', and `_'. |
816 (and (string-match "^[a-zA-Z]" tag) | 816 (and (string-match "^[a-zA-Z]" tag) |
817 (not (string-match "[^a-z0-9A-Z-_]" tag)))) | 817 (not (string-match "[^a-z0-9A-Z-_]" tag)))) |
818 | 818 |
819 | 819 |
820 (defun vc-cvs-parse-sticky-tag (match-type match-tag) | 820 (defun vc-cvs-parse-sticky-tag (match-type match-tag) |
821 "Parse and return the sticky tag as a string. | 821 "Parse and return the sticky tag as a string. |
822 `match-data' is protected." | 822 `match-data' is protected." |
823 (let ((data (match-data)) | 823 (let ((data (match-data)) |
824 (tag) | 824 (tag) |
825 (type (cond ((string= match-type "D") 'date) | 825 (type (cond ((string= match-type "D") 'date) |
826 ((string= match-type "T") | 826 ((string= match-type "T") |
828 'symbolic-name | 828 'symbolic-name |
829 'revision-number)) | 829 'revision-number)) |
830 (t nil)))) | 830 (t nil)))) |
831 (unwind-protect | 831 (unwind-protect |
832 (progn | 832 (progn |
833 (cond | 833 (cond |
834 ;; Sticky Date tag. Convert to to a proper date value (`encode-time') | 834 ;; Sticky Date tag. Convert to to a proper date value (`encode-time') |
835 ((eq type 'date) | 835 ((eq type 'date) |
836 (string-match | 836 (string-match |
837 "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" | 837 "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)" |
838 match-tag) | 838 match-tag) |
839 (let* ((year-tmp (string-to-number (match-string 1 match-tag))) | 839 (let* ((year-tmp (string-to-number (match-string 1 match-tag))) |
840 (month (string-to-number (match-string 2 match-tag))) | 840 (month (string-to-number (match-string 2 match-tag))) |
841 (day (string-to-number (match-string 3 match-tag))) | 841 (day (string-to-number (match-string 3 match-tag))) |
842 (hour (string-to-number (match-string 4 match-tag))) | 842 (hour (string-to-number (match-string 4 match-tag))) |
854 ((eq type 'revision-number) (setq tag match-tag)) | 854 ((eq type 'revision-number) (setq tag match-tag)) |
855 ;; Default is no sticky tag at all | 855 ;; Default is no sticky tag at all |
856 (t nil)) | 856 (t nil)) |
857 (cond ((eq vc-cvs-sticky-tag-display nil) nil) | 857 (cond ((eq vc-cvs-sticky-tag-display nil) nil) |
858 ((eq vc-cvs-sticky-tag-display t) | 858 ((eq vc-cvs-sticky-tag-display t) |
859 (cond ((eq type 'date) (format-time-string | 859 (cond ((eq type 'date) (format-time-string |
860 vc-cvs-sticky-date-format-string | 860 vc-cvs-sticky-date-format-string |
861 tag)) | 861 tag)) |
862 ((eq type 'symbolic-name) tag) | 862 ((eq type 'symbolic-name) tag) |
863 ((eq type 'revision-number) tag) | 863 ((eq type 'revision-number) tag) |
864 (t nil))) | 864 (t nil))) |
865 ((functionp vc-cvs-sticky-tag-display) | 865 ((functionp vc-cvs-sticky-tag-display) |
866 (funcall vc-cvs-sticky-tag-display tag type)) | 866 (funcall vc-cvs-sticky-tag-display tag type)) |
867 (t nil))) | 867 (t nil))) |
868 | 868 |
869 (set-match-data data)))) | 869 (set-match-data data)))) |
870 | 870 |
903 (vc-file-setprop file 'vc-checkout-time mtime) | 903 (vc-file-setprop file 'vc-checkout-time mtime) |
904 (if set-state (vc-file-setprop file 'vc-state 'up-to-date))) | 904 (if set-state (vc-file-setprop file 'vc-state 'up-to-date))) |
905 (t | 905 (t |
906 (vc-file-setprop file 'vc-checkout-time 0) | 906 (vc-file-setprop file 'vc-checkout-time 0) |
907 (if set-state (vc-file-setprop file 'vc-state 'edited)))))))) | 907 (if set-state (vc-file-setprop file 'vc-state 'edited)))))))) |
908 | 908 |
909 (provide 'vc-cvs) | 909 (provide 'vc-cvs) |
910 | 910 |
911 ;;; vc-cvs.el ends here | 911 ;;; vc-cvs.el ends here |