fix push status, broken when inParallel was adapted for -threaded
Before pushing ran in its own process, so exitSuccess was the right thing to do, but with the threaded code, that's caught as an exception.
This commit is contained in:
parent
3dce75fb23
commit
40c9973675
2 changed files with 8 additions and 15 deletions
|
@ -92,33 +92,26 @@ pushToRemotes threadname now st mpushmap remotes = do
|
||||||
, show rs
|
, show rs
|
||||||
]
|
]
|
||||||
Command.Sync.updateBranch (Command.Sync.syncBranch branch) g
|
Command.Sync.updateBranch (Command.Sync.syncBranch branch) g
|
||||||
{- TODO git push exits nonzero if the remote
|
|
||||||
- is already up-to-date. This code does not tell
|
|
||||||
- the difference between the two. Could perhaps
|
|
||||||
- be check the refs when it seemed to fail?
|
|
||||||
- Note bewloe -}
|
|
||||||
(succeeded, failed) <- inParallel (push g branch) rs
|
(succeeded, failed) <- inParallel (push g branch) rs
|
||||||
|
let ok = null failed
|
||||||
case mpushmap of
|
case mpushmap of
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just pushmap ->
|
Just pushmap ->
|
||||||
changeFailedPushMap pushmap $ \m ->
|
changeFailedPushMap pushmap $ \m ->
|
||||||
M.union (makemap failed) $
|
M.union (makemap failed) $
|
||||||
M.difference m (makemap succeeded)
|
M.difference m (makemap succeeded)
|
||||||
unless (null failed) $
|
unless (ok) $
|
||||||
debug threadname
|
debug threadname
|
||||||
[ "failed to push to"
|
[ "failed to push to"
|
||||||
, show failed
|
, show failed
|
||||||
]
|
]
|
||||||
if (null failed || not shouldretry)
|
if (ok || not shouldretry)
|
||||||
{- TODO see above TODO item -}
|
then return ok
|
||||||
then return True -- return $ null failed
|
|
||||||
else retry branch g failed
|
else retry branch g failed
|
||||||
|
|
||||||
makemap l = M.fromList $ zip l (repeat now)
|
makemap l = M.fromList $ zip l (repeat now)
|
||||||
|
|
||||||
push g branch remote =
|
push g branch remote = Command.Sync.pushBranch remote branch g
|
||||||
ifM (Command.Sync.pushBranch remote branch g)
|
|
||||||
( exitSuccess, exitFailure)
|
|
||||||
|
|
||||||
retry branch g rs = do
|
retry branch g rs = do
|
||||||
debug threadname [ "trying manual pull to resolve failed pushes" ]
|
debug threadname [ "trying manual pull to resolve failed pushes" ]
|
||||||
|
|
|
@ -18,7 +18,7 @@ import Control.Exception
|
||||||
-
|
-
|
||||||
- Returns the values partitioned into ones with which the action succeeded,
|
- Returns the values partitioned into ones with which the action succeeded,
|
||||||
- and ones with which it failed. -}
|
- and ones with which it failed. -}
|
||||||
inParallel :: (v -> IO ()) -> [v] -> IO ([v], [v])
|
inParallel :: (v -> IO Bool) -> [v] -> IO ([v], [v])
|
||||||
inParallel a l = do
|
inParallel a l = do
|
||||||
mvars <- mapM thread l
|
mvars <- mapM thread l
|
||||||
statuses <- mapM takeMVar mvars
|
statuses <- mapM takeMVar mvars
|
||||||
|
@ -28,8 +28,8 @@ inParallel a l = do
|
||||||
thread v = do
|
thread v = do
|
||||||
mvar <- newEmptyMVar
|
mvar <- newEmptyMVar
|
||||||
_ <- forkIO $ do
|
_ <- forkIO $ do
|
||||||
r <- try (a v) :: IO (Either SomeException ())
|
r <- try (a v) :: IO (Either SomeException Bool)
|
||||||
case r of
|
case r of
|
||||||
Left _ -> putMVar mvar False
|
Left _ -> putMVar mvar False
|
||||||
Right _ -> putMVar mvar True
|
Right b -> putMVar mvar b
|
||||||
return mvar
|
return mvar
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue