jj/lib/src/lib.rs

62 lines
1.4 KiB
Rust
Raw Normal View History

// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![feature(assert_matches)]
#![feature(get_mut_unchecked)]
index: add support for finding common ancestors We currently need to read the commit objects for finding common ancestors. That can be very slow when the common ancestor is far back in history. This patch adds a function for finding common ancestors using the index instead. Unlike the current algorithm, which only returns one common ancestor, the new index-based one correctly handles criss-cross merges. Here are some timings for finding the common ancestors in the git.git repo: | Without index | With Index | | First run | Subsequent | First run | Subsequent | v2.30.0-rc0 v2.30.0-rc1 | 5.68 ms | 5.94 us | 40.3 us | 4.77 us | v2.25.4 v2.26.1 | 1.75 ms | 1.42 us | 13.8 ms | 4.29 ms | v1.0.0 v2.0.0 | 492 ms | 2.79 ms | 23.4 ms | 6.41 ms | Finding ancestors of v2.25.4 and v2.26.1 got much slower because the new algorithm finds all common ancestors. Therefore, it also finds v2.24.2, v2.23.2, v2.22.3, v2.21.2, v2.20.3, v2.19.4, v2.18.3, and v2.17.4, which it then filters out because they're all ancestors of v2.25.3. Also note that the result was incorrect before, because the old algorithm would return as soon as it had found a common ancestor, even if it's not the latest common ancestor. For example, for the common ancestor between v1.0.0 and v2.0.0, it returned an ancestor of v1.0.0 because it happened to get there by following some side branch that led there more quickly. The only place we currently need to find the common ancestor is when merging trees, which we only do when the user runs `jj merge`, as well as when operating on existing merge commits (e.g. to diff or rebase them). That means that this change won't be very noticeable. However, it's something we clearly want to do sooner or later, so we might as well get it done.
2021-02-16 08:02:36 +00:00
#![feature(map_first_last)]
2021-04-14 23:54:27 +00:00
#![deny(unused_must_use)]
#[macro_use]
extern crate pest_derive;
2020-12-23 17:39:09 +00:00
#[cfg(test)]
#[macro_use]
extern crate maplit;
pub mod commit;
pub mod commit_builder;
pub mod conflicts;
pub mod dag_walk;
pub mod diff;
pub mod evolution;
pub mod file_util;
pub mod files;
pub mod git;
pub mod git_store;
pub mod gitignore;
pub mod index;
pub mod index_store;
pub mod local_store;
pub mod lock;
pub mod matchers;
pub mod op_heads_store;
pub mod op_store;
pub mod operation;
pub mod protos;
pub mod repo;
pub mod repo_path;
pub mod revset;
pub mod revset_graph_iterator;
pub mod rewrite;
pub mod settings;
pub mod simple_op_store;
pub mod store;
pub mod store_wrapper;
pub mod testutils;
pub mod transaction;
pub mod tree;
pub mod tree_builder;
pub mod view;
pub mod working_copy;