fix: preserve original branch across tag time travel

This commit is contained in:
Gatefixer
2026-11-27 08:31:12 +00:00
parent 844a621225
commit 2744447960
9 changed files with 439 additions and 147 deletions
+34
View File
@@ -2094,6 +2094,40 @@ impl Table {
})
}
/// The branch to reattach to after time travel, for pickle reopen state.
pub fn _tracking_branch(&self) -> PyResult<Option<String>> {
let inner = self.inner_ref()?;
Ok(inner
.dataset()
.map(|dataset| dataset.tracking_branch())
.unwrap_or_else(|| inner.current_branch()))
}
/// Reopen an exact snapshot without changing the handle's tracking branch.
#[pyo3(signature = (branch, version))]
pub fn _checkout_snapshot(
self_: PyRef<'_, Self>,
branch: Option<String>,
version: u64,
) -> PyResult<Bound<'_, PyAny>> {
let inner = self_.inner_ref()?.clone();
future_into_py(self_.py(), async move {
if let Some(dataset) = inner.dataset() {
dataset
.as_time_travel(Ref::Version(branch, Some(version)))
.await
.infer_error()
} else {
if inner.current_branch() != branch {
return Err(PyValueError::new_err(
"snapshot branch differs from the table handle's branch",
));
}
inner.checkout(version).await.infer_error()
}
})
}
#[pyo3(signature = (version=None))]
pub fn restore(
self_: PyRef<'_, Self>,