From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#66113: Apply the entire diff buffer Date: Fri, 22 Sep 2023 18:48:49 +0300 Organization: LINKOV.NET Message-ID: <86msxep69i.fsf@mail.linkov.net> References: <86o7hx4a11.fsf@mail.linkov.net> <86v8c2u34b.fsf@mail.linkov.net> <9cb6c329-8a81-414a-00e0-b3d8aa73d037@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20927"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 66113@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 22 18:06:11 2023 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 1qjifR-0005Bq-Nq for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Sep 2023 18:06:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjidT-00062o-EK; Fri, 22 Sep 2023 12:04:07 -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 1qjidE-0005j9-LU for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2023 12:03:52 -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 1qjidE-00071F-CL for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2023 12:03:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjidO-0005IW-Tl for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2023 12:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Sep 2023 16:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66113 X-GNU-PR-Package: emacs Original-Received: via spool by 66113-submit@debbugs.gnu.org id=B66113.169539859620268 (code B ref 66113); Fri, 22 Sep 2023 16:04:02 +0000 Original-Received: (at 66113) by debbugs.gnu.org; 22 Sep 2023 16:03:16 +0000 Original-Received: from localhost ([127.0.0.1]:37164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjice-0005Go-Cx for submit@debbugs.gnu.org; Fri, 22 Sep 2023 12:03:16 -0400 Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]:50881) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjicW-0005G7-42 for 66113@debbugs.gnu.org; Fri, 22 Sep 2023 12:03:11 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 1CB7660002; Fri, 22 Sep 2023 16:02:49 +0000 (UTC) In-Reply-To: <9cb6c329-8a81-414a-00e0-b3d8aa73d037@gutov.dev> (Dmitry Gutov's message of "Fri, 22 Sep 2023 16:49:29 +0300") X-GND-Sasl: juri@linkov.net 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:271114 Archived-At: >>>> + (t >>>> + (dolist (buf buffers) >>>> + (with-current-buffer buf >>>> + (display-buffer buf))) >>>> + (message "%d hunks failed; no buffers saved" failures))))) >>> >>> What happens next in this case? How do you undo in the buffers that had the >>> patch hunks already applied? >> Manually, like in case of ediff-patch-buffer. > > I've never used this, so I don't understand. ediff-patch-buffer is an example when trying to roll back a mess creates more mess with .orig/.rej files. >>> Any change you wanted to work on the idea of the "atomic rollback" as well? >> This would be an unreliable feature: in case of diff-apply creates >> a mess, >> such automatic undo can create more mess, because there are many different >> strategies to undo the mess such as using undo-auto-amalgamate, or >> applying the reverse diff partially, doing more damage in case when >> buffers were already modified before diff-apply. > > How about we save the tips of buffer-undo-list, then in case the buffer > needs reverting, basically 'undo' each of the buffers until the saved "tip" > is reached? I don't have a quick code anippet, but that seems doable. Maybe, but I definitely won't use such an option. >> But fortunately the need to undo will be extremely rare, because >> when patch hunks are already applied, it reports the failure, >> but doesn't modify the source buffer. Therefore there is >> nothing to undo! > > The problem situations is, of course, when one of the hunks (somewhere in > the middle or near the end) fails to apply cleanly or at all. Indeed, this is a problematic case when one of the hunks fails whereas all other hunks are applied cleanly. This sometimes happens when receiving an external patch, but the source already changed. > Another approach would be to first go through the patch and check that all > hunks apply without problems, and then, on the second pass, actually apply > them. This is a better option, thanks for the idea, will try to do this with 'diff-test-hunk' in a loop.