MCPcopy
hub / github.com/wavetermdev/waveterm / ContextUpdatesCommitTx

Function ContextUpdatesCommitTx

pkg/waveobj/ctxupdate.go:97–113  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

95}
96
97func ContextUpdatesCommitTx(ctx context.Context) {
98 updatesVal := ctx.Value(waveObjUpdateKey)
99 if updatesVal == nil {
100 return
101 }
102 updates := updatesVal.(*contextUpdatesType)
103 if len(updates.UpdatesStack) <= 1 {
104 panic(fmt.Errorf("no updates transaction to commit"))
105 }
106 // merge the last two updates
107 curUpdateMap := updates.UpdatesStack[len(updates.UpdatesStack)-1]
108 prevUpdateMap := updates.UpdatesStack[len(updates.UpdatesStack)-2]
109 for k, v := range curUpdateMap {
110 prevUpdateMap[k] = v
111 }
112 updates.UpdatesStack = updates.UpdatesStack[:len(updates.UpdatesStack)-1]
113}
114
115func ContextUpdatesRollbackTx(ctx context.Context) {
116 updatesVal := ctx.Value(waveObjUpdateKey)

Callers 2

WithTxFunction · 0.92
WithTxRtnFunction · 0.92

Calls 1

ValueMethod · 0.80

Tested by

no test coverage detected