Function: vc-hg-previous-revision

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

Signature

(vc-hg-previous-revision FILE REV)

Source Code

;; Defined in /usr/src/emacs/lisp/vc/vc-hg.el.gz
;;; Miscellaneous

(defun vc-hg-previous-revision (_file rev)
  ;; Prefer to return values with tildes not carets because that's more
  ;; compatible with MS-Windows (see `vc-git-previous-revision').
  ;;
  ;; See <https://repo.mercurial-scm.org/hg/help/revsets> for reference.
  (cond ((string-match "\\`\\.\\(\\^*\\)\\'" rev)
         (format ".~%d" (1+ (length (match-string 1 rev)))))
        ((string-match "\\`\\.~\\([0-9]+\\)\\'" rev)
         (format ".~%d" (1+ (string-to-number (match-string 1 rev)))))
        (t
         ;; We can't simply decrement by 1, because that revision might
         ;; be e.g. on a different branch (bug#22032).
         (with-temp-buffer
           (and (zerop (vc-hg-command t nil nil "id" "-n"
                                      "-r" (concat rev "~1")))
                ;; Trim the trailing newline.
                (buffer-substring (point-min) (1- (point-max))))))))