From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#66113: Apply the entire diff buffer Date: Fri, 22 Sep 2023 16:49:29 +0300 Message-ID: <9cb6c329-8a81-414a-00e0-b3d8aa73d037@gutov.dev> References: <86o7hx4a11.fsf@mail.linkov.net> <86v8c2u34b.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23121"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 66113@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 22 15:50:27 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 1qjgY6-0005q9-42 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 22 Sep 2023 15:50:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qjgXZ-0001eM-Dn; Fri, 22 Sep 2023 09:49:53 -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 1qjgXX-0001dq-NT for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2023 09:49:51 -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 1qjgXX-0003Tp-F9 for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2023 09:49:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qjgXi-0001Kr-15 for bug-gnu-emacs@gnu.org; Fri, 22 Sep 2023 09:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Sep 2023 13:50:01 +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.16953905885109 (code B ref 66113); Fri, 22 Sep 2023 13:50:01 +0000 Original-Received: (at 66113) by debbugs.gnu.org; 22 Sep 2023 13:49:48 +0000 Original-Received: from localhost ([127.0.0.1]:35685 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjgXU-0001KL-GO for submit@debbugs.gnu.org; Fri, 22 Sep 2023 09:49:48 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:60067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qjgXT-0001K8-6X for 66113@debbugs.gnu.org; Fri, 22 Sep 2023 09:49:47 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6084E5C00BC; Fri, 22 Sep 2023 09:49:31 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 22 Sep 2023 09:49:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1695390571; x=1695476971; bh=7x0It2K0rehUmygGNKhdXks/u2rUfd4IIz7 eQ6PIIRw=; b=drgffQz83eCb4jTqoddct2D1RWbLcKJhclYk880JGlGRsGHGZOc cVpXEZdLQkU+TVJAuqjpLSB/5vMeSXRrpzKcxWc5uzm5mMwkjA/ir4fKkRPvbXvZ 5UlLZmfVNxci1GSQDYEqm0BICScsTuUtbT2KzDa6tNqP+IArZTEfjxk75EcuRweu bGFU+/PGfOA21oz4/1/8LsBYKSNZuNF/qPRgqM/NFMF79rMn2XXh42AoMCy8ypU4 z/HQevPk9gxdKYqGd3DlKbQ1REZoeeFMFV0VHvQFr6qCAEioBrdQ46O8mce63uES IFfnhALC/d58nPT4aEJCDNg4e7j5UET8i7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1695390571; x=1695476971; bh=7x0It2K0rehUmygGNKhdXks/u2rUfd4IIz7 eQ6PIIRw=; b=f6wMz9x6pmfWuyg5CF+O3gz7+UoSa2QNW9Gq+Kl0Bc2fId62WTw il6pucM54ySqHgZI0/icTthakqf2maAI78E75QpJx1bh5Ostx1JZuXGpft5jDsU2 q3I8i/6vhq3soMtKBeS88IZvoTDJqHDbd4RBvH4TK3QgB/b/Hwoct5OCYpZlBtls cwS+/dYGNQMYHf5N9elRsmPuGSE/zwGn17OXyU897WXvX5kj5E9mkwtK++AIcMqA D3jfNxklRciO1fBrYaZ+pEcsLenThjJ80Syb+BEsgNLwcJq3Yp+5qHhw+K68j3IV jmrHA+wGcpDq9C/pU06UC73KedfGMgm56KQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudekkedggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhepiefgteevheevveffheeltdeukeeiieekueefgedugfefgefhudelgfefveel vdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepug hmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 22 Sep 2023 09:49:30 -0400 (EDT) Content-Language: en-US In-Reply-To: <86v8c2u34b.fsf@mail.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:271099 Archived-At: On 22/09/2023 09:45, Juri Linkov wrote: >>> + (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. >> 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. > 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. 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.