Set the current view (internal, does not update working copy). Update the view pointer on disk without materializing. This updates both the in-memory state and persists the change to disk, but does **NOT** update the working copy. The working copy may be left inconsistent with the view pointer — `status()` handles this gracefully (files tracked on other views show as `Added` rather than `Untrac
(
&mut self,
working_copy: WorkingCopyId,
view: &str,
)
| 1216 | /// Returns an error if the view does not exist or the pointer file |
| 1217 | /// cannot be written. |
| 1218 | pub fn set_current_view( |
| 1219 | &mut self, |
| 1220 | working_copy: WorkingCopyId, |
| 1221 | view: &str, |
| 1222 | ) -> Result<(), RepositoryError> { |
| 1223 | // Verify the view exists in the pristine database |
| 1224 | { |
| 1225 | let txn = self |
| 1226 | .pristine |
| 1227 | .read_txn() |
| 1228 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 1229 | |
| 1230 | if txn |
| 1231 | .get_view(view) |
| 1232 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 1233 | .is_none() |
| 1234 | { |
| 1235 | return Err(RepositoryError::ViewNotFound { |
| 1236 | name: view.to_string(), |
| 1237 | }); |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | self.update_working_copy_desired_view(working_copy, view)?; |
| 1242 | self.write_current_view(view)?; |
| 1243 | self.current_view = view.to_string(); |
| 1244 | Ok(()) |
| 1245 | } |
| 1246 | |
| 1247 | /// Align the view pointer without materializing the working copy. |
| 1248 | /// |