Subject: bug#18461: closed (Re: bug#18461: `vc-svn-registered' signals an error if a directory has be (re)moved.)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 24 Feb 2016 01:44:02 +0000

Your bug report

#18461: `vc-svn-registered' signals an error if a directory has be (re)moved.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
18461: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18461
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#18461: `vc-svn-registered' signals an error if a directory has be (re)moved.
From: Lars Ingebrigtsen <[email-masked]>
To: Dmitry Gutov <[email-masked]>
Cc: Stefan Monnier <[email-masked]>, Emilio Lopes <[email-masked]>, [email-masked]
Date: Wed, 24 Feb 2016 12:43:08 +1100
List-Id: <debbugs-submit.debbugs.gnu.org>

Dmitry Gutov <[email-masked]> writes:

> I _think_ this bug may have been fixed in
> 83114ccf77d2a5d59fccbdbda6edefacce1b979e, in the course of fixing
> http://debbugs.gnu.org/21984.

Ok; I'll close the bug.  If it's still a problem, we can reopen...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

Subject: `vc-svn-registered' signals an error if a directory has be (re)moved.
From: Emilio Lopes <[email-masked]>
To: [email-masked]
Date: Fri, 12 Sep 2014 18:09:39 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Here is a typical backtrace:

    Debugger entered--Lisp error: (error "No such directory found via
CDPATH environment variable")
      signal(error ("No such directory found via CDPATH environment variable"))
      error("No such directory found via CDPATH environment variable")
      cd("~/projects/shg/firmware-trunk/master-device-control/system-supervisor/")
      vc-svn-registered("~/projects/shg/firmware-trunk/master-device-control/system-supervisor/")
      apply(vc-svn-registered
"~/projects/shg/firmware-trunk/master-device-control/system-supervisor/")
      vc-call-backend(SVN registered
"~/projects/shg/firmware-trunk/master-device-control/system-supervisor/")
      ...

The following patch seems to fix the problem for me.

Regards,

 Emílio

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog    2014-09-08 13:57:19 +0000
+++ lisp/ChangeLog    2014-09-12 16:00:36 +0000
@@ -1,3 +1,10 @@
+2014-09-12  Emilio C. Lopes  <[email-masked]>
+
+    * vc/vc-svn.el (vc-svn-registered): `cd' to the project root, not
+    to the file's directory, in case the directory has been (re)moved,
+    and do this inside the `ignore-errors' form.
+    (vc-svn-state): Ditto, modulo `ignore-errors'.
+
 2014-09-08  Sam Steingold  <[email-masked]>

     * progmodes/sql.el (sql-send-line-and-next): New command,

=== modified file 'lisp/vc/vc-svn.el'
--- lisp/vc/vc-svn.el    2014-01-01 07:43:34 +0000
+++ lisp/vc/vc-svn.el    2014-09-12 16:00:36 +0000
@@ -135,30 +135,30 @@

 (defun vc-svn-registered (file)
   "Check if FILE is SVN registered."
-  (when (vc-svn-root file)
-    (with-temp-buffer
-      (cd (file-name-directory file))
-      (let* (process-file-side-effects
-         (status
-             (condition-case nil
-                 ;; Ignore all errors.
-                 (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))))
-        (when (eq 0 status)
-      (let ((parsed (vc-svn-parse-status file)))
-        (and parsed (not (memq parsed '(ignored unregistered))))))))))
+  (let ((dir (vc-svn-root file)))
+    (when dir
+      (with-temp-buffer
+        (let* (process-file-side-effects
+               (status
+                (ignore-errors
+                  ;; In case some problem might happen.  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.
+                  (cd dir)
+                  (vc-svn-command t t file "status" "-v"))))
+          (when (eq 0 status)
+            (let ((parsed (vc-svn-parse-status file)))
+              (and parsed (not (memq parsed '(ignored unregistered)))))))))))

 (defun vc-svn-state (file &optional localp)
   "SVN-specific version of `vc-state'."
   (let (process-file-side-effects)
     (setq localp (or localp (vc-stay-local-p file 'SVN)))
     (with-temp-buffer
-      (cd (file-name-directory file))
+      (cd (vc-svn-root file))
       (vc-svn-command t 0 file "status" (if localp "-v" "-u"))
       (vc-svn-parse-status file))))