summaryrefslogtreecommitdiff
path: root/lisp/vc/vc.el
diff options
context:
space:
mode:
authorPhilip Kaludercic <philipk@posteo.net>2022-10-30 16:52:08 +0100
committerPhilip Kaludercic <philipk@posteo.net>2022-10-30 16:52:08 +0100
commitd33998ed3b5e05a40b9c4c1799b6e911b582ef01 (patch)
treedc9320393da2470c9a22be3e3b0ed675495b1405 /lisp/vc/vc.el
parentbb86ed20e16358b39288010d41d911f732f88372 (diff)
downloademacs-d33998ed3b5e05a40b9c4c1799b6e911b582ef01.tar.gz
Have 'last-change' accept a line number instead of a range
* lisp/emacs-lisp/package-vc.el (package-vc-release-rev): Use new signature. * lisp/vc/vc-git.el (vc-git-last-change): Update signature * lisp/vc/vc.el (vc-default-last-change): Update signature and use 'annotate-command'.
Diffstat (limited to 'lisp/vc/vc.el')
-rw-r--r--lisp/vc/vc.el29
1 files changed, 16 insertions, 13 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index c8d28c144b5..d655a1c6259 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -449,10 +449,10 @@
;;
;; Return the common ancestor between REV1 and REV2 revisions.
;;
-;; - last-change (from to)
+;; - last-change (file line)
;;
-;; Return the most recent revision that made a change between FROM
-;; and TO.
+;; Return the most recent revision of FILE that made a change
+;; on LINE.
;; TAG/BRANCH SYSTEM
;;
@@ -3590,17 +3590,20 @@ it indicates a specific revision to check out."
(throw 'ok res)))))))
(declare-function log-view-current-tag "log-view" (&optional pos))
-(defun vc-default-last-change (_backend from to)
+(defun vc-default-last-change (_backend file line)
"Default `last-change' implementation.
-FROM and TO are used as region markers"
- (save-window-excursion
- (let* ((buf (window-buffer (vc-region-history from to)))
- (proc (get-buffer-process buf)))
- (cl-assert (processp proc))
- (while (accept-process-output proc))
- (with-current-buffer buf
- (prog1 (log-view-current-tag)
- (kill-buffer))))))
+It returns the last revision that changed LINE number in FILE."
+ (unless (file-exists-p file)
+ (signal 'file-error "File doesn't exist"))
+ (with-temp-buffer
+ (vc-call-backend (vc-backend file) 'annotate-command
+ file (current-buffer))
+ (goto-char (point-min))
+ (forward-line (1- line))
+ (let ((rev (vc-call-backend
+ (vc-backend file)
+ 'annotate-extract-revision-at-line)))
+ (if (consp rev) (car rev) rev))))