darcs-graph 0.2 → 0.3.1
raw patch · 3 files changed
+80/−22 lines, 3 filesdep +bytestringdep +containersdep +directorydep ~base
Dependencies added: bytestring, containers, directory, old-time, process
Dependency ranges changed: base
Files
- Graph.hs +29/−12
- LICENSE +27/−0
- darcs-graph.cabal +24/−10
Graph.hs view
@@ -5,7 +5,7 @@ -- -- darcs-graph:--- generate .png graphs of commit activity of a darcs repository, +-- generate .png graphs of commit activity of a darcs repository, -- including a 7 day sliding average -- -- requires gnuplot@@ -40,7 +40,7 @@ tmp :: FilePath tmp = unsafePerformIO $ getTemporaryDirectory -data Flag = DateFlag String | YFlag Int | Help+data Flag = DateFlag String | YFlag Int | Help | OFile FilePath | PName String deriving (Show,Eq) options :: [OptDescr Flag]@@ -49,6 +49,10 @@ "Don't display patches before date. Date is in format \"yyyymmdd\"", Option ['y'] ["y"] (ReqArg (\s -> YFlag (read s)) "INT") "Vertical scale of graphs. Integer.",+ Option ['o'] ["output"] (ReqArg (\s -> OFile s) "FILE")+ "Filename to write output to.",+ Option ['n'] ["name"] (ReqArg (\s -> PName s) "NAME")+ "Name of project used in generated graph.", Option ['h'] ["help"] (NoArg Help) "Display this help" ]@@ -72,6 +76,16 @@ let l' = [i | (YFlag i) <- l] in if null l' then Nothing else Just . head $ l' +getOFile :: [Flag] -> String -> FilePath+getOFile flags proj = case [ s | OFile s <- flags ] of+ [] -> tmp </> proj ++ "-commits.png"+ (fn:_) -> fn++getPName :: [Flag] -> String -> String+getPName flags proj = case [ s | PName s <- flags ] of+ [] -> proj+ (fn:_) -> fn+ data Range = Small | Big | Normal deriving Eq @@ -111,7 +125,8 @@ -- now run gnuplot on the result let proj = (unpack . basename $ path)- script = gnuplotScript f -- handle small repos + out = getOFile flags proj+ script = gnuplotScript f -- handle small repos -- can't generate average with less than 7 points, -- and the sliding line needs 3 points to plot csplines (if length days >= window && length avrg >= 3@@ -123,9 +138,11 @@ else if length days > 2500 then Big else Normal) -- only print days or months if range is ok- proj+ (getPName flags proj) mymax+ out + (ih,_,eh,pid) <- handle (\e -> error $ "Couldn't fork gnuplot: " ++ show e) (do mgnu <- findExecutable "gnuplot"@@ -137,7 +154,7 @@ hGetContents eh >>= putStr -- dump any error output it produces waitForProcess pid - putStrLn $ "Output written to: " ++ tmp </> proj ++ "-commits.png"+ putStrLn $ "Output written to: " ++ out where readFst (a,b) = ((fst . fromJust . C.readInt) a, b)@@ -150,7 +167,7 @@ && f /= pack "unrevert" && not (pack "." `C.isPrefixOf` f) - joinWithSpace s t = B.join (B.singleton 32) [s,t]+ joinWithSpace s t = B.intercalate (B.singleton 32) [s,t] ------------------------------------------------------------------------@@ -210,7 +227,7 @@ sliding [] _ = [] sliding xs days = [ (i,slidingAv i) | i <- days' ] where- m = window `div` 2 -- 1/2 n + m = window `div` 2 -- 1/2 n days' = drop m . take (max 0 (length days - window+m+1)) $ days table = I.fromList xs :: I.IntMap Int -- to handle missing elems easily@@ -223,8 +240,8 @@ -- generate the gnuplot script. only generate the avergage line, if -- there repo day range is larger than a window ---gnuplotScript :: FilePath -> Maybe FilePath -> Range -> String -> Maybe Int -> String-gnuplotScript f mg range p mymax = header ++ case mg of+gnuplotScript :: FilePath -> Maybe FilePath -> Range -> String -> Maybe Int -> FilePath -> String+gnuplotScript f mg range p mymax outFile = header ++ case mg of Nothing -> "plot \""++f++"\" using 1:2 with points pointsize 0.5 pointtype 2\n" Just g -> "plot \"" ++ f++"\" using 1:2 with points pointsize 0.5 pointtype 2, \"" ++@@ -252,9 +269,9 @@ -- ,"set terminal png font Vera 9 xffffff x000000 x404040 xd0d0d0 x0000ff" ,"set terminal png small xffffff x000000 x404040 xd0d0d0 x0000ff"- ,"set output \"" ++ tmp </> p ++"-commits.png\""]+ ,"set output \"" ++ outFile ++ "\""] --- +-- -- ByteString utilities -- @@ -289,7 +306,7 @@ if (dEnt == nullPtr) then return [] else do -- copy entry out before we free:- entry <- C.copyCString =<< d_name dEnt+ entry <- C.packCString =<< d_name dEnt C.length entry `seq` return () -- strictify freeDirEnt dEnt entries <- loop ptr_dEnt dir
+ LICENSE view
@@ -0,0 +1,27 @@+Copyright (c) Don Stewart 2006-07++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:+1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.+2. Redistributions in binary form must reproduce the above copyright+ notice, this list of conditions and the following disclaimer in the+ documentation and/or other materials provided with the distribution.+3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE+ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF+SUCH DAMAGE.
darcs-graph.cabal view
@@ -1,15 +1,29 @@ Name: darcs-graph-Version: 0.2-License: GPL+Version: 0.3.1+License: BSD3 License-file: LICENSE Category: Distribution-Synopsis: Generate pretty graphs of darcs repository activity-Description: Generate pretty graphs of darcs repository activity+Synopsis: Generate graphs of darcs repository activity+Description: Generate graphs of darcs repository activity Author: Don Stewart-Maintainer: dons@cse.unsw.edu.au-Build-Depends: base+Maintainer: dons@galois.com+build-type: Simple+Cabal-Version: >= 1.2 -Executable: darcs-graph-Main-is: Graph.hs-ghc-options: -fglasgow-exts -Wall -Werror -O -funbox-strict-fields -optl-Wl,-s- +flag small_base+ description: Choose the new smaller, split-up base package.++Executable darcs-graph+ Main-is: Graph.hs+ Extensions: CPP+ Ghc-options: -fglasgow-exts -Wall+ + if flag(small_base)+ build-depends: base >= 3,+ process,+ directory,+ old-time,+ bytestring,+ containers+ else+ build-depends: base < 3