From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: feature/package+vc 04c4c578c7 3/4: Allow for packages to be installed directly from VCS Date: Sun, 30 Oct 2022 15:55:00 +0000 Message-ID: <87pme99ui3.fsf@posteo.net> References: <164484721900.31751.1453162457552427931@vcs2.savannah.gnu.org> <878rle1i0k.fsf@posteo.net> <87ilkelc10.fsf@posteo.net> <878rl6syg8.fsf@posteo.net> <87zgdjqcu0.fsf@posteo.net> <87zgdivc3f.fsf@posteo.net> <874jvqv2u3.fsf@posteo.net> <875yg6qtbl.fsf@posteo.net> <87ilk33lqk.fsf@posteo.net> <87mt9epqlk.fsf@posteo.net> <87ilk1bgvd.fsf@posteo.net> <87edupbdp0.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32502"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Richard Stallman , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Oct 30 16:55:33 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opAeq-0008Dw-T2 for ged-emacs-devel@m.gmane-mx.org; Sun, 30 Oct 2022 16:55:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opAea-0001Cg-75; Sun, 30 Oct 2022 11:55:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opAeR-0001AM-BB for emacs-devel@gnu.org; Sun, 30 Oct 2022 11:55:12 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opAeP-0002Lg-87 for emacs-devel@gnu.org; Sun, 30 Oct 2022 11:55:07 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id DEF09240103 for ; Sun, 30 Oct 2022 16:55:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667145302; bh=SRTIQnA1GB+0XUVN3moD1OYVQiA9zvDLJgf4FM3ldzk=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=OWefnA6SeGl2QXnZsOSR6N0Vprm9mQ5+fRVnFIf484DUKi+qLt9DWtNpZoQ8kpoET v7aS4wbNv1s2YCn+L/614toiHVm3kslGLqLCOic7mEVIzpPNq4/5AGI26NLe1+yqnI 84+kP7KF05OhG4YrdxyBHu2u/lMDjq+u6qn+3HZ/0d+ZRIlmRSVaqvVbYQeLLt7FOT MKEDHUfJqVI3Sv7HC9NplXANyhKbsIfgLowtKPw5/iM1IZpjELmN4bMu6xuE0o09jS PCDsznyUPtOuhgcxu0EjgpfX2wf802Sq9AdDWIO7mS8AfEL1ZSNEOr783oF8vLnixN Di3oTZ8smmoGg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N0gpY2SLfz9rxB; Sun, 30 Oct 2022 16:55:01 +0100 (CET) In-Reply-To: <87edupbdp0.fsf@posteo.net> (Philip Kaludercic's message of "Sun, 30 Oct 2022 15:15:07 +0100") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298824 Archived-At: --=-=-= Content-Type: text/plain Philip Kaludercic writes: >>> The default handler just wraps vc-annotate, so it is a bit more fragile. >> >> Hmm... the code I see in your patch uses `vc-region-history` (which is >> only supported for Git and Hg, currently, and is fairly difficult to >> support in a generic way) rather than `vc-annotate`. >> Am I missing something? > > Uh, that is my mistake. I started writing that code yesterday (I > believe?) and simply forgot what I had used. I'll try to translate that > into vc-annotate before pushing anything. This patch changes the 'last-change' interface from (from to) into (file line), which matches how most VCS think about it to begin with, and uses 'annotate-command' in the default case: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Have-last-change-accept-a-line-number-instead-of-a-r.patch >From d33998ed3b5e05a40b9c4c1799b6e911b582ef01 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sun, 30 Oct 2022 16:52:08 +0100 Subject: [PATCH] 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 @@ package-vc-release-rev (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 @@ vc-git-annotate-extract-revision-at-line (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 @@ vc-clone (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)))) -- 2.38.0 --=-=-= Content-Type: text/plain With this, I think that the feature will work pretty well -- setting aside the detached HEAD stuff. --=-=-=--