Change a view's scope between Draft and Shared. This is useful after `git import` which creates Draft views by default.
(&self, name: &str, scope: ViewScope)
| 176 | /// This is useful after `git import` which creates Draft views by |
| 177 | /// default. |
| 178 | pub fn set_view_scope(&self, name: &str, scope: ViewScope) -> Result<(), RepositoryError> { |
| 179 | let mut txn = self |
| 180 | .pristine |
| 181 | .write_txn() |
| 182 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 183 | |
| 184 | let mut view = txn |
| 185 | .get_view(name) |
| 186 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 187 | .ok_or_else(|| RepositoryError::ViewNotFound { |
| 188 | name: name.to_string(), |
| 189 | })?; |
| 190 | |
| 191 | view.kind = scope; |
| 192 | // Clear parent when promoting to Shared root view |
| 193 | if scope.is_shared() { |
| 194 | view.parent = None; |
| 195 | } |
| 196 | |
| 197 | txn.update_view(&view) |
| 198 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 199 | |
| 200 | txn.commit() |
| 201 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 202 | |
| 203 | Ok(()) |
| 204 | } |
| 205 | |
| 206 | /// Walk the parent chain from `view_name` and return the name of the |
| 207 | /// first Shared view encountered. If `view_name` is itself Shared, |