filestore 0.3.4 → 0.3.4.1
raw patch · 5 files changed
+41/−15 lines, 5 filesdep −regex-posixPVP ok
version bump matches the API change (PVP)
Dependencies removed: regex-posix
API changes (from Hackage documentation)
Files
- CHANGES +15/−0
- Data/FileStore/Generic.hs +1/−1
- Data/FileStore/Git.hs +14/−7
- Data/FileStore/Utils.hs +9/−5
- filestore.cabal +2/−2
CHANGES view
@@ -1,3 +1,18 @@+Version 0.3.4.1 released 22 Jan 2010++* Rewrote splitEmailAuthor with list fns not regexes.+ Also removed regex-posix from cabal build-depends.++* Corrected error message for richDirectory++* Improved git search:+ + Previously git search would fail in some cases, with an error+ in parseMatchLine (for example, with unicode search term).+ + We replaced the regex with a simpler match-line parser using+ Preface functions.+ + We also now use --null to force a NUL separator in git grep.+ + The test case that previously failed now passes.+ Version 0.3.4 released 10 Dec 2009 * Added Mercurial module and associated tests.
Data/FileStore/Generic.hs view
@@ -143,7 +143,7 @@ richDirectory :: FileStore -> FilePath -> IO [(Resource, Either String Revision)] richDirectory fs fp = directory fs fp >>= mapM f where f r = Control.Exception.catch (g r) (\(e :: FileStoreError)-> return ( r, Left . show $ e ) )- g r@(FSDirectory _dir) = return (r,Left "richDirectory, we don't care about revision info for repos")+ g r@(FSDirectory _dir) = return (r,Left "richDirectory, we don't care about revision info for directories") g res@(FSFile file) = do rev <- revision fs =<< latest fs ( fp </> file ) return (res,Right rev)
Data/FileStore/Git.hs view
@@ -30,7 +30,6 @@ import System.FilePath ((</>)) import System.Directory (createDirectoryIfMissing, doesDirectoryExist, executable, getPermissions, setPermissions) import Control.Exception (throwIO)-import Text.Regex.Posix ((=~)) import Paths_filestore -- | Return a filestore implemented using the git distributed revision control system@@ -129,7 +128,7 @@ -- | Change the name of a resource. gitMove :: FilePath -> FilePath -> FilePath -> Author -> Description -> IO () gitMove repo oldName newName author logMsg = do- gitLatestRevId repo oldName -- will throw a NotFound error if oldName doesn't exist+ _ <- gitLatestRevId repo oldName -- will throw a NotFound error if oldName doesn't exist (statusAdd, err, _) <- withSanityCheck repo [".git"] newName $ runGitCommand repo "mv" [oldName, newName] if statusAdd == ExitSuccess then gitCommit repo [oldName, newName] author logMsg@@ -189,7 +188,7 @@ -- is interpreted as an ordinary string. gitSearch :: FilePath -> SearchQuery -> IO [SearchMatch] gitSearch repo query = do- let opts = ["-I","-n"] +++ let opts = ["-I","-n","--null"] ++ ["--ignore-case" | queryIgnoreCase query] ++ ["--all-match" | queryMatchAll query] ++ ["--word-regexp" | queryWholeWords query]@@ -203,10 +202,18 @@ -- Auxiliary function for searchResults parseMatchLine :: String -> SearchMatch parseMatchLine str =- let (_,_,_,res) = str =~ "^(([^:]|:[^0-9])*):([0-9]*):(.*)$" :: (String, String, String, [String])- in case res of- [fname,_,ln,cont] -> SearchMatch{matchResourceName = fname, matchLineNumber = read ln, matchLine = cont}- e -> error $ "parseMatchLine: (str,e)" ++ show (str,e) -- give better error for failing tests+ SearchMatch{ matchResourceName = fname+ , matchLineNumber = if not (null ln)+ then read ln+ else error $ "parseMatchLine: " ++ str+ , matchLine = cont}+ where (fname,xs) = break (== '\NUL') str+ rest = drop 1 xs + -- for some reason, NUL is used after line number instead of+ -- : when --match-all is passed to git-grep.+ (ln,ys) = span (`elem` ['0'..'9']) rest+ cont = drop 1 ys -- drop : or NUL after line number+ {- -- | Uses git-diff to get a dif between two revisions. gitDiff :: FilePath -> FilePath -> RevisionId -> RevisionId -> IO String
Data/FileStore/Utils.hs view
@@ -38,7 +38,6 @@ import System.FilePath ((</>), takeDirectory) import System.IO (openTempFile, hClose) import System.Process (runProcess, waitForProcess)-import Text.Regex.Posix ((=~)) import qualified Data.ByteString.Lazy as B import Data.FileStore.Types (SearchMatch(..), FileStoreError(IllegalResourceName, NotFound, UnknownError), SearchQuery(..))@@ -146,10 +145,15 @@ -- > splitEmailAuthor "foo bar baz@gmail.com" ~> (Nothing,"foo bar baz@gmail.com") -- > splitEmailAuthor "foo bar <baz@gmail.com>" ~> (Just "baz@gmail.com","foo bar") splitEmailAuthor :: String -> (Maybe String, String)-splitEmailAuthor x = if '<' `elem` x then (Just (tail $ init c), reverse . dropWhile isSpace $ reverse b)- else (Nothing,x)- -- Will still need to trim the '<>' brackets in the email, and whitespace at the end of name- where (_,b,c) = x =~ "[^<]*" :: (String,String,String)+splitEmailAuthor x = (mbEmail, trim name)+ where (name, rest) = break (=='<') x+ mbEmail = if null rest+ then Nothing+ else Just $ takeWhile (/='>') $ drop 1 rest++-- | Trim leading and trailing spaces+trim :: String -> String+trim = reverse . dropWhile isSpace . reverse . dropWhile isSpace -- | Search multiple files with a single regexp. -- This calls out to grep, and so supports the regular expressions grep does.
filestore.cabal view
@@ -1,5 +1,5 @@ Name: filestore-Version: 0.3.4+Version: 0.3.4.1 Cabal-version: >= 1.2 Build-type: Custom Tested-with: GHC==6.10.1@@ -32,7 +32,7 @@ Library Build-depends: base >= 4 && < 5, bytestring, utf8-string, filepath, directory, datetime,- parsec >= 2 && < 3, process, time, datetime, regex-posix, xml, split, Diff, old-locale+ parsec >= 2 && < 3, process, time, datetime, xml, split, Diff, old-locale Exposed-modules: Data.FileStore, Data.FileStore.Types, Data.FileStore.Git, Data.FileStore.Darcs, Data.FileStore.Mercurial, -- Data.FileStore.Sqlite3,