Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph: sort parents from farthest to closest #3070

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/tests/test_chmod_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ fn test_chmod_regular_conflict() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ conflict
├─╮
│ ◉ n
◉ │ x
│ ◉ x
◉ │ n
├─╯
◉ base
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_commit_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn test_log_parents() {
insta::assert_snapshot!(stdout, @r###"
@ c067170d4ca1bc6162b64f7550617ec809647f84
├─╮ P: 4db490c88528133d579540b6900b8098f0c17701 230dd059e1b059aefc0da06a2e5a7dbf22362f22
◉ │ 4db490c88528133d579540b6900b8098f0c17701
│ ◉ 4db490c88528133d579540b6900b8098f0c17701
├─╯ P: 230dd059e1b059aefc0da06a2e5a7dbf22362f22
◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22
│ P: 0000000000000000000000000000000000000000
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/test_duplicate_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ fn test_duplicate_many() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
◉ 8348ddcec733 e
├─╮
◉ │ 3b74d9691015 b
│ ◉ 3b74d9691015 b
│ │ @ 921dde6e55c0 e
│ ╭─┤
│ ◉ │ ebd06dba20ec d
│ ◉ │ c0cb3a0b73e7 c
╭───┤
◉ │ │ ebd06dba20ec d
◉ │ │ c0cb3a0b73e7 c
├─╯ │
│ ◉ 1394f625cbbd b
├───╯
Expand Down
64 changes: 60 additions & 4 deletions cli/tests/test_log_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,8 @@ fn test_log_limit() {
insta::assert_snapshot!(stdout, @r###"
@ d
├─╮
│ ◉ b
◉ │ c
│ ◉ c
◉ │ b
├─╯
"###);

Expand All @@ -845,7 +845,7 @@ fn test_log_limit() {
insta::assert_snapshot!(stdout, @r###"
@ d
├─╮
│ ◉ b
│ ◉ c
"###);

let stdout = test_env.jj_cmd_success(
Expand All @@ -866,7 +866,7 @@ fn test_log_limit() {
◉ a
├─╮
│ ◉ c
│ ◉ b
"###);
let stdout = test_env.jj_cmd_success(
&repo_path,
Expand Down Expand Up @@ -1287,6 +1287,62 @@ fn test_log_word_wrap() {
"###);
}

#[test]
fn test_merge_fix_and_initial() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");

test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "fix"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "merge", "@", "@-"]);

let get_log = |revs: &str| -> String {
test_env.jj_cmd_success(
&repo_path,
&["log", "-T", r#"description ++ "\n""#, "-r", revs],
)
};

insta::assert_snapshot!(get_log("::"), @r###"
@ merge
├─╮
│ ◉ fix
├─╯
◉ initial
"###);
}

#[test]
fn test_merge_initial_and_fix() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");

test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "fix"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "merge", "@-", "@"]);

let get_log = |revs: &str| -> String {
test_env.jj_cmd_success(
&repo_path,
&["log", "-T", r#"description ++ "\n""#, "-r", revs],
)
};

insta::assert_snapshot!(get_log("::"), @r###"
@ merge
├─╮
│ ◉ fix
├─╯
◉ initial
"###);
}

#[test]
fn test_elided() {
// Test that elided commits are shown as synthetic nodes.
Expand Down
24 changes: 12 additions & 12 deletions cli/tests/test_new_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,11 @@ fn test_new_insert_before() {
├─╯
@ G
├─┬─╮
│ │ ◉ B
│ │ ◉ A
│ │ ◉ E
│ ◉ │ D
│ ├─╯
◉ │ E
◉ │ B
◉ │ A
├─╯
◉ root
"###);
Expand Down Expand Up @@ -358,13 +358,13 @@ fn test_new_insert_before_root_successors() {
insta::assert_snapshot!(get_short_log_output(&test_env, &repo_path), @r###"
◉ F
├─╮
│ ◉ E
◉ │ D
│ ◉ D
◉ │ E
│ │ ◉ C
│ │ ◉ B
│ │ ◉ A
├───╯
@ │ G
│ ├─╯
│ @ G
├─╯
◉ root
"###);
Expand Down Expand Up @@ -428,13 +428,13 @@ fn test_new_insert_before_no_root_merge() {
insta::assert_snapshot!(get_short_log_output(&test_env, &repo_path), @r###"
◉ F
├─╮
│ ◉ E
◉ │ D
│ ◉ D
◉ │ E
│ │ ◉ C
│ │ ◉ B
├───╯
@ │ G
◉ │ A
│ ├─╯
│ @ G
│ ◉ A
├─╯
◉ root
"###);
Expand Down
14 changes: 7 additions & 7 deletions cli/tests/test_rebase_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ fn test_rebase_single_revision() {
◉ c
│ @ d
│ ├─╮
│ │ ◉ a
│ │ ◉ b
├───╯
│ ◉ b
│ ◉ a
├─╯
"###);
Expand Down Expand Up @@ -355,8 +355,8 @@ fn test_rebase_single_revision_merge_parent() {
◉ c
│ @ d
╭─┤
◉ │ a
│ ◉ b
◉ │ a
├─╯
"###);
Expand All @@ -376,8 +376,8 @@ fn test_rebase_revision_onto_descendant() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ merge
├─╮
│ ◉ a
◉ │ b
│ ◉ b
◉ │ a
├─╯
◉ base
Expand Down Expand Up @@ -482,8 +482,8 @@ fn test_rebase_multiple_destinations() {
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
◉ a
├─╮
◉ b
@c
@ c
b
├─╯
"###);
Expand Down
8 changes: 4 additions & 4 deletions cli/tests/test_workspaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ fn test_workspaces_add_second_workspace_on_merge() {
├─╮
│ │ @ 21a0ea6d1c86c413cb30d7f7d216a74754b148c4 default@
╭─┬─╯
│ ◉ 09ba8d9dfa21b8572c2361e6947ca024d8f0a198
◉ │ 1694f2ddf8ecf9e55ca3cd9554bc0654186b07e0
│ ◉ 1694f2ddf8ecf9e55ca3cd9554bc0654186b07e0
◉ │ 09ba8d9dfa21b8572c2361e6947ca024d8f0a198
├─╯
◉ 0000000000000000000000000000000000000000
"###);
Expand Down Expand Up @@ -217,10 +217,10 @@ fn test_workspaces_add_workspace_multiple_revisions() {
insta::assert_snapshot!(get_log_output(&test_env, &main_path), @r###"
◉ fa8fdc28af12d3c96b1e0ed062f5a8f9a99818f0 merge@
├─┬─╮
│ │ ◉ e7d7dbb91c5a543ea680711093e689916d5f31df
│ │ ◉ 23881f07b53ce1ea936ca8842e344dea9c3356e5
│ ◉ │ 1f6a15f0af2a985703864347f5fdf27a82fc3d73
│ ├─╯
◉ │ 23881f07b53ce1ea936ca8842e344dea9c3356e5
◉ │ e7d7dbb91c5a543ea680711093e689916d5f31df
├─╯
│ @ 5b36783cd11c4607a329c5e8c2fd9097c9ce2add default@
├─╯
Expand Down
4 changes: 3 additions & 1 deletion lib/src/default_index/revset_graph_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ impl<'revset, 'index> RevsetGraphIterator<'revset, 'index> {
) -> Vec<IndexGraphEdge> {
let mut edges = Vec::new();
let mut known_ancestors = HashSet::new();
for parent in index_entry.parents() {
let mut parents: Vec<_> = index_entry.parents().collect();
parents.sort_by(|a, b| a.position().cmp(&b.position()));
for parent in parents {
let parent_position = parent.position();
self.consume_to(parent_position);
if self.look_ahead.contains_key(&parent_position) {
Expand Down
Loading