From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#38044: 27.0.50; There should be an easier way to look at a specific vc commit Date: Fri, 22 Nov 2019 21:59:14 +0200 Message-ID: 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> <87y2warzv3.fsf@mail.linkov.net> <83r221xoll.fsf@gnu.org> <83a78pxenu.fsf@gnu.org> <215302ff-8252-1f6c-5f60-aaba01cd615f@yandex.ru> <837e3tx9s8.fsf@gnu.org> <0521b598-33ec-c0b5-42ff-fb6ff779b7e4@yandex.ru> <834kywxtr1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------7C9695B316889BCFD2E827E9" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="5805"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: larsi@gnus.org, stephen.berman@gmx.net, 38044@debbugs.gnu.org, juri@linkov.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 22 21:00:19 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 1iYF6J-0001Od-BW for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Nov 2019 21:00:19 +0100 Original-Received: from localhost ([::1]:54682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYF6I-0005Ug-76 for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Nov 2019 15:00:18 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51453) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iYF64-0005TQ-37 for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2019 15:00:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iYF62-0003ak-C9 for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2019 15:00:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iYF62-0003ac-6o for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2019 15:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iYF61-0002Im-W9 for bug-gnu-emacs@gnu.org; Fri, 22 Nov 2019 15:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Nov 2019 20:00:01 +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.15744527738789 (code B ref 38044); Fri, 22 Nov 2019 20:00:01 +0000 Original-Received: (at 38044) by debbugs.gnu.org; 22 Nov 2019 19:59:33 +0000 Original-Received: from localhost ([127.0.0.1]:55543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYF5Z-0002Hg-3p for submit@debbugs.gnu.org; Fri, 22 Nov 2019 14:59:33 -0500 Original-Received: from mail-wm1-f52.google.com ([209.85.128.52]:40064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iYF5W-0002HL-LK for 38044@debbugs.gnu.org; Fri, 22 Nov 2019 14:59:31 -0500 Original-Received: by mail-wm1-f52.google.com with SMTP id y5so8989336wmi.5 for <38044@debbugs.gnu.org>; Fri, 22 Nov 2019 11:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=4yFTPIcOLPH5PZu7O4srBhG1HrWVFBt1oZc2N0sG0lM=; b=SAyKjgO1MpgauMRdvqmLfno98CLqn7GciPWha5ROkdOkHbdLnwfynAp8eb9xJb83As WfbUelulinyY7jF7OP+Gdt/xmD/ghhO8OaAv89MHmsKte6dWbFW4qi6Qxu5/iawB81gZ cFOXrlnqdlugRChQVpURHArMC4JdwMo5f3P4uHyi6q+BcDiSIXrUxdezLnf3PZoWD6rL WPi+f13fT5Cw4tm7WTABw9swxX0XaoHTg/Ub6EyZogitpL692/TifZnzH4fc4JgWGT6Y QqDX3yerdGKYXlIl/NUadayjGgjFVp9FZf2l4BvsUpRJvf4Gg92Q8dYjokJ8ytd85xT2 gCfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=4yFTPIcOLPH5PZu7O4srBhG1HrWVFBt1oZc2N0sG0lM=; b=LaxWF0KRG5E+cPvfiGU/lxq9WgxDQtP3ma7Gq7nVnAHERWuA0UK11kMUoi5OJp/UuC roT8bd/xRhAVLr7B9mZ1dTWElgT07tFh0YTOhpH7zspk0gkywY4SnqozWJqpV1Fe/pyQ GVOxMmE9wcDubybSIr058+Uvy4TV2zI5C5nwVOwucDf04+tZEiXhh6nL2bwpjLNrGxxX ueQ8MY2anyt1b/sxP7QolvnuQwOCtZRr707qjvUV/x75YTk1pnbJDmzAJNQgmL2312AQ KtKJbHlWIc9qP80/gVmxbHwCBk9ZhBrkMiHvF3f08T+qeYCBjBf7P07rd8HvpocKnzGO iTsQ== X-Gm-Message-State: APjAAAXXCu0wP6E673b7PFghRoZ305rwQZ3MiKtNP/GKbj5cWFSnFjhY PC6ReWtcBhZO/3Cj/QOuyqE= X-Google-Smtp-Source: APXvYqyZ3hteUcERFI3g4RQTA8/kju9C+brB3rwHd5j3rSjsSEU8ifFl6n5KHPHmovk5aQ2TZ8Z5sg== X-Received: by 2002:a1c:20c6:: with SMTP id g189mr4312817wmg.6.1574452757594; Fri, 22 Nov 2019 11:59:17 -0800 (PST) Original-Received: from [192.168.0.5] ([212.50.117.215]) by smtp.googlemail.com with ESMTPSA id l26sm15689wmj.48.2019.11.22.11.59.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Nov 2019 11:59:16 -0800 (PST) In-Reply-To: <834kywxtr1.fsf@gnu.org> Content-Language: en-US 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:172259 Archived-At: This is a multi-part message in MIME format. --------------7C9695B316889BCFD2E827E9 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 22.11.2019 9:20, Eli Zaretskii wrote: >> Somewhat better, but all backends would have to be updated anyway, for >> this to work. > > It's new functionality, so that goes without saying. Or did you mean > something specific when you said "updated"? Not every new functionality needs explicit support from backends. >> So the change in VC backend API is comparable to adding a new >> action. > > We don't necessarily need a change in the API: vc-print-log-internal > has enough arguments to pass this new meaning to it and to the > backends. But even if there's a change in the API, it isn't a > catastrophe from my POV. The backend API. It also has certain backward compatibility expectations. Anyway, I'm saying the change you are proposing is roughly the same magnitude in complexity as adding a new backend action. >> I don't mind this too much (asking vc-git-print-log to include the diffs >> makes sense, at least), but doing it this way loses out on the >> opportunity to support all backends in one fell swoop. > > I don't understand why would we lose that opportunity. We will have > to write new code for each backend in any alternative, Not necessarily. See the attached patch (it's a modification of Juri's). Since we don't have a way to combine async process invocation, there is some complexity there with accept-process-output. But from what I see, the diff operation is considerably more resource-intensive, at least for big Hg repos. There is a catch, however: it requires an implementation of region-history-mode. But, as you remarked, it can be extracted to be more backend-independent. Consequently, for now this "default" implementation only adds print-revision support to Hg. > VC used to > be simple and elegant, and this proliferation of too many high-level > commands makes it more and more complex, I hardly see any complexity in the presence of a command. There's more more of it in tiny details of implementation of the main ones. > and inevitably causes us > tweak the user level and UI to this or that particular VCS, which is > wrong in the long run. When was the last time we did that? And how adding a new command would cause it in this case? --------------7C9695B316889BCFD2E827E9 Content-Type: text/x-patch; name="vc-print-revision-with-default.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vc-print-revision-with-default.diff" diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index ca4c66a06d..729d98f143 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 diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 17d38fa400..ae0c93bf9d 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -564,7 +564,8 @@ vc-hg-expanded-log-entry (defun vc-hg-revision-table (files) (let ((default-directory (file-name-directory (car files)))) (with-temp-buffer - (vc-hg-command t nil files "log" "--template" "{rev} ") + (vc-hg-command t nil nil "branches" "--template" "{branch}\n") + (vc-hg-command t nil nil "tags" "--template" "{tag}\n") (split-string (buffer-substring-no-properties (point-min) (point-max)))))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 0d29c80d02..be4ed95fe3 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. @@ -3091,6 +3120,30 @@ vc-default-dir-status-files (funcall update-function (mapcar (lambda (file) (list file 'up-to-date)) files))) +(defun vc-default-print-revision (backend buffer revision) + (let* ((buffer-name " *vc-revision-log*") + (buf (get-buffer-create buffer-name)) + proc) + (vc-call-backend backend 'print-log (list default-directory) buf nil revision 1) + (unwind-protect + (progn + (setq proc (get-buffer-process buf)) + (while (process-live-p proc) + (accept-process-output proc 0.1)) + (save-current-buffer + (vc-setup-buffer buffer) + (let ((inhibit-read-only t)) + (insert-buffer-substring buf) + (insert "\n")) + (vc-call-backend backend 'diff (list default-directory) + (vc-call-backend backend 'previous-revision nil revision) + revision + buffer + t) + (vc-run-delayed + (goto-char (point-min))))) + (kill-buffer buf)))) + (defun vc-check-headers () "Check if the current file has any headers in it." (interactive) --------------7C9695B316889BCFD2E827E9--