@@ -489,7 +489,8 @@ It can be a relative expression as well, such as \"HEAD^\" with Git, or
489489 ((eq state 'removed )
490490 `((:working . ,`((1 0 ,(line-number-at-pos (point-max )) delete))))))))))
491491
492- (defvar diff-hl-head-revision-alist '((Git . " HEAD" ) (Bzr . " last:1" ) (Hg . " ." )))
492+ (defvar diff-hl-head-revision-alist '((Git . " HEAD" ) (Bzr . " last:1" ) (Hg . " ." )
493+ (JJ . " @-" )))
493494
494495(defun diff-hl-head-revision (backend )
495496 (or (assoc-default backend diff-hl-head-revision-alist)
@@ -1451,51 +1452,44 @@ CONTEXT-LINES is the size of the unified diff context, defaults to 0."
14511452 (diff-hl-git-index-object-name file))
14521453 (diff-hl-create-revision
14531454 file
1454- (or (diff-hl-resolved-reference-revision backend)
1455- (diff-hl-working-revision file backend)))))
1455+ (or (diff-hl-resolved-revision
1456+ backend
1457+ (or diff-hl-reference-revision
1458+ (assoc-default backend diff-hl-head-revision-alist)))
1459+ (diff-hl-working-revision buffer-file-name backend)))))
14561460 (switches (format " -U %d --strip-trailing-cr " (or context-lines 0 ))))
14571461 (diff-no-select rev (current-buffer ) switches (not (diff-hl--use-async-p))
14581462 (get-buffer-create dest-buffer))
14591463 ; ; Function `diff-sentinel' adds a summary line, but that seems fine.
14601464 ; ; In all commands which use exact text we call it synchronously.
14611465 (get-buffer-create dest-buffer))))
14621466
1463- (defun diff-hl-resolved-reference-revision (backend )
1467+ (declare-function vc-jj--process-lines " vc-jj" )
1468+
1469+ (defun diff-hl-resolved-revision (backend revision )
14641470 (cond
1465- ((null diff-hl-reference-revision)
1466- nil )
14671471 ((eq backend 'Git )
1468- (vc-git--rev-parse diff-hl-reference- revision))
1472+ (vc-git--rev-parse revision))
14691473 ((eq backend 'Hg )
1470- ; ; Preserve the potentially buffer-local variables (e.g.,
1471- ; ; `diff-hl-reference-revision`, `vc-hg-program`) by not switching buffer
1472- ; ; until the vc-hg-command is done.
1473- (let ((temp-buffer (generate-new-buffer " *temp*" )))
1474- (unwind-protect
1475- (progn
1476- (vc-hg-command temp-buffer 0 nil
1477- " identify" " -r" diff-hl-reference-revision " -i" )
1478- (with-current-buffer temp-buffer
1479- (goto-char (point-min ))
1480- (buffer-substring-no-properties (point ) (line-end-position ))))
1481- (kill-buffer temp-buffer))))
1474+ (with-temp-buffer
1475+ (vc-hg-command (current-buffer ) 0 nil
1476+ " identify" " -r" revision " -i" )
1477+ (goto-char (point-min ))
1478+ (buffer-substring-no-properties (point ) (line-end-position ))))
14821479 ((eq backend 'Bzr )
1483- ; ; Preserve the potentially buffer-local variables (e.g.,
1484- ; ; `diff-hl-reference-revision`, `vc-bzr-program`) by not switching buffer
1485- ; ; until the vc-bzr-command is done.
1486- (let ((temp-buffer (generate-new-buffer " *temp*" )))
1487- (unwind-protect
1488- (progn
1489- (vc-bzr-command temp-buffer 0 nil
1490- " log" " --log-format=template"
1491- " --template-str='{revno}'"
1492- " -r" diff-hl-reference-revision)
1493- (with-current-buffer temp-buffer
1494- (goto-char (point-min ))
1495- (buffer-substring-no-properties (point ) (line-end-position ))))
1496- (kill-buffer temp-buffer))))
1497- (t
1498- diff-hl-reference-revision)))
1480+ (with-temp-buffer
1481+ (vc-bzr-command (current-buffer ) 0 nil
1482+ " log" " --log-format=template"
1483+ " --template-str='{revno}'"
1484+ " -r" revision)
1485+ (goto-char (point-min ))
1486+ (buffer-substring-no-properties (point ) (line-end-position ))))
1487+ ((eq backend 'JJ )
1488+ (car (last (vc-jj--process-lines " log" " --no-graph"
1489+ " -r" revision
1490+ " -T" " change_id" " -n" " 1" ))))
1491+ (t
1492+ revision)))
14991493
15001494; ; TODO: Cache based on .git/index's mtime, maybe.
15011495(defun diff-hl-git-index-object-name (file )
0 commit comments