OsPath build flag no longer depends on filepath-bytestring
However, filepath-bytestring is still in Setup-Depends. That's because Utility.OsPath uses it when not built with OsPath. It would be maybe possible to make Utility.OsPath fall back to using filepath, and eliminate that dependency too, but it would mean either wrapping all of System.FilePath's functions, or using `type OsPath = FilePath` Annex.Import uses ifdefs to avoid converting back to FilePath when not on windows. On windows it's a bit slower due to that conversion. Utility.Path.Windows.convertToWindowsNativeNamespace got a bit slower too, but not really worth optimising I think. Note that importing Utility.FileSystemEncoding at the same time as System.Posix.ByteString will result in conflicting definitions for RawFilePath. filepath-bytestring avoids that by importing RawFilePath from System.Posix.ByteString, but that's not possible in Utility.FileSystemEncoding, since Setup-Depends does not include unix. This turned out not to affect any code in git-annex though. Sponsored-by: Leon Schuermann
This commit is contained in:
parent
ce697aa8ae
commit
2ff716be30
13 changed files with 81 additions and 68 deletions
|
@ -6,6 +6,7 @@
|
|||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Annex.Import (
|
||||
ImportTreeConfig(..),
|
||||
|
@ -68,8 +69,10 @@ import Backend.Utilities
|
|||
import Control.Concurrent.STM
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Set as S
|
||||
import qualified System.FilePath.Posix.ByteString as Posix
|
||||
import qualified Data.ByteArray.Encoding as BA
|
||||
#ifdef mingw32_HOST_OS
|
||||
import qualified System.FilePath.Posix as Posix
|
||||
#endif
|
||||
|
||||
{- Configures how to build an import tree. -}
|
||||
data ImportTreeConfig
|
||||
|
@ -428,8 +431,12 @@ buildImportTreesGeneric converttree basetree msubdir importable@(ImportableConte
|
|||
-- Full directory prefix where the sub tree is located.
|
||||
let fullprefix = asTopFilePath $ case msubdir of
|
||||
Nothing -> subdir
|
||||
Just d -> toOsPath $
|
||||
fromOsPath (getTopFilePath d) Posix.</> fromOsPath subdir
|
||||
Just d ->
|
||||
#ifdef mingw32_HOST_OS
|
||||
toOsPath $ fromOsPath (getTopFilePath d) Posix.</> fromOsPath subdir
|
||||
#else
|
||||
getTopFilePath d </> subdir
|
||||
#endif
|
||||
Tree ts <- converttree (Just fullprefix) $
|
||||
map (\(p, i) -> (mkImportLocation p, i))
|
||||
(importableContentsSubTree c)
|
||||
|
@ -1091,7 +1098,11 @@ getImportableContents r importtreeconfig ci matcher = do
|
|||
isknown <||> (matches <&&> notignored)
|
||||
where
|
||||
-- Checks, from least to most expensive.
|
||||
#ifdef mingw32_HOST_OS
|
||||
ingitdir = ".git" `elem` Posix.splitDirectories (fromOsPath (fromImportLocation loc))
|
||||
#else
|
||||
ingitdir = literalOsPath ".git" `elem` splitDirectories (fromImportLocation loc)
|
||||
#endif
|
||||
matches = matchesImportLocation matcher loc sz
|
||||
isknown = isKnownImportLocation dbhandle loc
|
||||
notignored = notIgnoredImportLocation importtreeconfig ci loc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue