aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2003-04-19 22:40:18 +0000
committerStefan Monnier2003-04-19 22:40:18 +0000
commitd3ee404f7f2aec68fdf56fa35e34bb4618d7efa8 (patch)
tree5443e18d9b6ef08e85e351f6760a47daea548f9a
parent96d44c649994bf28e5ddcb8d51515fbebb320960 (diff)
downloademacs-d3ee404f7f2aec68fdf56fa35e34bb4618d7efa8.tar.gz
emacs-d3ee404f7f2aec68fdf56fa35e34bb4618d7efa8.zip
(vc-cvs-dir-state): Use vc-cvs-command.
(vc-cvs-could-register, vc-cvs-make-version-backups-p): Use defalias. (vc-cvs-merge-news): Simplify. (vc-cvs-diff): Remove unused var `options'. (vc-cvs-parse-entry): Use the same algorithm as cvs does.
-rw-r--r--lisp/vc-cvs.el117
1 files changed, 56 insertions, 61 deletions
diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el
index 6d072d0402c..4fcba6a07e1 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.52 2003/03/27 22:38:38 schwab Exp $ 8;; $Id: vc-cvs.el,v 1.53 2003/04/05 15:51:14 spiegel Exp $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -207,21 +207,21 @@ See also variable `vc-cvs-sticky-date-format-string'."
207 207
208(defun vc-cvs-dir-state (dir) 208(defun vc-cvs-dir-state (dir)
209 "Find the CVS state of all files in DIR." 209 "Find the CVS state of all files in DIR."
210 ;; if DIR is not under CVS control, don't do anything 210 ;; if DIR is not under CVS control, don't do anything.
211 (if (file-readable-p (expand-file-name "CVS/Entries" dir)) 211 (when (file-readable-p (expand-file-name "CVS/Entries" dir))
212 (if (vc-cvs-stay-local-p dir) 212 (if (vc-cvs-stay-local-p dir)
213 (vc-cvs-dir-state-heuristic dir) 213 (vc-cvs-dir-state-heuristic dir)
214 (let ((default-directory dir)) 214 (let ((default-directory dir))
215 ;; Don't specify DIR in this command, the default-directory is 215 ;; Don't specify DIR in this command, the default-directory is
216 ;; enough. Otherwise it might fail with remote repositories. 216 ;; enough. Otherwise it might fail with remote repositories.
217 (with-temp-buffer 217 (with-temp-buffer
218 (vc-do-command t 0 "cvs" nil "status" "-l") 218 (vc-cvs-command t 0 nil "status" "-l")
219 (goto-char (point-min)) 219 (goto-char (point-min))
220 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t) 220 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
221 (narrow-to-region (match-beginning 0) (match-end 0)) 221 (narrow-to-region (match-beginning 0) (match-end 0))
222 (vc-cvs-parse-status) 222 (vc-cvs-parse-status)
223 (goto-char (point-max)) 223 (goto-char (point-max))
224 (widen))))))) 224 (widen)))))))
225 225
226(defun vc-cvs-workfile-version (file) 226(defun vc-cvs-workfile-version (file)
227 "CVS-specific version of `vc-workfile-version'." 227 "CVS-specific version of `vc-workfile-version'."
@@ -292,19 +292,19 @@ COMMENT can be used to provide an initial description of FILE.
292 292
293`vc-register-switches' and `vc-cvs-register-switches' are passed to 293`vc-register-switches' and `vc-cvs-register-switches' are passed to
294the CVS command (in that order)." 294the CVS command (in that order)."
295 (let ((switches (append 295 (let ((switches (append
296 (if (stringp vc-register-switches) 296 (if (stringp vc-register-switches)
297 (list vc-register-switches) 297 (list vc-register-switches)
298 vc-register-switches) 298 vc-register-switches)
299 (if (stringp vc-cvs-register-switches) 299 (if (stringp vc-cvs-register-switches)
300 (list vc-cvs-register-switches) 300 (list vc-cvs-register-switches)
301 vc-cvs-register-switches)))) 301 vc-cvs-register-switches))))
302 302
303 (apply 'vc-cvs-command nil 0 file 303 (apply 'vc-cvs-command nil 0 file
304 "add" 304 "add"
305 (and comment (string-match "[^\t\n ]" comment) 305 (and comment (string-match "[^\t\n ]" comment)
306 (concat "-m" comment)) 306 (concat "-m" comment))
307 switches))) 307 switches)))
308 308
309(defun vc-cvs-responsible-p (file) 309(defun vc-cvs-responsible-p (file)
310 "Return non-nil if CVS thinks it is responsible for FILE." 310 "Return non-nil if CVS thinks it is responsible for FILE."
@@ -313,10 +313,9 @@ the CVS command (in that order)."
313 file 313 file
314 (file-name-directory file))))) 314 (file-name-directory file)))))
315 315
316(defun vc-cvs-could-register (file) 316(defalias 'vc-cvs-could-register 'vc-cvs-responsible-p
317 "Return non-nil if FILE could be registered in CVS. 317 "Return non-nil if FILE could be registered in CVS.
318This is only possible if CVS is responsible for FILE's directory." 318This is only possible if CVS is responsible for FILE's directory.")
319 (vc-cvs-responsible-p file))
320 319
321(defun vc-cvs-checkin (file rev comment) 320(defun vc-cvs-checkin (file rev comment)
322 "CVS-specific version of `vc-backend-checkin'." 321 "CVS-specific version of `vc-backend-checkin'."
@@ -484,8 +483,7 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
484 (concat "-j" first-version) 483 (concat "-j" first-version)
485 (concat "-j" second-version)) 484 (concat "-j" second-version))
486 (vc-file-setprop file 'vc-state 'edited) 485 (vc-file-setprop file 'vc-state 'edited)
487 (save-excursion 486 (with-current-buffer (get-buffer "*vc*")
488 (set-buffer (get-buffer "*vc*"))
489 (goto-char (point-min)) 487 (goto-char (point-min))
490 (if (re-search-forward "conflicts during merge" nil t) 488 (if (re-search-forward "conflicts during merge" nil t)
491 1 ; signal error 489 1 ; signal error
@@ -494,19 +492,16 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
494(defun vc-cvs-merge-news (file) 492(defun vc-cvs-merge-news (file)
495 "Merge in any new changes made to FILE." 493 "Merge in any new changes made to FILE."
496 (message "Merging changes into %s..." file) 494 (message "Merging changes into %s..." file)
497 (save-excursion 495 ;; (vc-file-setprop file 'vc-workfile-version nil)
498 ;; (vc-file-setprop file 'vc-workfile-version nil) 496 (vc-file-setprop file 'vc-checkout-time 0)
499 (vc-file-setprop file 'vc-checkout-time 0) 497 (vc-cvs-command nil 0 file "update")
500 (vc-cvs-command nil 0 file "update") 498 ;; Analyze the merge result reported by CVS, and set
501 ;; Analyze the merge result reported by CVS, and set 499 ;; file properties accordingly.
502 ;; file properties accordingly. 500 (with-current-buffer (get-buffer "*vc*")
503 (set-buffer (get-buffer "*vc*"))
504 (goto-char (point-min)) 501 (goto-char (point-min))
505 ;; get new workfile version 502 ;; get new workfile version
506 (if (re-search-forward (concat "^Merging differences between " 503 (if (re-search-forward
507 "[01234567890.]* and " 504 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t)
508 "\\([01234567890.]*\\) into")
509 nil t)
510 (vc-file-setprop file 'vc-workfile-version (match-string 1)) 505 (vc-file-setprop file 'vc-workfile-version (match-string 1))
511 (vc-file-setprop file 'vc-workfile-version nil)) 506 (vc-file-setprop file 'vc-workfile-version nil))
512 ;; get file status 507 ;; get file status
@@ -554,7 +549,7 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
554 549
555(defun vc-cvs-diff (file &optional oldvers newvers) 550(defun vc-cvs-diff (file &optional oldvers newvers)
556 "Get a difference report using CVS between two versions of FILE." 551 "Get a difference report using CVS between two versions of FILE."
557 (let (options status (diff-switches-list (vc-diff-switches-list 'CVS))) 552 (let (status (diff-switches-list (vc-diff-switches-list 'CVS)))
558 (if (string= (vc-workfile-version file) "0") 553 (if (string= (vc-workfile-version file) "0")
559 ;; This file is added but not yet committed; there is no master file. 554 ;; This file is added but not yet committed; there is no master file.
560 (if (or oldvers newvers) 555 (if (or oldvers newvers)
@@ -694,9 +689,8 @@ If UPDATE is non-nil, then update (resynch) any affected buffers."
694;;; Miscellaneous 689;;; Miscellaneous
695;;; 690;;;
696 691
697(defun vc-cvs-make-version-backups-p (file) 692(defalias 'vc-cvs-make-version-backups-p 'vc-cvs-stay-local-p
698 "Return non-nil if version backups should be made for FILE." 693 "Return non-nil if version backups should be made for FILE.")
699 (vc-cvs-stay-local-p file))
700 694
701(defun vc-cvs-check-headers () 695(defun vc-cvs-check-headers ()
702 "Check if the current file has any headers in it." 696 "Check if the current file has any headers in it."
@@ -891,18 +885,19 @@ is non-nil."
891 (vc-file-setprop file 'vc-cvs-sticky-tag 885 (vc-file-setprop file 'vc-cvs-sticky-tag
892 (vc-cvs-parse-sticky-tag (match-string 4) (match-string 5))) 886 (vc-cvs-parse-sticky-tag (match-string 4) (match-string 5)))
893 ;; compare checkout time and modification time 887 ;; compare checkout time and modification time
894 (let ((mtime (nth 5 (file-attributes file)))) 888 (let* ((mtime (nth 5 (file-attributes file)))
895 (require 'parse-time) 889 (system-time-locale "C")
896 (let ((parsed-time 890 (mtstr (format-time-string "%c" mtime 'utc)))
897 (parse-time-string (concat (match-string 2) " +0000")))) 891 ;; Solaris sometimes uses "Wed Sep 05" instead of "Wed Sep 5".
898 (cond ((and (not (string-match "\\+" (match-string 2))) 892 ;; See "grep '[^a-z_]ctime' cvs/src/*.c" for reference.
899 (car parsed-time) 893 (if (= (aref mtstr 8) ?0)
900 (equal mtime (apply 'encode-time parsed-time))) 894 (setq mtstr (concat (substring mtstr 0 8) " " (substring mtstr 9))))
901 (vc-file-setprop file 'vc-checkout-time mtime) 895 (cond ((equal mtstr (match-string 2))
902 (if set-state (vc-file-setprop file 'vc-state 'up-to-date))) 896 (vc-file-setprop file 'vc-checkout-time mtime)
903 (t 897 (if set-state (vc-file-setprop file 'vc-state 'up-to-date)))
904 (vc-file-setprop file 'vc-checkout-time 0) 898 (t
905 (if set-state (vc-file-setprop file 'vc-state 'edited))))))))) 899 (vc-file-setprop file 'vc-checkout-time 0)
900 (if set-state (vc-file-setprop file 'vc-state 'edited))))))))
906 901
907(provide 'vc-cvs) 902(provide 'vc-cvs)
908 903