From f3ad9f95f633525b4acb196269b20d4aafff737d Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 27 Oct 2022 22:48:16 -0700 Subject: [PATCH] git: pass old and new view - not full repo - into export function In order to fix #463, I'm going to make us export to Git a little earlier, before finishing the transation. That means we won't have an operation yet, but we don't need that anyway. --- lib/src/git.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/src/git.rs b/lib/src/git.rs index aa23470146..d01d1b945b 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -26,8 +26,8 @@ use crate::backend::CommitId; use crate::commit::Commit; use crate::op_store::{OperationId, RefTarget}; use crate::operation::Operation; -use crate::repo::{MutableRepo, ReadonlyRepo, RepoRef}; -use crate::view::RefName; +use crate::repo::{MutableRepo, ReadonlyRepo}; +use crate::view::{RefName, View}; #[derive(Error, Debug, PartialEq)] pub enum GitImportError { @@ -170,14 +170,12 @@ pub enum GitExportError { InternalGitError(#[from] git2::Error), } -/// Reflect changes between two Jujutsu repo states in the underlying Git repo. +/// Reflect changes between two Jujutsu repo views in the underlying Git repo. pub fn export_changes( - old_repo: RepoRef, - new_repo: RepoRef, + old_view: &View, + new_view: &View, git_repo: &git2::Repository, ) -> Result<(), GitExportError> { - let old_view = old_repo.view(); - let new_view = new_repo.view(); let old_branches: HashSet<_> = old_view.branches().keys().cloned().collect(); let new_branches: HashSet<_> = new_view.branches().keys().cloned().collect(); // TODO: Check that the ref is not pointed to by any worktree's HEAD. @@ -255,7 +253,7 @@ pub fn export_refs( let last_export_op = Operation::new(op_store.clone(), last_export_op_id, last_export_store_op); let old_repo = repo.loader().load_at(&last_export_op); - export_changes(old_repo.as_repo_ref(), repo.as_repo_ref(), git_repo)?; + export_changes(old_repo.view(), repo.view(), git_repo)?; } if let Ok(mut last_export_file) = OpenOptions::new() .write(true)