fuse: simplify state restoration logic

This commit is contained in:
raghu 2021-05-03 22:26:49 -04:00
parent 424d167905
commit 9db61a1566

View File

@ -2010,6 +2010,8 @@
((slog err) (emil moves)) ((slog err) (emil moves))
:: ::
++ take-fuse ++ take-fuse
|^
::
|= [bec=beak =riot] |= [bec=beak =riot]
^+ ..take-fuse ^+ ..take-fuse
?~ riot ?~ riot
@ -2031,33 +2033,24 @@
?. all-done ?. all-done
..take-fuse ..take-fuse
=| rag=rang =| rag=rang
=/ clean-hut-ran hut.ran =/ clean-state ..take-fuse
=/ initial-dome=dome:clay (need (~(got by sto.fiz) bas.fiz)) =/ initial-dome=dome:clay (need (~(got by sto.fiz) bas.fiz))
=/ continuation-yaki=yaki =/ continuation-yaki=yaki
(~(got by hut.ran) (~(got by hit.initial-dome) let.initial-dome)) (~(got by hut.ran) (~(got by hit.initial-dome) let.initial-dome))
=/ parents=(list tako) ~[(~(got by hit.initial-dome) let.initial-dome)] =/ parents=(list tako) ~[(~(got by hit.initial-dome) let.initial-dome)]
=/ merges con.fiz =/ merges con.fiz
::
:: We must ensure that we don't leave garbage around.
:: In all cases we want to clear fiz and restore hut.ran
:: to clean-hut-ran.
::
|- |-
^+ ..take-fuse ^+ ..take-fuse
?~ merges ?~ merges
=/ t=tang [leaf+"{<syd>} fused from {<bas.fiz>} {<con.fiz>}" ~] =/ t=tang [leaf+"{<syd>} fused from {<bas.fiz>} {<con.fiz>}" ~]
=. fiz *melt =. ..take-fuse (done-fuse clean-state %| %fuse-succeded t)
=. hut.ran clean-hut-ran (park | [%| continuation-yaki(p (flop parents))] rag)
=. ..take-fuse (park | [%| continuation-yaki(p (flop parents))] rag)
(done %| %fuse-succeded t)
=/ [bec=beak g=germ] i.merges =/ [bec=beak g=germ] i.merges
=/ ali-dom=dome:clay (need (~(got by sto.fiz) bec)) =/ ali-dom=dome:clay (need (~(got by sto.fiz) bec))
=/ result (merge-helper p.bec q.bec g ali-dom `continuation-yaki) =/ result (merge-helper p.bec q.bec g ali-dom `continuation-yaki)
?- -.result ?- -.result
%| %|
=. fiz *melt (done-fuse clean-state %| %fuse-merge-failed p.result)
=. hut.ran clean-hut-ran
(done %| %fuse-merge-failed p.result)
:: ::
%& %&
=/ merge-result=(unit merge-result) +.result =/ merge-result=(unit merge-result) +.result
@ -2070,9 +2063,7 @@
:: ::
:: If there are merge conflicts send the error and abort the merge :: If there are merge conflicts send the error and abort the merge
:: ::
=. fiz *melt (done-fuse clean-state %& conflicts.u.merge-result)
=. hut.ran clean-hut-ran
(done %& conflicts.u.merge-result)
=/ merged-yaki=yaki =/ merged-yaki=yaki
?- -.new.u.merge-result ?- -.new.u.merge-result
%| %|
@ -2101,6 +2092,15 @@
parents [(~(got by hit.ali-dom) let.ali-dom) parents] parents [(~(got by hit.ali-dom) let.ali-dom) parents]
== ==
== ==
:: +done-fuse: restore state after a fuse is attempted, whether it
:: succeeds or fails.
::
++ done-fuse
|= [to-restore=_..take-fuse result=(each (set path) (pair term tang))]
^+ ..take-fuse
=. fiz.to-restore *melt
(done:to-restore result)
--
:: ::
++ done ++ done
|= result=(each (set path) (pair term tang)) |= result=(each (set path) (pair term tang))