Function: vc-hg-state-fast
vc-hg-state-fast is a byte-compiled function defined in vc-hg.el.gz.
Signature
(vc-hg-state-fast FILENAME)
Documentation
Like vc-hg-state, but parse internal data structures directly.
Returns one of the usual vc-state enumeration values or
unsupported if we need to take the slow path and run the
hg binary.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc-hg.el.gz
(defun vc-hg-state-fast (filename)
"Like `vc-hg-state', but parse internal data structures directly.
Returns one of the usual `vc-state' enumeration values or
`unsupported' if we need to take the slow path and run the
hg binary."
(let* (truename
repo
dirstate
dirstate-attr
repo-relative-filename)
(if (or
;; Explicit user disable
(not vc-hg-parse-hg-data-structures)
;; It'll probably be faster to run hg remotely
(file-remote-p filename)
(progn
(setf truename (file-truename filename))
(file-remote-p truename))
(not (setf repo (vc-hg-root truename)))
;; dirstate must exist
(not (progn
(setf repo (expand-file-name repo))
(cl-assert (and (file-name-absolute-p repo)
(directory-name-p repo)))
(setf dirstate (concat repo ".hg/dirstate"))
(setf dirstate-attr (file-attributes dirstate))))
;; Repository must be in an understood format
(not (vc-hg--requirements-understood-p repo))
;; Dirstate too small to be valid
(< (file-attribute-size dirstate-attr) 40)
(progn
(setf repo-relative-filename
(file-relative-name truename repo))
;; We only try dealing with ASCII filenames
(string-match-p "[^[:ascii:]]" repo-relative-filename)))
'unsupported
(let* ((dirstate-entry
(vc-hg--cached-dirstate-search
dirstate dirstate-attr repo-relative-filename))
(state (car dirstate-entry))
(stat (file-attributes
(concat repo repo-relative-filename))))
(cond ((eq state ?r) 'removed)
((and (not state) stat)
(condition-case nil
(if (vc-hg--file-ignored-p repo repo-relative-filename)
'ignored
'unregistered)
(vc-hg-unsupported-syntax 'unsupported)))
((and state (not stat)) 'missing)
((eq state ?n)
(let ((vc-hg-size (nth 2 dirstate-entry))
(vc-hg-mtime (nth 3 dirstate-entry))
(fs-size (file-attribute-size stat))
(fs-mtime (time-convert
(file-attribute-modification-time stat)
'integer)))
(if (and (eql vc-hg-size fs-size) (eql vc-hg-mtime fs-mtime))
'up-to-date
'edited)))
((eq state ?a) 'added)
(state 'unsupported))))))