use built-in progress meters for git when in parallel mode
This commit is contained in:
parent
56eabe9b81
commit
f8e700ed06
5 changed files with 22 additions and 9 deletions
|
@ -190,6 +190,6 @@ disableDebugOutput = updateGlobalLogger rootLoggerName $ setLevel NOTICE
|
||||||
commandProgressDisabled :: Annex Bool
|
commandProgressDisabled :: Annex Bool
|
||||||
commandProgressDisabled = withOutputType $ \t -> return $ case t of
|
commandProgressDisabled = withOutputType $ \t -> return $ case t of
|
||||||
QuietOutput -> True
|
QuietOutput -> True
|
||||||
ProgressOutput -> True
|
ParallelOutput _ -> True
|
||||||
JSONOutput -> True
|
JSONOutput -> True
|
||||||
NormalOutput -> False
|
NormalOutput -> False
|
||||||
|
|
|
@ -17,7 +17,7 @@ handleMessage json normal = withOutputType go
|
||||||
where
|
where
|
||||||
go NormalOutput = liftIO normal
|
go NormalOutput = liftIO normal
|
||||||
go QuietOutput = q
|
go QuietOutput = q
|
||||||
go ProgressOutput = q
|
go (ParallelOutput _) = q
|
||||||
go JSONOutput = liftIO $ flushed json
|
go JSONOutput = liftIO $ flushed json
|
||||||
|
|
||||||
q :: Monad m => m ()
|
q :: Monad m => m ()
|
||||||
|
|
|
@ -26,6 +26,14 @@ metered combinemeterupdate key a = go (keySize key)
|
||||||
go (Just size) = meteredBytes combinemeterupdate size a
|
go (Just size) = meteredBytes combinemeterupdate size a
|
||||||
go _ = a (const noop)
|
go _ = a (const noop)
|
||||||
|
|
||||||
|
{- Use when the progress meter is only desired for parallel
|
||||||
|
- mode; as when a command's own progress output is preferred. -}
|
||||||
|
parallelMetered :: Maybe MeterUpdate -> Key -> (MeterUpdate -> Annex a) -> Annex a
|
||||||
|
parallelMetered combinemeterupdate key a = withOutputType go
|
||||||
|
where
|
||||||
|
go (ParallelOutput _) = metered combinemeterupdate key a
|
||||||
|
go _ = a (fromMaybe (const noop) combinemeterupdate)
|
||||||
|
|
||||||
{- Shows a progress meter while performing an action on a given number
|
{- Shows a progress meter while performing an action on a given number
|
||||||
- of bytes. -}
|
- of bytes. -}
|
||||||
meteredBytes :: Maybe MeterUpdate -> Integer -> (MeterUpdate -> Annex a) -> Annex a
|
meteredBytes :: Maybe MeterUpdate -> Integer -> (MeterUpdate -> Annex a) -> Annex a
|
||||||
|
@ -99,5 +107,5 @@ mkStderrRelayer = do
|
||||||
mkStderrEmitter :: Annex (String -> IO ())
|
mkStderrEmitter :: Annex (String -> IO ())
|
||||||
mkStderrEmitter = withOutputType go
|
mkStderrEmitter = withOutputType go
|
||||||
where
|
where
|
||||||
go ProgressOutput = return $ \s -> hPutStrLn stderr ("E: " ++ s)
|
go (ParallelOutput _) = return $ \s -> hPutStrLn stderr ("E: " ++ s)
|
||||||
go _ = return (hPutStrLn stderr)
|
go _ = return (hPutStrLn stderr)
|
||||||
|
|
|
@ -52,6 +52,7 @@ import qualified Remote.GCrypt
|
||||||
import Annex.Path
|
import Annex.Path
|
||||||
import Creds
|
import Creds
|
||||||
import Annex.CatFile
|
import Annex.CatFile
|
||||||
|
import Messages.Progress
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Concurrent.MSampleVar
|
import Control.Concurrent.MSampleVar
|
||||||
|
@ -354,9 +355,11 @@ dropKey r key
|
||||||
|
|
||||||
{- Tries to copy a key's content from a remote's annex to a file. -}
|
{- Tries to copy a key's content from a remote's annex to a file. -}
|
||||||
copyFromRemote :: Remote -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool
|
copyFromRemote :: Remote -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool
|
||||||
copyFromRemote r key file dest _p = copyFromRemote' r key file dest
|
copyFromRemote r key file dest p = metered (Just p) key $
|
||||||
copyFromRemote' :: Remote -> Key -> AssociatedFile -> FilePath -> Annex Bool
|
copyFromRemote' r key file dest
|
||||||
copyFromRemote' r key file dest
|
|
||||||
|
copyFromRemote' :: Remote -> Key -> AssociatedFile -> FilePath -> MeterUpdate -> Annex Bool
|
||||||
|
copyFromRemote' r key file dest meterupdate
|
||||||
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ do
|
| not $ Git.repoIsUrl (repo r) = guardUsable (repo r) (return False) $ do
|
||||||
params <- Ssh.rsyncParams r Download
|
params <- Ssh.rsyncParams r Download
|
||||||
u <- getUUID
|
u <- getUUID
|
||||||
|
@ -434,7 +437,9 @@ copyFromRemote' r key file dest
|
||||||
send bytes
|
send bytes
|
||||||
forever $
|
forever $
|
||||||
send =<< readSV v
|
send =<< readSV v
|
||||||
let feeder = writeSV v . fromBytesProcessed
|
let feeder = \n -> do
|
||||||
|
meterupdate n
|
||||||
|
writeSV v (fromBytesProcessed n)
|
||||||
let cleanup = do
|
let cleanup = do
|
||||||
void $ tryIO $ killThread tid
|
void $ tryIO $ killThread tid
|
||||||
tryNonAsync $
|
tryNonAsync $
|
||||||
|
@ -451,7 +456,7 @@ copyFromRemoteCheap r key file
|
||||||
liftIO $ catchBoolIO $ createSymbolicLink loc file >> return True
|
liftIO $ catchBoolIO $ createSymbolicLink loc file >> return True
|
||||||
| Git.repoIsSsh (repo r) =
|
| Git.repoIsSsh (repo r) =
|
||||||
ifM (Annex.Content.preseedTmp key file)
|
ifM (Annex.Content.preseedTmp key file)
|
||||||
( copyFromRemote' r key Nothing file
|
( metered Nothing key $ copyFromRemote' r key Nothing file
|
||||||
, return False
|
, return False
|
||||||
)
|
)
|
||||||
| otherwise = return False
|
| otherwise = return False
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Types.Messages where
|
||||||
|
|
||||||
import Data.Default
|
import Data.Default
|
||||||
|
|
||||||
data OutputType = NormalOutput | QuietOutput | ProgressOutput | JSONOutput
|
data OutputType = NormalOutput | QuietOutput | ParallelOutput Int | JSONOutput
|
||||||
|
|
||||||
data SideActionBlock = NoBlock | StartBlock | InBlock
|
data SideActionBlock = NoBlock | StartBlock | InBlock
|
||||||
deriving (Eq)
|
deriving (Eq)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue