Work around problem with concurrent-output when in a non-unicode locale by avoiding use of it in such a locale.

Instead -J will behave as if it was built without concurrent-output support
in this situation. Ie, it will be mostly quiet, except when there's an
error.

Note that it's not a problem for a filename to contain invalid utf-8 when
in a utf-8 locale. That is handled ok by concurrent-output. It's only
displaying unicode characters in a non-unicode locale that doesn't work.
This commit is contained in:
Joey Hess 2016-02-14 15:02:42 -04:00
parent d3130930db
commit 0f18636c8a
Failed to extract signature
8 changed files with 82 additions and 45 deletions

View file

@ -53,7 +53,7 @@ performCommandAction Command { cmdcheck = c, cmdname = name } seek cont = do
commandAction :: CommandStart -> Annex ()
commandAction a = withOutputType go
where
go (ConcurrentOutput n) = do
go o@(ConcurrentOutput n _) = do
ws <- Annex.getState Annex.workers
(st, ws') <- if null ws
then do
@ -63,7 +63,7 @@ commandAction a = withOutputType go
l <- liftIO $ drainTo (n-1) ws
findFreeSlot l
w <- liftIO $ async
$ snd <$> Annex.run st (inOwnConsoleRegion run)
$ snd <$> Annex.run st (inOwnConsoleRegion o run)
Annex.changeState $ \s -> s { Annex.workers = Right w:ws' }
go _ = run
run = void $ includeCommandAction a
@ -155,9 +155,13 @@ allowConcurrentOutput :: Annex a -> Annex a
allowConcurrentOutput a = go =<< Annex.getState Annex.concurrentjobs
where
go Nothing = a
go (Just n) = Regions.displayConsoleRegions $
bracket_ (setup n) cleanup a
setup = Annex.setOutput . ConcurrentOutput
go (Just n) = ifM (liftIO concurrentOutputSupported)
( Regions.displayConsoleRegions $
goconcurrent (ConcurrentOutput n True)
, goconcurrent (ConcurrentOutput n False)
)
goconcurrent o = bracket_ (setup o) cleanup a
setup = Annex.setOutput
cleanup = do
finishCommandActions
Annex.setOutput NormalOutput