[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/package+vc d33998ed3b 09/10: Have 'last-change' accept a line nu
From: |
Philip Kaludercic |
Subject: |
feature/package+vc d33998ed3b 09/10: Have 'last-change' accept a line number instead of a range |
Date: |
Sun, 30 Oct 2022 13:55:31 -0400 (EDT) |
branch: feature/package+vc
commit d33998ed3b5e05a40b9c4c1799b6e911b582ef01
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
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'.
---
lisp/emacs-lisp/package-vc.el | 4 ++--
lisp/vc/vc-git.el | 10 +++-------
lisp/vc/vc.el | 29 ++++++++++++++++-------------
3 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index c3f54c1be8..52e7e25e9f 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -507,8 +507,8 @@ If no such revision can be found, return nil."
(ignore-error vc-not-supported
(vc-call-backend (vc-backend (buffer-file-name))
'last-change
- (match-beginning 0)
- (match-end 0))))))))
+ (buffer-file-name)
+ (line-number-at-pos nil t))))))))
;;;###autoload
(defun package-vc-install (name-or-url &optional name rev backend)
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index cd62effd08..376892c720 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1632,17 +1632,13 @@ This requires git 1.8.4 or later, for the \"-L\" option
of \"git log\"."
(expand-file-name fname (vc-git-root default-directory))))
revision)))))
-(defun vc-git-last-change (from to)
+(defun vc-git-last-change (file line)
(vc-buffer-sync)
- (let ((file (file-relative-name
- (buffer-file-name)
- (vc-git-root (buffer-file-name))))
- (start (line-number-at-pos from t))
- (end (line-number-at-pos to t)))
+ (let ((file (file-relative-name file (vc-git-root (buffer-file-name)))))
(with-temp-buffer
(when (vc-git--out-ok
"blame" "--porcelain"
- (format "-L%d,%d" start end)
+ (format "-L%d,+1" line)
file)
(goto-char (point-min))
(save-match-data
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index c8d28c144b..d655a1c625 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))))
- feature/package+vc updated (eaafc10f67 -> 2a4f37fe52), Philip Kaludercic, 2022/10/30
- feature/package+vc bb86ed20e1 08/10: Display a message after installing source packages, Philip Kaludercic, 2022/10/30
- feature/package+vc a00ec87c0b 01/10: Update handling for new elpa-packages.eld format, Philip Kaludercic, 2022/10/30
- feature/package+vc 4097781655 03/10: Ensure that package specifications are always fetched, Philip Kaludercic, 2022/10/30
- feature/package+vc a52cec7b6b 04/10: Explicitly handle :vc-backend in a package specification, Philip Kaludercic, 2022/10/30
- feature/package+vc 30f1e7c1e9 05/10: Extract last source package release from local VCS data, Philip Kaludercic, 2022/10/30
- feature/package+vc 8b49d553b6 06/10: ; Avoid a type error on malformed "elpa-packages.eld" input, Philip Kaludercic, 2022/10/30
- feature/package+vc ec3f102b8c 07/10: Prefer "Package-Version" over "Version" if available, Philip Kaludercic, 2022/10/30
- feature/package+vc 60b3eb0754 02/10: Allow specifying the VC backend used by 'package-vc-install', Philip Kaludercic, 2022/10/30
- feature/package+vc d33998ed3b 09/10: Have 'last-change' accept a line number instead of a range,
Philip Kaludercic <=
- feature/package+vc 2a4f37fe52 10/10: Merge remote-tracking branch 'origin/master' into feature/package+vc, Philip Kaludercic, 2022/10/30