mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-26 14:00:51 +00:00
96f5ca47d4
There are several existing commands that would benefit from an API that makes it easier to rewrite a whole graph of commits while transforming them in some way. `jj squash` is one example. When squashing into an ancestor, that command currently rewrites the ancestor, then rebases descendants, and then rewrites the rewritten source commit. It would be better to rewrite the source commit (and any descendants) only once. Another example is the future `jj fix`. That command will want to rewrite a graph while updating the trees. There's currently no good API for that; you have to manually iterate over descendants and rewrite them. This patch adds a new `MutableRepo::transform_descendants()` method that takes a callback which gets a `CommitRewriter` passed to it. The callback can then decide to change the parents, the tree, etc. The callback is also free to leave the commit in place or to abandon it. I updated the regular `rebase_descendants()` to use the new function in order to exercise it. I hope we can replace all of the `rebase_descendant_*()` flavors later. I added a `replace_parent()` method that was a bit useful for the test case. It could easily be hard-coded in the test case instead, but I think the method will be useful for `jj git sync` and similar in the future.
36 lines
827 B
Rust
36 lines
827 B
Rust
use std::path::PathBuf;
|
|
|
|
#[test]
|
|
fn test_no_forgotten_test_files() {
|
|
let test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests");
|
|
testutils::assert_no_forgotten_test_files(&test_dir);
|
|
}
|
|
|
|
mod test_bad_locking;
|
|
mod test_commit_builder;
|
|
mod test_commit_concurrent;
|
|
mod test_conflicts;
|
|
mod test_default_revset_graph_iterator;
|
|
mod test_diff_summary;
|
|
mod test_git;
|
|
mod test_git_backend;
|
|
mod test_gpg;
|
|
mod test_id_prefix;
|
|
mod test_index;
|
|
mod test_init;
|
|
mod test_load_repo;
|
|
mod test_local_working_copy;
|
|
mod test_local_working_copy_concurrent;
|
|
mod test_local_working_copy_sparse;
|
|
mod test_merge_trees;
|
|
mod test_merged_tree;
|
|
mod test_mut_repo;
|
|
mod test_operations;
|
|
mod test_refs;
|
|
mod test_revset;
|
|
mod test_rewrite;
|
|
mod test_rewrite_transform;
|
|
mod test_signing;
|
|
mod test_ssh_signing;
|
|
mod test_view;
|
|
mod test_workspace;
|