mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 10:07:28 +00:00
Fixes suggested by new version of Clippy
This commit is contained in:
parent
0870c47559
commit
2b8dabaae4
11 changed files with 18 additions and 18 deletions
|
@ -65,7 +65,7 @@ impl GitBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_internal(store_path: &Path) -> Self {
|
pub fn init_internal(store_path: &Path) -> Self {
|
||||||
let git_repo = git2::Repository::init_bare(&store_path.join("git")).unwrap();
|
let git_repo = git2::Repository::init_bare(store_path.join("git")).unwrap();
|
||||||
let extra_path = store_path.join("extra");
|
let extra_path = store_path.join("extra");
|
||||||
std::fs::create_dir(&extra_path).unwrap();
|
std::fs::create_dir(&extra_path).unwrap();
|
||||||
let mut git_target_file = File::create(store_path.join("git_target")).unwrap();
|
let mut git_target_file = File::create(store_path.join("git_target")).unwrap();
|
||||||
|
@ -174,7 +174,7 @@ impl Backend for GitBackend {
|
||||||
|
|
||||||
fn git_repo(&self) -> Option<git2::Repository> {
|
fn git_repo(&self) -> Option<git2::Repository> {
|
||||||
let path = self.repo.lock().unwrap().path().to_owned();
|
let path = self.repo.lock().unwrap().path().to_owned();
|
||||||
Some(git2::Repository::open(&path).unwrap())
|
Some(git2::Repository::open(path).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_file(&self, _path: &RepoPath, id: &FileId) -> BackendResult<Box<dyn Read>> {
|
fn read_file(&self, _path: &RepoPath, id: &FileId) -> BackendResult<Box<dyn Read>> {
|
||||||
|
|
|
@ -280,7 +280,7 @@ impl HexPrefix {
|
||||||
let bytes = hex::decode(&self.0).unwrap();
|
let bytes = hex::decode(&self.0).unwrap();
|
||||||
(CommitId::new(bytes.clone()), CommitId::new(bytes))
|
(CommitId::new(bytes.clone()), CommitId::new(bytes))
|
||||||
} else {
|
} else {
|
||||||
let min_bytes = hex::decode(&(self.0.clone() + "0")).unwrap();
|
let min_bytes = hex::decode(self.0.clone() + "0").unwrap();
|
||||||
let prefix = min_bytes[0..min_bytes.len() - 1].to_vec();
|
let prefix = min_bytes[0..min_bytes.len() - 1].to_vec();
|
||||||
(CommitId::new(prefix), CommitId::new(min_bytes))
|
(CommitId::new(prefix), CommitId::new(min_bytes))
|
||||||
}
|
}
|
||||||
|
@ -559,7 +559,7 @@ impl MutableIndex {
|
||||||
let mut temp_file = NamedTempFile::new_in(&dir)?;
|
let mut temp_file = NamedTempFile::new_in(&dir)?;
|
||||||
let file = temp_file.as_file_mut();
|
let file = temp_file.as_file_mut();
|
||||||
file.write_all(&buf)?;
|
file.write_all(&buf)?;
|
||||||
persist_content_addressed_temp_file(temp_file, &index_file_path)?;
|
persist_content_addressed_temp_file(temp_file, index_file_path)?;
|
||||||
|
|
||||||
let mut cursor = Cursor::new(&buf);
|
let mut cursor = Cursor::new(&buf);
|
||||||
ReadonlyIndex::load_from(&mut cursor, dir, index_file_id_hex, hash_length).map_err(|err| {
|
ReadonlyIndex::load_from(&mut cursor, dir, index_file_id_hex, hash_length).map_err(|err| {
|
||||||
|
@ -1307,7 +1307,7 @@ impl ReadonlyIndex {
|
||||||
file.read_exact(&mut parent_filename_bytes)?;
|
file.read_exact(&mut parent_filename_bytes)?;
|
||||||
let parent_filename = String::from_utf8(parent_filename_bytes).unwrap();
|
let parent_filename = String::from_utf8(parent_filename_bytes).unwrap();
|
||||||
let parent_file_path = dir.join(&parent_filename);
|
let parent_file_path = dir.join(&parent_filename);
|
||||||
let mut index_file = File::open(&parent_file_path).unwrap();
|
let mut index_file = File::open(parent_file_path).unwrap();
|
||||||
let parent_file =
|
let parent_file =
|
||||||
ReadonlyIndex::load_from(&mut index_file, dir, parent_filename, hash_length)?;
|
ReadonlyIndex::load_from(&mut index_file, dir, parent_filename, hash_length)?;
|
||||||
num_parent_commits = parent_file.num_parent_commits + parent_file.num_local_commits;
|
num_parent_commits = parent_file.num_parent_commits + parent_file.num_local_commits;
|
||||||
|
|
|
@ -52,7 +52,7 @@ impl IndexStore {
|
||||||
|
|
||||||
pub fn get_index_at_op(&self, op: &Operation, store: &Arc<Store>) -> Arc<ReadonlyIndex> {
|
pub fn get_index_at_op(&self, op: &Operation, store: &Arc<Store>) -> Arc<ReadonlyIndex> {
|
||||||
let op_id_hex = op.id().hex();
|
let op_id_hex = op.id().hex();
|
||||||
let op_id_file = self.dir.join("operations").join(&op_id_hex);
|
let op_id_file = self.dir.join("operations").join(op_id_hex);
|
||||||
if op_id_file.exists() {
|
if op_id_file.exists() {
|
||||||
match self.load_index_at_operation(store.hash_length(), op.id()) {
|
match self.load_index_at_operation(store.hash_length(), op.id()) {
|
||||||
Err(IndexLoadError::IndexCorrupt(_)) => {
|
Err(IndexLoadError::IndexCorrupt(_)) => {
|
||||||
|
@ -88,7 +88,7 @@ impl IndexStore {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let index_file_id_hex = String::from_utf8(buf).unwrap();
|
let index_file_id_hex = String::from_utf8(buf).unwrap();
|
||||||
let index_file_path = self.dir.join(&index_file_id_hex);
|
let index_file_path = self.dir.join(&index_file_id_hex);
|
||||||
let mut index_file = File::open(&index_file_path).unwrap();
|
let mut index_file = File::open(index_file_path).unwrap();
|
||||||
ReadonlyIndex::load_from(
|
ReadonlyIndex::load_from(
|
||||||
&mut index_file,
|
&mut index_file,
|
||||||
self.dir.clone(),
|
self.dir.clone(),
|
||||||
|
@ -164,7 +164,7 @@ impl IndexStore {
|
||||||
file.write_all(index.name().as_bytes())?;
|
file.write_all(index.name().as_bytes())?;
|
||||||
persist_content_addressed_temp_file(
|
persist_content_addressed_temp_file(
|
||||||
temp_file,
|
temp_file,
|
||||||
&self.dir.join("operations").join(op_id.hex()),
|
self.dir.join("operations").join(op_id.hex()),
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,7 +335,7 @@ impl MutableTable {
|
||||||
let mut temp_file = NamedTempFile::new_in(&store.dir)?;
|
let mut temp_file = NamedTempFile::new_in(&store.dir)?;
|
||||||
let file = temp_file.as_file_mut();
|
let file = temp_file.as_file_mut();
|
||||||
file.write_all(&buf)?;
|
file.write_all(&buf)?;
|
||||||
persist_content_addressed_temp_file(temp_file, &file_path)?;
|
persist_content_addressed_temp_file(temp_file, file_path)?;
|
||||||
|
|
||||||
let mut cursor = Cursor::new(&buf);
|
let mut cursor = Cursor::new(&buf);
|
||||||
ReadonlyTable::load_from(&mut cursor, store, file_id_hex, store.key_size)
|
ReadonlyTable::load_from(&mut cursor, store, file_id_hex, store.key_size)
|
||||||
|
@ -442,7 +442,7 @@ impl TableStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let table_file_path = self.dir.join(&name);
|
let table_file_path = self.dir.join(&name);
|
||||||
let mut table_file = File::open(&table_file_path)?;
|
let mut table_file = File::open(table_file_path)?;
|
||||||
let table = ReadonlyTable::load_from(&mut table_file, self, name, self.key_size)?;
|
let table = ReadonlyTable::load_from(&mut table_file, self, name, self.key_size)?;
|
||||||
{
|
{
|
||||||
let mut write_locked_cache = self.cached_tables.write().unwrap();
|
let mut write_locked_cache = self.cached_tables.write().unwrap();
|
||||||
|
|
|
@ -49,7 +49,7 @@ fn files_recursively(dir: &Path) -> HashSet<String> {
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Args = Args::parse();
|
let args: Args = Args::parse();
|
||||||
let edit_script_path = PathBuf::from(std::env::var_os("DIFF_EDIT_SCRIPT").unwrap());
|
let edit_script_path = PathBuf::from(std::env::var_os("DIFF_EDIT_SCRIPT").unwrap());
|
||||||
let edit_script = String::from_utf8(std::fs::read(&edit_script_path).unwrap()).unwrap();
|
let edit_script = String::from_utf8(std::fs::read(edit_script_path).unwrap()).unwrap();
|
||||||
for instruction in edit_script.split('\0') {
|
for instruction in edit_script.split('\0') {
|
||||||
let (command, payload) = instruction.split_once('\n').unwrap_or((instruction, ""));
|
let (command, payload) = instruction.split_once('\n').unwrap_or((instruction, ""));
|
||||||
let parts = command.split(' ').collect_vec();
|
let parts = command.split(' ').collect_vec();
|
||||||
|
@ -83,7 +83,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
["reset", file] => {
|
["reset", file] => {
|
||||||
if args.before.join(file).exists() {
|
if args.before.join(file).exists() {
|
||||||
std::fs::copy(&args.before.join(file), &args.after.join(file)).unwrap();
|
std::fs::copy(args.before.join(file), args.after.join(file)).unwrap();
|
||||||
} else {
|
} else {
|
||||||
std::fs::remove_file(args.after.join(file)).unwrap();
|
std::fs::remove_file(args.after.join(file)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct Args {
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Args = Args::parse();
|
let args: Args = Args::parse();
|
||||||
let edit_script_path = PathBuf::from(std::env::var_os("EDIT_SCRIPT").unwrap());
|
let edit_script_path = PathBuf::from(std::env::var_os("EDIT_SCRIPT").unwrap());
|
||||||
let edit_script = String::from_utf8(std::fs::read(&edit_script_path).unwrap()).unwrap();
|
let edit_script = String::from_utf8(std::fs::read(edit_script_path).unwrap()).unwrap();
|
||||||
for instruction in edit_script.split('\0') {
|
for instruction in edit_script.split('\0') {
|
||||||
let (command, payload) = instruction.split_once('\n').unwrap_or((instruction, ""));
|
let (command, payload) = instruction.split_once('\n').unwrap_or((instruction, ""));
|
||||||
let parts = command.split(' ').collect_vec();
|
let parts = command.split(' ').collect_vec();
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub mod common;
|
||||||
fn test_git_clone() {
|
fn test_git_clone() {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
let git_repo_path = test_env.env_root().join("source");
|
let git_repo_path = test_env.env_root().join("source");
|
||||||
let git_repo = git2::Repository::init(&git_repo_path).unwrap();
|
let git_repo = git2::Repository::init(git_repo_path).unwrap();
|
||||||
|
|
||||||
// Clone an empty repo
|
// Clone an empty repo
|
||||||
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["git", "clone", "source", "empty"]);
|
let stdout = test_env.jj_cmd_success(test_env.env_root(), &["git", "clone", "source", "empty"]);
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub mod common;
|
||||||
fn set_up() -> (TestEnvironment, PathBuf) {
|
fn set_up() -> (TestEnvironment, PathBuf) {
|
||||||
let test_env = TestEnvironment::default();
|
let test_env = TestEnvironment::default();
|
||||||
let git_repo_path = test_env.env_root().join("git-repo");
|
let git_repo_path = test_env.env_root().join("git-repo");
|
||||||
let git_repo = git2::Repository::init_bare(&git_repo_path).unwrap();
|
let git_repo = git2::Repository::init_bare(git_repo_path).unwrap();
|
||||||
let signature =
|
let signature =
|
||||||
git2::Signature::new("Some One", "some.one@example.com", &git2::Time::new(0, 0)).unwrap();
|
git2::Signature::new("Some One", "some.one@example.com", &git2::Time::new(0, 0)).unwrap();
|
||||||
let empty_tree_oid = git_repo.treebuilder(None).unwrap().write().unwrap();
|
let empty_tree_oid = git_repo.treebuilder(None).unwrap().write().unwrap();
|
||||||
|
|
|
@ -131,7 +131,7 @@ fn test_obslog_squash() {
|
||||||
std::fs::write(repo_path.join("file1"), "foo\nbar\n").unwrap();
|
std::fs::write(repo_path.join("file1"), "foo\nbar\n").unwrap();
|
||||||
|
|
||||||
let edit_script = test_env.set_up_fake_editor();
|
let edit_script = test_env.set_up_fake_editor();
|
||||||
std::fs::write(&edit_script, "write\nsquashed").unwrap();
|
std::fs::write(edit_script, "write\nsquashed").unwrap();
|
||||||
test_env.jj_cmd_success(&repo_path, &["squash"]);
|
test_env.jj_cmd_success(&repo_path, &["squash"]);
|
||||||
|
|
||||||
let stdout = get_log_output(&test_env, &repo_path, &["obslog", "-p", "-r", "@-"]);
|
let stdout = get_log_output(&test_env, &repo_path, &["obslog", "-p", "-r", "@-"]);
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
|
||||||
args.extend(parents);
|
args.extend(parents);
|
||||||
test_env.jj_cmd_success(repo_path, &args);
|
test_env.jj_cmd_success(repo_path, &args);
|
||||||
}
|
}
|
||||||
std::fs::write(repo_path.join(name), &format!("{name}\n")).unwrap();
|
std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap();
|
||||||
test_env.jj_cmd_success(repo_path, &["branch", "create", name]);
|
test_env.jj_cmd_success(repo_path, &["branch", "create", name]);
|
||||||
test_env.jj_cmd_success(repo_path, &["close", "-m", name]);
|
test_env.jj_cmd_success(repo_path, &["close", "-m", name]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ fn test_touchup_merge() {
|
||||||
|
|
||||||
// Remove file1. The conflict remains in the working copy on top of the merge.
|
// Remove file1. The conflict remains in the working copy on top of the merge.
|
||||||
std::fs::write(
|
std::fs::write(
|
||||||
&edit_script,
|
edit_script,
|
||||||
"files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1",
|
"files-before file1\0files-after JJ-INSTRUCTIONS file1 file3\0rm file1",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue