Function: vc-cvs-parse-entry

vc-cvs-parse-entry is a byte-compiled function defined in vc-cvs.el.gz.

Signature

(vc-cvs-parse-entry FILE &optional SET-STATE)

Documentation

Parse a line from CVS/Entries.

Compare modification time to that of the FILE, set file properties accordingly. However, vc-state is set only if optional arg SET-STATE is non-nil.

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-cvs.el.gz
(defun vc-cvs-parse-entry (file &optional set-state)
  "Parse a line from CVS/Entries.
Compare modification time to that of the FILE, set file properties
accordingly.  However, `vc-state' is set only if optional arg SET-STATE
is non-nil."
  (cond
   ;; entry for a "locally added" file (not yet committed)
   ((looking-at "/[^/]+/0/")
    (vc-file-setprop file 'vc-checkout-time 0)
    (vc-file-setprop file 'vc-working-revision "0")
    (if set-state (vc-file-setprop file 'vc-state 'added)))
   ;; normal entry
   ((looking-at
     (concat "/[^/]+"
	     ;; revision
	     "/\\([^/]*\\)"
	     ;; timestamp and optional conflict field
	     "/\\([^/]*\\)/"
	     ;; options
	     "\\([^/]*\\)/"
	     ;; sticky tag
	     "\\(.\\|\\)" ;Sticky tag type (date or tag name, could be empty)
	     "\\(.*\\)"))		;Sticky tag
    (vc-file-setprop file 'vc-working-revision (match-string 1))
    (vc-file-setprop file 'vc-cvs-sticky-tag
		     (vc-cvs-parse-sticky-tag (match-string 4)
                                              (match-string 5)))
    ;; Compare checkout time and modification time.
    ;; This is intentionally different from the algorithm that CVS uses
    ;; (which is based on textual comparison), because there can be problems
    ;; generating a time string that looks exactly like the one from CVS.
    (let* ((time (match-string 2))
           (mtime (file-attribute-modification-time (file-attributes file)))
           (parsed-time (progn (require 'parse-time)
                               (parse-time-string (concat time " +0000")))))
      (cond ((and (not (string-search "+" time))
                  (decoded-time-second parsed-time)
                  ;; Compare just the seconds part of the file time,
                  ;; since CVS file time stamp resolution is just 1 second.
		  (= (time-convert mtime 'integer)
		     (time-convert (encode-time parsed-time) 'integer)))
             (vc-file-setprop file 'vc-checkout-time mtime)
             (if set-state (vc-file-setprop file 'vc-state 'up-to-date)))
            (t
             (vc-file-setprop file 'vc-checkout-time 0)
             (if set-state (vc-file-setprop file 'vc-state 'edited))))))))