Subject: Re: bug#5345: Password asked when visiting a file in a lightweight checkout

From: Juanma Barranquero <[email-masked]>
Date: Sat, 9 Jan 2010 21:08:58 +0100

On Sat, Jan 9, 2010 at 20:20, Dan Nicolaescu <[email-masked]> wrote:

> Is that the correct URL syntax?

Yes. This kind of URL is very common when dealing with files on
Windows. According to RFC 1738 ("Uniform Resource Locators (URL)"),
section 3.10 ("FILES"), the syntax is

     file://<host>/<path>

i.e., the slashes are separators. And "[a]s a special case, <host> can
be the string "localhost" or the empty string; this is interpreted as
`the machine from which the URL is being interpreted'.". So
file:///C:/path is a perfectly valid URL for a local file on Windows,
as a shorthand for file://localhost/C:/path. I'm surprised Unix URLs
for absolute paths do not start with file:////.

> But please do it with a system-type test, /C:/emacs/repo/bugs/5313/ is a
> valid unix file name.  Probably not used too much, but valid, so it
> should not be excluded.

Are you OK with the following patch?

    Juanma

=== modified file 'lisp/vc-bzr.el'
--- lisp/vc-bzr.el	2010-01-06 15:11:52 +0000
+++ lisp/vc-bzr.el	2010-01-09 20:06:10 +0000
@@ -361,6 +361,11 @@
 		     ;; look there for the version information.
 		     (when (re-search-forward "file://\\(.+\\)" nil t)
 		       (let ((l-c-parent-dir (match-string 1)))
+			 (when (and (memq system-type '(ms-dos windows-nt))
+				    (string-match-p "^/[[:alpha:]]:" l-c-parent-dir))
+			   ;;; On Windows, file:// URLs often have three slashes,
+			   ;;; so we must remove the remaining one (bug#5345)
+			   (setq l-c-parent-dir (substring l-c-parent-dir 1)))
 			 (setq branch-format-file
 			       (expand-file-name vc-bzr-admin-branch-format-file
 						 l-c-parent-dir))