all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62693: 28.2; VC: CVS: Fix lost file reporting and enable reverting it
@ 2023-04-06  9:51 Olivier Certner
  2023-04-12 22:48 ` Dmitry Gutov
  0 siblings, 1 reply; 14+ messages in thread
From: Olivier Certner @ 2023-04-06  9:51 UTC (permalink / raw)
  To: 62693

[-- Attachment #1: Type: text/plain, Size: 622 bytes --]

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

[-- Attachment #2: 0001-VC-CVS-Fix-ROOT-file-parsing.patch --]
[-- Type: text/x-patch, Size: 1200 bytes --]

From 8302329ab590abe4a8b4f05d32894be93410e10c Mon Sep 17 00:00:00 2001
From: Olivier Certner <olce.emacs@certner.fr>
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


[-- Attachment #3: 0002-VC-CVS-Fix-parsing-of-cvs-qn-update-for-missing-file.patch --]
[-- Type: text/x-patch, Size: 1735 bytes --]

From 64fa9e81277663581e88e6093a8833c4038b170f Mon Sep 17 00:00:00 2001
From: Olivier Certner <olce.emacs@certner.fr>
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


[-- Attachment #4: 0003-VC-Allow-vc-default-revert-and-CVS-to-revert-a-missi.patch --]
[-- Type: text/x-patch, Size: 1149 bytes --]

From 7840ef7059a160be850aa58086eed992881ea30d Mon Sep 17 00:00:00 2001
From: Olivier Certner <olce.emacs@certner.fr>
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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-04-20 10:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06  9:51 bug#62693: 28.2; VC: CVS: Fix lost file reporting and enable reverting it Olivier Certner
2023-04-12 22:48 ` Dmitry Gutov
2023-04-13 16:40   ` Olivier Certner
2023-04-14 22:59     ` Dmitry Gutov
2023-04-15  9:28       ` Eli Zaretskii
2023-04-17  9:24         ` Olivier Certner
2023-04-17 17:48           ` Eli Zaretskii
2023-04-17 20:10             ` Olivier Certner
2023-04-19  0:54           ` Dmitry Gutov
2023-04-19  8:10             ` Olivier Certner
2023-04-20  8:55             ` Eli Zaretskii
2023-04-20  9:42               ` Olivier Certner
2023-04-20 10:22                 ` Dmitry Gutov
2023-04-17  8:04       ` Olivier Certner

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.