diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-06 21:27:42 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-06 21:32:08 -0400 |
commit | 8e7de0104702d59e327694451303e8fbe53c9ea5 (patch) | |
tree | d88304288cf83e39984df73410e1a9836217d888 /Command/Log.hs | |
parent | 539f8c6f144e7fa9cb76f34c06417e3c13ff3420 (diff) |
log --before=date
Diffstat (limited to 'Command/Log.hs')
-rw-r--r-- | Command/Log.hs | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/Command/Log.hs b/Command/Log.hs index b28abfc18..3336df873 100644 --- a/Command/Log.hs +++ b/Command/Log.hs @@ -24,6 +24,7 @@ import qualified Git import Git.Command import qualified Remote import qualified Option +import qualified Annex data RefChange = RefChange { changetime :: POSIXTime @@ -32,29 +33,28 @@ data RefChange = RefChange } def :: [Command] -def = [withOptions [afterOption, maxcountOption] $ +def = [withOptions options $ command "log" paramPaths seek "shows location log"] -afterOption :: Option -afterOption = Option.field [] "after" paramDate "show log after date" - -maxcountOption :: Option -maxcountOption = Option.field ['n'] "max-count" paramNumber "limit number of logs displayed" +options :: [Option] +options = + [ Option.field [] "after" paramDate "show log after date" + , Option.field [] "before" paramDate "show log before date" + , Option.field ['n'] "max-count" paramNumber "limit number of logs displayed" + ] seek :: [CommandSeek] -seek = [withField afterOption return $ \afteropt -> - withField maxcountOption return $ \maxcount -> - withFilesInGit $ whenAnnexed $ start afteropt maxcount] +seek = [withValue (concat <$> mapM getoption options) $ \os -> + withFilesInGit $ whenAnnexed $ start os] + where + getoption o = maybe [] (use o) <$> + Annex.getField (Option.name o) + use o v = [Param ("--" ++ Option.name o), Param v] -start :: Maybe String -> Maybe String -> FilePath -> (Key, Backend) -> CommandStart -start afteropt maxcount file (key, _) = do - showLog file =<< readLog <$> getLog key ps +start :: [CommandParam] -> FilePath -> (Key, Backend) -> CommandStart +start os file (key, _) = do + showLog file =<< readLog <$> getLog key os stop - where - ps = concatMap (\(o, p) -> maybe [] p o) - [ (afteropt, \d -> [Param "--after", Param d]) - , (maxcount, \c -> [Param "--max-count", Param c]) - ] showLog :: FilePath -> [RefChange] -> Annex () showLog file ps = do @@ -87,13 +87,13 @@ showLog file ps = do [ addel, time, file, "|", r ] getLog :: Key -> [CommandParam] -> Annex [String] -getLog key ps = do +getLog key os = do top <- fromRepo Git.workTree p <- liftIO $ relPathCwdToFile top let logfile = p </> Logs.Location.logFile key inRepo $ pipeNullSplit $ [ Params "log -z --pretty=format:%ct --raw --abbrev=40" - ] ++ ps ++ + ] ++ os ++ [ Param $ show Annex.Branch.fullname , Param "--" , Param logfile |