unify elipsis handling

And add a simple dots-based progress display, currently only used in v2
upgrade.
This commit is contained in:
Joey Hess 2011-07-19 14:07:23 -04:00
parent ec9e9343d9
commit 00153eed48
22 changed files with 76 additions and 62 deletions

View file

@ -76,7 +76,7 @@ bupSetup u c = do
-- bup init will create the repository.
-- (If the repository already exists, bup init again appears safe.)
showNote "bup init"
showAction "bup init"
bup "init" buprepo [] >>! error "bup init failed"
storeBupUUID u buprepo
@ -93,7 +93,7 @@ bupParams command buprepo params =
bup :: String -> BupRepo -> [CommandParam] -> Annex Bool
bup command buprepo params = do
showProgress -- make way for bup output
showOutput -- make way for bup output
liftIO $ boolSystem "bup" $ bupParams command buprepo params
pipeBup :: [CommandParam] -> Maybe Handle -> Maybe Handle -> IO Bool
@ -109,7 +109,7 @@ bupSplitParams :: Git.Repo -> BupRepo -> Key -> CommandParam -> Annex [CommandPa
bupSplitParams r buprepo k src = do
o <- getConfig r "bup-split-options" ""
let os = map Param $ words o
showProgress -- make way for bup output
showOutput -- make way for bup output
return $ bupParams "split" buprepo
(os ++ [Param "-n", Param (show k), src])
@ -157,7 +157,7 @@ remove _ = do
checkPresent :: Git.Repo -> Git.Repo -> Key -> Annex (Either IOException Bool)
checkPresent r bupr k
| Git.repoIsUrl bupr = do
showNote ("checking " ++ Git.repoDescribe r ++ "...")
showAction $ "checking " ++ Git.repoDescribe r
ok <- onBupRemote bupr boolSystem "git" params
return $ Right ok
| otherwise = liftIO $ try $ boolSystem "git" $ Git.gitCommandLine bupr params
@ -172,7 +172,7 @@ storeBupUUID u buprepo = do
r <- liftIO $ bup2GitRemote buprepo
if Git.repoIsUrl r
then do
showNote "storing uuid"
showAction "storing uuid"
onBupRemote r boolSystem "git"
[Params $ "config annex.uuid " ++ u]
>>! error "ssh failed"

View file

@ -115,7 +115,7 @@ inAnnex r key = if Git.repoIsUrl r
a <- Annex.new r
Annex.eval a (Content.inAnnex key)
checkremote = do
showNote ("checking " ++ Git.repoDescribe r ++ "...")
showAction $ "checking " ++ Git.repoDescribe r
inannex <- onRemote r (boolSystem, False) "inannex"
[Param (show key)]
return $ Right inannex
@ -156,7 +156,7 @@ copyToRemote r key
rsyncHelper :: [CommandParam] -> Annex Bool
rsyncHelper p = do
showProgress -- make way for progress bar
showOutput -- make way for progress bar
res <- liftIO $ rsync p
if res
then return res

View file

@ -98,7 +98,7 @@ runHook :: String -> String -> Key -> Maybe FilePath -> Annex Bool -> Annex Bool
runHook hooktype hook k f a = maybe (return False) run =<< lookupHook hooktype hook
where
run command = do
showProgress -- make way for hook output
showOutput -- make way for hook output
res <- liftIO $ boolSystemEnv
"sh" [Param "-c", Param command] $ hookEnv k f
if res
@ -133,7 +133,7 @@ remove h k = runHook h "remove" k Nothing $ return True
checkPresent :: Git.Repo -> String -> Key -> Annex (Either IOException Bool)
checkPresent r h k = do
showNote ("checking " ++ Git.repoDescribe r ++ "...")
showAction $ "checking " ++ Git.repoDescribe r
v <- lookupHook h "checkpresent"
liftIO (try (check v) ::IO (Either IOException Bool))
where

View file

@ -141,7 +141,7 @@ remove o k = withRsyncScratchDir $ \tmp -> do
checkPresent :: Git.Repo -> RsyncOpts -> Key -> Annex (Either IOException Bool)
checkPresent r o k = do
showNote ("checking " ++ Git.repoDescribe r ++ "...")
showAction $ "checking " ++ Git.repoDescribe r
-- note: Does not currently differnetiate between rsync failing
-- to connect, and the file not being present.
res <- liftIO $ boolSystem "sh" [Param "-c", Param cmd]
@ -174,7 +174,7 @@ withRsyncScratchDir a = do
rsyncRemote :: RsyncOpts -> [CommandParam] -> Annex Bool
rsyncRemote o params = do
showProgress -- make way for progress bar
showOutput -- make way for progress bar
res <- liftIO $ rsync $ rsyncOptions o ++ defaultParams ++ params
if res
then return res

View file

@ -185,7 +185,7 @@ remove r k = s3Action r False $ \(conn, bucket) -> do
checkPresent :: Remote Annex -> Key -> Annex (Either IOException Bool)
checkPresent r k = s3Action r noconn $ \(conn, bucket) -> do
showNote ("checking " ++ name r ++ "...")
showAction $ "checking " ++ name r
res <- liftIO $ getObjectInfo conn $ bucketKey r bucket k
case res of
Right _ -> return $ Right True
@ -241,13 +241,13 @@ iaMunge = (>>= munge)
genBucket :: RemoteConfig -> Annex ()
genBucket c = do
conn <- s3ConnectionRequired c
showNote "checking bucket"
showAction "checking bucket"
loc <- liftIO $ getBucketLocation conn bucket
case loc of
Right _ -> return ()
Left err@(NetworkError _) -> s3Error err
Left (AWSError _ _) -> do
showNote $ "creating bucket in " ++ datacenter
showAction $ "creating bucket in " ++ datacenter
res <- liftIO $ createBucketIn conn bucket datacenter
case res of
Right _ -> return ()

View file

@ -106,7 +106,7 @@ checkKey key = do
checkKey' :: [URLString] -> Annex Bool
checkKey' [] = return False
checkKey' (u:us) = do
showNote ("checking " ++ u)
showAction $ "checking " ++ u
e <- liftIO $ urlexists u
if e then return e else checkKey' us
@ -129,6 +129,6 @@ urlexists url =
download :: [URLString] -> FilePath -> Annex Bool
download [] _ = return False
download (url:us) file = do
showProgress -- make way for curl progress bar
showOutput -- make way for curl progress bar
ok <- liftIO $ boolSystem "curl" [Params "-L -C - -# -o", File file, File url]
if ok then return ok else download us file