[darcs-users] double dots are not allowed in filenames?

David Roundy daveroundy at gmail.com
Wed Aug 29 14:06:14 UTC 2007


On Wed, Aug 29, 2007 at 01:10:47AM +0300, Yitzchak Gale wrote:
> I wrote:
> >> rcp... man page says:
> >>    Each file or directory argument is
> >>    either a remote file name of the form ``rname at rhost:path'',
> >>    or a local file name
> >>    (containing no `:' characters, or a `/' before any `:'s).
> >> Perhaps darcs should follow that convention.
> 
> David Roundy wrote:
> > Yeah, checking for '/' before ':' would make a lot of sense.
> 
> >> How does darcs distinguish a URL from an rcp-style
> >> remote file?
> >> ...Am I correct that not every legal URL conforming
> > > to RFC 3986 can be accepted?
> 
> > Don't URLs always have :// in them?
> 
> No. But I think it is reasonable for darcs to recognize
> only those that do. So that answers both of my
> questions.
> 
> >> ..."file:" URLs are allowed to
> >> contain ':'. Does darcs support this?
> 
> > In the original poster's situation, any URL is invalid,
> > and it's a pure and simple darcs bug.
> 
> Well, OK, but what is the correct behavior?
> 
> I propose the following algorithm:

I agree, except for one bit (see below)

> In contexts where only local paths make sense,
> we interpret every file spec as a local path.
> (Can that include UNC paths on Windows?
> It would be nice.)

I'm not sure what an UNC path is on windows.

Note, implementing this will require a rather extensive code review.
Eric's put together some code implementing specific data types that
are intended to describe what sort of object a given String is.  I think
switching functions over to use a "LocalPath" type when this is what is
intended should fix this.  Then when reading a "LocalPath" we'll never try
to treat it as a URL.

> Otherwise:

In this case, I think we should have a "UrlPath" data type, which could be
any of the below.  We use UrlPaths almost exclusively for identifying
(possibly remote) repositories, but also (of course) for accessing files
within a repository.

Along the way, we might find it helpful to refactor Repository into two
types: ReadableRepository and LockedRepository (which is writeable), with
the latter holding a LocalPath describing its absolute path.

> 1. If a file spec begins with a valid URI scheme
> name followed by "://", it is a URL.
> 
> 2. If it contains a ':' that is not after a '/', then it is
> an rcp-style remote file. (Even on Windows,
> for consistency.)

On windows, I think we should treat c:/path/to... as a local path (i.e. c
is the drive letter).  If someone really has a one-character hostname, they
can always use a fully-qualified domain name for their scp path.

> 3. Otherwise, it is a local file path (or UNC on
> Windows).
> 
> Note that according to RFC3986, a valid URI
> scheme name is:
> 
> scheme      = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
-- 
David Roundy
http://www.darcs.net


More information about the darcs-users mailing list