GNU bug report logs - #73232
[PATCH] Allow vc-diff to suggest a default revision in vc-dir

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Fri, 13 Sep 2024 15:53:01 UTC

Severity: normal

Tags: patch

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Spencer Baugh <sbaugh <at> janestreet.com>
Subject: bug#73232: closed (Re: bug#73232: [PATCH] Allow vc-diff to
 suggest a default revision in vc-dir)
Date: Wed, 09 Oct 2024 23:38:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#73232: [PATCH] Allow vc-diff to suggest a default revision in vc-dir

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 73232 <at> debbugs.gnu.org.

-- 
73232: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73232
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 73232-done <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#73232: [PATCH] Allow vc-diff to suggest a default revision in
 vc-dir
Date: Thu, 10 Oct 2024 02:36:54 +0300
On 04/10/2024 14:38, Spencer Baugh wrote:
>>> Here's what seems to me an overall improvement, based on the
>>> original change. And more consistent as well.
>>> * No special case for when FIRST is a directory OR it's not
>>> up-to-date.
>>> * Make REV1-DEFAULT a list value.
>>> * In 'vc-root-version-diff', don't try calling 'vc-deduce-fileset'
>>> and construct a (BACKEND DEFAULT-DIR) fileset right away.
>>> As a result, 'C-u C-x v d' consistently provides completion and diff
>>> relating to the whole repository, not for files as point (if
>>> any). Previously, it used the revision that last touched the
>>> corresponding file, or nil, if the file was untracked (e.g. in
>>> Dired).
>>> Further, don't offer the working revision as REV1-DEFAULT. Except
>>> for historical reasons and some idea of consistency, I can't see a
>>> scenario where that would be useful, which would not be covered by
>>> calling 'C-x v d' without a prefix. Someone please correct me here.
>>> And combined with Spencer's patch from
>>> https://debbugs.gnu.org/62940#46, we get this:
>>> * First default is HEAD^ (the last revision before the latest).
>>> * Second default is @{upstream}.
>>> * Then the elements from vc-revision-history.
>>> WDYT?
> This seems reasonable to me.  Then we have the following reliable
> behaviors:
> 
> - [some diff command] RET
>     diffs the working tree against HEAD
> - C-u [some diff command] RET RET
>     diffs the working tree against HEAD^
> - C-u [some diff command] M-n RET RET
>     diffs the working tree against @{upstream}
> 
> This seems like a big improvement, since previously would need to
> actually read the prompt in the C-u case to figure out whether the
> default was correct/what you wanted.

Yep, I think predictability is key.

Since there seem to be no objections, I've pushed the proposed change to 
master (just step number 2, the 3rd one is in another bug#). If 
anybody's having problems as a result, feedback welcome.

[Message part 3 (message/rfc822, inline)]
From: Spencer Baugh <sbaugh <at> janestreet.com>
To: bug-gnu-emacs <at> gnu.org
Cc: Juri Linkov <juri <at> linkov.net>
Subject: [PATCH] Allow vc-diff to suggest a default revision in vc-dir
Date: Fri, 13 Sep 2024 11:51:47 -0400
[Message part 4 (text/plain, inline)]
Tags: patch


C-u M-x vc-root-diff will prompt for the old revision to use for the
diff.  The prompt will have a default calculated by
vc-diff-build-argument-list-internal.  The default is either the
working revision of the current fileset or the revision before that.

vc-diff-build-argument-list-internal contained a check (added in
c0d66cb21bac57f5ec0378e8a04aac8f35c3eb5c) which explicitly avoided
setting a default if the current fileset was a directory.  This check
was added in 1997 when vc only worked for single files.

This prevents a backend from choosing to return a non-nil value from
'working-revision when passed a directory.  (The vc-hg and vc-git
backends, at least, will do this)

Allow this by moving the file-directory-p check, so that we try
calling 'working-revision when the fileset is a single directory.  The
call is in inside ignore-errors, so if a backend errors when passed a
directory, we'll just get no default, as before.  (Most backends will
just return nil for a directory, rather than erroring)

Also, while we're here, explicitly pass the backend to
vc-working-revision rather than having vc-working-revision recompute
it.

Concretely this has the effect that for the vc-git and vc-hg backends,
running C-u M-x vc-root-diff in vc-dir will have the same behavior as
running C-u M-x vc-root-diff in a clean file: The "Previous revision:"
prompt's default will be the revision before HEAD.

* lisp/vc/vc.el (vc-diff-build-argument-list-internal): Move
file-directory-p check.

In GNU Emacs 29.2.50 (build 17, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2024-09-06 built on
 igm-qws-u22796a
Repository revision: e6d04c06a7eb6ce932b52a346368d02b7a811a00
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --with-x-toolkit=lucid --without-gpm --without-gconf
 --without-selinux --without-imagemagick --with-modules --with-gif=no
 --with-cairo --with-rsvg --without-compress-install
 --with-native-compilation=aot --with-tree-sitter
 PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'

[0001-Allow-vc-diff-to-suggest-a-default-revision-in-vc-di.patch (text/patch, attachment)]

This bug report was last modified 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.