From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Alfred M. Szmidt" Newsgroups: gmane.emacs.devel Subject: Re: vc-modify-change-comment for "modern" backend fix Date: Wed, 18 May 2022 02:34:48 -0400 Message-ID: References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9184"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 18 08:43:32 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 1nrDPA-0002D2-2M for ged-emacs-devel@m.gmane-mx.org; Wed, 18 May 2022 08:43:32 +0200 Original-Received: from localhost ([::1]:43326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nrDP8-0004b5-Oo for ged-emacs-devel@m.gmane-mx.org; Wed, 18 May 2022 02:43:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrDGj-00009I-U4 for emacs-devel@gnu.org; Wed, 18 May 2022 02:34:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:52196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nrDGi-00078n-Up; Wed, 18 May 2022 02:34:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=mHX+vwHhAiQiwoC2gvuXlAA+rcv2nmKHOpbIS02G1eY=; b=ITtIIC51pURa y+UJCKmdn5eNoONz10Gl5JhMIeQOOUfV1DJCieEleRsWdqBmlJXCc3OxSi22iTv6rXfhttP6LjtIA XNjkeimzhsm6IyK3tYpL3qkj+bksU/VAL2Is9uxliMHtRn54bN1xoYfgsVCaNo0MT6fJyuJwlR/7m nxcicI1Zd+GzTwOyuzhImu/TZTvFA92g8xRK/hG63S1f7aOOpG9twUBC29nKVwuZQL3OZIK1JsinZ 4uQJ8Y/giaLYS7cXObaOHYa+2Nl5JX61a9QVmNpnjqWSVH4oykyRG3PqTQCkserPk9iwp+OUy4XOQ 4z0aNsVQxHNWx6BFYF5J8A==; Original-Received: from ams by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1nrDGi-0006Q7-Fy; Wed, 18 May 2022 02:34:48 -0400 In-Reply-To: (message from Stefan Monnier on Tue, 17 May 2022 14:31:28 -0400) 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: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289908 Archived-At: What about something like this, I've tested it briefly with a vc-fossil-get-log-entry, and with RCS and it seems to behave as it does previously -- though slightly confused by what it does for RCS (it inserts the header, but not the commit?). diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el index 415b1564ed..93e38bf3d2 100644 --- a/lisp/vc/log-view.el +++ b/lisp/vc/log-view.el @@ -521,17 +520,6 @@ (defun log-view-extract-comment () - "Parse comment from around the current point in the log." - (save-excursion - (let (st en (backend (vc-backend (log-view-current-file)))) - (log-view-end-of-defun) - (cond ((eq backend 'SVN) - (forward-line -1))) - (setq en (point)) - (or (log-view-current-entry nil t) - (throw 'beginning-of-buffer nil)) - (cond ((memq backend '(SCCS RCS CVS SVN)) - (forward-line 2)) - ((eq backend 'Hg) - (forward-line 4) - (re-search-forward "summary: *" nil t))) - (setq st (point)) - (buffer-substring st en)))) + "Extract the commit message for the current file." + (vc-call-backend log-view-vc-backend + 'get-log-entry + (log-view-current-file) + (log-view-current-tag))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 3508f684c4..01ff7db356 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -359,6 +359,11 @@ ;; and make sure it is displayed in the buffer's window. The default ;; implementation of this function works for RCS-style logs. ;; +;; - get-log-entry (file revision) +;; +;; Return a string containing the log entry for FILE at revision +;; REVISION. + ;; - comment-history (file) ;; ;; Return a string containing all log entries that were made for FILE. @@ -671,12 +676,7 @@ ;; - The git backend supports amending, but in a different ;; way (press `C-c C-e' in log-edit buffer, when making a new commit). ;; -;; - Second, `log-view-modify-change-comment' doesn't seem to support -;; modern backends at all because `log-view-extract-comment' -;; unconditionally calls `log-view-current-file'. This should be easy to -;; fix. -;; -;; - Third, doing message editing in log-view might be a natural way to go +;; - Second, doing message editing in log-view might be a natural way to go ;; about it, but editing any but the last commit (and even it, if it's ;; been pushed) is a dangerous operation in Git, which we shouldn't make ;; too easy for users to perform. @@ -3158,6 +3158,23 @@ vc-default-show-log-entry (with-no-warnings (log-view-goto-rev rev))) +(defun vc-default-get-log-entry (_backend _file _revision) + (save-excursion + (let (st en (backend (vc-backend (log-view-current-file)))) + (log-view-end-of-defun) + (cond ((eq backend 'SVN) + (forward-line -1))) + (setq en (point)) + (or (log-view-current-entry nil t) + (throw 'beginning-of-buffer nil)) + (cond ((memq backend '(SCCS RCS CVS SVN)) + (forward-line 2)) + ((eq backend 'Hg) + (forward-line 4) + (re-search-forward "summary: *" nil t))) + (setq st (point)) + (buffer-substring st en)))) + (defun vc-default-comment-history (backend file) "Return a string with all log entries stored in BACKEND for FILE." (when (vc-find-backend-function backend 'print-log)