jj/lib/tests
Ilya Grigoriev 316ab8efb8 rewrite.rs: refactor new_parents to depend only on parent_mapping
Previously, the function relied on both the `self.parent_mapping` and
`self.rebased`. If `(A,B)` was in `parent_mapping` and `(B,C)` was in `rebased`,
`new_parents` would map `A` to `C`.

Now, `self.rebased` is ignored by `new_parents`. In the same situation,
DescendantRebaser is changed so that both `(A,B)` and `(B,C)` are in
`parent_mapping` before. `new_parents` now applies `parent_mapping` repeatedly,
and will map `A` to `C` in this situation.

## Cons

- The semantics are changed; `new_parents` now panics if `self.parent_mapping`
  contain cycles. AFAICT, such cycles never happen in `jj` anyway, except for
one test that I had to fix. I think it's a sensible restriction to live with;
if you do want to swap children of two commits, you can call
`rebase_descendants` twice.

## Pros

- I find the new logic much easier to reason about. I plan to extract it into a
function, to be used in refactors for `jj rebase -r` and `jj new --after`. It
will make it much easier to have a correct implementation of `jj rebase -r
--after`, even when rebasing onto a descendant.

- The de-duplication is no longer O(n^2). I tried to keep the common case fast.

## Alternatives

- We could make `jj rebase` and `jj new` use a separate function with the
algorithm shown here, without changing DescendantRebaser. I believe that the new
algorithm makes DescendatRebaser easier to understand, though, and it feels more
elegant to reduce code duplication.

- The de-duplication optimization here is independent of other changes, and
could be used on its own.
2023-12-12 19:35:51 -08:00
..
test_bad_locking.rs workspace: load working copy implementation dynamically 2023-10-16 22:33:44 -07:00
test_commit_builder.rs repo_path: split RepoPath into owned and borrowed types 2023-11-28 07:33:28 +09:00
test_commit_concurrent.rs
test_conflicts.rs repo_path: split RepoPath into owned and borrowed types 2023-11-28 07:33:28 +09:00
test_default_revset_graph_iterator.rs index: move default_index_store.rs to sub directory named default_index 2023-12-12 08:07:52 +09:00
test_diff_summary.rs repo_path: split RepoPath into owned and borrowed types 2023-11-28 07:33:28 +09:00
test_git.rs git: unimplement PartialEq on FailedRefExportReason 2023-12-09 15:18:19 +09:00
test_id_prefix.rs
test_index.rs index: move default_index_store.rs to sub directory named default_index 2023-12-12 08:07:52 +09:00
test_init.rs tests: make sure to specify external git repository path including ".git" 2023-12-07 08:43:49 +09:00
test_load_repo.rs
test_local_working_copy.rs working_copy: use proto file states without rebuilding BTreeMap 2023-11-30 12:09:31 +09:00
test_local_working_copy_concurrent.rs repo_path: split RepoPath into owned and borrowed types 2023-11-28 07:33:28 +09:00
test_local_working_copy_sparse.rs working_copy: use proto file states without rebuilding BTreeMap 2023-11-30 12:09:31 +09:00
test_merge_trees.rs repo_path: split RepoPath into owned and borrowed types 2023-11-28 07:33:28 +09:00
test_merged_tree.rs merged_tree: remove canceling terms prior to resolving file-level conflict 2023-12-03 07:44:58 +09:00
test_mut_repo.rs view: add tracking state to RemoteRef 2023-10-16 23:21:05 +09:00
test_operations.rs
test_refs.rs merge: add Merge constructor that accepts interleaved values 2023-11-07 17:10:12 +09:00
test_revset.rs repo_path: split RepoPath into owned and borrowed types 2023-11-28 07:33:28 +09:00
test_rewrite.rs rewrite.rs: refactor new_parents to depend only on parent_mapping 2023-12-12 19:35:51 -08:00
test_signing.rs sign: Implement a test signing backend and add a few basic tests 2023-11-30 23:36:56 +02:00
test_view.rs refs: merge tracking state of remote branches 2023-10-24 07:13:58 +09:00
test_workspace.rs workspace: make working-copy type customizable 2023-10-16 22:33:44 -07:00