unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, stephen.berman@gmx.net, 38044@debbugs.gnu.org,
	juri@linkov.net
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	[thread overview]
Message-ID: <e5760bd3-34e9-dec5-df60-5e38d3c39b3f@yandex.ru> (raw)
In-Reply-To: <834kywxtr1.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2209 bytes --]

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?

[-- Attachment #2: vc-print-revision-with-default.diff --]
[-- Type: text/x-patch, Size: 6090 bytes --]

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)

  reply	other threads:[~2019-11-22 19:59 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-03 15:17 bug#38044: 27.0.50; There should be an easier way to look at a specific vc commit Lars Ingebrigtsen
2019-11-03 15:43 ` Stephen Berman
2019-11-03 20:16   ` Juri Linkov
2019-11-13 21:03     ` Juri Linkov
2019-11-16 20:31       ` Juri Linkov
2019-11-17 11:53       ` Dmitry Gutov
2019-11-17 21:20         ` Juri Linkov
2019-11-17 21:58           ` Dmitry Gutov
2019-11-17 22:36             ` Juri Linkov
2019-11-17 23:19               ` Dmitry Gutov
2019-11-18 21:31                 ` Juri Linkov
2019-11-19  3:34                   ` Eli Zaretskii
2019-11-19 11:12                   ` Dmitry Gutov
2019-11-19 16:12                     ` Eli Zaretskii
2019-11-19 16:59                       ` Dmitry Gutov
2019-11-19 17:43                         ` Eli Zaretskii
2019-11-19 23:17                           ` Dmitry Gutov
2019-11-20  3:43                             ` Eli Zaretskii
2019-11-20 12:19                               ` Dmitry Gutov
2019-11-20 16:34                                 ` Eli Zaretskii
2019-11-20 19:40                                   ` Dmitry Gutov
2019-11-20 19:57                                     ` Dmitry Gutov
2019-11-20 20:12                                       ` Eli Zaretskii
2019-11-20 20:07                                     ` Eli Zaretskii
2019-11-20 11:04                         ` Lars Ingebrigtsen
2019-11-21 15:00                           ` Eli Zaretskii
2019-11-19 22:20                       ` Juri Linkov
2019-11-20  3:44                         ` Eli Zaretskii
2019-11-20 21:50                           ` Juri Linkov
2019-11-20 23:37                             ` Dmitry Gutov
2019-11-21 23:08                               ` Juri Linkov
2019-11-22 18:51                                 ` Dmitry Gutov
2019-11-21 14:59                             ` Eli Zaretskii
2019-11-21 15:34                               ` Dmitry Gutov
2019-11-21 15:50                               ` Dmitry Gutov
2019-11-21 18:33                                 ` Eli Zaretskii
2019-11-21 19:08                                   ` Dmitry Gutov
2019-11-21 20:19                                     ` Eli Zaretskii
2019-11-21 21:05                                       ` Dmitry Gutov
2019-11-22  7:20                                         ` Eli Zaretskii
2019-11-22 19:59                                           ` Dmitry Gutov [this message]
2019-11-22 21:03                                             ` Eli Zaretskii
2019-11-22 21:43                                               ` Dmitry Gutov
2019-11-22 21:51                                                 ` Eli Zaretskii
2019-11-23 13:59                                                 ` Eli Zaretskii
2019-11-23 18:52                                                   ` Dmitry Gutov
2019-11-21 21:15                                       ` Stephen Berman
2019-11-22  7:24                                         ` Eli Zaretskii
2019-11-22  9:25                                           ` Stephen Berman
2019-11-23 12:13                                             ` Eli Zaretskii
2019-11-23 13:16                                               ` Stephen Berman
2019-11-22 11:19                                           ` Dmitry Gutov
2019-11-22 12:12                                             ` Lars Ingebrigtsen
2019-11-22 13:04                                             ` Eli Zaretskii
2019-11-22 16:27                                               ` Dmitry Gutov
2019-12-01 13:13                                           ` Stephen Berman
2019-12-01 17:53                                             ` Eli Zaretskii
2019-12-01 20:43                                               ` Stephen Berman
2019-12-01 21:29                                               ` Dmitry Gutov
2019-12-01 21:39                                                 ` Stephen Berman
2019-12-01 22:30                                                   ` Dmitry Gutov
2019-12-02  3:34                                                     ` Eli Zaretskii
2019-12-02 10:39                                                       ` Dmitry Gutov
2019-12-02 11:07                                                         ` Andreas Schwab
2019-12-02 15:58                                                         ` Eli Zaretskii
2019-12-02 16:05                                                           ` Dmitry Gutov
2019-11-23 18:50                                       ` Juri Linkov
2019-11-23 19:11                                         ` Dmitry Gutov
2019-11-23 22:43                                           ` Juri Linkov
2019-11-24 16:05                                             ` Eli Zaretskii
2019-11-26 23:01                                               ` Juri Linkov
2019-11-27  5:39                                                 ` Eli Zaretskii
2019-11-27 22:15                                                   ` Juri Linkov
2019-11-25  0:12                                             ` Dmitry Gutov
2019-11-26 23:06                                               ` Juri Linkov
2019-11-27  0:09                                                 ` Dmitry Gutov
2019-11-27  5:40                                                 ` Eli Zaretskii
2019-11-27 21:32                                                   ` Juri Linkov
2019-11-28  3:34                                                     ` Eli Zaretskii
2019-11-21 23:13                               ` Juri Linkov
2019-11-22  8:03                                 ` Eli Zaretskii
2019-11-22 11:20                                   ` Dmitry Gutov
2019-11-22 13:06                                     ` Eli Zaretskii
2019-11-22 16:26                                       ` Dmitry Gutov
2019-11-22 16:38                                         ` Eli Zaretskii
2019-11-21 22:36 ` Andrii Kolomoiets
2019-11-22  7:40   ` Eli Zaretskii
2020-07-19 15:31 ` Lars Ingebrigtsen
2020-07-19 17:14   ` Dmitry Gutov
2020-07-19 17:16     ` Lars Ingebrigtsen
2020-07-19 19:43       ` Dmitry Gutov
2020-07-19 19:51         ` Lars Ingebrigtsen
2020-07-20 20:56           ` Dmitry Gutov
2020-07-21 21:44             ` Lars Ingebrigtsen
2020-07-22 15:36               ` Dmitry Gutov
2020-07-22 16:14                 ` Dmitry Gutov
2020-07-22 16:25                 ` Eli Zaretskii
2020-07-22 16:38                   ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5760bd3-34e9-dec5-df60-5e38d3c39b3f@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=38044@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    --cc=stephen.berman@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).