mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-31 03:42:39 +00:00
cli: when importing Git HEAD in shared working copy, use reset()
This commit is contained in:
parent
cd4fbd3565
commit
c52b001d9c
@ -55,7 +55,7 @@ use jujutsu_lib::settings::UserSettings;
|
||||
use jujutsu_lib::store::Store;
|
||||
use jujutsu_lib::transaction::Transaction;
|
||||
use jujutsu_lib::tree::TreeDiffIterator;
|
||||
use jujutsu_lib::working_copy::{CheckoutStats, WorkingCopy};
|
||||
use jujutsu_lib::working_copy::{CheckoutStats, ResetError, WorkingCopy};
|
||||
use jujutsu_lib::workspace::{Workspace, WorkspaceInitError, WorkspaceLoadError};
|
||||
use jujutsu_lib::{conflicts, diff, files, git, revset, tree};
|
||||
use maplit::{hashmap, hashset};
|
||||
@ -99,6 +99,12 @@ impl From<WorkspaceInitError> for CommandError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ResetError> for CommandError {
|
||||
fn from(_: ResetError) -> Self {
|
||||
CommandError::InternalError("Failed to reset the working copy".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DiffEditError> for CommandError {
|
||||
fn from(err: DiffEditError) -> Self {
|
||||
CommandError::UserError(format!("Failed to edit diff: {}", err))
|
||||
@ -293,11 +299,8 @@ impl WorkspaceCommandHelper {
|
||||
}
|
||||
self.repo = tx.commit();
|
||||
if let Some(new_wc_commit) = new_wc_commit {
|
||||
// TODO: We should probably do a regular checkout of new_wc_commit here even
|
||||
// though it would usually have no effect. The issue is that if
|
||||
// the update removed file ignored, we currently leave that as
|
||||
// tracked, making it appear like it was added.
|
||||
let locked_working_copy = self.workspace.working_copy_mut().start_mutation();
|
||||
let mut locked_working_copy = self.workspace.working_copy_mut().start_mutation();
|
||||
locked_working_copy.reset(&new_wc_commit.tree())?;
|
||||
locked_working_copy.finish(new_wc_commit.id().clone());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user