103
// compared to other version histories. This is because that version history could be associated with a
104
// state transition history with higher version.
105
>
func AddAndSwitchVersionHistory(h *historyspb.VersionHistories, v *historyspb.VersionHistory) (bool, int32, error) {
version_histories.go
106
>
newVersionHistoryIndex, err := AddVersionHistory(h, v)
107
>
if err != nil {
108
return false, 0, err
109
}
110
111
// check if need to switch current branch
113
>
if err != nil {
114
return false, 0, err
115
}
116
>
currentVersionHistory, err := GetVersionHistory(h, h.CurrentVersionHistoryIndex)
version_histories.go
117
>
if err != nil {
118
return false, 0, err
119
}
121
>
if err != nil {
122
return false, 0, err
123
}
124
126
>
if newLastItem.Version > currentLastItem.Version {
127
currentBranchChanged = true
128
h.CurrentVersionHistoryIndex = newVersionHistoryIndex
129
}
131
}
132