forked from mirrors/jj
thrift: add legacy-thrift
Cargo feature
This patch adds a `legacy-thrift` Cargo feature that's enabled by default. If it's disabled, the upgrade from Thrift-based operation log does not happen, and the `thrift` depdendency is not included.
This commit is contained in:
parent
6b964218bf
commit
84a4dee673
4 changed files with 19 additions and 7 deletions
|
@ -44,7 +44,7 @@ dirs = "4.0.0"
|
|||
git2 = "0.15.0"
|
||||
hex = "0.4.3"
|
||||
itertools = "0.10.5"
|
||||
jujutsu-lib = { version = "=0.5.1", path = "lib"}
|
||||
jujutsu-lib = { version = "=0.5.1", path = "lib", default-features = false }
|
||||
once_cell = "1.15.0"
|
||||
maplit = "1.0.2"
|
||||
pest = "2.5.0"
|
||||
|
@ -75,5 +75,5 @@ test-case = "2.2.2"
|
|||
testutils = { path = "lib/testutils" }
|
||||
|
||||
[features]
|
||||
default = ["vendored-openssl"]
|
||||
default = ["vendored-openssl", "jujutsu-lib/legacy-thrift"]
|
||||
vendored-openssl = ["git2/vendored-openssl", "jujutsu-lib/vendored-openssl"]
|
||||
|
|
|
@ -39,7 +39,7 @@ serde_json = "1.0.89"
|
|||
tempfile = "3.3.0"
|
||||
thiserror = "1.0.37"
|
||||
# thrift v0.17.0 (specified by hash for security reasons)
|
||||
thrift = { git = "https://github.com/apache/thrift", rev = "4d493e867b349f3475203ef9848353b315203c51", default-features = false }
|
||||
thrift = { git = "https://github.com/apache/thrift", rev = "4d493e867b349f3475203ef9848353b315203c51", default-features = false, optional = true }
|
||||
uuid = { version = "1.2.2", features = ["v4"] }
|
||||
whoami = "1.2.3"
|
||||
zstd = "0.12.0"
|
||||
|
@ -53,4 +53,9 @@ test-case = "2.2.2"
|
|||
testutils = { path = "testutils" }
|
||||
|
||||
[features]
|
||||
default = ["legacy-thrift"]
|
||||
vendored-openssl = ["git2/vendored-openssl"]
|
||||
# Enable upgrade of repositories created with storage backends based on
|
||||
# Thrift format. Only repos accessed by an unreleased jj version in the
|
||||
# (0.5.1,0.6.0) range used Thrift.
|
||||
legacy-thrift = ["thrift"]
|
||||
|
|
|
@ -30,6 +30,7 @@ pub mod git_backend;
|
|||
pub mod gitignore;
|
||||
pub mod index;
|
||||
pub mod index_store;
|
||||
#[cfg(feature = "legacy-thrift")]
|
||||
mod legacy_thrift_op_store;
|
||||
pub mod local_backend;
|
||||
pub mod lock;
|
||||
|
@ -48,6 +49,7 @@ pub mod revset_graph_iterator;
|
|||
pub mod rewrite;
|
||||
pub mod settings;
|
||||
pub mod simple_op_store;
|
||||
#[cfg(feature = "legacy-thrift")]
|
||||
mod simple_op_store_model;
|
||||
pub mod stacked_table;
|
||||
pub mod store;
|
||||
|
|
|
@ -12,15 +12,11 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fmt::Debug;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use itertools::Itertools;
|
||||
use tempfile::PersistError;
|
||||
|
||||
use crate::legacy_thrift_op_store::ThriftOpStore;
|
||||
use crate::op_store::{OpStore, OpStoreError, OpStoreResult, Operation, OperationId, View, ViewId};
|
||||
use crate::proto_op_store::ProtoOpStore;
|
||||
|
||||
|
@ -43,7 +39,15 @@ pub struct SimpleOpStore {
|
|||
delegate: ProtoOpStore,
|
||||
}
|
||||
|
||||
#[cfg(feature = "legacy-thrift")]
|
||||
fn upgrade_from_thrift(store_path: PathBuf) -> std::io::Result<()> {
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::fs;
|
||||
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::legacy_thrift_op_store::ThriftOpStore;
|
||||
|
||||
println!("Upgrading operation log to Protobuf format...");
|
||||
let old_store = ThriftOpStore::load(store_path.clone());
|
||||
let tmp_store_dir = tempfile::Builder::new()
|
||||
|
@ -117,6 +121,7 @@ impl SimpleOpStore {
|
|||
}
|
||||
|
||||
pub fn load(store_path: PathBuf) -> Self {
|
||||
#[cfg(feature = "legacy-thrift")]
|
||||
if store_path.join("thrift_store").exists() {
|
||||
upgrade_from_thrift(store_path.clone())
|
||||
.expect("Failed to upgrade operation log to Protobuf format");
|
||||
|
|
Loading…
Reference in a new issue