diff options
-rw-r--r-- | Messages/Progress.hs | 31 | ||||
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | git-annex.cabal | 11 |
3 files changed, 45 insertions, 5 deletions
diff --git a/Messages/Progress.hs b/Messages/Progress.hs index 9bc335570..25e2e03ae 100644 --- a/Messages/Progress.hs +++ b/Messages/Progress.hs @@ -5,6 +5,8 @@ - Licensed under the GNU GPL version 3 or higher. -} +{-# LANGUAGE CPP #-} + module Messages.Progress where import Common @@ -15,9 +17,15 @@ import Types import Types.Messages import Types.Key +#ifdef WITH_ASCIIPROGRESS import System.Console.AsciiProgress import qualified System.Console.Terminal.Size as Terminal import Control.Concurrent +#else +import Data.Progress.Meter +import Data.Progress.Tracker +import Data.Quantity +#endif {- Shows a progress meter while performing a transfer of a key. - The action is passed a callback to use to update the meter. -} @@ -28,6 +36,7 @@ metered combinemeterupdate key af a = case keySize key of where go _ QuietOutput = nometer go _ JSONOutput = nometer +#ifdef WITH_ASCIIPROGRESS go size _ = do showOutput liftIO $ putStrLn "" @@ -55,20 +64,42 @@ metered combinemeterupdate key af a = case keySize key of complete pg return r +#else + -- Old progress bar code, not suitable for parallel output. + go _ (ParallelOutput _) = do + r <- nometer + liftIO $ putStrLn $ fromMaybe (key2file key) af + return r + go size NormalOutput = do + showOutput + progress <- liftIO $ newProgress "" size + meter <- liftIO $ newMeter progress "B" 25 (renderNums binaryOpts 1) + r <- a $ liftIO . pupdate meter progress + liftIO $ clearMeter stdout meter + return r +#endif +#ifdef WITH_ASCIIPROGRESS pupdate pg n = do let i = fromBytesProcessed n sofar <- stCompleted <$> getProgressStats pg when (i > sofar) $ tickN pg (i - sofar) threadDelay 100 +#else + pupdate meter progress n = do + setP progress $ fromBytesProcessed n + displayMeter stdout meter +#endif maybe noop (\m -> m n) combinemeterupdate nometer = a (const noop) +#ifdef WITH_ASCIIPROGRESS truncatepretty n s | length s > n = take (n-2) s ++ ".." | otherwise = s +#endif {- Use when the progress meter is only desired for parallel - mode; as when a command's own progress output is preferred. -} diff --git a/debian/changelog b/debian/changelog index 53a59875d..980b856c0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,3 @@ - * get, move, copy, mirror: Concurrent downloads and uploads are - now supported! For example: git-annex get -J10 - git-annex (5.20150508.2) UNRELEASED; urgency=medium * import: Refuse to import files that are within the work tree, as that @@ -8,6 +5,11 @@ git-annex (5.20150508.2) UNRELEASED; urgency=medium * drop: Now supports --all, --unused, and --key. * drop: Now defaults to --all when run in a bare repository. (Previously, did nothing when run in a bare repository.) + * get, move, copy, mirror: Concurrent transfers are now supported! + For example: git-annex get -J10 + However, progress bars are not yet displayed for concurrent transfers, + pending an updated version of the ascii-progress library. + * --quiet now makes progress output by rsync, wget, etc be quiet too. -- Joey Hess <id@joeyh.name> Mon, 11 May 2015 12:45:06 -0400 diff --git a/git-annex.cabal b/git-annex.cabal index a67cc8ea5..cf9af63f7 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -93,6 +93,10 @@ Flag DesktopNotify Flag TorrentParser Description: Use haskell torrent library to parse torrent files +Flag AsciiProgress + Description: Use ascii-progress library (experimental) + Default: False + Flag EKG Description: Enable use of EKG to monitor git-annex as it runs (at http://localhost:4242/) Default: False @@ -122,8 +126,7 @@ Executable git-annex monad-control, transformers, bloomfilter, edit-distance, resourcet, http-conduit, http-types, - esqueleto, persistent-sqlite, persistent, persistent-template, - ascii-progress (<= 0.2.1.2), terminal-size + esqueleto, persistent-sqlite, persistent, persistent-template CC-Options: -Wall GHC-Options: -Wall -fno-warn-tabs Extensions: PackageImports @@ -261,6 +264,10 @@ Executable git-annex Build-Depends: torrent (>= 10000.0.0) CPP-Options: -DWITH_TORRENTPARSER + if flag(AsciiProgress) + Build-Depends: ascii-progress (<= 0.2.1.2), terminal-size + CPP-Options: -DWITH_ASCIIPROGRESS + if flag(EKG) Build-Depends: ekg GHC-Options: -with-rtsopts=-T |