forked from mirrors/jj
cleanup: fix lots of issues found in the lib crate by clippy
I had forgotten to pass `--workspace` to clippy all this time :P
This commit is contained in:
parent
48b800e5c4
commit
031a39ecba
13 changed files with 83 additions and 133 deletions
|
@ -720,7 +720,7 @@ mod tests {
|
|||
&rewritten_commit,
|
||||
&initial_change,
|
||||
&[],
|
||||
&[initial_commit.clone()],
|
||||
&[initial_commit],
|
||||
false,
|
||||
);
|
||||
assert!(state.is_orphan(&orphan_commit1));
|
||||
|
@ -751,13 +751,7 @@ mod tests {
|
|||
&[initial_commit.clone()],
|
||||
false,
|
||||
);
|
||||
state.add_commit_data(
|
||||
&new_commit,
|
||||
&new_change,
|
||||
&[initial_commit.clone()],
|
||||
&[],
|
||||
false,
|
||||
);
|
||||
state.add_commit_data(&new_commit, &new_change, &[initial_commit], &[], false);
|
||||
assert!(state.is_orphan(&new_commit));
|
||||
}
|
||||
|
||||
|
@ -784,17 +778,11 @@ mod tests {
|
|||
state.add_commit_data(
|
||||
&orphan_commit,
|
||||
&orphan_change,
|
||||
&[initial_commit.clone()],
|
||||
&[],
|
||||
false,
|
||||
);
|
||||
state.add_commit_data(
|
||||
&new_commit,
|
||||
&new_change,
|
||||
&[orphan_commit.clone()],
|
||||
&[initial_commit],
|
||||
&[],
|
||||
false,
|
||||
);
|
||||
state.add_commit_data(&new_commit, &new_change, &[orphan_commit], &[], false);
|
||||
assert!(state.is_orphan(&new_commit));
|
||||
}
|
||||
|
||||
|
@ -808,13 +796,7 @@ mod tests {
|
|||
let new_change = ChangeId::from_hex("bbb111");
|
||||
|
||||
state.add_commit_data(&pruned_commit, &pruned_change, &[], &[], true);
|
||||
state.add_commit_data(
|
||||
&new_commit,
|
||||
&new_change,
|
||||
&[pruned_commit.clone()],
|
||||
&[],
|
||||
false,
|
||||
);
|
||||
state.add_commit_data(&new_commit, &new_change, &[pruned_commit], &[], false);
|
||||
assert!(state.is_orphan(&new_commit));
|
||||
}
|
||||
|
||||
|
@ -876,7 +858,7 @@ mod tests {
|
|||
assert!(!state.is_divergent(&duplicate_change2));
|
||||
assert_eq!(
|
||||
state.successors(&initial_commit),
|
||||
hashset!(duplicate_commit1.clone(), duplicate_commit2.clone())
|
||||
hashset!(duplicate_commit1, duplicate_commit2)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -910,7 +892,7 @@ mod tests {
|
|||
assert!(state.is_divergent(&initial_change));
|
||||
assert_eq!(
|
||||
state.successors(&initial_commit),
|
||||
hashset!(rewritten_commit1.clone(), rewritten_commit2.clone())
|
||||
hashset!(rewritten_commit1, rewritten_commit2)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -945,7 +927,7 @@ mod tests {
|
|||
assert!(state.is_divergent(&initial_change));
|
||||
assert_eq!(
|
||||
state.successors(&initial_commit),
|
||||
hashset!(rewritten_pruned.clone(), rewritten_non_pruned.clone())
|
||||
hashset!(rewritten_pruned, rewritten_non_pruned)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1009,7 +991,7 @@ mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
state.successors(&rewritten_commit2),
|
||||
hashset!(convergent_commit.clone())
|
||||
hashset!(convergent_commit)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
use std::fmt::{Debug, Error, Formatter};
|
||||
use std::io::Cursor;
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::path::Path;
|
||||
use std::sync::Mutex;
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -52,7 +52,7 @@ pub struct GitStore {
|
|||
}
|
||||
|
||||
impl GitStore {
|
||||
pub fn load(path: PathBuf) -> Self {
|
||||
pub fn load(path: &Path) -> Self {
|
||||
let repo = Mutex::new(git2::Repository::open(path).unwrap());
|
||||
let empty_tree_id =
|
||||
TreeId(hex::decode("4b825dc642cb6eb9a060e54bf8d69288fbee4904").unwrap());
|
||||
|
@ -145,9 +145,11 @@ fn write_note(
|
|||
Ok(_) => Ok(()),
|
||||
}
|
||||
};
|
||||
let mut backoff = ExponentialBackoff::default();
|
||||
backoff.initial_interval = Duration::from_millis(1);
|
||||
backoff.max_elapsed_time = Some(Duration::from_secs(10));
|
||||
let mut backoff = ExponentialBackoff {
|
||||
initial_interval: Duration::from_millis(1),
|
||||
max_elapsed_time: Some(Duration::from_secs(10)),
|
||||
..Default::default()
|
||||
};
|
||||
try_write_note
|
||||
.retry(&mut backoff)
|
||||
.map_err(|err| match err {
|
||||
|
@ -495,7 +497,7 @@ mod tests {
|
|||
fn read_plain_git_commit() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let git_repo_path = temp_dir.path();
|
||||
let git_repo = git2::Repository::init(git_repo_path.clone()).unwrap();
|
||||
let git_repo = git2::Repository::init(git_repo_path).unwrap();
|
||||
|
||||
// Add a commit with some files in
|
||||
let blob1 = git_repo.blob(b"content1").unwrap();
|
||||
|
@ -534,7 +536,7 @@ mod tests {
|
|||
.unwrap();
|
||||
let commit_id = CommitId(git_commit_id.as_bytes().to_vec());
|
||||
|
||||
let store = GitStore::load(git_repo_path.to_owned());
|
||||
let store = GitStore::load(git_repo_path);
|
||||
let commit = store.read_commit(&commit_id).unwrap();
|
||||
assert_eq!(
|
||||
&commit.change_id,
|
||||
|
@ -605,8 +607,8 @@ mod tests {
|
|||
fn commit_has_ref() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let git_repo_path = temp_dir.path();
|
||||
let git_repo = git2::Repository::init(git_repo_path.clone()).unwrap();
|
||||
let store = GitStore::load(git_repo_path.to_owned());
|
||||
let git_repo = git2::Repository::init(git_repo_path).unwrap();
|
||||
let store = GitStore::load(git_repo_path);
|
||||
let signature = Signature {
|
||||
name: "Someone".to_string(),
|
||||
email: "someone@example.com".to_string(),
|
||||
|
@ -639,8 +641,8 @@ mod tests {
|
|||
fn overlapping_git_commit_id() {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let git_repo_path = temp_dir.path();
|
||||
git2::Repository::init(git_repo_path.clone()).unwrap();
|
||||
let store = GitStore::load(git_repo_path.to_owned());
|
||||
git2::Repository::init(git_repo_path).unwrap();
|
||||
let store = GitStore::load(git_repo_path);
|
||||
let signature = Signature {
|
||||
name: "Someone".to_string(),
|
||||
email: "someone@example.com".to_string(),
|
||||
|
|
|
@ -496,10 +496,10 @@ impl MutableIndex {
|
|||
buf.write_u32::<LittleEndian>(num_commits).unwrap();
|
||||
// We'll write the actual value later
|
||||
let parent_overflow_offset = buf.len();
|
||||
buf.write_u32::<LittleEndian>(0 as u32).unwrap();
|
||||
buf.write_u32::<LittleEndian>(0_u32).unwrap();
|
||||
// We'll write the actual value later
|
||||
let predecessor_overflow_offset = buf.len();
|
||||
buf.write_u32::<LittleEndian>(0 as u32).unwrap();
|
||||
buf.write_u32::<LittleEndian>(0_u32).unwrap();
|
||||
|
||||
let mut parent_overflow = vec![];
|
||||
let mut predecessor_overflow = vec![];
|
||||
|
@ -1851,24 +1851,12 @@ mod tests {
|
|||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(
|
||||
id_5.clone(),
|
||||
null_change_id(),
|
||||
false,
|
||||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(id_5.clone(), null_change_id(), false, vec![id_0], vec![]);
|
||||
index.add_commit_data(
|
||||
id_6.clone(),
|
||||
null_change_id(),
|
||||
false,
|
||||
vec![
|
||||
id_1.clone(),
|
||||
id_2.clone(),
|
||||
id_3.clone(),
|
||||
id_4.clone(),
|
||||
id_5.clone(),
|
||||
],
|
||||
vec![id_1, id_2, id_3, id_4, id_5],
|
||||
vec![],
|
||||
);
|
||||
let index = if on_disk {
|
||||
|
@ -1912,22 +1900,22 @@ mod tests {
|
|||
let id_3 = CommitId::from_hex("055444");
|
||||
let id_4 = CommitId::from_hex("055555");
|
||||
let id_5 = CommitId::from_hex("033333");
|
||||
index.add_commit_data(id_3.clone(), null_change_id(), false, vec![], vec![]);
|
||||
index.add_commit_data(id_4.clone(), null_change_id(), false, vec![], vec![]);
|
||||
index.add_commit_data(id_5.clone(), null_change_id(), false, vec![], vec![]);
|
||||
index.add_commit_data(id_3, null_change_id(), false, vec![], vec![]);
|
||||
index.add_commit_data(id_4, null_change_id(), false, vec![], vec![]);
|
||||
index.add_commit_data(id_5, null_change_id(), false, vec![], vec![]);
|
||||
|
||||
// Can find commits given the full hex number
|
||||
assert_eq!(
|
||||
index.resolve_prefix(&HexPrefix::new(id_0.hex())),
|
||||
PrefixResolution::SingleMatch(id_0.clone())
|
||||
PrefixResolution::SingleMatch(id_0)
|
||||
);
|
||||
assert_eq!(
|
||||
index.resolve_prefix(&HexPrefix::new(id_1.hex())),
|
||||
PrefixResolution::SingleMatch(id_1.clone())
|
||||
PrefixResolution::SingleMatch(id_1)
|
||||
);
|
||||
assert_eq!(
|
||||
index.resolve_prefix(&HexPrefix::new(id_2.hex())),
|
||||
PrefixResolution::SingleMatch(id_2.clone())
|
||||
PrefixResolution::SingleMatch(id_2)
|
||||
);
|
||||
// Test non-existent commits
|
||||
assert_eq!(
|
||||
|
@ -2128,17 +2116,14 @@ mod tests {
|
|||
vec![id_1.clone()]
|
||||
);
|
||||
assert_eq!(
|
||||
index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_4.clone()]),
|
||||
index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_4]),
|
||||
vec![id_1.clone()]
|
||||
);
|
||||
assert_eq!(
|
||||
index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_5.clone()]),
|
||||
index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_5]),
|
||||
vec![id_1.clone(), id_2.clone()]
|
||||
);
|
||||
assert_eq!(
|
||||
index.common_ancestors(&[id_1.clone(), id_2.clone()], &[id_3.clone()]),
|
||||
vec![id_0.clone()]
|
||||
);
|
||||
assert_eq!(index.common_ancestors(&[id_1, id_2], &[id_3]), vec![id_0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2163,13 +2148,7 @@ mod tests {
|
|||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(
|
||||
id_2.clone(),
|
||||
null_change_id(),
|
||||
false,
|
||||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(id_2.clone(), null_change_id(), false, vec![id_0], vec![]);
|
||||
index.add_commit_data(
|
||||
id_3.clone(),
|
||||
null_change_id(),
|
||||
|
@ -2185,9 +2164,9 @@ mod tests {
|
|||
vec![],
|
||||
);
|
||||
|
||||
let mut common_ancestors = index.common_ancestors(&[id_3.clone()], &[id_4.clone()]);
|
||||
let mut common_ancestors = index.common_ancestors(&[id_3], &[id_4]);
|
||||
common_ancestors.sort();
|
||||
assert_eq!(common_ancestors, vec![id_1.clone(), id_2.clone()]);
|
||||
assert_eq!(common_ancestors, vec![id_1, id_2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2206,13 +2185,7 @@ mod tests {
|
|||
let id_4 = CommitId::from_hex("444444");
|
||||
let id_5 = CommitId::from_hex("555555");
|
||||
index.add_commit_data(id_0.clone(), null_change_id(), false, vec![], vec![]);
|
||||
index.add_commit_data(
|
||||
id_1.clone(),
|
||||
null_change_id(),
|
||||
false,
|
||||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(id_1, null_change_id(), false, vec![id_0.clone()], vec![]);
|
||||
index.add_commit_data(
|
||||
id_2.clone(),
|
||||
null_change_id(),
|
||||
|
@ -2220,13 +2193,7 @@ mod tests {
|
|||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(
|
||||
id_3.clone(),
|
||||
null_change_id(),
|
||||
false,
|
||||
vec![id_0.clone()],
|
||||
vec![],
|
||||
);
|
||||
index.add_commit_data(id_3, null_change_id(), false, vec![id_0.clone()], vec![]);
|
||||
index.add_commit_data(
|
||||
id_4.clone(),
|
||||
null_change_id(),
|
||||
|
@ -2238,13 +2205,13 @@ mod tests {
|
|||
id_5.clone(),
|
||||
null_change_id(),
|
||||
false,
|
||||
vec![id_0.clone(), id_2.clone()],
|
||||
vec![id_0, id_2.clone()],
|
||||
vec![],
|
||||
);
|
||||
|
||||
let mut common_ancestors = index.common_ancestors(&[id_4.clone()], &[id_5.clone()]);
|
||||
let mut common_ancestors = index.common_ancestors(&[id_4], &[id_5]);
|
||||
common_ancestors.sort();
|
||||
assert_eq!(common_ancestors, vec![id_2.clone()]);
|
||||
assert_eq!(common_ancestors, vec![id_2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -37,9 +37,11 @@ impl FileLock {
|
|||
}
|
||||
Err(err) => Err(backoff::Error::Permanent(err)),
|
||||
};
|
||||
let mut backoff = ExponentialBackoff::default();
|
||||
backoff.initial_interval = Duration::from_millis(1);
|
||||
backoff.max_elapsed_time = Some(Duration::from_secs(10));
|
||||
let mut backoff = ExponentialBackoff {
|
||||
initial_interval: Duration::from_millis(1),
|
||||
max_elapsed_time: Some(Duration::from_secs(10)),
|
||||
..Default::default()
|
||||
};
|
||||
match try_write_lock_file.retry(&mut backoff) {
|
||||
Err(err) => panic!(
|
||||
"failed to create lock file {}: {}",
|
||||
|
|
|
@ -139,7 +139,7 @@ impl ReadonlyRepo {
|
|||
let git_store_path = fs::canonicalize(git_store_path).unwrap();
|
||||
let mut store_file = File::create(store_path).unwrap();
|
||||
store_file.write_all(b"git: git").unwrap();
|
||||
let store = Box::new(GitStore::load(git_store_path));
|
||||
let store = Box::new(GitStore::load(&git_store_path));
|
||||
ReadonlyRepo::init(settings, repo_path, wc_path, store)
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ impl ReadonlyRepo {
|
|||
store_file
|
||||
.write_all(format!("git: {}", git_store_path.to_str().unwrap()).as_bytes())
|
||||
.unwrap();
|
||||
let store = Box::new(GitStore::load(git_store_path));
|
||||
let store = Box::new(GitStore::load(&git_store_path));
|
||||
ReadonlyRepo::init(settings, repo_path, wc_path, store)
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ impl ReadonlyRepo {
|
|||
let git_store_path_str = contents[5..].to_string();
|
||||
let git_store_path =
|
||||
fs::canonicalize(repo_path.join(PathBuf::from(git_store_path_str))).unwrap();
|
||||
store = Box::new(GitStore::load(git_store_path));
|
||||
store = Box::new(GitStore::load(&git_store_path));
|
||||
}
|
||||
let store = StoreWrapper::new(store);
|
||||
let repo_settings = user_settings.with_repo(&repo_path).unwrap();
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UserSettings {
|
||||
|
@ -43,7 +43,7 @@ impl UserSettings {
|
|||
Ok(UserSettings { config })
|
||||
}
|
||||
|
||||
pub fn with_repo(&self, repo_path: &PathBuf) -> Result<RepoSettings, config::ConfigError> {
|
||||
pub fn with_repo(&self, repo_path: &Path) -> Result<RepoSettings, config::ConfigError> {
|
||||
let mut config = self.config.clone();
|
||||
config.merge(
|
||||
config::File::from(repo_path.join("config"))
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
use std::cmp::min;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -154,11 +155,11 @@ pub enum OpHeadResolutionError {
|
|||
NoHeads,
|
||||
}
|
||||
|
||||
fn add_op_head(op_heads_dir: &PathBuf, id: &OperationId) {
|
||||
fn add_op_head(op_heads_dir: &Path, id: &OperationId) {
|
||||
std::fs::write(op_heads_dir.join(id.hex()), "").unwrap();
|
||||
}
|
||||
|
||||
fn remove_op_head(op_heads_dir: &PathBuf, id: &OperationId) {
|
||||
fn remove_op_head(op_heads_dir: &Path, id: &OperationId) {
|
||||
// It's fine if the old head was not found. It probably means
|
||||
// that we're on a distributed file system where the locking
|
||||
// doesn't work. We'll probably end up with two current
|
||||
|
@ -166,7 +167,7 @@ fn remove_op_head(op_heads_dir: &PathBuf, id: &OperationId) {
|
|||
std::fs::remove_file(op_heads_dir.join(id.hex())).ok();
|
||||
}
|
||||
|
||||
fn get_op_heads(op_heads_dir: &PathBuf) -> Vec<OperationId> {
|
||||
fn get_op_heads(op_heads_dir: &Path) -> Vec<OperationId> {
|
||||
let mut op_heads = vec![];
|
||||
for op_head_entry in std::fs::read_dir(op_heads_dir).unwrap() {
|
||||
let op_head_file_name = op_head_entry.unwrap().file_name();
|
||||
|
@ -250,7 +251,7 @@ pub fn merge_views(
|
|||
fn get_single_op_head(
|
||||
store: &StoreWrapper,
|
||||
op_store: &Arc<dyn OpStore>,
|
||||
op_heads_dir: &PathBuf,
|
||||
op_heads_dir: &Path,
|
||||
) -> Result<(OperationId, op_store::Operation, op_store::View), OpHeadResolutionError> {
|
||||
let mut op_heads = get_op_heads(&op_heads_dir);
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ use std::os::unix::fs::symlink;
|
|||
use std::os::unix::fs::PermissionsExt;
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::fs::symlink_file;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
|
@ -125,7 +126,7 @@ fn file_states_from_proto(
|
|||
file_states
|
||||
}
|
||||
|
||||
fn create_parent_dirs(disk_path: &PathBuf) {
|
||||
fn create_parent_dirs(disk_path: &Path) {
|
||||
fs::create_dir_all(disk_path.parent().unwrap())
|
||||
.unwrap_or_else(|_| panic!("failed to create parent directories for {:?}", &disk_path));
|
||||
}
|
||||
|
@ -242,7 +243,7 @@ impl TreeState {
|
|||
.unwrap();
|
||||
}
|
||||
|
||||
fn file_state(&self, path: &PathBuf) -> Option<FileState> {
|
||||
fn file_state(&self, path: &Path) -> Option<FileState> {
|
||||
let metadata = path.symlink_metadata().ok()?;
|
||||
let time = metadata.modified().unwrap();
|
||||
let since_epoch = time.duration_since(UNIX_EPOCH).unwrap();
|
||||
|
@ -268,12 +269,12 @@ impl TreeState {
|
|||
})
|
||||
}
|
||||
|
||||
fn write_file_to_store(&self, path: &FileRepoPath, disk_path: &PathBuf) -> FileId {
|
||||
fn write_file_to_store(&self, path: &FileRepoPath, disk_path: &Path) -> FileId {
|
||||
let file = File::open(disk_path).unwrap();
|
||||
self.store.write_file(path, &mut Box::new(file)).unwrap()
|
||||
}
|
||||
|
||||
fn write_symlink_to_store(&self, path: &FileRepoPath, disk_path: &PathBuf) -> SymlinkId {
|
||||
fn write_symlink_to_store(&self, path: &FileRepoPath, disk_path: &Path) -> SymlinkId {
|
||||
let target = disk_path.read_link().unwrap();
|
||||
let str_target = target.to_str().unwrap();
|
||||
self.store.write_symlink(path, str_target).unwrap()
|
||||
|
@ -375,7 +376,7 @@ impl TreeState {
|
|||
|
||||
fn write_file(
|
||||
&self,
|
||||
disk_path: &PathBuf,
|
||||
disk_path: &Path,
|
||||
path: &FileRepoPath,
|
||||
id: &FileId,
|
||||
executable: bool,
|
||||
|
@ -402,7 +403,7 @@ impl TreeState {
|
|||
file_state
|
||||
}
|
||||
|
||||
fn write_symlink(&self, disk_path: &PathBuf, path: &FileRepoPath, id: &SymlinkId) -> FileState {
|
||||
fn write_symlink(&self, disk_path: &Path, path: &FileRepoPath, id: &SymlinkId) -> FileState {
|
||||
create_parent_dirs(disk_path);
|
||||
#[cfg(windows)]
|
||||
{
|
||||
|
@ -417,7 +418,7 @@ impl TreeState {
|
|||
self.file_state(&disk_path).unwrap()
|
||||
}
|
||||
|
||||
fn set_executable(&self, disk_path: &PathBuf, executable: bool) {
|
||||
fn set_executable(&self, disk_path: &Path, executable: bool) {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::path::Path;
|
||||
|
||||
use tempfile::TempDir;
|
||||
|
||||
|
@ -21,7 +21,7 @@ use jujube_lib::testutils;
|
|||
use std::sync::Arc;
|
||||
use test_case::test_case;
|
||||
|
||||
fn copy_directory(src: &PathBuf, dst: &PathBuf) {
|
||||
fn copy_directory(src: &Path, dst: &Path) {
|
||||
std::fs::create_dir(dst).ok();
|
||||
for entry in std::fs::read_dir(src).unwrap() {
|
||||
let child_src = entry.unwrap().path();
|
||||
|
@ -35,7 +35,7 @@ fn copy_directory(src: &PathBuf, dst: &PathBuf) {
|
|||
}
|
||||
}
|
||||
|
||||
fn merge_directories(left: &PathBuf, base: &PathBuf, right: &PathBuf, output: &PathBuf) {
|
||||
fn merge_directories(left: &Path, base: &Path, right: &Path, output: &Path) {
|
||||
std::fs::create_dir(output).ok();
|
||||
let mut sub_dirs = vec![];
|
||||
// Walk the left side and copy to the output
|
||||
|
|
|
@ -495,7 +495,7 @@ impl EvolveListener for RecordingEvolveListener {
|
|||
|
||||
fn divergent_resolved(&mut self, _tx: &mut Transaction, sources: &[Commit], resolved: &Commit) {
|
||||
self.evolved_divergents
|
||||
.push((sources.iter().cloned().collect(), resolved.clone()));
|
||||
.push((sources.to_vec(), resolved.clone()));
|
||||
}
|
||||
|
||||
fn divergent_no_common_predecessor(
|
||||
|
@ -644,7 +644,7 @@ fn test_evolve_divergent(use_git: bool) {
|
|||
&[commit6.clone(), commit4.clone()]
|
||||
);
|
||||
let resolved = listener.evolved_divergents[0].1.clone();
|
||||
assert_eq!(resolved.predecessors(), &[commit6.clone(), commit4.clone()]);
|
||||
assert_eq!(resolved.predecessors(), &[commit6, commit4]);
|
||||
|
||||
let tree = resolved.tree();
|
||||
let entries: Vec<_> = tree.entries().collect();
|
||||
|
|
|
@ -292,7 +292,7 @@ fn test_init() {
|
|||
let initial_git_commit = empty_git_commit(&git_repo, "refs/heads/main", &[]);
|
||||
let initial_commit_id = commit_id(&initial_git_commit);
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
let repo = ReadonlyRepo::init_external_git(&settings, jj_repo_dir.clone(), git_repo_dir);
|
||||
let repo = ReadonlyRepo::init_external_git(&settings, jj_repo_dir, git_repo_dir);
|
||||
// The refs were *not* imported -- it's the caller's responsibility to import
|
||||
// any refs they care about.
|
||||
assert!(!repo.view().heads().contains(&initial_commit_id));
|
||||
|
@ -310,13 +310,13 @@ fn test_fetch_success() {
|
|||
let clone_git_repo =
|
||||
git2::Repository::clone(&source_repo_dir.to_str().unwrap(), &clone_repo_dir).unwrap();
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
ReadonlyRepo::init_external_git(&settings, jj_repo_dir.clone(), clone_repo_dir.clone());
|
||||
ReadonlyRepo::init_external_git(&settings, jj_repo_dir.clone(), clone_repo_dir);
|
||||
|
||||
let new_git_commit =
|
||||
empty_git_commit(&source_git_repo, "refs/heads/main", &[&initial_git_commit]);
|
||||
|
||||
// The new commit is not visible before git::fetch().
|
||||
let jj_repo = ReadonlyRepo::load(&settings, jj_repo_dir.clone()).unwrap();
|
||||
let jj_repo = ReadonlyRepo::load(&settings, jj_repo_dir).unwrap();
|
||||
assert!(!jj_repo.view().heads().contains(&commit_id(&new_git_commit)));
|
||||
|
||||
// The new commit is visible after git::fetch().
|
||||
|
@ -335,8 +335,7 @@ fn test_fetch_no_such_remote() {
|
|||
let jj_repo_dir = temp_dir.path().join("jj");
|
||||
let git_repo = git2::Repository::init_bare(&source_repo_dir).unwrap();
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
let jj_repo =
|
||||
ReadonlyRepo::init_external_git(&settings, jj_repo_dir.clone(), source_repo_dir.clone());
|
||||
let jj_repo = ReadonlyRepo::init_external_git(&settings, jj_repo_dir, source_repo_dir);
|
||||
|
||||
let mut tx = jj_repo.start_transaction("test");
|
||||
let result = git::fetch(&mut tx, &git_repo, "invalid-remote");
|
||||
|
@ -360,10 +359,9 @@ fn set_up_push_repos(settings: &UserSettings, temp_dir: &TempDir) -> PushTestSet
|
|||
let initial_commit_id = commit_id(&initial_git_commit);
|
||||
git2::Repository::clone(&source_repo_dir.to_str().unwrap(), &clone_repo_dir).unwrap();
|
||||
std::fs::create_dir(&jj_repo_dir).unwrap();
|
||||
let mut jj_repo =
|
||||
ReadonlyRepo::init_external_git(&settings, jj_repo_dir.clone(), clone_repo_dir.clone());
|
||||
let mut jj_repo = ReadonlyRepo::init_external_git(&settings, jj_repo_dir, clone_repo_dir);
|
||||
let new_commit = testutils::create_random_commit(&settings, &jj_repo)
|
||||
.set_parents(vec![initial_commit_id.clone()])
|
||||
.set_parents(vec![initial_commit_id])
|
||||
.write_to_new_transaction(&jj_repo, "test");
|
||||
Arc::get_mut(&mut jj_repo).unwrap().reload();
|
||||
PushTestSetup {
|
||||
|
|
|
@ -53,10 +53,7 @@ fn test_index_commits_empty_repo(use_git: bool) {
|
|||
0
|
||||
);
|
||||
assert_eq!(
|
||||
generation_number(
|
||||
index.clone(),
|
||||
&repo.working_copy_locked().current_commit_id()
|
||||
),
|
||||
generation_number(index, &repo.working_copy_locked().current_commit_id()),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
@ -295,7 +292,7 @@ fn test_index_commits_previous_operations(use_git: bool) {
|
|||
|
||||
assert_eq!(generation_number(index.clone(), commit_a.id()), 1);
|
||||
assert_eq!(generation_number(index.clone(), commit_b.id()), 2);
|
||||
assert_eq!(generation_number(index.clone(), commit_c.id()), 3);
|
||||
assert_eq!(generation_number(index, commit_c.id()), 3);
|
||||
}
|
||||
|
||||
#[test_case(false ; "local store")]
|
||||
|
@ -344,7 +341,7 @@ fn test_index_commits_incremental(use_git: bool) {
|
|||
assert_eq!(generation_number(index.clone(), root_commit.id()), 0);
|
||||
assert_eq!(generation_number(index.clone(), commit_a.id()), 1);
|
||||
assert_eq!(generation_number(index.clone(), commit_b.id()), 2);
|
||||
assert_eq!(generation_number(index.clone(), commit_c.id()), 3);
|
||||
assert_eq!(generation_number(index, commit_c.id()), 3);
|
||||
}
|
||||
|
||||
#[test_case(false ; "local store")]
|
||||
|
@ -388,7 +385,7 @@ fn test_index_commits_incremental_empty_transaction(use_git: bool) {
|
|||
assert_ne!(stats.levels[1].name, stats.levels[0].name);
|
||||
|
||||
assert_eq!(generation_number(index.clone(), root_commit.id()), 0);
|
||||
assert_eq!(generation_number(index.clone(), commit_a.id()), 1);
|
||||
assert_eq!(generation_number(index, commit_a.id()), 1);
|
||||
}
|
||||
|
||||
#[test_case(false ; "local store")]
|
||||
|
|
|
@ -69,7 +69,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
Symlink,
|
||||
Tree,
|
||||
GitSubmodule,
|
||||
};
|
||||
}
|
||||
|
||||
fn write_path(
|
||||
settings: &UserSettings,
|
||||
|
@ -130,7 +130,7 @@ fn test_checkout_file_transitions(use_git: bool) {
|
|||
}
|
||||
};
|
||||
tree_builder.set(RepoPath::from(path), value);
|
||||
};
|
||||
}
|
||||
|
||||
let mut kinds = vec![
|
||||
Kind::Missing,
|
||||
|
|
Loading…
Reference in a new issue