From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#38044: 27.0.50; There should be an easier way to look at a specific vc commit Date: Wed, 20 Nov 2019 23:50:00 +0200 Organization: LINKOV.NET Message-ID: <87y2warzv3.fsf@mail.linkov.net> References: <87ftj5at1q.fsf@gnus.org> <87r22phsoj.fsf@gmx.net> <87bltslnpo.fsf@mail.linkov.net> <87d0dvmqu8.fsf@mail.linkov.net> <590e595e-8220-1c7e-bd4a-b2eb0968e289@yandex.ru> <87r226xl8m.fsf@mail.linkov.net> <24c56bca-8d7d-3a20-aeef-5d11f8a075e6@yandex.ru> <87pnhquo4k.fsf@mail.linkov.net> <6087186e-a444-0aac-e87d-596d2e36f0ce@yandex.ru> <877e3wub09.fsf@mail.linkov.net> <5ce7d4f0-3884-fd27-09dc-c38f01a19958@yandex.ru> <83zhgr26c3.fsf@gnu.org> <87blt7qxhz.fsf@mail.linkov.net> <837e3v1aae.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="117988"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: larsi@gnus.org, stephen.berman@gmx.net, 38044@debbugs.gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 20 23:49:40 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iXYn5-000USa-Aw for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Nov 2019 23:49:39 +0100 Original-Received: from localhost ([::1]:34898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXYn3-0002y5-UV for geb-bug-gnu-emacs@m.gmane.org; Wed, 20 Nov 2019 17:49:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47911) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iXYle-0001Ev-SV for bug-gnu-emacs@gnu.org; Wed, 20 Nov 2019 17:48:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iXYld-0006WZ-Dp for bug-gnu-emacs@gnu.org; Wed, 20 Nov 2019 17:48:10 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42226) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iXYld-0006WM-A0 for bug-gnu-emacs@gnu.org; Wed, 20 Nov 2019 17:48:09 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iXYld-00063U-7Z for bug-gnu-emacs@gnu.org; Wed, 20 Nov 2019 17:48:09 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Nov 2019 22:48:09 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38044 X-GNU-PR-Package: emacs Original-Received: via spool by 38044-submit@debbugs.gnu.org id=B38044.157429002923060 (code B ref 38044); Wed, 20 Nov 2019 22:48:09 +0000 Original-Received: (at 38044) by debbugs.gnu.org; 20 Nov 2019 22:47:09 +0000 Original-Received: from localhost ([127.0.0.1]:51019 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iXYke-0005zr-Ny for submit@debbugs.gnu.org; Wed, 20 Nov 2019 17:47:09 -0500 Original-Received: from dragonfly.birch.relay.mailchannels.net ([23.83.209.51]:21529) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iXYkW-0005zL-O1 for 38044@debbugs.gnu.org; Wed, 20 Nov 2019 17:47:07 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 066CF5A0C1B; Wed, 20 Nov 2019 22:46:59 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a44.g.dreamhost.com (100-96-4-107.trex.outbound.svc.cluster.local [100.96.4.107]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 66D375A1058; Wed, 20 Nov 2019 22:46:58 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a44.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.5); Wed, 20 Nov 2019 22:46:58 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Decisive-Descriptive: 526ae3e412871bd1_1574290018674_3340243958 X-MC-Loop-Signature: 1574290018674:2073534326 X-MC-Ingress-Time: 1574290018674 Original-Received: from pdx1-sub0-mail-a44.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a44.g.dreamhost.com (Postfix) with ESMTP id 707E5832D8; Wed, 20 Nov 2019 14:46:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=Q2m43f2r7UwrFaPu02Jtllg4Jyo=; b= zlszsaJg7PhdPj3Ex2HDMwVdMvLaGUOpjRkbR75S9xRLkt7/AiZra2Qo+eG5QBs5 e0lnAEQo+MMHeKN5uBiXN0W1Z0OfWaxejNci/Bzjwf+S46SwekQCdXNk7vb+c+YG ysPUfOIVZe9SyC3Ckq6g4Xwn+rXJymRLE1bZhuHHuVc= Original-Received: from mail.jurta.org (m91-129-102-1.cust.tele2.ee [91.129.102.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a44.g.dreamhost.com (Postfix) with ESMTPSA id A87D4832D5; Wed, 20 Nov 2019 14:46:53 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a44 In-Reply-To: <837e3v1aae.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 20 Nov 2019 05:44:41 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:172081 Archived-At: --=-=-= Content-Type: text/plain >> > Stepping a notch back, wasn't the original request to have a command >> > that would display a specific commit? If so, that's not a "log" >> > command, that's closer to a "diff" command. And don't we already have >> > a "diff" command which shows diffs for a specific revision? >> >> Then we could use something like the existing backend 'region-history' >> that for vc-git uses 'git log', but displays both the log and diff >> in one output buffer. > > region-history is slow, so I'm not sure it is a good starting point > for this feature. A diff command is usually very fats with every VCS. It doesn't use 'region-history'. I meant using 'region-history-mode' on the output buffer. Everything works perfectly with this patch that also implements defaulting to the revision under point and prompting for the directory like Lars asked to do: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-print-revision.patch diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 0d29c80d02..fedc30e932 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -359,6 +359,10 @@ ;; and make sure it is displayed in the buffer's window. The default ;; implementation of this function works for RCS-style logs. ;; +;; - print-revision (revision) +;; +;; Show details of REVISION. +;; ;; - comment-history (file) ;; ;; Return a string containing all log entries that were made for FILE. @@ -2516,6 +2520,31 @@ vc-print-branch-log (list default-directory) branch t (when (> vc-log-show-limit 0) vc-log-show-limit))) +;;;###autoload +(defun vc-print-revision (revision) + "Show the details of the revision REVISION." + (interactive (list (unless current-prefix-arg + (let ((default (thing-at-point 'word))) + (vc-read-revision + (if default + (format "Revision to show (default %s): " default) + "Revision to show: ") + nil nil default))))) + (when (equal revision "") + (error "No revision specified")) + (let ((backend (vc-deduce-backend)) + rootdir) + (if backend + (setq rootdir (vc-call-backend backend 'root default-directory)) + (setq rootdir (read-directory-name "Directory for VC print-revision: ")) + (setq backend (vc-responsible-backend rootdir)) + (unless backend + (error "Directory is not version controlled"))) + (setq default-directory rootdir) + (vc-incoming-outgoing-internal backend revision + "*vc-revision*" 'print-revision) + (vc-call-backend backend 'region-history-mode))) + ;;;###autoload (defun vc-log-incoming (&optional remote-location) "Show a log of changes that will be received with a pull operation from REMOTE-LOCATION. diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 5ab8e7ec53..a330adaa52 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -80,6 +80,7 @@ ;; - log-search (buffer pattern) OK ;; - log-view-mode () OK ;; - show-log-entry (revision) OK +;; - print-revision (revision) OK ;; - comment-history (file) ?? ;; - update-changelog (files) COULD BE SUPPORTED ;; * diff (file &optional rev1 rev2 buffer async) OK @@ -1163,6 +1164,22 @@ vc-git-print-log (list start-revision))) '("--"))))))) +(defun vc-git-print-revision (buffer revision) + "Show the details of REVISION with output in BUFFER. +With a prefix argument, ask for a command to run that will output +the revision information." + (let ((args `("show" "--no-color" ,(or revision "")))) + (when current-prefix-arg + (setq args (cdr (split-string + (read-shell-command + "Show revision with command: " + (format "%s %s" vc-git-program + (mapconcat 'identity args " ")) + 'vc-git-history) + " " t)))) + (vc-setup-buffer buffer) + (apply 'vc-git-command buffer 'async nil args))) + (defun vc-git-log-outgoing (buffer remote-location) (vc-setup-buffer buffer) (vc-git-command @@ -1226,7 +1243,7 @@ vc-git-log-view-mode (set (make-local-variable 'log-view-file-re) regexp-unmatchable) (set (make-local-variable 'log-view-per-file-logs) nil) (set (make-local-variable 'log-view-message-re) - (if (not (memq vc-log-view-type '(long log-search))) + (if (not (memq vc-log-view-type '(long log-search print-revision))) (cadr vc-git-root-log-format) "^commit *\\([0-9a-z]+\\)")) ;; Allow expanding short log entries. @@ -1235,7 +1252,7 @@ vc-git-log-view-mode (set (make-local-variable 'log-view-expanded-log-entry-function) 'vc-git-expanded-log-entry)) (set (make-local-variable 'log-view-font-lock-keywords) - (if (not (memq vc-log-view-type '(long log-search))) + (if (not (memq vc-log-view-type '(long log-search print-revision))) (list (cons (nth 1 vc-git-root-log-format) (nth 2 vc-git-root-log-format))) (append --=-=-=--