[darcs-users] [patch368] Fix for issue1932

Florent Becker bugs at darcs.net
Wed Sep 1 15:39:57 UTC 2010


Florent Becker <florent.becker at ens-lyon.org> added the comment:

>
>New patches:
>
>[Fix for issue1932
>Dmitry Astapov <dastapov at gmail.com>**20100825173045
> Ignore-this: 68db2c42ef376307271a7f609e62481c
> Do _not_ check for colons in "isRelative" - everything is covered
> inside Add.lhs and governed by use of "--reserved-ok" option.
> 
> Replace isRelative and isAbsolute with functions from System.FilePath
> for correct handling of platform specifics.
>] hunk ./src/Darcs/Commands/Add.lhs 48
>                    , doesFileReallyExist, treeHas, treeHasDir,
treeHasAnycase )
> import Darcs.RepoPath ( SubPath, toFilePath, simpleSubPath, toPath )
> import Darcs.Repository.Prefs ( darcsdirFilter, boringFileFilter )
>-import Data.Maybe ( maybeToList, fromJust )
>+import Data.Maybe ( maybeToList )
> import System.FilePath.Posix ( takeDirectory, (</>) )
> import qualified System.FilePath.Windows as WindowsFilePath
> import Printer( text )
>hunk ./src/Darcs/Commands/Add.lhs 54
> 
> #include "gadts.h"
>+#include "impossible.h"
> 
> addDescription :: String
> addDescription = "Add one or more new files or directories."
>
Why exchange the import of fromJust for the inclusion of impossible? I don't
see the point.

>hunk ./src/Darcs/URL.hs 30
>     * A URL contains the sequence @\":\/\/\"@.
> 
>     * A local filepath does not contain colons, except
>-      as second character (windows drives).
>+      as second character (windows drives) when this
>+      filepath is meant to be used as repository name
> 
>     * A path that is neither a URL nor a local file
>       is an ssh-path.
>hunk ./src/Darcs/URL.hs 56
>     isSshNopath
>   ) where
> 
>+import qualified System.FilePath as FP (isRelative, isAbsolute, isValid)
>+
> #include "impossible.h"
> 
> isRelative :: String -> Bool
>hunk ./src/Darcs/URL.hs 61
>-isRelative (_:':':_) = False
>-isRelative f@(c:_) = isFile f && c /= '/' && c /= '~'
> isRelative "" = bug "Empty filename in isRelative"
>hunk ./src/Darcs/URL.hs 62
>+isRelative f  = FP.isRelative f
> 
> isAbsolute :: String -> Bool
> isAbsolute "" = bug "isAbsolute called with empty filename"
>hunk ./src/Darcs/URL.hs 66
>-isAbsolute f = isFile f && (not $ isRelative f)
>+isAbsolute f = FP.isAbsolute f
>
We are now using the stdlib isRelative and isAbsolute. We still have
isAbsolute = not . isRelative .
 
> isFile :: String -> Bool
>hunk ./src/Darcs/URL.hs 69
>-isFile (_:_:fou) = ':' `notElem` fou
>-isFile _ = True
>+isFile f@(_:_:fou) = ':' `notElem` fou && FP.isValid f
>+isFile f = FP.isValid f
> 
> isUrl :: String -> Bool
> isUrl (':':'/':'/':_:_) = True
>

We still have :

isSsh :: String -> Bool
isSsh s = not (isFile s || isUrl s)

This means (IIUC) that on windows, trying to use a "special" filename
such as "prn" would try to do an "ssh prn". I'm applying this anyway,
but we should give some other error message ("darcs pull prn" --> "no
route to host prn" would be a bit puzzling). Can you do that in a
followup patch?

----------
status: review-in-progress -> accepted-pending-tests

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


More information about the darcs-users mailing list