From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73232: [PATCH] Allow vc-diff to suggest a default revision in vc-dir Date: Fri, 13 Sep 2024 11:51:47 -0400 Message-ID: Reply-To: Spencer Baugh Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22632"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Juri Linkov To: 73232@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 13 17:53:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sp8bo-0005jx-8A for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 13 Sep 2024 17:53:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sp8be-0000oA-EK; Fri, 13 Sep 2024 11:53:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sp8bM-0000lS-TM for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 11:52:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sp8bM-0003sw-Iu for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 11:52:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=u5v69PST72OOA+gpV+IQcxKhmGCb8oPCNJoj4G0CXUE=; b=d51in4RA6m/JfrfpWXstl2xAMmS9A7VExNSqD4w3TZ63dEzsWX7PMlKAWTwRPNO/ongurv9Fm2dC2WJIQz72I10dMy7Jjd1+NsWceiFF1Jsi1P4918ybn45MY8IB+ED0lsj7U/8kxe1QtHuEPUBUyX7a5NixrNh/FLi1OapWfZLNkSXi+gC3oQCSrs42TGjLprlTy3ozINR/1AIDoGpaNOk5xB26PwiYWJq+s5/VlU3k4MJgZeWTUsWt2Z/HmBXVtvWmOczLYW3ecRIiz3EVJ+cQJKt8LpBZtwi0m81mF9MbEK6oGl9yS9HVTGbNQxaKuZdN/1chhtkDiLQQaFP7NA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sp8bV-0007V0-OT for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 11:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 13 Sep 2024 15:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73232 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172624272628686 (code B ref -1); Fri, 13 Sep 2024 15:53:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Sep 2024 15:52:06 +0000 Original-Received: from localhost ([127.0.0.1]:44094 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sp8ab-0007SV-Hl for submit@debbugs.gnu.org; Fri, 13 Sep 2024 11:52:06 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:58884) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sp8aY-0007S5-Q7 for submit@debbugs.gnu.org; Fri, 13 Sep 2024 11:52:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sp8aO-0005Mq-On for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 11:51:52 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sp8aL-0003gQ-Mt for bug-gnu-emacs@gnu.org; Fri, 13 Sep 2024 11:51:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1726242707; bh=u5v69PST72OOA+gpV+IQcxKhmGCb8oPCNJoj4G0CXUE=; h=From:To:Cc:Subject:Date; b=GQv+oniSZ7BiRjUuoW6aUlz2KBTuFFvL/yNm/9w0sjjHGvsBzmBHE09Lps4j6Iu1n oi7fea6ogdB1qogR1cBddVX7PDq1S5fFMUpUMWDBKEiQtVIhzAAlwLtrbWrdBi/4Nr ad7UetXvOaFXWD4RAB8T0XHlPdLjfxcbaO6BoPVOCI2amPniEogJRN9ZQoZI2JtMg+ Sk/eq/rneZN9lT+W4DjQruWtDeyTjNx6EsV4x3lrBIaamB9+3YLFmeYbQAFn9vuGbj rz/khMxFlKhL6V98zN+5N3HI2xIEqOzI40QktRfQ26ZYSARjYjgsiy22SG5ogWzW6D z3EejQUcRxh8Q== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291663 Archived-At: --=-=-= Content-Type: text/plain 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/' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Allow-vc-diff-to-suggest-a-default-revision-in-vc-di.patch >From e57db4d91cf098d26c8c131d715ef3619466d159 Mon Sep 17 00:00:00 2001 From: Spencer Baugh 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. --- 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..d88a655dc6b 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))) + ((not (and (file-directory-p first) (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 --=-=-=--