[darcs-devel] [issue2516] Invalid URI error when cloning repo with darcs on windows without curl

Mihai Giurgeanu bugs at darcs.net
Wed Nov 23 07:59:08 UTC 2016


Mihai Giurgeanu <mihai.giurgeanu at gmail.com> added the comment:

Hi Guillaume,

I checked a little bit and I am almost sure that the problem was introduced by the patch http://hub.darcs.net/darcs/darcs-
2.12/patch/109a5667e7cf1f4db879a2aa4076237229f90b09

This patch refactored some things about Darcs.Repository module. One of the things was, I quote, "consistent use of the </> operator from 
System.FilePath". The use of </> operator was extended to building url paths, which, in my opinion is not correct, since the url paths do not depend on 
the platform and local file system as I understand the </> operator does.

The previous code in Darcs.Repository,

    -copyBasicRepoPacked ::
    -  forall p wR wU wT. (RepoPatch p, ApplyState (PrimOf p) ~ Tree, ApplyState p ~ Tree)
    -  => Repository p wR wU wT
    -  -> Verbosity -> UseCache
    -  -> UMask -> RemoteDarcs
    -  -> WithWorkingDir
    -  -> IO ()
    -copyBasicRepoPacked r@(Repo fromDir _ _ _) verb useCache umask rdarcs withWorkingDir =
    -  do let hashURL = fromDir ++ packsDir ++ "pristine"
    -     mPackHash <- (Just <$> gzFetchFilePS hashURL Uncachable) `catchall` (return Nothing)
    -     let hiURL = fromDir ++ "/" ++ darcsdir ++ "/hashed_inventory"
    -     i <- gzFetchFilePS hiURL Uncachable
    -     let currentHash = BS.pack $ inv2pris i
    -     let copyNormally = copyBasicRepoNotPacked r verb useCache umask rdarcs withWorkingDir
    -     case mPackHash of
    -      Just packHash | packHash == currentHash
    -              -> ( copyBasicRepoPacked2 r verb useCache withWorkingDir
    -                    `catchall` do putStrLn "Problem while copying basic pack, copying normally."
    -                                  copyNormally)
    -      _       -> do putVerbose verb $ text "Remote repo has no basic pack or outdated basic pack, copying normally."
    -                    copyNormally

was replaced with the new code in Darcs.Repository.Clone:

    301:                           | copyBasicRepoPacked ::
    302:      ganesh at earth.li  #13 |   forall rt p wR wU wT. (IsRepoType rt, RepoPatch p, ApplyState (PrimOf p) ~ Tree, ApplyState p ~ Tree)
    303:      ganesh at earth.li  #17 |   => Repository rt p wR wU wT -- remote
    304:                           |   -> Repository rt p wR wU wT -- existing empty local repository
    305:  guillaumh at gmail.com   #3 |   -> Verbosity
    306:                           |   -> RemoteDarcs
    307: benjamin.franksen at he   #2 |   -> WithWorkingDir
    308:                           |   -> IO ()
    309:  guillaumh at gmail.com   #3 | copyBasicRepoPacked r@(Repo fromDir _ _ _) toRepo verb rdarcs withWorkingDir =
    310: benjamin.franksen at he   #2 |   do let hashURL = fromDir </> darcsdir </> packsDir </> "pristine"
    311:                           |      mPackHash <- (Just <$> gzFetchFilePS hashURL Uncachable) `catchall` (return Nothing)
    312:                           |      let hiURL = fromDir </> darcsdir </> "hashed_inventory"
    313:                           |      i <- gzFetchFilePS hiURL Uncachable
    314:                           |      let currentHash = BS.pack $ inv2pris i
    315:  guillaumh at gmail.com   #3 |      let copyNormally = copyBasicRepoNotPacked r toRepo verb rdarcs withWorkingDir
    316: benjamin.franksen at he   #2 |      case mPackHash of
    317:                           |       Just packHash | packHash == currentHash
    318:  guillaumh at gmail.com   #3 |               -> ( copyBasicRepoPacked2 r toRepo verb withWorkingDir
    319:                           |                     `catch` \(e :: SomeException) ->
    320:                           |                                do putStrLn ("Exception while getting basic pack:\n" ++ show e)
    321: benjamin.franksen at he   #2 |                                   copyNormally)
    322:                           |       _       -> do putVerbose verb $ text "Remote repo has no basic pack or outdated basic pack, copying normally."
    323:                           |                     copyNormally
    324:                           |


Please note that, in the previous version (one that works with Windows too), the URL was constructed using "/", but in the latest version, the url is 
constrtucted using System.FilePath </> operator.

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


More information about the darcs-devel mailing list