Unrecord a change from the current view. This removes the change from the view's change log without deleting the change itself. The change remains in the change store and graph, and can be re-applied later. This is similar to Gerrit's workflow where a patch can be removed from a change set, modified, and re-inserted. # Arguments `hash` - Hash of the change to unrecord `options` - Options contro
(
&self,
hash: &Hash,
options: UnrecordOptions,
)
| 213 | /// repo.reinsert_change(&hash, outcome.original_sequence)?; |
| 214 | /// ``` |
| 215 | pub fn unrecord( |
| 216 | &self, |
| 217 | hash: &Hash, |
| 218 | options: UnrecordOptions, |
| 219 | ) -> Result<UnrecordOutcome, RepositoryError> { |
| 220 | // Get write transaction |
| 221 | let mut txn = self |
| 222 | .pristine |
| 223 | .write_txn() |
| 224 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 225 | |
| 226 | // Determine which view to use |
| 227 | let view_name = options.view.as_deref().unwrap_or(&self.current_view); |
| 228 | |
| 229 | // Get the view |
| 230 | let mut view = txn |
| 231 | .open_or_create_view(view_name) |
| 232 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 233 | |
| 234 | // Get internal ID |
| 235 | let change_id = txn |
| 236 | .get_internal(hash) |
| 237 | .map_err(|e| RepositoryError::Database(e.to_string()))? |
| 238 | .ok_or_else(|| RepositoryError::ChangeNotFound { |
| 239 | hash: hash.to_base32(), |
| 240 | })?; |
| 241 | |
| 242 | // Check if this is a dry run |
| 243 | if options.dry_run { |
| 244 | // Preview mode - just return what would happen |
| 245 | let preview = crate::unrecord::preview_unrecord(&txn, &view, &[*hash], &options) |
| 246 | .map_err(|e| RepositoryError::Unrecord(e.to_string()))?; |
| 247 | return Ok(preview); |
| 248 | } |
| 249 | |
| 250 | // Remove the change from the view |
| 251 | let original_seq = txn |
| 252 | .del_change(&mut view, change_id, hash) |
| 253 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 254 | |
| 255 | if original_seq.is_none() { |
| 256 | return Err(RepositoryError::Unrecord(format!( |
| 257 | "Change {} is not in view '{}'", |
| 258 | hash.to_base32(), |
| 259 | view_name |
| 260 | ))); |
| 261 | } |
| 262 | |
| 263 | // Update the view |
| 264 | txn.update_view(&view) |
| 265 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 266 | |
| 267 | // Commit the transaction |
| 268 | txn.commit() |
| 269 | .map_err(|e| RepositoryError::Database(e.to_string()))?; |
| 270 | |
| 271 | // ── Post-unrecord: invalidate file index for affected paths ─── |
| 272 | // |
no test coverage detected