GNU bug report logs - #57407
[PATCH] Handle error of ’vc-registered’

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Simon Tournier <zimon.toutoune@HIDDEN>; Keywords: patch moreinfo; dated Thu, 25 Aug 2022 16:21:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 57407 <at> debbugs.gnu.org:


Received: (at 57407) by debbugs.gnu.org; 27 Sep 2022 11:39:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 27 07:39:23 2022
Received: from localhost ([127.0.0.1]:53170 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1od8vr-0003lB-0G
	for submit <at> debbugs.gnu.org; Tue, 27 Sep 2022 07:39:23 -0400
Received: from quimby.gnus.org ([95.216.78.240]:51514)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1od8vp-0003kw-45
 for 57407 <at> debbugs.gnu.org; Tue, 27 Sep 2022 07:39:21 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=xtEyUv4Srf8iN5HaJ870nPtqRulMBZ16TMz6Y+JQd/c=; b=Yi/sKV29v05ieeoFNL0Cj8AXev
 CH0x1TGQi5S+sDj/zYQV8bp4ENIvlZcwmc49tkQSNEDgsaBoTzhesBnFw5SKZ4O3vN3NYrRlOzr5t
 KpPVPNF5N43rgz/fOdxvH8XiFDpyOQSWDobDg394EIDnvotMsclTRuN4RzeXxHQkDPww=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1od8vf-0001Nz-RV; Tue, 27 Sep 2022 13:39:14 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Simon Tournier <zimon.toutoune@HIDDEN>
Subject: Re: bug#57407: [PATCH] Handle error of =?utf-8?Q?=E2=80=99vc-regi?=
 =?utf-8?Q?stered=E2=80=99?=
In-Reply-To: <86pmfivzr2.fsf@HIDDEN> (Simon Tournier's message of "Mon, 26
 Sep 2022 18:58:41 +0200")
References: <87lercwb0o.fsf@HIDDEN> <86pmfivzr2.fsf@HIDDEN>
X-Now-Playing: Simon & Garfunkel's _Parsley, Sage, Rosemary and Thyme_: "A
 Poem on the Underground Wall"
Date: Tue, 27 Sep 2022 13:39:11 +0200
Message-ID: <874jwt59nk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Simon Tournier <zimon.toutoune@HIDDEN> writes: > This is
 a friendly ping about patch #57407 [1]. > > 1:
 <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57407>
 > > I would like to know what is the next step and how I can help for >
 testing and/or th [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57407
Cc: Juri Linkov <juri@HIDDEN>, 57407 <at> debbugs.gnu.org,
 Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Simon Tournier <zimon.toutoune@HIDDEN> writes:

> This is a friendly ping about patch #57407 [1].
>
> 1: <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=57407>
>
> I would like to know what is the next step and how I can help for
> testing and/or the reviewing process about the patch.

If Dmitry is busy at the moment, perhaps Juri has some comments here?
Added to the CCs.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.

Message received at 57407 <at> debbugs.gnu.org:


Received: (at 57407) by debbugs.gnu.org; 26 Sep 2022 16:58:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 26 12:58:56 2022
Received: from localhost ([127.0.0.1]:51672 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ocrRX-0001Zg-WF
	for submit <at> debbugs.gnu.org; Mon, 26 Sep 2022 12:58:56 -0400
Received: from mail-wm1-f48.google.com ([209.85.128.48]:56228)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1ocrRX-0001ZU-0X
 for 57407 <at> debbugs.gnu.org; Mon, 26 Sep 2022 12:58:55 -0400
Received: by mail-wm1-f48.google.com with SMTP id t4so4947166wmj.5
 for <57407 <at> debbugs.gnu.org>; Mon, 26 Sep 2022 09:58:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject
 :date; bh=X/N+gzakuvYCQddkGpxk5xNVXI53HVPj7y1fp41sKCk=;
 b=MRmk3JHPUdkCfgsPQA7RnODDKMGbPUMYl7JrOrZZx6wKa6fK4CLfJ1p4ZlxeZmCS30
 4ZQLi8Bu0nSd4jGkzYLATBjhq0i0Wq2nSJdRPlwrBhqSbbH5pLqrCuyhR1KbtkBVT2iG
 U3UaQW1JqWf23akHB4B1gXjN48JnPL1x9oHvMHPJ1zTqPX8o/cfK/qVOZ9OIY+w+f+ZF
 hPqyu73G5zDeAswjvfUILVvgehNt2hEdXKuiT9Co+X8uqvPdtER6kJ1RPEurI6/EjWOV
 mrR0O/OTz7tRdaSQnTVM6WBaeTHK8Yl1Si/dsE9aeoI/mFS3kcN7JY/daPPmKCaDqFNc
 ZOKg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state
 :from:to:cc:subject:date;
 bh=X/N+gzakuvYCQddkGpxk5xNVXI53HVPj7y1fp41sKCk=;
 b=2uKejsQeToPW4vUBj90di8wcmeKycO1sA2eLiPE+8OgAIRuoxNZm0ESRbPA418SKt5
 txi03HJ5AGjg7llH0RZM+XCXUy+tjao/Fp0G1KS4t2du82FVuA0cSN7lVjQjpWxHfJLI
 WgtuQThTW7m2JG0bnbEUe3OP/y2gFdkD0QSH9bS69L4vEdJVFaH6+Z1xDOGjcpcnayYM
 8VWE3S11GwLxuJT4zKINu8+6TKGb1VpxtlvcY+VANdaYNUh6MY5pzLYNAlBzeasl6cPd
 9FCK0gVxTPq2xmZgl9zHsVqqwHW8hE1pil50bBysz7W0/3CHSMLx/0sK9/hzyZNmrGgH
 +aBg==
X-Gm-Message-State: ACrzQf36npirGhdWjQ8ImGm+te04V28h1E9d6DCVoZfT4tD2RAx3KFxC
 F5R6Coqlu0ZytzhGwx9KiR8=
X-Google-Smtp-Source: AMsMyM758rLfThQXNZjARg3Yu6ZkzkekWwAX5olMJ2nflzHP9wOho7l1diQlRMfSSKVzyUGUnB7S6Q==
X-Received: by 2002:a05:600c:a4c:b0:3b4:fc1b:81 with SMTP id
 c12-20020a05600c0a4c00b003b4fc1b0081mr15437849wmq.125.1664211529000; 
 Mon, 26 Sep 2022 09:58:49 -0700 (PDT)
Received: from lili (roam-nat-fw-prg-194-254-61-41.net.univ-paris-diderot.fr.
 [194.254.61.41]) by smtp.gmail.com with ESMTPSA id
 i6-20020a05600c354600b003b47b80cec3sm12485412wmq.42.2022.09.26.09.58.48
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 26 Sep 2022 09:58:48 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: 57407 <at> debbugs.gnu.org
Subject: Re: bug#57407: [PATCH] Handle error of =?utf-8?Q?=E2=80=99vc-regi?=
 =?utf-8?Q?stered=E2=80=99?=
References: <87lercwb0o.fsf@HIDDEN>
Date: Mon, 26 Sep 2022 18:58:41 +0200
In-Reply-To: <87lercwb0o.fsf@HIDDEN> (Simon Tournier's message of "Thu, 25
 Aug 2022 18:20:07 +0200")
Message-ID: <86pmfivzr2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 57407
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

This is a friendly ping about patch #57407 [1].

1: <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D57407>


I would like to know what is the next step and how I can help for
testing and/or the reviewing process about the patch.


On Thu, 25 Aug 2022 at 18:20, Simon Tournier <zimon.toutoune@HIDDEN> wro=
te:

> Submission (Bug#18481) [0] merged on 2020-08-13 with commit
> 991e145450ec8b02865597bc80fd797e39e81f07 [1] aims to:
>
> =E2=80=9CNotify the user if we errors when querying for registered git fi=
les=E2=80=9C
>
> However, the replacement of =E2=80=99ignore-errors=E2=80=99 by =E2=80=99w=
ith-demoted-errors=E2=80=99
> introduces spurious messages.  This patch proposes to handle the errors
> in a way that:
>
>  1. the user is still informed (avoid silent error)
>  2. improve the messages trying to be more accurate
>  3. do it for all the VC backends
>
> 0: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D18481
> 1: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3D991e145450ec8=
b02865597bc80fd797e39e81f07



All the best,
simon




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.

Message received at 57407 <at> debbugs.gnu.org:


Received: (at 57407) by debbugs.gnu.org; 12 Sep 2022 12:19:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 12 08:19:09 2022
Received: from localhost ([127.0.0.1]:44495 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oXiP6-0006kA-La
	for submit <at> debbugs.gnu.org; Mon, 12 Sep 2022 08:19:09 -0400
Received: from mail-wm1-f46.google.com ([209.85.128.46]:38463)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1oXiP4-0006jE-37
 for 57407 <at> debbugs.gnu.org; Mon, 12 Sep 2022 08:19:06 -0400
Received: by mail-wm1-f46.google.com with SMTP id
 n23-20020a7bc5d7000000b003a62f19b453so10851297wmk.3
 for <57407 <at> debbugs.gnu.org>; Mon, 12 Sep 2022 05:19:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:from:to:cc:subject
 :date; bh=U6gYU43BvUkBJl238H248ckP8i1ZAKZyvioFNHj4HFM=;
 b=bUiSRttuiEbz/KxJXweqLpQo/3Gz1qJBHhXc+8bkFa+3TZvF3Af0X1jnuaCdPaJaOj
 iEmDN7TVBFuTR2yRYtr45DyGwJqLtFBVShoblTzD8rb16q33ywgK2RfcfPBTPqpBbQSY
 NUDFb5SfXbIp+iZWRI5p3vSoVHBkintifjxlozR0vlIu0bb9loAUIH5TinyU6caNQkQI
 UF+fKhQ/9VRPsylA4KOpqtPQhyhZrz19r6+WvnBN5q5V3yFw0UFKHEDsaoy8ctXC4yFC
 0oX+Htxjp450F5TMy7M9hFIM0eUg68RYzi0FyzF10MwoUNdBjhW2u1hl3zD3+EkwnIu0
 1nDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:cc:to:from:x-gm-message-state
 :from:to:cc:subject:date;
 bh=U6gYU43BvUkBJl238H248ckP8i1ZAKZyvioFNHj4HFM=;
 b=c6dQFDG9FHKyPP8dXyNsok27NZatCUlz/XC4TklJMAIKe45zovpuj/lzobNJcetgqT
 W7lP70NzV0k+Iqffi0GvrbT7jud9YF5gjy4aQPZ/8tUoAzDm8Uet6Vbc5Cai6UrccqyE
 kg1kglHCyJiyF+jChqJ1d54NMvWwNgAnS96Orfn9GR02/5gL0biWe+eam6j9OZ9y8p3z
 ZRGr9CaZJ45L0cjPGTb78bujYMCOVULd4a0uQK05mtXsjob/6RpUyl6j9Pdo+v6BkDM7
 S3UoZpaE4AezfwVyoPqLnj6ZiBG+FBHAml5BgNlt1mC9H7WteCnazhv0KoTX3LP11A+l
 c9+g==
X-Gm-Message-State: ACgBeo3tD/r0MWIc6lpu673BJhvwfiFTcuKqADc1nGGA1hmIyApJeyi/
 QVUK9OlT4brFeonDM+WiAziAkVIePBM=
X-Google-Smtp-Source: AA6agR4W4FogeIKlQv1eVfAYIsB0YDKNkEg30mRP/PaYxzI+Nz8kxxv//77Lwg8Wdgh6IR2NAsyxBA==
X-Received: by 2002:a05:600c:3544:b0:3b4:6278:8b60 with SMTP id
 i4-20020a05600c354400b003b462788b60mr8812513wmq.188.1662985139766; 
 Mon, 12 Sep 2022 05:18:59 -0700 (PDT)
Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id
 bh16-20020a05600c3d1000b003a60ff7c082sm9959997wmb.15.2022.09.12.05.18.59
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 12 Sep 2022 05:18:59 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
Subject: Re: bug#57407: [PATCH] Handle error of =?utf-8?Q?=E2=80=99vc-regi?=
 =?utf-8?Q?stered=E2=80=99?=
References: <87lercwb0o.fsf@HIDDEN>
 <f0750a8d-cbfb-0a49-d18c-40c3fd1122b2@HIDDEN>
Date: Mon, 12 Sep 2022 14:18:52 +0200
In-Reply-To: <f0750a8d-cbfb-0a49-d18c-40c3fd1122b2@HIDDEN> (Dmitry Gutov's
 message of "Mon, 12 Sep 2022 04:08:23 +0300")
Message-ID: <87czc0eqfn.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 57407
Cc: 57407 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

Thanks for your comments.


On lun., 12 sept. 2022 at 04:08, Dmitry Gutov <dgutov@HIDDEN> wrote:

> Do I take this right that the main purpose of the patch is to have the "E=
rror:
> ..." messages replaced with "Warning: ..."?

Somehow yes.  More explicitly, replace =E2=80=9CError: <useless message>=E2=
=80=9D with
=E2=80=9CWarning: <more helpful>=E2=80=9D.


> But you also add a bunch of re-signaling code like
>
> +  (let ((state (condition-case err
> +                   (vc-bzr-state-heuristic file)
> +                 (error (signal (car err) (cdr err))))))
>
> What is the idea behind this? Why not just keep the call?

What do you mean?  You need to catch the error and propagates it.

If the heuristic fails in vc-bzr-state-heuristic, then =E2=80=99vc-bzr-stat=
e=E2=80=99 is
called, which itself then calls =E2=80=99vc-bzr-status=E2=80=99.  This stat=
us function
can signal an error and it requires to be raised again.


> And in vc-svn-registered, for example. You re-signal whatever error is ca=
ught,
> without any alternative. Do we need the condition-case there at all, then?

Yes, you need to re-throw the error to propagate it.  See
=E2=80=99(elisp)Handling Errors=E2=80=99:

     Sometimes it is necessary to re-throw a signal caught by
     =E2=80=98condition-case=E2=80=99, for some outer-level handler to catc=
h.  Here=E2=80=99s
     how to do that:

            (signal (car err) (cdr err))

     where =E2=80=98err=E2=80=99 is the error description variable, the fir=
st argument
     to =E2=80=98condition-case=E2=80=99 whose error condition you want to =
re-throw.

Or I am missing a point. :-)


> Furthermore, we'll have to examine the resulting effect on the behavior of
> various backend methods. Apparently, up until now vc-svn-registered never
> signaled an error (swallowed all of them). And now whatever callers it ha=
s,
> will need to handle possible errors.

I think it is what this patch is doing: handle possible errors by the
=E2=80=99vc-<backend>-registered=E2=80=99 callers.


> It's probably fine, though. vc-backend is a more popular function, and it
> seems not much is changing for it, since, for some reason, vc-refresh-sta=
te
> wrapped its call in with-demoted-errors anyway.

For what my opinion is worth, the commit
991e145450ec8b02865597bc80fd797e39e81f07 =E2=80=93 which replaces
=E2=80=99ignore-errors=E2=80=99 with =E2=80=99with-demoted-errors=E2=80=99 =
only for the Git backend =E2=80=93 is
a valuable idea but incorrectly implemented.  This patch is an attempt
to improve the situation.


> But I think we have other callers of it in-tree, and not all of them guard
> with with-demoted-errors or condition-case. What do you think we should do
> with them?

Could you be more specific about these =E2=80=9Cother callers=E2=80=9D?  Fr=
om my
understanding, =E2=80=99vc-<backend>-registered=E2=80=99 is called by =E2=
=80=99vc-registered=E2=80=99
and this patch handles this case; even =E2=80=99vc-registered=E2=80=99 is n=
ot modified
by this patch and the handler happens in =E2=80=99vc-refresh-state=E2=80=99.

Moreover,

--8<---------------cut here---------------start------------->8---
$ for backend in svn git hg ;do ag --elisp vc-${backend}-registered ;done
lisp/ldefs-boot.el
33455: (defun vc-svn-registered (f)
33462:      (vc-svn-registered f))))

lisp/vc/vc-svn.el
110:;; vc-svn-registered, but we want the value to be compiled at startup, =
not
133:;;;###autoload (defun vc-svn-registered (f)
140:;;;###autoload       (vc-svn-registered f))))
142:(defun vc-svn-registered (file)
242:  (vc-svn-registered file)
lisp/ldefs-boot.el
33399: (defun vc-git-registered (file)
33404:        (vc-git-registered file))))

lisp/vc/vc-git.el
244:;;;###autoload (defun vc-git-registered (file)
249:;;;###autoload         (vc-git-registered file))))
251:(defun vc-git-registered (file)
lisp/ldefs-boot.el
33410: (defun vc-hg-registered (file)
33415:        (vc-hg-registered file))))

lisp/vc/vc-hg.el
85:;; vc-hg-registered and vc-hg-state
198:;;;###autoload (defun vc-hg-registered (file)
203:;;;###autoload         (vc-hg-registered file))))
206:(defun vc-hg-registered (file)
--8<---------------cut here---------------end--------------->8---

means that another caller is =E2=80=99vc-svn-working-revision=E2=80=99 used=
 by,

--8<---------------cut here---------------start------------->8---
(defun vc-working-revision (file &optional backend)
  "Return the repository version from which FILE was checked out.
If FILE is not registered, this function always returns nil."
  (or (vc-file-getprop file 'vc-working-revision)
      (progn
        (setq backend (or backend (vc-backend file)))
        (when backend
          (vc-file-setprop file 'vc-working-revision
                           (vc-call-backend
                            backend 'working-revision file))))))
--8<---------------cut here---------------end--------------->8---

Therefore, =E2=80=99vc-svn-working-revision=E2=80=99 should also be guarded=
 with
=E2=80=99condition-case=E2=80=99 and display an appropriate message, indeed.


>> It is probably an abuse of =E2=80=99pcase=E2=80=99.  Is =E2=80=99cond=E2=
=80=99 better here?  Last,
>> I have not found in the documentation how to differentiate what it is
>> raised depending on the error type, hence the =E2=80=99pcase=E2=80=99.
>
> I think you just need to write the specific error type instead of 'error'=
 in
> the handler clause.

Maybe I am missing a point about error handling and how they propagate.
If I consider this change removing =E2=80=99pcase=E2=80=99 and write the sp=
ecific error
as you are suggesting,

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index 778d1139fc..39ad27f2fd 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -361,15 +361,13 @@ vc-do-command
 	    (let ((buffer-undo-list t))
               (condition-case err
 	          (setq status (apply #'process-file command nil t nil squeezed))
-                (error
-                 (pcase (car err)
-                   ('file-missing
-                    (if (string=3D (cadr err) "Searching for program")
-                        ;; The most probable is the lack of the backend bi=
nary.
-                        (signal 'vc-not-supported (cdr err))
-                      (signal (car err) (cdr err))))
-                   (_
-                    (signal (car err) (cdr err)))))))
+                ((file-missing
+                  (if (string=3D (cadr err) "Searching for program")
+                      ;; The most probable is the lack of the backend bina=
ry.
+                      (signal 'vc-not-supported (cdr err))
+                    (signal (car err) (cdr err))))
+                 (_
+                  (signal (car err) (cdr err))))))
 	    (when (and (not (eq t okstatus))
 		       (or (not (integerp status))
 			   (and okstatus (< okstatus status))))
--8<---------------cut here---------------end--------------->8---

then instead of,

--8<---------------cut here---------------start------------->8---
Warning: (vc-not-supported "Searching for program" "No such file or directo=
ry" "git")
--8<---------------cut here---------------end--------------->8---

the report is,

--8<---------------cut here---------------start------------->8---
VC refresh error: (void-function _)
--8<---------------cut here---------------end--------------->8---

Well, I do not know how to avoid the =E2=80=99pcase=E2=80=99 here to correc=
tly propagate
the errors.


About the other =E2=80=99pcase=E2=80=99, this code,

--8<---------------cut here---------------start------------->8---
       ((setq backend (condition-case err
                          (vc-backend buffer-file-name)
                        ((vc-not-supported
                          (message "Warning: %S" err))
                         (_
                          (message "VC refresh error: %S" err)))))
--8<---------------cut here---------------end--------------->8---

does not raise the correct message.


Somehow, I probably miss how to correctly propagate errors but the patch
is, IMHO, the simplest way.


> Regarding the rest of the patch, could you explain the change in
> vc-bzr-state-heuristic? Looking at the code, I figure the idea was to
> future-proof the parser against some future change in file format, to fall
> back to (slower) calling the 'bzr' program. Are we somehow certain now th=
is is
> not needed?

Nothing has really changed.  The current pattern is:

--8<---------------cut here---------------start------------->8---
      (condition-case err
          (with-temp-buffer
            ...
            (if (not (looking-at "#bazaar dirstate flat format 3"))
                (vc-bzr-state file)     ; Some other unknown format?
              (let* ...)))
        ;; The dirstate file can't be read, or some other problem.
        (error
         (message "Falling back on \"slow\" status detection (%S)" err)
         (vc-bzr-state file)))
--8<---------------cut here---------------end--------------->8---

where it means =E2=80=99vc-bzr-state=E2=80=99 is at two places =E2=80=93 wh=
ich is redundant.
Instead, the pattern,

--8<---------------cut here---------------start------------->8---
      (condition-case err
          (with-temp-buffer
            ...
            (if (not (looking-at "#bazaar dirstate flat format 3"))
                (signal 'error "VC: Bzr dirstate is not flat format 3")
              (let* ...)))
        ;; The dirstate file can't be read, or some other problem.
        (error
         (message "Falling back on \"slow\" status detection (%S)" err)
         (vc-bzr-state file)))
--8<---------------cut here---------------end--------------->8---

is better because it appears only at one location.  Now, knowing if this
test about the BZR format is relevant or not is another story. :-)

The patch is just tweaking how the errors are handled, not the logic
behind.  In another patch, this =E2=80=99vc-bzr-state-heuristic=E2=80=99 co=
uld be split;
as it is done with HG: vc-hg-state calling vc-hg-state-fast falling back
to vc-hg-state-slow =E2=80=93 instead of having the fast (heuristic) includ=
ed.


Let me know how to proceed for helping in the review process.

All the best,
simon




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.

Message received at 57407 <at> debbugs.gnu.org:


Received: (at 57407) by debbugs.gnu.org; 12 Sep 2022 01:08:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 11 21:08:34 2022
Received: from localhost ([127.0.0.1]:43757 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oXXw9-0005so-WA
	for submit <at> debbugs.gnu.org; Sun, 11 Sep 2022 21:08:34 -0400
Received: from mail-wm1-f48.google.com ([209.85.128.48]:55135)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1oXXw7-0005sW-4D
 for 57407 <at> debbugs.gnu.org; Sun, 11 Sep 2022 21:08:32 -0400
Received: by mail-wm1-f48.google.com with SMTP id az6so6149792wmb.4
 for <57407 <at> debbugs.gnu.org>; Sun, 11 Sep 2022 18:08:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date;
 bh=LmF3+DY8hXZQJTi4E73jAJDca2Jw4wbgo+88OKpIxNU=;
 b=fWPNWQBkWlGR5srGYUYUleu1R2vNND4cpsMduzqJt/2ipiJ5D/2lADWjNx88D5fPma
 Cl4AFb6sP0n940J+sIn/vh0niKS/+hXmX1omhGds6dvq/chanqQBhdEPNp75N5ZI1S/9
 50KT1YyL0nrmwwHCk2/FZjo9D4asz/uNKDyqcihvHZS+/Uv1dY4Tmn8u7nCfwVAQIoaP
 sfPvmHxS3cUmKDldJYCYTTXDnSAz2yG8FPGs71PFStKwLDMa9+EaFc3VFFhICgynshV7
 WneDHIAr+NYaTixPNqoNTBZJrYXruAnPAb8Z8Yzuj7G/SVQOSvNPhVTJxEf3iPcCikoB
 GTNg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date;
 bh=LmF3+DY8hXZQJTi4E73jAJDca2Jw4wbgo+88OKpIxNU=;
 b=cuO+wJGr1ANHPdzDPDe018l+VtkYcboNtrAMqgU126hiFv8WgKnHaLDiZO3AZtFXUu
 pZ2gVriF7XrwpsZiLUUv8n1m45EI027M8Lg6SQmgQPPtlpxiuBv7ogxkf3dS81oPRdtE
 hlkSJDAjDwp3PhtJ9L3X5Hzln0DMguSCVJUrMG64ouicixgjb44NlbKpEywIdEBy/2R2
 ulM0HmXOKGrrjyKVFF1TUpRdqoe+zAi/DJvVMMKAa3qbM3pYLzM0hvW9LDS5Jwy22WDX
 rbuMGTclBKQ88RElVcAMxmnA2F+VZeGAQHpiZfOIaDfTt5mkGAHzfffHN+IVnJEkB2C6
 UPjQ==
X-Gm-Message-State: ACgBeo0h8aPyfychvzxgMC4UOiWahLUsi8wVvpkEyjVeyGEHikAWOOeP
 8mlqZRLYQRJ7t9pafjiVSY0=
X-Google-Smtp-Source: AA6agR7ityX+4OKS0Fda3AIEmpm3cMFwRzBjLPnsQBZxvB+CBUYCkbMmNEpkm3esRDfHwYV7dL+c5Q==
X-Received: by 2002:a05:600c:4ec7:b0:3a8:4622:ad27 with SMTP id
 g7-20020a05600c4ec700b003a84622ad27mr12806371wmq.88.1662944905109; 
 Sun, 11 Sep 2022 18:08:25 -0700 (PDT)
Received: from [192.168.0.6] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 g14-20020a05600c4ece00b003a4c6e67f01sm8733625wmq.6.2022.09.11.18.08.24
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 11 Sep 2022 18:08:24 -0700 (PDT)
Message-ID: <f0750a8d-cbfb-0a49-d18c-40c3fd1122b2@HIDDEN>
Date: Mon, 12 Sep 2022 04:08:23 +0300
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.11.0
Subject: =?UTF-8?B?UmU6IGJ1ZyM1NzQwNzogW1BBVENIXSBIYW5kbGUgZXJyb3Igb2Yg4oCZ?=
 =?UTF-8?Q?vc-registered=e2=80=99?=
Content-Language: en-US
To: Simon Tournier <zimon.toutoune@HIDDEN>, 57407 <at> debbugs.gnu.org
References: <87lercwb0o.fsf@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <87lercwb0o.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 57407
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.5 (/)

Hi!

On 25.08.2022 19:20, Simon Tournier wrote:
> Hi,
> 
> Submission (Bug#18481) [0] merged on 2020-08-13 with commit
> 991e145450ec8b02865597bc80fd797e39e81f07 [1] aims to:
> 
> “Notify the user if we errors when querying for registered git files“
> 
> However, the replacement of ’ignore-errors’ by ’with-demoted-errors’
> introduces spurious messages.  This patch proposes to handle the errors
> in a way that:
> 
>   1. the user is still informed (avoid silent error)
>   2. improve the messages trying to be more accurate
>   3. do it for all the VC backends
> 
> 0: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18481
> 1: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=991e145450ec8b02865597bc80fd797e39e81f07
> 
> 
> 
> First, let compare the previous situation with the patched one.  If the
> user runs ’find-file’ in a Git repository without having installed the
> Git binary, then Emacs complains and the error is misleading.
> Reproducer:
> 
> --8<---------------cut here---------------start------------->8---
> $  which git
> which: no git in …
> $ mkdir -p /tmp/Git/.git
> $ emacs -q --batch --eval="(find-file \"/tmp/Git/foo\")"
> Error: (file-missing "Searching for program" "No such file or directory" "git")
> Package vc-mtn is deprecated
> --8<---------------cut here---------------end--------------->8---
> 
> Not having a working Git installation is not an error for opening one
> file belonging to a folder containing a ’.git’ subdirectory.  For
> instance, if an user processes many files reporting many messages, then
> it seems hard to locate the real error, if any.

Do I take this right that the main purpose of the patch is to have the 
"Error: ..." messages replaced with "Warning: ..."?

> Moreover, the messages are inconsistent depending on the VC backend;
> from nothing reported to a backtrace.
> 
> --8<---------------cut here---------------start------------->8---
> $ mkdir -p /tmp/Bzr/.bzr
> $ emacs -q --batch --eval="(find-file \"/tmp/Bzr/foo\")"
> Error: (file-missing "Searching for program" "No such file or directory" "bzr")
> Error: (file-missing "Searching for program" "No such file or directory" "bzr")
> 
> Error: file-missing ("Searching for program" "No such file or directory" "bzr")
> 
> [...]
> 
> Searching for program: No such file or directory, bzr
> --8<---------------cut here---------------end--------------->8---
> 
> Considering the patch, it would become:
> 
> --8<---------------cut here---------------start------------->8---
> $ emacs -q --batch --eval="(find-file \"/tmp/Git/foo\")"
> Warning: (vc-not-supported "Searching for program" "No such file or directory" "git")
> 
> $ emacs -q --batch --eval="(find-file \"/tmp/Bzr/foo\")"
> Falling back on "slow" status detection ((error . "VC: Bzr dirstate is not flat format 3"))
> Warning: (vc-not-supported "Searching for program" "No such file or directory" "bzr")
> --8<---------------cut here---------------end--------------->8---
> 
> and all the VC backends report similarly when something fails.

Some better consistency would be nice indeed.

> Second, I have tested various configurations using Guix (65cabb0) and
> also the Emacs test suite is passing.  However, note that a) I barely
> use VC so b) I am lacking imagination for testing scenarii where the
> bubble error could wrongly propagate and thus would provide an
> unexpected behavior.  Especially with remote as Tramp allows.
> 
> 
> Third, I do not know if it is the correct way for catching the errors.
> The core of the change is:
> 
> --8<---------------cut here---------------start------------->8---
> lisp/vc/vc-dispatcher.el (vc-do-command):
> 
>                (condition-case err
> 	          (setq status (apply #'process-file command nil t nil squeezed))
>                  (error
>                   (pcase (car err)
>                     ('file-missing
>                      (if (string= (cadr err) "Searching for program")
>                          ;; The most probable is the lack of the backend binary.
>                          (signal 'vc-not-supported (cdr err))
>                        (signal (car err) (cdr err))))
>                     (_
>                      (signal (car err) (cdr err))))))
> 
> lisp/vc/vc-hooks.el (vc-refresh-state):
> 
>                        (condition-case err
>                            (vc-backend buffer-file-name)
>                          (error
>                           (pcase (car err)
>                             ('vc-not-supported
>                              (message "Warning: %S" err))
>                             (_
>                              (message "VC refresh error: %S" err)))
>                           nil))
> --8<---------------cut here---------------end--------------->8---
> 
> and the rest of the change is just bubble error propagation from this
> ’vc-do-command’ to this ’vc-refresh-state’.

This general idea seems reasonable.

But you also add a bunch of re-signaling code like

+  (let ((state (condition-case err
+                   (vc-bzr-state-heuristic file)
+                 (error (signal (car err) (cdr err))))))

What is the idea behind this? Why not just keep the call?

And in vc-svn-registered, for example. You re-signal whatever error is 
caught, without any alternative. Do we need the condition-case there at 
all, then?

Furthermore, we'll have to examine the resulting effect on the behavior 
of various backend methods. Apparently, up until now vc-svn-registered 
never signaled an error (swallowed all of them). And now whatever 
callers it has, will need to handle possible errors.

It's probably fine, though. vc-backend is a more popular function, and 
it seems not much is changing for it, since, for some reason, 
vc-refresh-state wrapped its call in with-demoted-errors anyway.

But I think we have other callers of it in-tree, and not all of them 
guard with with-demoted-errors or condition-case. What do you think we 
should do with them?

> It is probably an abuse of ’pcase’.  Is ’cond’ better here?  Last,
> I have not found in the documentation how to differentiate what it is
> raised depending on the error type, hence the ’pcase’.

I think you just need to write the specific error type instead of 
'error' in the handler clause.

Regarding the rest of the patch, could you explain the change in 
vc-bzr-state-heuristic? Looking at the code, I figure the idea was to 
future-proof the parser against some future change in file format, to 
fall back to (slower) calling the 'bzr' program. Are we somehow certain 
now this is not needed?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.

Message received at 57407 <at> debbugs.gnu.org:


Received: (at 57407) by debbugs.gnu.org; 8 Sep 2022 15:25:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 08 11:25:53 2022
Received: from localhost ([127.0.0.1]:59901 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oWJPd-0006EJ-C5
	for submit <at> debbugs.gnu.org; Thu, 08 Sep 2022 11:25:53 -0400
Received: from mail-wr1-f54.google.com ([209.85.221.54]:33536)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1oWJPb-0006Dz-JJ
 for 57407 <at> debbugs.gnu.org; Thu, 08 Sep 2022 11:25:51 -0400
Received: by mail-wr1-f54.google.com with SMTP id k9so26728361wri.0
 for <57407 <at> debbugs.gnu.org>; Thu, 08 Sep 2022 08:25:51 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:to:from:from:to:cc:subject:date;
 bh=KDDtvjqyUxDtAXNNFeWwbyzO4I7hbjo0XUlljUkOMK4=;
 b=aE3Z+BVzZYOERAYdLqquhPwaED94yhSdyoBNdl+Pd0tdhaxZX0xV5Sdp5zpkR3LWhI
 PiyWXyyEXT0ZddYsprxZVf6SPjTf+lFapBVy3gMVjkPDZ+JxO4Oq6PkUnvrSjtfAOCMQ
 +SufEFMfC+ItEh6XlBgCFIzc9CSAlL8S5ihokIp1eMin0HNvz+z4zrJcAWl57G9SocAq
 d8v66fHk40yjTql2aNwxUt6lSi3MlCWhom9rBd2UIQUSbZWFbPCNXcoodqjAk739T71e
 NYU7ynSrQwLeniprYlPi5FX+1FQSJiemZpNcwMAiagHD/FZ0UkznaUVION6dA4ahvp0s
 YbLA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:user-agent:message-id
 :in-reply-to:date:references:subject:to:from:x-gm-message-state:from
 :to:cc:subject:date;
 bh=KDDtvjqyUxDtAXNNFeWwbyzO4I7hbjo0XUlljUkOMK4=;
 b=aH41nbHtgn0mHrWYVPb+jT1spRk1JCN28Knvdojr9dwcTKOFeVET+wdHquNtd5bxME
 8T5dNkxFYmk0rkH+4kO1xb5PwEnlA6PG0xAeBalhWa3Ddg8bn0pUmyMc6V3WhS9cn+xT
 FG2i0gbTGOP865jjQ6lH1BZ0thQD+nm/AoTHuVm75LbnyCnrxciUQDjpsBDaWTNjAGBg
 t9ZYjGKGy+lWh8bbg7GiV8wn3EnzK2t+D6p/hcVVINMA0u6HC+EfqczfMQDq5/poh8sU
 yb2bYsiq1SqrI7G8CBFWUHLRN76RIB4YsaMZ7ALfWJg1tHB3xnj3Y94TWUszufPeZu4d
 IM9g==
X-Gm-Message-State: ACgBeo1T2GuOB+TM4c5Qx5wh0hnKCwjOCLhs2gPOq1CdObt15fEU1cOu
 cNCCBI1+868aGpWDeK3Lvra6/QIBb1w=
X-Google-Smtp-Source: AA6agR66F21+v9byni0PD9Y2wPIZRY6QlkBIh/BEpSIBNmvO5bjUXee7JFagLpSEcoAH5bquNVmGAg==
X-Received: by 2002:a05:6000:18a3:b0:21f:d6a4:1aec with SMTP id
 b3-20020a05600018a300b0021fd6a41aecmr5526889wri.468.1662650745614; 
 Thu, 08 Sep 2022 08:25:45 -0700 (PDT)
Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id
 fc15-20020a05600c524f00b003a5260b8392sm3576239wmb.23.2022.09.08.08.25.44
 for <57407 <at> debbugs.gnu.org>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 08 Sep 2022 08:25:45 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: 57407 <at> debbugs.gnu.org
Subject: Copyright Assignment done (was bug#57407: [PATCH] Handle error of
 =?utf-8?Q?=E2=80=99vc-registered=E2=80=99=29?=
References: <87lercwb0o.fsf@HIDDEN>
Date: Thu, 08 Sep 2022 17:25:31 +0200
In-Reply-To: <87lercwb0o.fsf@HIDDEN> (Simon Tournier's message of "Thu, 25
 Aug 2022 18:20:07 +0200")
Message-ID: <87bkrplwgk.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 57407
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi,

On jeu., 25 ao=C3=BBt 2022 at 18:20, Simon Tournier <zimon.toutoune@HIDDEN=
om> wrote:

> PS: If this patch makes sense for inclusion, then let me know and I will
> complete the Copyright Assignment process.

Just to let you know that now the Copyright Assignment process is
complete.


Cheers,
simon




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.
Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 57407 <at> debbugs.gnu.org:


Received: (at 57407) by debbugs.gnu.org; 4 Sep 2022 21:54:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Sep 04 17:54:48 2022
Received: from localhost ([127.0.0.1]:45852 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oUxZo-0005p2-Bn
	for submit <at> debbugs.gnu.org; Sun, 04 Sep 2022 17:54:48 -0400
Received: from quimby.gnus.org ([95.216.78.240]:33088)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oUxZm-0005om-K4
 for 57407 <at> debbugs.gnu.org; Sun, 04 Sep 2022 17:54:47 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=LWgjVGfPzOx19Jd9tRp0wBMYgv7GtD9Ho0y8TBrjcNY=; b=aFZdXbcB0bk+I/kEzN8M+XeqDp
 IDDh5J7CBibU6pJrfQBwLQwU6aYsBpH+9t1kGRX3LW+IoPw2bIcOWq8C+BK0uG1pXPh7M3H6mvWLy
 gi6GOcoSwNHY3E3F9iD1ePloLgmA34+k7UgtMOjMw7RPSATEW0jh5k2hEwNQ/RM+UIrI=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oUxZd-00034h-TV; Sun, 04 Sep 2022 23:54:39 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Simon Tournier <zimon.toutoune@HIDDEN>
Subject: Re: bug#57407: [PATCH] Handle error of =?utf-8?Q?=E2=80=99vc-regi?=
 =?utf-8?Q?stered=E2=80=99?=
In-Reply-To: <87lercwb0o.fsf@HIDDEN> (Simon Tournier's message of "Thu, 25
 Aug 2022 18:20:07 +0200")
References: <87lercwb0o.fsf@HIDDEN>
X-Now-Playing: Neil Young's _Harvest_: "A Man Needs A Maid"
Date: Sun, 04 Sep 2022 23:54:36 +0200
Message-ID: <87wnai6c0z.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 
 Content preview:  Simon Tournier <zimon.toutoune@HIDDEN> writes: > However,
    the replacement of ’ignore-errors’ by ’with-demoted-errors’ > introduces
    spurious messages. This patch proposes to handle the errors > in a way that:
    > > 1. the user is still inform [...] 
 
 Content analysis details:   (-2.9 points, 5.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
                             [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 57407
Cc: 57407 <at> debbugs.gnu.org, Dmitry Gutov <dgutov@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Simon Tournier <zimon.toutoune@HIDDEN> writes:

> However, the replacement of =E2=80=99ignore-errors=E2=80=99 by =E2=80=99w=
ith-demoted-errors=E2=80=99
> introduces spurious messages.  This patch proposes to handle the errors
> in a way that:
>
>  1. the user is still informed (avoid silent error)
>  2. improve the messages trying to be more accurate
>  3. do it for all the VC backends

Makes sense to me.  Perhaps Dmitry has some comments; added to the CCs.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 25 Aug 2022 16:20:42 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Aug 25 12:20:42 2022
Received: from localhost ([127.0.0.1]:51110 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oRFay-0002kd-SB
	for submit <at> debbugs.gnu.org; Thu, 25 Aug 2022 12:20:41 -0400
Received: from lists.gnu.org ([209.51.188.17]:44728)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1oRFav-0002kU-0U
 for submit <at> debbugs.gnu.org; Thu, 25 Aug 2022 12:20:39 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:56076)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <zimon.toutoune@HIDDEN>)
 id 1oRFam-0002vc-TH
 for bug-gnu-emacs@HIDDEN; Thu, 25 Aug 2022 12:20:36 -0400
Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:39553)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <zimon.toutoune@HIDDEN>)
 id 1oRFah-00064v-9G
 for bug-gnu-emacs@HIDDEN; Thu, 25 Aug 2022 12:20:27 -0400
Received: by mail-wr1-x42d.google.com with SMTP id az27so5254376wrb.6
 for <bug-gnu-emacs@HIDDEN>; Thu, 25 Aug 2022 09:20:20 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:message-id:date:subject:to:from:from:to:cc;
 bh=o+iVlyF7wW8w7iopzv4YWEGKpAC7yv+gzfs98yB0nV0=;
 b=E4GHSedfCEcaaywE7O2t7BhiSJarccgJnlj1RSaJygpHp1VdCRnhLVwDH0h3GJ78zO
 Ct/fpCNSkxET92cCkIbnksA2dYMIPgJfudor79lwVZt6q2OBC5AvT7M62E8YukBo5/vF
 Yx56v/iD8O11DJOdAk87ENqiJ5nGnc+dpZup84hEo3Im+1mjl6EUdSBRGi2WEwIZztDC
 zctyGxUFUy9HH9heLNRs08iHbuemwS5Me3aUAAi/FhFuTVObVShwlXJgJryTVRcI1n+7
 xzWZDU3j96rLNhvUNtOcLPgZ1UyqTrn/CGPb41wN/jXaOu9jjyBjlWy51JAVaOTVT7GV
 8bew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=mime-version:message-id:date:subject:to:from:x-gm-message-state
 :from:to:cc;
 bh=o+iVlyF7wW8w7iopzv4YWEGKpAC7yv+gzfs98yB0nV0=;
 b=ixG6HeqUzomgOtaTt9EdXp9nLKdvWj2H0XwjwGCrdQyeMV+R8gHtLUcIFbLDTKvHag
 OY0+13w9Nf6tVaehV9N8rP2tOExscB7nNPunBnJk8+6pp0jTmOaEoXQKGG4BKfDsTJeK
 dyPVA1C+3yjiD2qPDyEOM1SXZzb+uXUII4F621wi0QRZDgcNVaIgcKjaDdJaIxzbXyjD
 iP0OZNRYu3RjvEJg7KCfZ1oHg/A4h8TMEOp4tWuFuMF605QjHhq+tbEahM4ZnL81MFyt
 s5vevNC1qhFPZdPY13n09qBmiko5Y3JJCwmPoccB+KZQHM0WyiXfLRXaHTN6Iha8tSh5
 U8eQ==
X-Gm-Message-State: ACgBeo3OXlPlJ85o0P+6puPu6HAJNZg3l6yYIhlpjAsKJi+RnUU3rSVg
 eOjVto3sZtL5ZzunEpD7CXnktlIeOms=
X-Google-Smtp-Source: AA6agR48zyZNss7BEY/5Z+6aPF5+ir4kpUBf9RATUyXVerM8ZHB0L4Jd2a+AaR6zaXxTj83W4yUEGA==
X-Received: by 2002:adf:e78c:0:b0:225:2de2:940d with SMTP id
 n12-20020adfe78c000000b002252de2940dmr2639936wrm.686.1661444418910; 
 Thu, 25 Aug 2022 09:20:18 -0700 (PDT)
Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id
 v2-20020a5d6b02000000b0021e30e9e44asm19701949wrw.53.2022.08.25.09.20.17
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 25 Aug 2022 09:20:17 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Handle error of =?utf-8?Q?=E2=80=99vc-registered=E2=80=99?=
Date: Thu, 25 Aug 2022 18:20:07 +0200
Message-ID: <87lercwb0o.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=2a00:1450:4864:20::42d;
 envelope-from=zimon.toutoune@HIDDEN; helo=mail-wr1-x42d.google.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, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi,

Submission (Bug#18481) [0] merged on 2020-08-13 with commit
991e145450ec8b02865597bc80fd797e39e81f07 [1] aims to:

=E2=80=9CNotify the user if we errors when querying for registered git file=
s=E2=80=9C

However, the replacement of =E2=80=99ignore-errors=E2=80=99 by =E2=80=99wit=
h-demoted-errors=E2=80=99
introduces spurious messages.  This patch proposes to handle the errors
in a way that:

 1. the user is still informed (avoid silent error)
 2. improve the messages trying to be more accurate
 3. do it for all the VC backends

0: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D18481
1: https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3D991e145450ec8b0=
2865597bc80fd797e39e81f07



First, let compare the previous situation with the patched one.  If the
user runs =E2=80=99find-file=E2=80=99 in a Git repository without having in=
stalled the
Git binary, then Emacs complains and the error is misleading.
Reproducer:

--8<---------------cut here---------------start------------->8---
$  which git
which: no git in =E2=80=A6
$ mkdir -p /tmp/Git/.git
$ emacs -q --batch --eval=3D"(find-file \"/tmp/Git/foo\")"
Error: (file-missing "Searching for program" "No such file or directory" "g=
it")
Package vc-mtn is deprecated
--8<---------------cut here---------------end--------------->8---

Not having a working Git installation is not an error for opening one
file belonging to a folder containing a =E2=80=99.git=E2=80=99 subdirectory=
.  For
instance, if an user processes many files reporting many messages, then
it seems hard to locate the real error, if any.


Moreover, the messages are inconsistent depending on the VC backend;
from nothing reported to a backtrace.

--8<---------------cut here---------------start------------->8---
$ mkdir -p /tmp/Bzr/.bzr
$ emacs -q --batch --eval=3D"(find-file \"/tmp/Bzr/foo\")"
Error: (file-missing "Searching for program" "No such file or directory" "b=
zr")
Error: (file-missing "Searching for program" "No such file or directory" "b=
zr")

Error: file-missing ("Searching for program" "No such file or directory" "b=
zr")

[...]

Searching for program: No such file or directory, bzr
--8<---------------cut here---------------end--------------->8---

Considering the patch, it would become:

--8<---------------cut here---------------start------------->8---
$ emacs -q --batch --eval=3D"(find-file \"/tmp/Git/foo\")"
Warning: (vc-not-supported "Searching for program" "No such file or directo=
ry" "git")

$ emacs -q --batch --eval=3D"(find-file \"/tmp/Bzr/foo\")"
Falling back on "slow" status detection ((error . "VC: Bzr dirstate is not =
flat format 3"))
Warning: (vc-not-supported "Searching for program" "No such file or directo=
ry" "bzr")
--8<---------------cut here---------------end--------------->8---

and all the VC backends report similarly when something fails.


Second, I have tested various configurations using Guix (65cabb0) and
also the Emacs test suite is passing.  However, note that a) I barely
use VC so b) I am lacking imagination for testing scenarii where the
bubble error could wrongly propagate and thus would provide an
unexpected behavior.  Especially with remote as Tramp allows.


Third, I do not know if it is the correct way for catching the errors.
The core of the change is:

--8<---------------cut here---------------start------------->8---
lisp/vc/vc-dispatcher.el (vc-do-command):

              (condition-case err
	          (setq status (apply #'process-file command nil t nil squeezed))
                (error
                 (pcase (car err)
                   ('file-missing
                    (if (string=3D (cadr err) "Searching for program")
                        ;; The most probable is the lack of the backend bin=
ary.
                        (signal 'vc-not-supported (cdr err))
                      (signal (car err) (cdr err))))
                   (_
                    (signal (car err) (cdr err))))))

lisp/vc/vc-hooks.el (vc-refresh-state):

                      (condition-case err
                          (vc-backend buffer-file-name)
                        (error
                         (pcase (car err)
                           ('vc-not-supported
                            (message "Warning: %S" err))
                           (_
                            (message "VC refresh error: %S" err)))
                         nil))
--8<---------------cut here---------------end--------------->8---

and the rest of the change is just bubble error propagation from this
=E2=80=99vc-do-command=E2=80=99 to this =E2=80=99vc-refresh-state=E2=80=99.

It is probably an abuse of =E2=80=99pcase=E2=80=99.  Is =E2=80=99cond=E2=80=
=99 better here?  Last,
I have not found in the documentation how to differentiate what it is
raised depending on the error type, hence the =E2=80=99pcase=E2=80=99.


I hope all this is helpful and going in the right direction for
improving the reported messages.  If not, let me know what could be
better.

Cheers,
simon


PS: If this patch makes sense for inclusion, then let me know and I will
complete the Copyright Assignment process.

Simon Tournier (1):
  Handle error of 'vc-registered'

 lisp/vc/vc-bzr.el        | 82 ++++++++++++++++++++--------------------
 lisp/vc/vc-dispatcher.el | 12 +++++-
 lisp/vc/vc-git.el        | 24 +++++++-----
 lisp/vc/vc-hg.el         | 13 +++----
 lisp/vc/vc-hooks.el      | 11 +++++-
 lisp/vc/vc-svn.el        |  5 +--
 6 files changed, 84 insertions(+), 63 deletions(-)


base-commit: 1007800a5994ac49b6bc9cd7528edb2d709d2031
--=20
2.36.0


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment;
 filename=0001-Handle-error-of-vc-registered.patch
Content-Description: the.patch

From befbe14487c1ba4ee2a98edb8dc6ef1f111d9fbd Mon Sep 17 00:00:00 2001
From: Simon Tournier <zimon.toutoune@HIDDEN>
Date: Thu, 25 Aug 2022 02:47:03 +0200
Subject: [PATCH 1/1] Handle error of 'vc-registered'

This follows up commit 991e145450ec8b02865597bc80fd797e39e81f07:

2020-08-13 "Notify the user if we errors when querying for registered
git files"

closing Bug#18481.

* lisp/vc/vc-bzr.el (vc-bzr-state-heuristic): Raise an error for
unknown Bazaar dirstate format.
(vc-bzr-registered): Catch the error.
(vc-bzr-status): Tweak error catch.

* lisp/vc/vc-dispatcher.el (vc-do-command): Catch errors of command
run synchronously.

* lisp/vc/vc-git.el (vc-git-registered): Raise the errors reported by
'vc-git-command'.

* lisp/vc/vc-hg.el (vc-hg-registered): Avoid unnecessary calls by
directly call specialized 'vc-hg-state', replace generic
'process-file' by specialized 'vc-hg-command', do not ignore errors.

* lisp/vc/vc-hooks.el (vc-refresh-state): Notify accordindly to the
failure.

* lisp/vc/vc-svn.el (vc-svn-registered): Raise the errors.
---
 lisp/vc/vc-bzr.el        | 82 ++++++++++++++++++++--------------------
 lisp/vc/vc-dispatcher.el | 12 +++++-
 lisp/vc/vc-git.el        | 24 +++++++-----
 lisp/vc/vc-hg.el         | 13 +++----
 lisp/vc/vc-hooks.el      | 11 +++++-
 lisp/vc/vc-svn.el        |  5 +--
 6 files changed, 84 insertions(+), 63 deletions(-)

diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index f6b17d4ce0..7bfb3d0ed3 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -226,7 +226,7 @@ vc-bzr-state-heuristic
             (insert-file-contents dirstate)
             (goto-char (point-min))
             (if (not (looking-at "#bazaar dirstate flat format 3"))
-                (vc-bzr-state file)     ; Some other unknown format?
+                (signal 'error "VC: Bzr dirstate is not flat format 3")
               (let* ((relfile (file-relative-name file root))
                      (reldir (file-name-directory relfile)))
                 (cond
@@ -314,7 +314,9 @@ vc-bzr-state-heuristic
 
 (defun vc-bzr-registered (file)
   "Return non-nil if FILE is registered with bzr."
-  (let ((state (vc-bzr-state-heuristic file)))
+  (let ((state (condition-case err
+                   (vc-bzr-state-heuristic file)
+                 (error (signal (car err) (cdr err))))))
     (not (memq state '(nil unregistered ignored)))))
 
 (defconst vc-bzr-state-words
@@ -445,45 +447,45 @@ vc-bzr-status
 ;; (unchanged . WARNING).  FIXME unchanged is not the best status to
 ;; return in case of error.
   (with-temp-buffer
-    ;; This is with-demoted-errors without the condition-case-unless-debug
-    ;; annoyance, which makes it fail during ert testing.
-    (condition-case err (vc-bzr-command "status" t 0 file)
-      (error (message "Error: %S" err) nil))
     (let ((status 'unchanged))
-      ;; the only secure status indication in `bzr status' output
-      ;; is a couple of lines following the pattern::
-      ;;   | <status>:
-      ;;   |   <file name>
-      ;; if the file is up-to-date, we get no status report from `bzr',
-      ;; so if the regexp search for the above pattern fails, we consider
-      ;; the file to be up-to-date.
-      (goto-char (point-min))
-      (when (re-search-forward
-             ;; bzr prints paths relative to the repository root.
-             (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
-                     (regexp-quote (vc-bzr-file-name-relative file))
-                     ;; Bzr appends a '/' to directory names and
-                     ;; '*' to executable files
-                     (if (file-directory-p file) "/?" "\\*?")
-                     "[ \t\n]*$")
-             nil t)
-        (let ((statusword (match-string 1)))
-          ;; Erase the status text that matched.
-          (delete-region (match-beginning 0) (match-end 0))
-          (setq status
-                (intern (string-replace " " "" statusword)))))
-      (when status
-        (goto-char (point-min))
-        (skip-chars-forward " \n\t") ;Throw away spaces.
-        (cons status
-              ;; "bzr" will output warnings and informational messages to
-              ;; stderr; due to Emacs's `vc-do-command' (and, it seems,
-              ;; `start-process' itself) limitations, we cannot catch stderr
-              ;; and stdout into different buffers.  So, if there's anything
-              ;; left in the buffer after removing the above status
-              ;; keywords, let us just presume that any other message from
-              ;; "bzr" is a user warning, and display it.
-              (unless (eobp) (buffer-substring (point) (point-max))))))))
+      (condition-case err
+          (progn
+            (vc-bzr-command "status" t 0 file)
+            ;; the only secure status indication in `bzr status' output
+            ;; is a couple of lines following the pattern::
+            ;;   | <status>:
+            ;;   |   <file name>
+            ;; if the file is up-to-date, we get no status report from `bzr',
+            ;; so if the regexp search for the above pattern fails, we consider
+            ;; the file to be up-to-date.
+            (goto-char (point-min))
+            (when (re-search-forward
+                   ;; bzr prints paths relative to the repository root.
+                   (concat "^\\(" vc-bzr-state-words "\\):[ \t\n]+"
+                           (regexp-quote (vc-bzr-file-name-relative file))
+                           ;; Bzr appends a '/' to directory names and
+                           ;; '*' to executable files
+                           (if (file-directory-p file) "/?" "\\*?")
+                           "[ \t\n]*$")
+                   nil t)
+              (let ((statusword (match-string 1)))
+                ;; Erase the status text that matched.
+                (delete-region (match-beginning 0) (match-end 0))
+                (setq status
+                      (intern (string-replace " " "" statusword)))))
+            (when status
+              (goto-char (point-min))
+              (skip-chars-forward " \n\t") ;Throw away spaces.
+              (cons status
+                    ;; "bzr" will output warnings and informational messages to
+                    ;; stderr; due to Emacs's `vc-do-command' (and, it seems,
+                    ;; `start-process' itself) limitations, we cannot catch stderr
+                    ;; and stdout into different buffers.  So, if there's anything
+                    ;; left in the buffer after removing the above status
+                    ;; keywords, let us just presume that any other message from
+                    ;; "bzr" is a user warning, and display it.
+                    (unless (eobp) (buffer-substring (point) (point-max))))))
+        (error (signal (car err) (cdr err)))))))
 
 (defun vc-bzr-state (file)
   (let ((result (vc-bzr-status file)))
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index e2a490092b..778d1139fc 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -359,7 +359,17 @@ vc-do-command
 	      (let ((inhibit-message vc-inhibit-message))
 		(message "Running in foreground: %s" full-command)))
 	    (let ((buffer-undo-list t))
-	      (setq status (apply #'process-file command nil t nil squeezed)))
+              (condition-case err
+	          (setq status (apply #'process-file command nil t nil squeezed))
+                (error
+                 (pcase (car err)
+                   ('file-missing
+                    (if (string= (cadr err) "Searching for program")
+                        ;; The most probable is the lack of the backend binary.
+                        (signal 'vc-not-supported (cdr err))
+                      (signal (car err) (cdr err))))
+                   (_
+                    (signal (car err) (cdr err)))))))
 	    (when (and (not (eq t okstatus))
 		       (or (not (integerp status))
 			   (and okstatus (< okstatus status))))
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 46a486a46c..dda00a8089 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -259,15 +259,18 @@ vc-git-registered
                ;; path specs.
                ;; See also: https://marc.info/?l=git&m=125787684318129&w=2
                (name (file-relative-name file dir))
-               (str (with-demoted-errors "Error: %S"
-                      (cd dir)
-                      (vc-git--out-ok "ls-files" "-c" "-z" "--" name)
-                      ;; If result is empty, use ls-tree to check for deleted
-                      ;; file.
-                      (when (eq (point-min) (point-max))
-                        (vc-git--out-ok "ls-tree" "--name-only" "-z" "HEAD"
-                                        "--" name))
-                      (buffer-string))))
+               (str (condition-case err
+                        (progn
+                          (cd dir)
+                          (vc-git-command (current-buffer) nil
+                                          name "ls-files" "-c" "-z" "--")
+                          ;; If result is empty, use ls-tree to check for deleted
+                          ;; file.
+                          (when (eq (point-min) (point-max))
+                            (vc-git-command (current-buffer) nil
+                                            name "ls-tree" "--name-only" "-z" "HEAD" "--"))
+                          (buffer-string))
+                      (error (signal (car err) (cdr err))))))
           (and str
                (> (length str) (length name))
                (string= (substring str 0 (1+ (length name)))
@@ -1775,7 +1778,8 @@ vc-git-command
   "A wrapper around `vc-do-command' for use in vc-git.el.
 The difference to vc-do-command is that this function always invokes
 `vc-git-program'."
-  (let ((coding-system-for-read
+  (let ((inhibit-null-byte-detection t)
+        (coding-system-for-read
          (or coding-system-for-read vc-git-log-output-coding-system))
 	(coding-system-for-write
          (or coding-system-for-write vc-git-commits-coding-system))
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index f4a44df3c2..713f0abd19 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -206,7 +206,7 @@ vc-hg-update-on-retrieve-tag
 (defun vc-hg-registered (file)
   "Return non-nil if FILE is registered with hg."
   (when (vc-hg-root file)           ; short cut
-    (let ((state (vc-state file 'Hg)))  ; expensive
+    (let ((state (vc-hg-state file)))
       (if (memq state '(ignored unregistered nil))
           ;; Clear the cache for proper fallback to another backend.
           (ignore (vc-file-setprop file 'vc-state nil))
@@ -228,23 +228,22 @@ vc-hg-state-slow
           (with-current-buffer
               standard-output
             (setq status
-                  (condition-case nil
-                      ;; Ignore all errors.
+                  (condition-case err
 		      (let ((process-environment
 			     ;; Avoid localization of messages so we
 			     ;; can parse the output.  Disable pager.
 			     (append
 			      (list "TERM=dumb" "LANGUAGE=C" "HGPLAIN=1")
 			      process-environment)))
-			(process-file
-			 vc-hg-program nil t nil
+			(vc-hg-command (current-buffer) nil
+                         (file-relative-name file)
                          "--config" "ui.report_untrusted=0"
 			 "--config" "alias.status=status"
 			 "--config" "defaults.status="
-			 "status" "-A" (file-relative-name file)))
+			 "status" "-A"))
                     ;; Some problem happened.  E.g. We can't find an `hg'
                     ;; executable.
-                    (error nil)))))))
+                    (error (signal (car err) (cdr err)))))))))
     (when (and (eq 0 status)
 	       (> (length out) 0)
 	       (null (string-match ".*: No such file or directory$" out)))
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 1f0eeb7e18..bd9acfc958 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -791,8 +791,15 @@ vc-refresh-state
     (add-hook 'vc-mode-line-hook #'vc-mode-line nil t)
     (let (backend)
       (cond
-       ((setq backend (with-demoted-errors "VC refresh error: %S"
-                        (vc-backend buffer-file-name)))
+       ((setq backend (condition-case err
+                          (vc-backend buffer-file-name)
+                        (error
+                         (pcase (car err)
+                           ('vc-not-supported
+                            (message "Warning: %S" err))
+                           (_
+                            (message "VC refresh error: %S" err)))
+                         nil)))
         ;; Let the backend setup any buffer-local things he needs.
         (vc-call-backend backend 'find-file-hook)
 	;; Compute the state and put it in the mode line.
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index 08b53a7169..7eb529a5d9 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -148,15 +148,14 @@ vc-svn-registered
       (cd (file-name-directory file))
       (let* (process-file-side-effects
 	     (status
-             (condition-case nil
-                 ;; Ignore all errors.
+             (condition-case err
                  (vc-svn-command t t file "status" "-v")
                ;; Some problem happened.  E.g. We can't find an `svn'
                ;; executable.  We used to only catch `file-error' but when
                ;; the process is run on a remote host via Tramp, the error
                ;; is only reported via the exit status which is turned into
                ;; an `error' by vc-do-command.
-               (error nil))))
+               (error (signal (car err) (cdr err))))))
         (when (eq 0 status)
 	  (let ((parsed (vc-svn-parse-status file)))
 	    (and parsed (not (memq parsed '(ignored unregistered))))))))))
-- 
2.36.0


--=-=-=--




Acknowledgement sent to Simon Tournier <zimon.toutoune@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#57407; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 27 Sep 2022 11:45:01 UTC

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