| 1161 | } |
| 1162 | |
| 1163 | pub(super) fn sole_operation_head( |
| 1164 | &self, |
| 1165 | scope: OperationScope, |
| 1166 | ) -> Result<OperationId, RepositoryError> { |
| 1167 | let txn = self.pristine.read_txn().map_err(pristine_error)?; |
| 1168 | let heads = txn.get_operation_heads(scope).map_err(pristine_error)?; |
| 1169 | match heads.as_slice() { |
| 1170 | [head] => Ok(*head), |
| 1171 | [] => Err(RepositoryError::OperationNotFound { |
| 1172 | selector: format!("current head of {scope}"), |
| 1173 | }), |
| 1174 | many => Err(RepositoryError::OperationHeadsDiverged { |
| 1175 | scope: scope.to_string(), |
| 1176 | heads: many.iter().map(ToString::to_string).collect(), |
| 1177 | }), |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | /// Return operations reachable from a scope's heads in deterministic causal order. |
| 1182 | /// |