Function: vc-hg-after-dir-status

vc-hg-after-dir-status is a byte-compiled function defined in vc-hg.el.gz.

Signature

(vc-hg-after-dir-status UPDATE-FUNCTION)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-hg.el.gz
(defun vc-hg-after-dir-status (update-function)
  (let ((translation '((?= . up-to-date)
                       (?C . up-to-date)
                       (?A . added)
                       (?R . removed)
                       (?M . edited)
                       (?I . ignored)
                       (?! . missing)
                       (?  . copy-rename-line)
                       (?? . unregistered)))
        (copies (make-hash-table :test #'equal))
        result)
    (goto-char (point-min))
    (while (not (eobp))
      (let ((translated (cdr (assq (char-after) translation)))
            (file (buffer-substring-no-properties (+ (point) 2)
                                                  (line-end-position))))
        (pcase translated
          ;; For copied files the output looks like this:
          ;;     A COPIED_FILE_NAME
          ;;       ORIGINAL_FILE_NAME
          ;; For renamed files the output looks like this:
          ;;     A NEW_FILE_NAME
          ;;       ORIGINAL_FILE_NAME
          ;;     R ORIGINAL_FILE_NAME
          ;; but the last line can come arbitrarily later in the output.
          ;; So we have to remember the entry for the copy in RESULT to
          ;; potentially modify later.
          ('copy-rename-line
           (let ((last (car result)))
             (setf (caddr last)
                   (vc-hg-create-extra-fileinfo 'copied file))
             (puthash file last copies)))
          ((and 'removed
                (let (and last (guard last)) (gethash file copies)))
           (setf (vc-hg-extra-fileinfo->rename-state (caddr last))
                 'renamed-from)
           (push (list file translated
                       (vc-hg-create-extra-fileinfo 'renamed-to (car last)))
                 result))
          (_ (push (list file translated nil) result))))
      (forward-line))
    (funcall update-function result)))