Subject: Re: bug#73604: [PATCH] Properly operate on current fileset revision in vc-hg-print-log

From: Spencer Baugh <[email-masked]>
Date: Fri, 11 Oct 2024 16:53:29 -0400

Sean Whitton <[email-masked]> writes:
> Hello,
>
> On Thu 03 Oct 2024 at 11:18am -04, Spencer Baugh wrote:
>
>> I think you both may be misinterpreting this prompt - the typed-in
>> revision doesn't actually specify where the log starts.  It doesn't
>> affect what goes in the buffer at all; the value typed in doesn't get
>> passed to 'print-log at all.
>>
>> The prompt is just about where point goes in the buffer - "last
>> revision" just means that point starts at point-min.  Typing a revision
>> at the prompt just moves point to that revision.
>>
>> (This is of course extremely confusing; I have definitely typed
>> revisions in the vc-print-log prompt and expected them to change the log
>> output.  Maybe this prompt and command should be changed in other ways,
>> but let's defer that for other bugs.  Also note that this is very
>> different behavior from M-1 C-x v L (vc-print-root-log), where typing a
>> revision at the prompt *does* change what's logged.)
>>
>> So, anyway, that prompt says nothing about what actual logs should print
>> with vc-print-log.  And (potentially) including commits which don't even
>> contain the current fileset seems very wrong.
>>
>> Note also that the print-log docs also say:
>>
>> ;;   If START-REVISION is given, then show the log starting from that
>> ;;   revision ("starting" in the sense of it being the _newest_
>> ;;   revision shown, rather than the working revision, which is normally
>> ;;   the case).
>>
>> vc-print-log always passes nil for START-REVISION, so it seems we expect
>> to start from the working revision.
>
> Thanks.  Based on this explanation I'd like to install your patch, but
> can you move the substantive commentary in the commit message into the
> code as a comment, please?  Generally that is preferred in this repo.

Sure - even better, I put it in the docstring.

>From d353b8eef6134cd2a25e0a778d9ac9cd7fcae50f Mon Sep 17 00:00:00 2001
From: Spencer Baugh <[email-masked]>
Date: Wed, 2 Oct 2024 15:20:31 -0400
Subject: [PATCH] Properly operate on current fileset revision in
 vc-hg-print-log

* lisp/vc/vc-hg.el (vc-hg-print-log): If start-revision is nil,
reliably log the working revision. (bug#73604)
---
 lisp/vc/vc-hg.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index c0afb225871..677cb3fd166 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -397,8 +397,11 @@ vc-hg-log-format
 (defun vc-hg-print-log (files buffer &optional shortlog start-revision limit)
   "Print commit log associated with FILES into specified BUFFER.
 If SHORTLOG is non-nil, use a short format based on `vc-hg-root-log-format'.
-If START-REVISION is non-nil, it is the newest revision to show.
-If LIMIT is non-nil, show no more than this many entries."
+If LIMIT is non-nil, show no more than this many entries.
+
+If START-REVISION is nil, the commit log is printed starting from the
+working directory parent (revset \".\").  If START-REVISION is non-nil,
+the log is printed starting from that revision."
   ;; `vc-do-command' creates the buffer, but we need it before running
   ;; the command.
   (vc-setup-buffer buffer)
@@ -408,8 +411,8 @@ vc-hg-print-log
     (with-current-buffer
 	buffer
       (apply #'vc-hg-command buffer 'async files "log"
+             (format "-r%s:0" (or start-revision "."))
 	     (nconc
-	      (when start-revision (list (format "-r%s:0" start-revision)))
 	      (when limit (list "-l" (format "%s" limit)))
               (when (eq vc-log-view-type 'with-diff)
                 (list "-p"))
-- 
2.39.3