ok/jj
1
0
Fork 0
forked from mirrors/jj

repo: remove code for upgrading old repos to have .jj/store/git/

1b6efdc3f8 moved `.jj/git/` into `.jj/store/` for consistency with
the layout of native stores. It provided automatic format upgrades for
repos with the old format. It's been about four months now, so let's
remove the migration code.
This commit is contained in:
Martin von Zweigbergk 2022-02-17 22:34:39 -08:00
parent 1eb913d444
commit 7c247116b9

View file

@ -16,8 +16,6 @@ use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::fmt::{Debug, Formatter};
use std::fs;
use std::fs::File;
use std::io::Read;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
@ -298,27 +296,6 @@ pub struct RepoLoader {
impl RepoLoader {
pub fn init(user_settings: &UserSettings, repo_path: PathBuf) -> Self {
let store_path = repo_path.join("store");
if store_path.is_file() {
// This is the old format. Let's be nice and upgrade any existing repos.
// TODO: Delete this in early 2022 or so
println!("The repo format has changed. Upgrading...");
let mut buf = vec![];
{
let mut store_file = File::open(&store_path).unwrap();
store_file.read_to_end(&mut buf).unwrap();
}
let contents = String::from_utf8(buf).unwrap();
assert!(contents.starts_with("git: "));
let git_backend_path_str = contents[5..].to_string();
fs::remove_file(&store_path).unwrap();
fs::create_dir(&store_path).unwrap();
if repo_path.join("git").is_dir() {
fs::rename(repo_path.join("git"), store_path.join("git")).unwrap();
}
fs::write(store_path.join("git_target"), &git_backend_path_str).unwrap();
println!("Done. .jj/git is now .jj/store/git");
}
let store = Store::load_store(repo_path.join("store"));
let repo_settings = user_settings.with_repo(&repo_path).unwrap();
let op_store: Arc<dyn OpStore> = Arc::new(SimpleOpStore::load(repo_path.join("op_store")));