GNU bug report logs -
#73232
[PATCH] Allow vc-diff to suggest a default revision in vc-dir
Previous Next
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
Message #11 received at 73232 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Eli Zaretskii <eliz <at> gnu.org> writes:
>> Cc: Juri Linkov <juri <at> linkov.net>
>> Date: Fri, 13 Sep 2024 11:51:47 -0400
>> From: Spencer Baugh via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> - ;; if it's a directory, don't supply any revision default
>> - ((file-directory-p first)
>> - nil)
>> ;; if the file is not up-to-date, use working revision as older revision
>> - ((not (vc-up-to-date-p first))
>> - (setq rev1-default (vc-working-revision first)))
>> + ((not (and (file-directory-p first) (vc-up-to-date-p first)))
>> + (setq rev1-default (vc-working-revision first backend)))
>
> Doesn't this change the conditions under which we use
> vc-working-revision for regular files? Did you perhaps mean
>
> ((and (not (file-directory-p first)) (vc-up-to-date-p first))
>
> instead?
Oops, yes, fixed.
[0001-Allow-vc-diff-to-suggest-a-default-revision-in-vc-di.patch (text/x-patch, inline)]
From f87b92ce5775d0558b7d9dd502687d1f460bcd2a Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Fri, 13 Sep 2024 11:34:55 -0400
Subject: [PATCH] Allow vc-diff to suggest a default revision in vc-dir
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 single 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. (bug#73232)
---
lisp/vc/vc.el | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 597a1622f5a..7b1133565f9 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2074,17 +2074,14 @@ vc-diff-build-argument-list-internal
;; filesets, but not yet.
((/= (length files) 1)
nil)
- ;; if it's a directory, don't supply any revision default
- ((file-directory-p first)
- nil)
;; if the file is not up-to-date, use working revision as older revision
- ((not (vc-up-to-date-p first))
- (setq rev1-default (vc-working-revision first)))
+ ((and (not (file-directory-p first)) (not (vc-up-to-date-p first)))
+ (setq rev1-default (vc-working-revision first backend)))
;; if the file is not locked, use last revision and current source as defaults
(t
(setq rev1-default (ignore-errors ;If `previous-revision' doesn't work.
(vc-call-backend backend 'previous-revision first
- (vc-working-revision first))))
+ (vc-working-revision first backend))))
(when (string= rev1-default "") (setq rev1-default nil))))
;; construct argument list
(let* ((rev1-prompt (format-prompt "Older revision" rev1-default))
--
2.39.3
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.