@@ -1442,21 +1442,35 @@ CONTEXT-LINES is the size of the unified diff context, defaults to 0."
14421442 ((eq backend 'Git )
14431443 (vc-git--rev-parse diff-hl-reference-revision))
14441444 ((eq backend 'Hg )
1445- (with-temp-buffer
1446- (vc-hg-command (current-buffer ) 0 nil
1447- " identify" " -r" diff-hl-reference-revision
1448- " -i" )
1449- (goto-char (point-min ))
1450- (buffer-substring-no-properties (point ) (line-end-position ))))
1445+ ; ; Preserve the potentially buffer-local variables (e.g.,
1446+ ; ; `diff-hl-reference-revision`, `vc-hg-program`) by not switching buffer
1447+ ; ; until the vc-hg-command is done.
1448+ (let ((temp-buffer (generate-new-buffer " *temp*" )))
1449+ (unwind-protect
1450+ (progn
1451+ (vc-hg-command temp-buffer 0 nil
1452+ " identify" " -r" diff-hl-reference-revision " -i" )
1453+ (with-current-buffer temp-buffer
1454+ (goto-char (point-min ))
1455+ (buffer-substring-no-properties (point ) (line-end-position ))))
1456+ (kill-buffer temp-buffer))))
14511457 ((eq backend 'Bzr )
1452- (with-temp-buffer
1453- (vc-bzr-command (current-buffer ) 0 nil
1454- " log" " --log-format=template" " --template-str='{revno}'"
1455- " -r" diff-hl-reference-revision)
1456- (goto-char (point-min ))
1457- (buffer-substring-no-properties (point ) (line-end-position ))))
1458- (t
1459- diff-hl-reference-revision)))
1458+ ; ; Preserve the potentially buffer-local variables (e.g.,
1459+ ; ; `diff-hl-reference-revision`, `vc-bzr-program`) by not switching buffer
1460+ ; ; until the vc-bzr-command is done.
1461+ (let ((temp-buffer (generate-new-buffer " *temp*" )))
1462+ (unwind-protect
1463+ (progn
1464+ (vc-bzr-command temp-buffer 0 nil
1465+ " log" " --log-format=template"
1466+ " --template-str='{revno}'"
1467+ " -r" diff-hl-reference-revision)
1468+ (with-current-buffer temp-buffer
1469+ (goto-char (point-min ))
1470+ (buffer-substring-no-properties (point ) (line-end-position ))))
1471+ (kill-buffer temp-buffer))))
1472+ (t
1473+ diff-hl-reference-revision)))
14601474
14611475; ; TODO: Cache based on .git/index's mtime, maybe.
14621476(defun diff-hl-git-index-object-name (file )
0 commit comments