diff --git a/lib/src/op_heads_store.rs b/lib/src/op_heads_store.rs index 2bd3b9712..a136439a6 100644 --- a/lib/src/op_heads_store.rs +++ b/lib/src/op_heads_store.rs @@ -187,7 +187,7 @@ fn merge_op_heads( mut op_heads: Vec, ) -> Result { op_heads.sort_by_key(|op| op.store_operation().metadata.end_time.timestamp.clone()); - let base_repo = repo_loader.load_at(&op_heads[0]).unwrap(); + let base_repo = repo_loader.load_at(&op_heads[0]); let mut tx = base_repo.start_transaction("resolve concurrent operations"); let merged_repo = tx.mut_repo(); let neighbors_fn = |op: &Operation| op.parents(); @@ -199,8 +199,8 @@ fn merge_op_heads( &|op: &Operation| op.id().clone(), ) .unwrap(); - let base_repo = repo_loader.load_at(&ancestor_op).unwrap(); - let other_repo = repo_loader.load_at(&other_op_head).unwrap(); + let base_repo = repo_loader.load_at(&ancestor_op); + let other_repo = repo_loader.load_at(&other_op_head); merged_repo.merge(&base_repo, &other_repo); } let op_parent_ids = op_heads.iter().map(|op| op.id().clone()).collect(); diff --git a/lib/src/repo.rs b/lib/src/repo.rs index 559f3ba1d..b5c3ea0ff 100644 --- a/lib/src/repo.rs +++ b/lib/src/repo.rs @@ -254,7 +254,7 @@ impl ReadonlyRepo { user_settings: &UserSettings, wc_path: PathBuf, ) -> Result, RepoLoadError> { - RepoLoader::init(user_settings, wc_path)?.load_at_head() + Ok(RepoLoader::init(user_settings, wc_path)?.load_at_head()) } pub fn loader(&self) -> RepoLoader { @@ -365,11 +365,11 @@ impl ReadonlyRepo { Transaction::new(mut_repo, description) } - pub fn reload(&self) -> Result, RepoLoadError> { + pub fn reload(&self) -> Arc { self.loader().load_at_head() } - pub fn reload_at(&self, operation: &Operation) -> Result, RepoLoadError> { + pub fn reload_at(&self, operation: &Operation) -> Arc { self.loader().load_at(operation) } } @@ -437,13 +437,13 @@ impl RepoLoader { &self.op_heads_store } - pub fn load_at_head(&self) -> Result, RepoLoadError> { + pub fn load_at_head(&self) -> Arc { let op = self.op_heads_store.get_single_op_head(&self).unwrap(); let view = ReadonlyView::new(op.view().take_store_view()); self._finish_load(op, view) } - pub fn load_at(&self, op: &Operation) -> Result, RepoLoadError> { + pub fn load_at(&self, op: &Operation) -> Arc { let view = ReadonlyView::new(op.view().take_store_view()); self._finish_load(op.clone(), view) } @@ -473,11 +473,7 @@ impl RepoLoader { Arc::new(repo) } - fn _finish_load( - &self, - operation: Operation, - view: ReadonlyView, - ) -> Result, RepoLoadError> { + fn _finish_load(&self, operation: Operation, view: ReadonlyView) -> Arc { let working_copy = WorkingCopy::load( self.store.clone(), self.wc_path.clone(), @@ -497,7 +493,7 @@ impl RepoLoader { view, evolution: Mutex::new(None), }; - Ok(Arc::new(repo)) + Arc::new(repo) } } diff --git a/lib/src/working_copy.rs b/lib/src/working_copy.rs index b84d4134b..fdb14e0c5 100644 --- a/lib/src/working_copy.rs +++ b/lib/src/working_copy.rs @@ -778,7 +778,7 @@ impl WorkingCopy { // Reload the repo so the new commit is visible in the index and view // TODO: This is not enough. The new commit is not necessarily still in the // view when we reload. - repo = repo.reload().unwrap(); + repo = repo.reload(); } _ => {} } diff --git a/lib/tests/test_bad_locking.rs b/lib/tests/test_bad_locking.rs index 0ffe331d6..aa5821ed9 100644 --- a/lib/tests/test_bad_locking.rs +++ b/lib/tests/test_bad_locking.rs @@ -145,7 +145,7 @@ fn test_bad_locking_interrupted(use_git: bool) { let initial = testutils::create_random_commit(&settings, &repo) .set_parents(vec![repo.store().root_commit_id().clone()]) .write_to_new_transaction(&repo, "test"); - let repo = repo.reload().unwrap(); + let repo = repo.reload(); // Simulate a crash that resulted in the old op-head left in place. We simulate // it somewhat hackily by copying the .jj/op_heads/ directory before the diff --git a/lib/tests/test_commit_builder.rs b/lib/tests/test_commit_builder.rs index 8e66c3335..c43cf5b44 100644 --- a/lib/tests/test_commit_builder.rs +++ b/lib/tests/test_commit_builder.rs @@ -79,7 +79,7 @@ fn test_rewrite(use_git: bool) { CommitBuilder::for_new_commit(&settings, &store, initial_tree.id().clone()) .set_parents(vec![store.root_commit_id().clone()]) .write_to_new_transaction(&repo, "test"); - let repo = repo.reload().unwrap(); + let repo = repo.reload(); let rewritten_tree = testutils::create_tree( &repo, diff --git a/lib/tests/test_commit_concurrent.rs b/lib/tests/test_commit_concurrent.rs index fcc1c43e9..12b1188d8 100644 --- a/lib/tests/test_commit_concurrent.rs +++ b/lib/tests/test_commit_concurrent.rs @@ -60,7 +60,7 @@ fn test_commit_parallel(use_git: bool) { for thread in threads { thread.join().ok().unwrap(); } - let repo = repo.reload().unwrap(); + let repo = repo.reload(); // One commit per thread plus the commit from the initial checkout on top of the // root commit assert_eq!(repo.view().heads().len(), num_threads + 1); diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index a64fe784a..af7d504aa 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -228,7 +228,7 @@ fn test_import_refs_merge() { tx2.commit(); // Reload the repo, causing the operations to be merged. - let repo = repo.reload().unwrap(); + let repo = repo.reload(); let view = repo.view(); let git_refs = view.git_refs(); @@ -369,7 +369,7 @@ fn set_up_push_repos(settings: &UserSettings, temp_dir: &TempDir) -> PushTestSet let new_commit = testutils::create_random_commit(&settings, &jj_repo) .set_parents(vec![initial_commit_id]) .write_to_new_transaction(&jj_repo, "test"); - let jj_repo = jj_repo.reload().unwrap(); + let jj_repo = jj_repo.reload(); PushTestSetup { source_repo_dir, jj_repo, @@ -412,7 +412,7 @@ fn test_push_commit_not_fast_forward() { let mut setup = set_up_push_repos(&settings, &temp_dir); let new_commit = testutils::create_random_commit(&settings, &setup.jj_repo) .write_to_new_transaction(&setup.jj_repo, "test"); - setup.jj_repo = setup.jj_repo.reload().unwrap(); + setup.jj_repo = setup.jj_repo.reload(); let result = git::push_commit( &setup.jj_repo.store().git_repo().unwrap(), &new_commit, diff --git a/lib/tests/test_index.rs b/lib/tests/test_index.rs index 1d2c9e87b..f8ff0b1f7 100644 --- a/lib/tests/test_index.rs +++ b/lib/tests/test_index.rs @@ -302,7 +302,7 @@ fn test_index_commits_incremental(use_git: bool) { let root_commit = repo.store().root_commit(); let commit_a = child_commit(&settings, &repo, &root_commit).write_to_new_transaction(&repo, "test"); - repo = repo.reload().unwrap(); + repo = repo.reload(); let index = repo.index(); // There should be the root commit and the working copy commit, plus @@ -349,7 +349,7 @@ fn test_index_commits_incremental_empty_transaction(use_git: bool) { let root_commit = repo.store().root_commit(); let commit_a = child_commit(&settings, &repo, &root_commit).write_to_new_transaction(&repo, "test"); - repo = repo.reload().unwrap(); + repo = repo.reload(); let index = repo.index(); // There should be the root commit and the working copy commit, plus @@ -393,7 +393,7 @@ fn test_index_commits_incremental_already_indexed(use_git: bool) { let root_commit = repo.store().root_commit(); let commit_a = child_commit(&settings, &repo, &root_commit).write_to_new_transaction(&repo, "test"); - repo = repo.reload().unwrap(); + repo = repo.reload(); assert!(repo.index().has_id(commit_a.id())); assert_eq!(repo.index().num_commits(), 2 + 1); diff --git a/lib/tests/test_load_repo.rs b/lib/tests/test_load_repo.rs index 4f55f5752..6ccf580fb 100644 --- a/lib/tests/test_load_repo.rs +++ b/lib/tests/test_load_repo.rs @@ -58,12 +58,12 @@ fn test_load_at_operation(use_git: bool) { // If we load the repo at head, we should not see the commit since it was // removed let loader = RepoLoader::init(&settings, repo.working_copy_path().clone()).unwrap(); - let head_repo = loader.load_at_head().unwrap(); + let head_repo = loader.load_at_head(); assert!(!head_repo.view().heads().contains(commit.id())); // If we load the repo at the previous operation, we should see the commit since // it has not been removed yet let loader = RepoLoader::init(&settings, repo.working_copy_path().clone()).unwrap(); - let old_repo = loader.load_at(&repo.operation()).unwrap(); + let old_repo = loader.load_at(&repo.operation()); assert!(old_repo.view().heads().contains(commit.id())); } diff --git a/lib/tests/test_operations.rs b/lib/tests/test_operations.rs index 067fb1476..7acceb891 100644 --- a/lib/tests/test_operations.rs +++ b/lib/tests/test_operations.rs @@ -66,7 +66,7 @@ fn test_consecutive_operations(use_git: bool) { assert_ne!(op_id1, op_id0); assert_eq!(list_dir(&op_heads_dir), vec![op_id1.hex()]); - let repo = repo.reload().unwrap(); + let repo = repo.reload(); let mut tx2 = repo.start_transaction("transaction 2"); testutils::create_random_commit(&settings, &repo).write_to_repo(tx2.mut_repo()); let op_id2 = tx2.commit().operation().id().clone(); @@ -76,7 +76,7 @@ fn test_consecutive_operations(use_git: bool) { // Reloading the repo makes no difference (there are no conflicting operations // to resolve). - let _repo = repo.reload().unwrap(); + let _repo = repo.reload(); assert_eq!(list_dir(&op_heads_dir), vec![op_id2.hex()]); } @@ -112,7 +112,7 @@ fn test_concurrent_operations(use_git: bool) { assert_eq!(actual_heads_on_disk, expected_heads_on_disk); // Reloading the repo causes the operations to be merged - let repo = repo.reload().unwrap(); + let repo = repo.reload(); let merged_op_id = repo.op_id().clone(); assert_ne!(merged_op_id, op_id0); assert_ne!(merged_op_id, op_id1); @@ -136,7 +136,7 @@ fn test_isolation(use_git: bool) { let initial = testutils::create_random_commit(&settings, &repo) .set_parents(vec![repo.store().root_commit_id().clone()]) .write_to_new_transaction(&repo, "test"); - let repo = repo.reload().unwrap(); + let repo = repo.reload(); let mut tx1 = repo.start_transaction("transaction 1"); let mut_repo1 = tx1.mut_repo(); @@ -184,7 +184,7 @@ fn test_isolation(use_git: bool) { tx2.commit(); assert_heads(repo.as_repo_ref(), vec![&wc_id, initial.id()]); // After reload, the base repo sees both rewrites. - let repo = repo.reload().unwrap(); + let repo = repo.reload(); assert_heads( repo.as_repo_ref(), vec![&wc_id, initial.id(), rewrite1.id(), rewrite2.id()], diff --git a/src/commands.rs b/src/commands.rs index d06e3147a..614aaf971 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -123,9 +123,9 @@ fn get_repo(ui: &Ui, matches: &ArgMatches) -> Result, CommandE let loader = RepoLoader::init(ui.settings(), wc_path)?; if let Some(op_str) = matches.value_of("at_op") { let op = resolve_single_op_from_store(loader.op_store(), op_str)?; - Ok(loader.load_at(&op)?) + Ok(loader.load_at(&op)) } else { - Ok(loader.load_at_head()?) + Ok(loader.load_at_head()) } } @@ -2199,8 +2199,8 @@ fn cmd_op_undo( } let mut tx = repo_command.start_transaction(&format!("undo operation {}", bad_op.id().hex())); - let bad_repo = repo.loader().load_at(&bad_op)?; - let parent_repo = repo.loader().load_at(&parent_ops[0])?; + let bad_repo = repo.loader().load_at(&bad_op); + let parent_repo = repo.loader().load_at(&parent_ops[0]); tx.mut_repo().merge(&bad_repo, &parent_repo); repo_command.finish_transaction(ui, tx)?;