mirror of
https://github.com/unisonweb/unison.git
synced 2024-10-05 14:17:33 +03:00
Fix for #294, thanks to @francisdb for identifying root cause
This commit is contained in:
parent
74d9a8980f
commit
2aeae346ee
@ -600,7 +600,11 @@ intersectWithFile branch file =
|
||||
|
||||
|
||||
modify :: (Branch0 -> Branch0) -> Branch -> Branch
|
||||
modify f (Branch b) = Branch $ Causal.step f b
|
||||
modify f b@(Branch causal) = let
|
||||
b0 = head b
|
||||
b1 = f b0
|
||||
in if b1 == b0 then b
|
||||
else Branch $ Causal.cons b1 causal
|
||||
|
||||
append :: Branch0 -> Branch -> Branch
|
||||
append b0 = modify (<> b0)
|
||||
|
@ -516,9 +516,6 @@ notifyUser dir o = case o of
|
||||
allow :: FilePath -> Bool
|
||||
allow = (||) <$> (".u" `isSuffixOf`) <*> (".uu" `isSuffixOf`)
|
||||
|
||||
-- TODO: Return all of these thread IDs so we can throw async exceptions at
|
||||
-- them when we need to quit.
|
||||
|
||||
watchFileSystem :: TQueue Event -> FilePath -> IO (IO ())
|
||||
watchFileSystem q dir = do
|
||||
(cancel, watcher) <- Watch.watchDirectory dir allow
|
||||
@ -527,13 +524,19 @@ watchFileSystem q dir = do
|
||||
atomically . Q.enqueue q $ UnisonFileChanged (Text.pack filePath) text
|
||||
pure (cancel >> killThread t)
|
||||
|
||||
watchBranchUpdates :: TQueue Event -> Codebase IO v a -> IO (IO ())
|
||||
watchBranchUpdates q codebase = do
|
||||
watchBranchUpdates :: IO (Branch, BranchName) -> TQueue Event -> Codebase IO v a -> IO (IO ())
|
||||
watchBranchUpdates currentBranch q codebase = do
|
||||
(cancelExternalBranchUpdates, externalBranchUpdates) <-
|
||||
Codebase.branchUpdates codebase
|
||||
thread <- forkIO . forever $ do
|
||||
updatedBranches <- externalBranchUpdates
|
||||
atomically . Q.enqueue q . UnisonBranchChanged $ updatedBranches
|
||||
(b, bname) <- currentBranch
|
||||
b' <- Codebase.getBranch codebase bname
|
||||
-- We only issue the event if the branch is different than what's already
|
||||
-- in memory. This skips over file events triggered by saving to disk what's
|
||||
-- already in memory.
|
||||
when (b' /= Just b) $
|
||||
atomically . Q.enqueue q . UnisonBranchChanged $ updatedBranches
|
||||
pure (cancelExternalBranchUpdates >> killThread thread)
|
||||
|
||||
warnNote :: String -> String
|
||||
@ -899,7 +902,7 @@ main dir currentBranchName _initialFile startRuntime codebase = do
|
||||
runtime <- startRuntime
|
||||
branchRef <- newIORef (currentBranch, currentBranchName)
|
||||
cancelFileSystemWatch <- watchFileSystem eventQueue dir
|
||||
cancelWatchBranchUpdates <- watchBranchUpdates eventQueue codebase
|
||||
cancelWatchBranchUpdates <- watchBranchUpdates (readIORef branchRef) eventQueue codebase
|
||||
let patternMap =
|
||||
Map.fromList
|
||||
$ validInputs
|
||||
|
@ -196,7 +196,13 @@ loop s = Free.unfold' go s
|
||||
else Editor.addCollisionHandler
|
||||
updateo <- Free.eval $ SlurpFile collisionHandler (currentBranch s) uf'
|
||||
let branch' = updatedBranch updateo
|
||||
doMerge (currentBranchName s) branch'
|
||||
-- Don't bother doing anything if the branch is unchanged by the slurping
|
||||
when (branch' /= currentBranch s) $ do
|
||||
-- This order is important - we tell the app state about the
|
||||
-- branch change before doing the merge, so it knows to ignore
|
||||
-- the file system event that is triggered by `doMerge`
|
||||
Free.eval $ SwitchBranch branch' (currentBranchName s)
|
||||
doMerge (currentBranchName s) branch'
|
||||
Free.eval . Notify $ SlurpOutput updateo
|
||||
pure . Right $ s { currentBranch = branch' }
|
||||
ListBranchesI ->
|
||||
|
Loading…
Reference in New Issue
Block a user