]> code.delx.au - gnu-emacs/commitdiff
Use 'hg id' in vc-hg-previous-revision
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 18 Dec 2015 04:58:49 +0000 (06:58 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Fri, 18 Dec 2015 04:59:03 +0000 (06:59 +0200)
* lisp/vc/vc-hg.el (vc-hg-previous-revision):
Use 'hg id' to retrieve it (bug#22032).

lisp/vc/vc-hg.el

index dd897adc59cc412165889e9650d90be5319b58f5..62fbfde5f871b129bc0353c43d44ac70bc67efe7 100644 (file)
@@ -430,9 +430,13 @@ Optional arg REVISION is a revision to annotate from."
 ;;; Miscellaneous
 
 (defun vc-hg-previous-revision (_file rev)
-  (let ((newrev (1- (string-to-number rev))))
-    (when (>= newrev 0)
-      (number-to-string newrev))))
+  ;; We can't simply decrement by 1, because that revision might be
+  ;; e.g. on a different branch (bug#22032).
+  (with-temp-buffer
+    (and (eq 0
+             (vc-hg-command t nil nil "id" "-n" "-r" (concat rev "^")))
+         ;; Trim the trailing newline.
+         (buffer-substring (point-min) (1- (point-max))))))
 
 (defun vc-hg-next-revision (_file rev)
   (let ((newrev (1+ (string-to-number rev)))