comparison lisp/vc-cvs.el @ 85139:8ba0e30716a5

Terminology cleanup.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Wed, 10 Oct 2007 18:52:45 +0000
parents 52ca2a6a41bf
children 119299b8a040 d38543a1c0f9
comparison
equal deleted inserted replaced
85138:9eb84ff59d9b 85139:8ba0e30716a5
227 (narrow-to-region (match-beginning 0) (match-end 0)) 227 (narrow-to-region (match-beginning 0) (match-end 0))
228 (vc-cvs-parse-status) 228 (vc-cvs-parse-status)
229 (goto-char (point-max)) 229 (goto-char (point-max))
230 (widen))))))) 230 (widen)))))))
231 231
232 (defun vc-cvs-workfile-version (file) 232 (defun vc-cvs-working-revision (file)
233 "CVS-specific version of `vc-workfile-version'." 233 "CVS-specific version of `vc-working-revision'."
234 ;; There is no need to consult RCS headers under CVS, because we 234 ;; There is no need to consult RCS headers under CVS, because we
235 ;; get the workfile version for free when we recognize that a file 235 ;; get the workfile version for free when we recognize that a file
236 ;; is registered in CVS. 236 ;; is registered in CVS.
237 (vc-cvs-registered file) 237 (vc-cvs-registered file)
238 (vc-file-getprop file 'vc-workfile-version)) 238 (vc-file-getprop file 'vc-working-revision))
239 239
240 (defun vc-cvs-checkout-model (file) 240 (defun vc-cvs-checkout-model (file)
241 "CVS-specific version of `vc-checkout-model'." 241 "CVS-specific version of `vc-checkout-model'."
242 (if (getenv "CVSREAD") 242 (if (getenv "CVSREAD")
243 'announce 243 'announce
259 Handle the special case of a CVS file that is added but not yet 259 Handle the special case of a CVS file that is added but not yet
260 committed and support display of sticky tags." 260 committed and support display of sticky tags."
261 (let* ((sticky-tag (vc-file-getprop file 'vc-cvs-sticky-tag)) 261 (let* ((sticky-tag (vc-file-getprop file 'vc-cvs-sticky-tag))
262 help-echo 262 help-echo
263 (string 263 (string
264 (if (string= (vc-workfile-version file) "0") 264 (if (string= (vc-working-revision file) "0")
265 ;; A file that is added but not yet committed. 265 ;; A file that is added but not yet committed.
266 (progn 266 (progn
267 (setq help-echo "Added file (needs commit) under CVS") 267 (setq help-echo "Added file (needs commit) under CVS")
268 "CVS @@") 268 "CVS @@")
269 (let ((def-ml (vc-default-mode-line-string 'CVS file))) 269 (let ((def-ml (vc-default-mode-line-string 'CVS file)))
280 280
281 (defun vc-cvs-dired-state-info (file) 281 (defun vc-cvs-dired-state-info (file)
282 "CVS-specific version of `vc-dired-state-info'." 282 "CVS-specific version of `vc-dired-state-info'."
283 (let ((cvs-state (vc-state file))) 283 (let ((cvs-state (vc-state file)))
284 (cond ((eq cvs-state 'edited) 284 (cond ((eq cvs-state 'edited)
285 (if (equal (vc-workfile-version file) "0") 285 (if (equal (vc-working-revision file) "0")
286 "(added)" "(modified)")) 286 "(added)" "(modified)"))
287 ((eq cvs-state 'needs-patch) "(patch)") 287 ((eq cvs-state 'needs-patch) "(patch)")
288 ((eq cvs-state 'needs-merge) "(merge)")))) 288 ((eq cvs-state 'needs-merge) "(merge)"))))
289 289
290 290
328 t (directory-file-name dir)))) 328 t (directory-file-name dir))))
329 (eq dir t))) 329 (eq dir t)))
330 330
331 (defun vc-cvs-checkin (files rev comment) 331 (defun vc-cvs-checkin (files rev comment)
332 "CVS-specific version of `vc-backend-checkin'." 332 "CVS-specific version of `vc-backend-checkin'."
333 (unless (or (not rev) (vc-cvs-valid-version-number-p rev)) 333 (unless (or (not rev) (vc-cvs-valid-revision-number-p rev))
334 (if (not (vc-cvs-valid-symbolic-tag-name-p rev)) 334 (if (not (vc-cvs-valid-symbolic-tag-name-p rev))
335 (error "%s is not a valid symbolic tag name" rev) 335 (error "%s is not a valid symbolic tag name" rev)
336 ;; If the input revison is a valid symbolic tag name, we create it 336 ;; If the input revison is a valid symbolic tag name, we create it
337 ;; as a branch, commit and switch to it. 337 ;; as a branch, commit and switch to it.
338 (apply 'vc-cvs-command nil 0 files "tag" "-b" (list rev)) 338 (apply 'vc-cvs-command nil 0 files "tag" "-b" (list rev))
357 (t 357 (t
358 (pop-to-buffer (current-buffer)) 358 (pop-to-buffer (current-buffer))
359 (goto-char (point-min)) 359 (goto-char (point-min))
360 (shrink-window-if-larger-than-buffer) 360 (shrink-window-if-larger-than-buffer)
361 (error "Check-in failed")))) 361 (error "Check-in failed"))))
362 ;; Single-file commit? Then update the version by parsing the buffer. 362 ;; Single-file commit? Then update the revision by parsing the buffer.
363 ;; Otherwise we can't necessarily tell what goes with what; clear 363 ;; Otherwise we can't necessarily tell what goes with what; clear
364 ;; its properties so they have to be refetched. 364 ;; its properties so they have to be refetched.
365 (if (= (length files) 1) 365 (if (= (length files) 1)
366 (vc-file-setprop 366 (vc-file-setprop
367 (car files) 'vc-workfile-version 367 (car files) 'vc-working-revision
368 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2)) 368 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
369 (mapc (lambda (file) (vc-file-clearprops file)) files)) 369 (mapc (lambda (file) (vc-file-clearprops file)) files))
370 ;; Anyway, forget the checkout model of the file, because we might have 370 ;; Anyway, forget the checkout model of the file, because we might have
371 ;; guessed wrong when we found the file. After commit, we can 371 ;; guessed wrong when we found the file. After commit, we can
372 ;; tell it from the permissions of the file (see 372 ;; tell it from the permissions of the file (see
377 ;; if this was an explicit check-in (does not include creation of 377 ;; if this was an explicit check-in (does not include creation of
378 ;; a branch), remove the sticky tag. 378 ;; a branch), remove the sticky tag.
379 (if (and rev (not (vc-cvs-valid-symbolic-tag-name-p rev))) 379 (if (and rev (not (vc-cvs-valid-symbolic-tag-name-p rev)))
380 (vc-cvs-command nil 0 files "update" "-A")))) 380 (vc-cvs-command nil 0 files "update" "-A"))))
381 381
382 (defun vc-cvs-find-version (file rev buffer) 382 (defun vc-cvs-find-revision (file rev buffer)
383 (apply 'vc-cvs-command 383 (apply 'vc-cvs-command
384 buffer 0 file 384 buffer 0 file
385 "-Q" ; suppress diagnostic output 385 "-Q" ; suppress diagnostic output
386 "update" 386 "update"
387 (and rev (not (string= rev "")) 387 (and rev (not (string= rev ""))
402 (and editable (not (eq (vc-cvs-checkout-model file) 'implicit)) 402 (and editable (not (eq (vc-cvs-checkout-model file) 'implicit))
403 (if vc-cvs-use-edit 403 (if vc-cvs-use-edit
404 (vc-cvs-command nil 0 file "edit") 404 (vc-cvs-command nil 0 file "edit")
405 (set-file-modes file (logior (file-modes file) 128)) 405 (set-file-modes file (logior (file-modes file) 128))
406 (if (equal file buffer-file-name) (toggle-read-only -1)))) 406 (if (equal file buffer-file-name) (toggle-read-only -1))))
407 ;; Check out a particular version (or recreate the file). 407 ;; Check out a particular revision (or recreate the file).
408 (vc-file-setprop file 'vc-workfile-version nil) 408 (vc-file-setprop file 'vc-working-revision nil)
409 (apply 'vc-cvs-command nil 0 file 409 (apply 'vc-cvs-command nil 0 file
410 (and editable "-w") 410 (and editable "-w")
411 "update" 411 "update"
412 (when rev 412 (when rev
413 (unless (eq rev t) 413 (unless (eq rev t)
424 (defun vc-cvs-delete-file (file) 424 (defun vc-cvs-delete-file (file)
425 (vc-cvs-command nil 0 file "remove" "-f") 425 (vc-cvs-command nil 0 file "remove" "-f")
426 (vc-cvs-command nil 0 file "commit" "-mRemoved.")) 426 (vc-cvs-command nil 0 file "commit" "-mRemoved."))
427 427
428 (defun vc-cvs-revert (file &optional contents-done) 428 (defun vc-cvs-revert (file &optional contents-done)
429 "Revert FILE to the version on which it was based." 429 "Revert FILE to the working revision on which it was based."
430 (vc-default-revert 'CVS file contents-done) 430 (vc-default-revert 'CVS file contents-done)
431 (unless (eq (vc-checkout-model file) 'implicit) 431 (unless (eq (vc-checkout-model file) 'implicit)
432 (if vc-cvs-use-edit 432 (if vc-cvs-use-edit
433 (vc-cvs-command nil 0 file "unedit") 433 (vc-cvs-command nil 0 file "unedit")
434 ;; Make the file read-only by switching off all w-bits 434 ;; Make the file read-only by switching off all w-bits
435 (set-file-modes file (logand (file-modes file) 3950))))) 435 (set-file-modes file (logand (file-modes file) 3950)))))
436 436
437 (defun vc-cvs-merge (file first-version &optional second-version) 437 (defun vc-cvs-merge (file first-revision &optional second-revision)
438 "Merge changes into current working copy of FILE. 438 "Merge changes into current working copy of FILE.
439 The changes are between FIRST-VERSION and SECOND-VERSION." 439 The changes are between FIRST-REVISION and SECOND-REVISION."
440 (vc-cvs-command nil 0 file 440 (vc-cvs-command nil 0 file
441 "update" "-kk" 441 "update" "-kk"
442 (concat "-j" first-version) 442 (concat "-j" first-revision)
443 (concat "-j" second-version)) 443 (concat "-j" second-revision))
444 (vc-file-setprop file 'vc-state 'edited) 444 (vc-file-setprop file 'vc-state 'edited)
445 (with-current-buffer (get-buffer "*vc*") 445 (with-current-buffer (get-buffer "*vc*")
446 (goto-char (point-min)) 446 (goto-char (point-min))
447 (if (re-search-forward "conflicts during merge" nil t) 447 (if (re-search-forward "conflicts during merge" nil t)
448 1 ; signal error 448 1 ; signal error
449 0))) ; signal success 449 0))) ; signal success
450 450
451 (defun vc-cvs-merge-news (file) 451 (defun vc-cvs-merge-news (file)
452 "Merge in any new changes made to FILE." 452 "Merge in any new changes made to FILE."
453 (message "Merging changes into %s..." file) 453 (message "Merging changes into %s..." file)
454 ;; (vc-file-setprop file 'vc-workfile-version nil) 454 ;; (vc-file-setprop file 'vc-working-revision nil)
455 (vc-file-setprop file 'vc-checkout-time 0) 455 (vc-file-setprop file 'vc-checkout-time 0)
456 (vc-cvs-command nil 0 file "update") 456 (vc-cvs-command nil 0 file "update")
457 ;; Analyze the merge result reported by CVS, and set 457 ;; Analyze the merge result reported by CVS, and set
458 ;; file properties accordingly. 458 ;; file properties accordingly.
459 (with-current-buffer (get-buffer "*vc*") 459 (with-current-buffer (get-buffer "*vc*")
460 (goto-char (point-min)) 460 (goto-char (point-min))
461 ;; get new workfile version 461 ;; get new working revision
462 (if (re-search-forward 462 (if (re-search-forward
463 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t) 463 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t)
464 (vc-file-setprop file 'vc-workfile-version (match-string 1)) 464 (vc-file-setprop file 'vc-working-revision (match-string 1))
465 (vc-file-setprop file 'vc-workfile-version nil)) 465 (vc-file-setprop file 'vc-working-revision nil))
466 ;; get file status 466 ;; get file status
467 (prog1 467 (prog1
468 (if (eq (buffer-size) 0) 468 (if (eq (buffer-size) 0)
469 0 ;; there were no news; indicate success 469 0 ;; there were no news; indicate success
470 (if (re-search-forward 470 (if (re-search-forward
510 "Remove all non-comment information from log output." 510 "Remove all non-comment information from log output."
511 (vc-call-backend 'RCS 'wash-log) 511 (vc-call-backend 'RCS 'wash-log)
512 nil) 512 nil)
513 513
514 (defun vc-cvs-diff (files &optional oldvers newvers buffer) 514 (defun vc-cvs-diff (files &optional oldvers newvers buffer)
515 "Get a difference report using CVS between two versions of FILE." 515 "Get a difference report using CVS between two revisions of FILE."
516 (let* ((async (and (not vc-disable-async-diff) 516 (let* ((async (and (not vc-disable-async-diff)
517 (vc-stay-local-p files) 517 (vc-stay-local-p files)
518 (fboundp 'start-process))) 518 (fboundp 'start-process)))
519 (status (apply 'vc-cvs-command (or buffer "*vc-diff*") 519 (status (apply 'vc-cvs-command (or buffer "*vc-diff*")
520 (if async 'async 1) 520 (if async 'async 1)
557 (process-put process 'output string) 557 (process-put process 'output string)
558 (let ((vc-filter (process-get process 'vc-filter))) 558 (let ((vc-filter (process-get process 'vc-filter)))
559 (set-process-filter process vc-filter) 559 (set-process-filter process vc-filter)
560 (funcall vc-filter process (substring string (match-beginning 0)))))) 560 (funcall vc-filter process (substring string (match-beginning 0))))))
561 561
562 (defun vc-cvs-annotate-command (file buffer &optional version) 562 (defun vc-cvs-annotate-command (file buffer &optional revision)
563 "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER. 563 "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER.
564 Optional arg VERSION is a version to annotate from." 564 Optional arg REVISION is a revision to annotate from."
565 (vc-cvs-command buffer 565 (vc-cvs-command buffer
566 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 566 (if (and (vc-stay-local-p file) (fboundp 'start-process))
567 'async 0) 567 'async 0)
568 file "annotate" 568 file "annotate"
569 (if version (concat "-r" version))) 569 (if revision (concat "-r" revision)))
570 ;; Strip the leading few lines. 570 ;; Strip the leading few lines.
571 (let ((proc (get-buffer-process buffer))) 571 (let ((proc (get-buffer-process buffer)))
572 (if proc 572 (if proc
573 ;; If running asynchronously, use a process filter. 573 ;; If running asynchronously, use a process filter.
574 (progn 574 (progn
631 ;;; 631 ;;;
632 ;;; Snapshot system 632 ;;; Snapshot system
633 ;;; 633 ;;;
634 634
635 (defun vc-cvs-create-snapshot (dir name branchp) 635 (defun vc-cvs-create-snapshot (dir name branchp)
636 "Assign to DIR's current version a given NAME. 636 "Assign to DIR's current revision a given NAME.
637 If BRANCHP is non-nil, the name is created as a branch (and the current 637 If BRANCHP is non-nil, the name is created as a branch (and the current
638 workspace is immediately moved to that new branch)." 638 workspace is immediately moved to that new branch)."
639 (vc-cvs-command nil 0 dir "tag" "-c" (if branchp "-b") name) 639 (vc-cvs-command nil 0 dir "tag" "-c" (if branchp "-b") name)
640 (when branchp (vc-cvs-command nil 0 dir "update" "-r" name))) 640 (when branchp (vc-cvs-command nil 0 dir "update" "-r" name)))
641 641
661 (when buffer 661 (when buffer
662 (cond 662 (cond
663 ((or (string= state "U") 663 ((or (string= state "U")
664 (string= state "P")) 664 (string= state "P"))
665 (vc-file-setprop file 'vc-state 'up-to-date) 665 (vc-file-setprop file 'vc-state 'up-to-date)
666 (vc-file-setprop file 'vc-workfile-version nil) 666 (vc-file-setprop file 'vc-working-revision nil)
667 (vc-file-setprop file 'vc-checkout-time 667 (vc-file-setprop file 'vc-checkout-time
668 (nth 5 (file-attributes file)))) 668 (nth 5 (file-attributes file))))
669 ((or (string= state "M") 669 ((or (string= state "M")
670 (string= state "C")) 670 (string= state "C"))
671 (vc-file-setprop file 'vc-state 'edited) 671 (vc-file-setprop file 'vc-state 'edited)
672 (vc-file-setprop file 'vc-workfile-version nil) 672 (vc-file-setprop file 'vc-working-revision nil)
673 (vc-file-setprop file 'vc-checkout-time 0))) 673 (vc-file-setprop file 'vc-checkout-time 0)))
674 (vc-file-setprop file 'vc-cvs-sticky-tag sticky-tag) 674 (vc-file-setprop file 'vc-cvs-sticky-tag sticky-tag)
675 (vc-resynch-buffer file t t)))) 675 (vc-resynch-buffer file t t))))
676 (forward-line 1)))))) 676 (forward-line 1))))))
677 677
798 (if (and full 798 (if (and full
799 (re-search-forward 799 (re-search-forward
800 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\ 800 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\
801 \[\t ]+\\([0-9.]+\\)" 801 \[\t ]+\\([0-9.]+\\)"
802 nil t)) 802 nil t))
803 (vc-file-setprop file 'vc-latest-version (match-string 2))) 803 (vc-file-setprop file 'vc-latest-revision (match-string 2)))
804 (vc-file-setprop 804 (vc-file-setprop
805 file 'vc-state 805 file 'vc-state
806 (cond 806 (cond
807 ((string-match "Up-to-date" status) 807 ((string-match "Up-to-date" status)
808 (vc-file-setprop file 'vc-checkout-time 808 (vc-file-setprop file 'vc-checkout-time
841 ;; an uppercase or lowercase letter and can contain uppercase and 841 ;; an uppercase or lowercase letter and can contain uppercase and
842 ;; lowercase letters, digits, `-', and `_'. 842 ;; lowercase letters, digits, `-', and `_'.
843 (and (string-match "^[a-zA-Z]" tag) 843 (and (string-match "^[a-zA-Z]" tag)
844 (not (string-match "[^a-z0-9A-Z-_]" tag)))) 844 (not (string-match "[^a-z0-9A-Z-_]" tag))))
845 845
846 (defun vc-cvs-valid-version-number-p (tag) 846 (defun vc-cvs-valid-revision-number-p (tag)
847 "Return non-nil if TAG is a valid version number." 847 "Return non-nil if TAG is a valid revision number."
848 (and (string-match "^[0-9]" tag) 848 (and (string-match "^[0-9]" tag)
849 (not (string-match "[^0-9.]" tag)))) 849 (not (string-match "[^0-9.]" tag))))
850 850
851 (defun vc-cvs-parse-sticky-tag (match-type match-tag) 851 (defun vc-cvs-parse-sticky-tag (match-type match-tag)
852 "Parse and return the sticky tag as a string. 852 "Parse and return the sticky tag as a string.
906 is non-nil." 906 is non-nil."
907 (cond 907 (cond
908 ;; entry for a "locally added" file (not yet committed) 908 ;; entry for a "locally added" file (not yet committed)
909 ((looking-at "/[^/]+/0/") 909 ((looking-at "/[^/]+/0/")
910 (vc-file-setprop file 'vc-checkout-time 0) 910 (vc-file-setprop file 'vc-checkout-time 0)
911 (vc-file-setprop file 'vc-workfile-version "0") 911 (vc-file-setprop file 'vc-working-revision "0")
912 (if set-state (vc-file-setprop file 'vc-state 'edited))) 912 (if set-state (vc-file-setprop file 'vc-state 'edited)))
913 ;; normal entry 913 ;; normal entry
914 ((looking-at 914 ((looking-at
915 (concat "/[^/]+" 915 (concat "/[^/]+"
916 ;; revision 916 ;; revision
920 ;; options 920 ;; options
921 "\\([^/]*\\)/" 921 "\\([^/]*\\)/"
922 ;; sticky tag 922 ;; sticky tag
923 "\\(.\\|\\)" ;Sticky tag type (date or tag name, could be empty) 923 "\\(.\\|\\)" ;Sticky tag type (date or tag name, could be empty)
924 "\\(.*\\)")) ;Sticky tag 924 "\\(.*\\)")) ;Sticky tag
925 (vc-file-setprop file 'vc-workfile-version (match-string 1)) 925 (vc-file-setprop file 'vc-working-revision (match-string 1))
926 (vc-file-setprop file 'vc-cvs-sticky-tag 926 (vc-file-setprop file 'vc-cvs-sticky-tag
927 (vc-cvs-parse-sticky-tag (match-string 4) 927 (vc-cvs-parse-sticky-tag (match-string 4)
928 (match-string 5))) 928 (match-string 5)))
929 ;; Compare checkout time and modification time. 929 ;; Compare checkout time and modification time.
930 ;; This is intentionally different from the algorithm that CVS uses 930 ;; This is intentionally different from the algorithm that CVS uses