[darcs-devel] [issue1932] isFile skips real files with colons, breaks "add" in darcs 2.4.98

Dmitry Astapov bugs at darcs.net
Wed Aug 25 17:34:26 UTC 2010


Dmitry Astapov <dastapov at gmail.com> added the comment:

The real issue at hand is with handling
"tricky" characters in file names. On Unix, I can have ':' and '?' or '<' in
my filename, while on Windows they are forbidden. This is supposed to be handled by "--reserved-ok" 
option, so I guess that the official position is that users are allowed
to shoot themselves in the foot however they like.

I am fine with that and will assume this much for the rest of the text. So,
the correct behavior for darcs would be to add files like "aaa:bbb" and even
"c:\src" to the repository, as long as those files really exist and are
really files, and "--reserved-ok" was supplied.

Now, colon has a special role in Darcs, since it is used in names of remote
scp-accessible repositories. It seems that a colon in repository name should
automatically mean that it is either a HTTP repo or an scp repo. Unless we
make a drastical change and start requiring "scp://" in front of the scp
repo names, all colons in repo dir names should be disallowed.

Then, functions in Darcs.URL clearly serve to distinguish between possible
forms of repo names.
* isUrl should be true for names like http://....
* isSsh should be true for all names that are not URLs and containin ':'
* isFile should be true whenever both isSSH and isURL are false.

I browsed through the source and isFile, isSsh, and isUrl are indeed used to
differentiate between possible forms of repository names everywhere, except
for the "isRelative" in URL.hs

My proposal is:
1)Replace isRelative from URL.hs by isRelative from System.FilePath, which
should take into account differences between platforms and handle colon
under unix in sensible way.

2)Submit the proposal to mark ssh-accesible repositories by "ssh://" (see old 
comments at the end of the Darcs.URL description!) and
replace a horrible ad-hoc implementations of isSsh and isFile with much
better ad-hoc implementation:

isSsh f = "ssh://" `isPrefixOf` f
isUrl f = not (isSsh f) && "://" `isInfixOf` f
isFile f = not (isSsh f || isUrl f)

Do you agree?

I'll be submitting the patch for (1) shortly (along with proper test-case).

__________________________________
Darcs bug tracker <bugs at darcs.net>
<http://bugs.darcs.net/issue1932>
__________________________________


More information about the darcs-devel mailing list