Function: vc--incoming-revision

vc--incoming-revision is a byte-compiled function defined in vc.el.gz.

Signature

(vc--incoming-revision BACKEND &optional UPSTREAM-LOCATION REFRESH)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc--incoming-revision (backend &optional upstream-location refresh)
  ;; Some backends don't support REFRESH and so always behave as though
  ;; REFRESH is non-nil.  This is not just for a lack of implementation
  ;; in Emacs; for example, Mercurial repositories don't store any
  ;; representation of the incoming revision between running commands.
  ;;
  ;; Fetching the incoming revision is often slow, and in many cases the
  ;; last known incoming revision will serve perfectly well.  For
  ;; example, when finding revisions that are outgoing, the last known
  ;; incoming revision is fine except for the rare case in which someone
  ;; else cherry-picks the very same commits that you have outstanding,
  ;; and pushes them.  Given this, we implement our own caching.
  ;;
  ;; Do store `nil', before signaling an error, if there is no incoming
  ;; revision, because that's also something that can be slow to
  ;; determine and so should be remembered.
  (if-let* ((_ (not refresh))
            (record (assoc upstream-location
                           (vc--repo-getprop backend 'vc-incoming-revision))))
      (cdr record)
    (let ((res (vc-call-backend backend 'incoming-revision
                                upstream-location refresh)))
      (if-let* ((alist (vc--repo-getprop backend 'vc-incoming-revision)))
          (setf (alist-get upstream-location alist nil nil #'equal)
                res)
        (vc--repo-setprop backend
                          'vc-incoming-revision
                          `((,upstream-location . ,res))))
      (or res
          (user-error "No incoming revision -- local-only branch?")))))