mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-05 20:55:05 +00:00
op heads: drop support for old location/format
We move `.jj/repo/op_heads/*` into `.jj/repo/op_heads/heads/*` almost a year ago, in commits90a66ec262
and37ba17589d
. We said we would drop support for it in 0.9+. I think we said that before we started doing monthly releases, but I we're still past the goal of 6 months (which is what I think we were aiming for).
This commit is contained in:
parent
49165d33ec
commit
8137975785
1 changed files with 0 additions and 122 deletions
|
@ -49,26 +49,6 @@ impl SimpleOpHeadsStore {
|
|||
|
||||
pub fn load(dir: &Path) -> Self {
|
||||
let op_heads_dir = dir.join("heads");
|
||||
// TODO: Delete this migration code at 0.9+ or so
|
||||
if !op_heads_dir.exists() {
|
||||
// For some months during 0.7 development, the name was "simple_op_heads"
|
||||
if dir.join("simple_op_heads").exists() {
|
||||
fs::rename(dir.join("simple_op_heads"), &op_heads_dir).unwrap();
|
||||
} else {
|
||||
let old_store = Self {
|
||||
dir: dir.to_path_buf(),
|
||||
};
|
||||
fs::create_dir(&op_heads_dir).unwrap();
|
||||
let new_store = Self { dir: op_heads_dir };
|
||||
|
||||
for id in old_store.get_op_heads() {
|
||||
old_store.remove_op_head(&id);
|
||||
new_store.add_op_head(&id);
|
||||
}
|
||||
return new_store;
|
||||
}
|
||||
}
|
||||
|
||||
Self { dir: op_heads_dir }
|
||||
}
|
||||
}
|
||||
|
@ -123,105 +103,3 @@ impl OpHeadsStore for SimpleOpHeadsStore {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::collections::HashSet;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::backend::ObjectId;
|
||||
use crate::op_heads_store::OpHeadsStore;
|
||||
use crate::op_store::OperationId;
|
||||
use crate::simple_op_heads_store::SimpleOpHeadsStore;
|
||||
|
||||
fn read_dir(dir: &Path) -> Vec<String> {
|
||||
fs::read_dir(dir)
|
||||
.unwrap()
|
||||
.map(|entry| entry.unwrap().file_name().to_str().unwrap().to_string())
|
||||
.sorted()
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_op_heads_store_migration_into_subdir() {
|
||||
let test_dir = testutils::new_temp_dir();
|
||||
let store_path = test_dir.path().join("op_heads");
|
||||
fs::create_dir(&store_path).unwrap();
|
||||
|
||||
let op1 = OperationId::from_hex("012345");
|
||||
let op2 = OperationId::from_hex("abcdef");
|
||||
let mut ops = HashSet::new();
|
||||
ops.insert(op1.clone());
|
||||
ops.insert(op2.clone());
|
||||
|
||||
let old_store = SimpleOpHeadsStore {
|
||||
dir: store_path.clone(),
|
||||
};
|
||||
old_store.add_op_head(&op1);
|
||||
old_store.add_op_head(&op2);
|
||||
|
||||
assert_eq!(vec!["012345", "abcdef"], read_dir(&store_path));
|
||||
drop(old_store);
|
||||
|
||||
let new_store = SimpleOpHeadsStore::load(&store_path);
|
||||
assert_eq!(&ops, &new_store.get_op_heads().into_iter().collect());
|
||||
assert_eq!(vec!["heads"], read_dir(&store_path));
|
||||
assert_eq!(
|
||||
vec!["012345", "abcdef"],
|
||||
read_dir(&store_path.join("heads"))
|
||||
);
|
||||
|
||||
// Migration is idempotent
|
||||
let new_store = SimpleOpHeadsStore::load(&store_path);
|
||||
assert_eq!(&ops, &new_store.get_op_heads().into_iter().collect());
|
||||
assert_eq!(vec!["heads"], read_dir(&store_path));
|
||||
assert_eq!(
|
||||
vec!["012345", "abcdef"],
|
||||
read_dir(&store_path.join("heads"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_op_heads_store_migration_change_dirname() {
|
||||
let test_dir = testutils::new_temp_dir();
|
||||
let store_path = test_dir.path().join("op_heads");
|
||||
fs::create_dir(&store_path).unwrap();
|
||||
let old_heads_path = store_path.join("simple_op_heads");
|
||||
fs::create_dir(&old_heads_path).unwrap();
|
||||
|
||||
let op1 = OperationId::from_hex("012345");
|
||||
let op2 = OperationId::from_hex("abcdef");
|
||||
let mut ops = HashSet::new();
|
||||
ops.insert(op1.clone());
|
||||
ops.insert(op2.clone());
|
||||
|
||||
let old_store = SimpleOpHeadsStore {
|
||||
dir: old_heads_path,
|
||||
};
|
||||
old_store.add_op_head(&op1);
|
||||
old_store.add_op_head(&op2);
|
||||
|
||||
assert_eq!(vec!["simple_op_heads"], read_dir(&store_path));
|
||||
drop(old_store);
|
||||
|
||||
let new_store = SimpleOpHeadsStore::load(&store_path);
|
||||
assert_eq!(&ops, &new_store.get_op_heads().into_iter().collect());
|
||||
assert_eq!(vec!["heads"], read_dir(&store_path));
|
||||
assert_eq!(
|
||||
vec!["012345", "abcdef"],
|
||||
read_dir(&store_path.join("heads"))
|
||||
);
|
||||
|
||||
// Migration is idempotent
|
||||
let new_store = SimpleOpHeadsStore::load(&store_path);
|
||||
assert_eq!(&ops, &new_store.get_op_heads().into_iter().collect());
|
||||
assert_eq!(vec!["heads"], read_dir(&store_path));
|
||||
assert_eq!(
|
||||
vec!["012345", "abcdef"],
|
||||
read_dir(&store_path.join("heads"))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue