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-output-to-string
           (vc-hg-command standard-output 0 nil "log"
                          "-r" (format "revset(%s~1)" rev)
                          "--template" (if vc-use-short-revision
                                           "{node|short}" "{node}"))))))