From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Certner Newsgroups: gmane.emacs.bugs Subject: bug#62693: 28.2; VC: CVS: Fix lost file reporting and enable reverting it Date: Thu, 06 Apr 2023 11:51:48 +0200 Message-ID: <2029306.bkXEbi1Pq8@ravel> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2548462.IJazd48b8O" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40878"; mail-complaints-to="usenet@ciao.gmane.io" To: 62693@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 06 11:52:38 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 1pkMII-000AS7-Gn for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 Apr 2023 11:52:38 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pkMHu-0007xs-Bf; Thu, 06 Apr 2023 05:52:14 -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 1pkMHj-0007wr-GP for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 05:52:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pkMHj-0008BP-8R for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 05:52:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pkMHi-00075v-HO for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 05:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Olivier Certner Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Apr 2023 09:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 62693 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168077472127261 (code B ref -1); Thu, 06 Apr 2023 09:52:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Apr 2023 09:52:01 +0000 Original-Received: from localhost ([127.0.0.1]:53452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkMHg-00075d-Nc for submit@debbugs.gnu.org; Thu, 06 Apr 2023 05:52:01 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:33462) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pkMHf-00075V-5C for submit@debbugs.gnu.org; Thu, 06 Apr 2023 05:51:59 -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 1pkMHb-0007wD-5l for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 05:51:57 -0400 Original-Received: from smtp2-g21.free.fr ([212.27.42.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pkMHY-00089D-UX for bug-gnu-emacs@gnu.org; Thu, 06 Apr 2023 05:51:54 -0400 Original-Received: from ravel.localnet (unknown [90.118.140.172]) (Authenticated sender: ocert.dev@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id 3811A2003DC for ; Thu, 6 Apr 2023 11:51:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1680774709; bh=9m2CxfItTWpElK3wV2qbLq0swM6jRrJPhBtdXcVeVa8=; h=From:To:Subject:Date:From; b=A4w7RoWezAJxVjQu3rC1n1PDrFEY0XacFsVbp9faM/TG/EzIeXS0CnuZZSQrwEY+J w9jAIAv0M0ZAmmhgrqpKYiNdnyBiGzE6fiO3eIDm7Xkreoaz9i2bLrATRLw3L4IIde YAOP/W9bSr7OimGEn9xMsSZG8pjv5dRXqWjYlYC3wvsJlaNW5s4LTcK/UD936915Gw JntDeAyEdKKMdB1A42EEp3ibKMWZM6kR2BojnPmOBMs/0LTIZmExqpa5Li55XLUJzV OHNxYNa51r0XpErT+GLYuVU5oXdSsipks0VbJg3uLl/HolwpBLheTf56T7OsuJQHX9 UI/qTlxHgcXjg== Received-SPF: pass client-ip=212.27.42.2; envelope-from=ocert.dev@free.fr; helo=smtp2-g21.free.fr 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_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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:259302 Archived-At: This is a multi-part message in MIME format. --nextPart2548462.IJazd48b8O Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" Hi, When using CVS 1.12.3+, VC dir doesn't list correctly some missing file, including quotes produced by CVS in the file name, then preventing to operate on it. The fix works on all "recent" versions of CVS (1.11 and 1.12). Once this is fixed, it's still not possible to revert such a file yet since `vc-default-revert', called by `vc-cvs-revert', tries to backup the non-existing file (`copy-file' just fails). While here, fixed `vc-cvs-parse-root', which is not correctly reporting whether some repository is local. All three patches can be applied to 'master' directly (e579c9cc33d). Regards. -- Olivier Certner --nextPart2548462.IJazd48b8O Content-Disposition: attachment; filename="0001-VC-CVS-Fix-ROOT-file-parsing.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="unicode-2-0-utf-8"; name="0001-VC-CVS-Fix-ROOT-file-parsing.patch" >From 8302329ab590abe4a8b4f05d32894be93410e10c Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 6 Apr 2023 10:16:33 +0200 Subject: [PATCH 1/3] VC: CVS: Fix ROOT file parsing * lisp/vc/vc-cvs.el (vc-cvs-parse-root): Don't artificially prepend 'x:' in an attempt to preserve ":" at start, and not even compensating for it later on. Function `split-string' with an explicit SEPARATORS doesn't default OMIT-NULLS to t. --- lisp/vc/vc-cvs.el | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 6e0246ea762..695442b98d4 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -846,9 +846,7 @@ vc-cvs-parse-root is `ext'. For an empty string, nil is returned (invalid CVS root)." ;; Split CVS root into colon separated fields (0-4). - ;; The `x:' makes sure, that leading colons are not lost; - ;; `HOST:/PATH' is then different from `:METHOD:/PATH'. - (let* ((root-list (cdr (split-string (concat "x:" root) ":"))) + (let* ((root-list (cdr (split-string root ":"))) (len (length root-list)) ;; All syntactic varieties will get a proper METHOD. (root-list -- 2.39.2 --nextPart2548462.IJazd48b8O Content-Disposition: attachment; filename="0002-VC-CVS-Fix-parsing-of-cvs-qn-update-for-missing-file.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="unicode-2-0-utf-8"; name="0002-VC-CVS-Fix-parsing-of-cvs-qn-update-for-missing-file.patch" >From 64fa9e81277663581e88e6093a8833c4038b170f Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 6 Apr 2023 10:52:23 +0200 Subject: [PATCH 2/3] VC: CVS: Fix parsing of 'cvs -qn update' for missing files for 1.12 * lisp/vc/vc-cvs.el (vc-cvs-after-dir-status): Fix the name reported for missing files in the case of CVS 1.12.3+ where name is quoted in the warning line (it was not before this version). Use instead the following U line, where the name is never quoted on all versions. --- lisp/vc/vc-cvs.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 695442b98d4..039015a50b7 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -953,13 +953,16 @@ vc-cvs-after-dir-status (cdr (assoc (char-after) translation))) result) (cond - ((looking-at "cvs update: warning: \\(.*\\) was lost") + ((looking-at "cvs update: warning: .* was lost") ;; Format is: ;; cvs update: warning: FILENAME was lost ;; U FILENAME - (push (list (match-string 1) 'missing) result) - ;; Skip the "U" line - (forward-line 1)) + ;; with FILENAME in the first line possibly enclosed in + ;; quotes (since CVS 1.12.3). To avoid problems, use the U + ;; line where name is never quoted. + (forward-line 1) + (when (looking-at "^U \\(.*\\)$") + (push (list (match-string 1) 'missing) result))) ((looking-at "cvs update: New directory `\\(.*\\)' -- ignored") (push (list (match-string 1) 'unregistered) result)))) (forward-line 1)) -- 2.39.2 --nextPart2548462.IJazd48b8O Content-Disposition: attachment; filename="0003-VC-Allow-vc-default-revert-and-CVS-to-revert-a-missi.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="unicode-2-0-utf-8"; name="0003-VC-Allow-vc-default-revert-and-CVS-to-revert-a-missi.patch" >From 7840ef7059a160be850aa58086eed992881ea30d Mon Sep 17 00:00:00 2001 From: Olivier Certner Date: Thu, 6 Apr 2023 11:25:33 +0200 Subject: [PATCH 3/3] VC: Allow `vc-default-revert' (and CVS) to revert a missing file * lisp/vc/vc.el (vc-default-revert): Fix reverting a missing file case by not trying to create a backup through `copy-file'. Notably impacts CVS, where `vc-cvs-revert' calls `vc-default-revert'. --- lisp/vc/vc.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 90905edb887..ff42a9e6394 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -3604,7 +3604,8 @@ vc-default-revert (file-buffer (or (get-file-buffer file) (current-buffer)))) (message "Checking out %s..." file) (let ((failed t) - (backup-name (car (find-backup-file-name file)))) + (backup-name (when (file-exists-p file) + (car (find-backup-file-name file))))) (when backup-name (copy-file file backup-name 'ok-if-already-exists 'keep-date) (unless (file-writable-p file) -- 2.39.2 --nextPart2548462.IJazd48b8O--