From 2905a70b180b66529117fa5e143e28650e3e9449 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 13 Feb 2024 14:56:46 +0900 Subject: [PATCH] doc, tests: drop use of deprecated revset dag range operator --- cli/tests/test_log_command.rs | 2 +- lib/src/revset.rs | 42 +++++++++++------------ lib/tests/test_revset.rs | 64 +++++++++++++++++------------------ 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index c2f5a1431..043b68004 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -420,7 +420,7 @@ fn test_log_shortest_accessors() { "###); // Can get shorter prefixes in configured revset - test_env.add_config(r#"revsets.short-prefixes = "(@----):""#); + test_env.add_config(r#"revsets.short-prefixes = "(@----)::""#); insta::assert_snapshot!( render("::@", r#"format_id(change_id) ++ " " ++ format_id(commit_id) ++ "\n""#), @r###" diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 6f152d25b..61655b024 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -1801,7 +1801,7 @@ fn fold_difference(expression: &Rc) -> TransformedExpression { complement: &Rc, ) -> Rc { match (expression.as_ref(), complement.as_ref()) { - // :heads & ~(:roots) -> roots..heads + // ::heads & ~(::roots) -> roots..heads ( RevsetExpression::Ancestors { heads, generation, .. @@ -1844,7 +1844,7 @@ fn fold_difference(expression: &Rc) -> TransformedExpression { /// further by `fold_redundant_expression()`. fn unfold_difference(expression: &Rc) -> TransformedExpression { transform_expression_bottom_up(expression, |expression| match expression.as_ref() { - // roots..heads -> :heads & ~(:roots) + // roots..heads -> ::heads & ~(::roots) RevsetExpression::Range { roots, heads, @@ -1886,8 +1886,8 @@ fn fold_generation(expression: &Rc) -> TransformedExpression { } => { match heads.as_ref() { // (h-)- -> ancestors(ancestors(h, 1), 1) -> ancestors(h, 2) - // :(h-) -> ancestors(ancestors(h, 1), ..) -> ancestors(h, 1..) - // (:h)- -> ancestors(ancestors(h, ..), 1) -> ancestors(h, 1..) + // ::(h-) -> ancestors(ancestors(h, 1), ..) -> ancestors(h, 1..) + // (::h)- -> ancestors(ancestors(h, ..), 1) -> ancestors(h, 1..) RevsetExpression::Ancestors { heads, generation: generation2, @@ -1907,8 +1907,8 @@ fn fold_generation(expression: &Rc) -> TransformedExpression { } => { match roots.as_ref() { // (r+)+ -> descendants(descendants(r, 1), 1) -> descendants(r, 2) - // (r+): -> descendants(descendants(r, 1), ..) -> descendants(r, 1..) - // (r:)+ -> descendants(descendants(r, ..), 1) -> descendants(r, 1..) + // (r+):: -> descendants(descendants(r, 1), ..) -> descendants(r, 1..) + // (r::)+ -> descendants(descendants(r, ..), 1) -> descendants(r, 1..) RevsetExpression::Descendants { roots, generation: generation2, @@ -3004,7 +3004,7 @@ mod tests { assert_eq!(parse("x&~y").unwrap(), parse("x&(~y)").unwrap()); assert_eq!(parse("x~~y").unwrap(), parse("x~(~y)").unwrap()); assert_eq!(parse("x~~~y").unwrap(), parse("x~(~(~y))").unwrap()); - assert_eq!(parse("~x:y").unwrap(), parse("~(x:y)").unwrap()); + assert_eq!(parse("~x::y").unwrap(), parse("~(x::y)").unwrap()); assert_eq!(parse("x|y|z").unwrap(), parse("(x|y)|z").unwrap()); assert_eq!(parse("x&y|z").unwrap(), parse("(x&y)|z").unwrap()); assert_eq!(parse("x|y&z").unwrap(), parse("x|(y&z)").unwrap()); @@ -3173,8 +3173,8 @@ mod tests { parse("(a|b)|c").unwrap() ); assert_eq!( - parse_with_aliases("AB:heads(AB)", [("AB", "a|b")]).unwrap(), - parse("(a|b):heads(a|b)").unwrap() + parse_with_aliases("AB::heads(AB)", [("AB", "a|b")]).unwrap(), + parse("(a|b)::heads(a|b)").unwrap() ); // Not string substitution 'a&b|c', but tree substitution. @@ -3265,8 +3265,8 @@ mod tests { // Arguments should be resolved in the current scope. assert_eq!( - parse_with_aliases("F(a:y,b:x)", [("F(x,y)", "x|y")]).unwrap(), - parse("(a:y)|(b:x)").unwrap() + parse_with_aliases("F(a::y,b::x)", [("F(x,y)", "x|y")]).unwrap(), + parse("(a::y)|(b::x)").unwrap() ); // F(a) -> G(a)&y -> (x|a)&y assert_eq!( @@ -3379,7 +3379,7 @@ mod tests { .range(&RevsetExpression::tags()) ); assert_eq!( - optimize(parse("(branches() & all()):(all() & tags())").unwrap()), + optimize(parse("(branches() & all())::(all() & tags())").unwrap()), RevsetExpression::branches(StringPattern::everything()) .dag_range_to(&RevsetExpression::tags()) ); @@ -3588,7 +3588,7 @@ mod tests { "###); // Range expression. - insta::assert_debug_snapshot!(optimize(parse(":foo & ~:bar").unwrap()), @r###" + insta::assert_debug_snapshot!(optimize(parse("::foo & ~::bar").unwrap()), @r###" Range { roots: CommitRef( Symbol( @@ -3603,7 +3603,7 @@ mod tests { generation: 0..18446744073709551615, } "###); - insta::assert_debug_snapshot!(optimize(parse("~:foo & :bar").unwrap()), @r###" + insta::assert_debug_snapshot!(optimize(parse("~::foo & ::bar").unwrap()), @r###" Range { roots: CommitRef( Symbol( @@ -4466,7 +4466,7 @@ mod tests { is_legacy: false, } "###); - insta::assert_debug_snapshot!(optimize(parse(":(foo---)").unwrap()), @r###" + insta::assert_debug_snapshot!(optimize(parse("::(foo---)").unwrap()), @r###" Ancestors { heads: CommitRef( Symbol( @@ -4477,7 +4477,7 @@ mod tests { is_legacy: false, } "###); - insta::assert_debug_snapshot!(optimize(parse("(:foo)---").unwrap()), @r###" + insta::assert_debug_snapshot!(optimize(parse("(::foo)---").unwrap()), @r###" Ancestors { heads: CommitRef( Symbol( @@ -4635,7 +4635,7 @@ mod tests { is_legacy: false, } "###); - insta::assert_debug_snapshot!(optimize(parse("(foo+++):").unwrap()), @r###" + insta::assert_debug_snapshot!(optimize(parse("(foo+++)::").unwrap()), @r###" Descendants { roots: CommitRef( Symbol( @@ -4646,7 +4646,7 @@ mod tests { is_legacy: false, } "###); - insta::assert_debug_snapshot!(optimize(parse("(foo:)+++").unwrap()), @r###" + insta::assert_debug_snapshot!(optimize(parse("(foo::)+++").unwrap()), @r###" Descendants { roots: CommitRef( Symbol( @@ -4676,9 +4676,9 @@ mod tests { "###); // TODO: Inner Descendants can be folded into DagRange. Perhaps, we can rewrite - // 'x:y' to 'x: & :y' first, so the common substitution rule can handle both - // 'x+:y' and 'x+ & :y'. - insta::assert_debug_snapshot!(optimize(parse("(foo++):bar").unwrap()), @r###" + // 'x::y' to 'x:: & ::y' first, so the common substitution rule can handle both + // 'x+::y' and 'x+ & ::y'. + insta::assert_debug_snapshot!(optimize(parse("(foo++)::bar").unwrap()), @r###" DagRange { roots: Descendants { roots: CommitRef( diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index b5150915f..7f786aca2 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -1160,14 +1160,14 @@ fn test_evaluate_expression_ancestors() { // The ancestors of the root commit is just the root commit itself assert_eq!( - resolve_commit_ids(mut_repo, ":root()"), + resolve_commit_ids(mut_repo, "::root()"), vec![root_commit.id().clone()] ); // Can find ancestors of a specific commit. Commits reachable via multiple paths // are not repeated. assert_eq!( - resolve_commit_ids(mut_repo, &format!(":{}", commit4.id().hex())), + resolve_commit_ids(mut_repo, &format!("::{}", commit4.id().hex())), vec![ commit4.id().clone(), commit3.id().clone(), @@ -1180,7 +1180,7 @@ fn test_evaluate_expression_ancestors() { // Can find ancestors of parents or parents of ancestors, which may be optimized // to single query assert_eq!( - resolve_commit_ids(mut_repo, &format!(":({}-)", commit4.id().hex()),), + resolve_commit_ids(mut_repo, &format!("::({}-)", commit4.id().hex()),), vec![ commit3.id().clone(), commit2.id().clone(), @@ -1191,7 +1191,7 @@ fn test_evaluate_expression_ancestors() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("(:({}|{}))-", commit3.id().hex(), commit2.id().hex()), + &format!("(::({}|{}))-", commit3.id().hex(), commit2.id().hex()), ), vec![ commit2.id().clone(), @@ -1202,7 +1202,7 @@ fn test_evaluate_expression_ancestors() { assert_eq!( resolve_commit_ids( mut_repo, - &format!(":(({}|{})-)", commit3.id().hex(), commit2.id().hex()), + &format!("::(({}|{})-)", commit3.id().hex(), commit2.id().hex()), ), vec![ commit2.id().clone(), @@ -1329,7 +1329,7 @@ fn test_evaluate_expression_dag_range() { // Can get DAG range of just the root commit assert_eq!( - resolve_commit_ids(mut_repo, "root():root()"), + resolve_commit_ids(mut_repo, "root()::root()"), vec![root_commit_id.clone()] ); @@ -1337,7 +1337,7 @@ fn test_evaluate_expression_dag_range() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("{}:{}", root_commit_id.hex(), commit2.id().hex()) + &format!("{}::{}", root_commit_id.hex(), commit2.id().hex()) ), vec![ commit2.id().clone(), @@ -1350,14 +1350,14 @@ fn test_evaluate_expression_dag_range() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("{}:{}", commit2.id().hex(), commit4.id().hex()) + &format!("{}::{}", commit2.id().hex(), commit4.id().hex()) ), vec![] ); // Empty root assert_eq!( - resolve_commit_ids(mut_repo, &format!("none():{}", commit5.id().hex())), + resolve_commit_ids(mut_repo, &format!("none()::{}", commit5.id().hex())), vec![], ); @@ -1366,7 +1366,7 @@ fn test_evaluate_expression_dag_range() { resolve_commit_ids( mut_repo, &format!( - "({}|{}):{}", + "({}|{})::{}", commit1.id().hex(), commit2.id().hex(), commit3.id().hex() @@ -1383,7 +1383,7 @@ fn test_evaluate_expression_dag_range() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("{}:{}", commit1.id().hex(), commit5.id().hex()) + &format!("{}::{}", commit1.id().hex(), commit5.id().hex()) ), vec![ commit5.id().clone(), @@ -1398,7 +1398,7 @@ fn test_evaluate_expression_dag_range() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("{}:{}", commit2.id().hex(), commit5.id().hex()) + &format!("{}::{}", commit2.id().hex(), commit5.id().hex()) ), vec![ commit5.id().clone(), @@ -1531,7 +1531,7 @@ fn test_evaluate_expression_descendants() { // The descendants of the root commit are all the commits in the repo assert_eq!( - resolve_commit_ids(mut_repo, "root():"), + resolve_commit_ids(mut_repo, "root()::"), vec![ commit6.id().clone(), commit5.id().clone(), @@ -1545,7 +1545,7 @@ fn test_evaluate_expression_descendants() { // Can find descendants of a specific commit assert_eq!( - resolve_commit_ids(mut_repo, &format!("{}:", commit2.id().hex())), + resolve_commit_ids(mut_repo, &format!("{}::", commit2.id().hex())), vec![ commit6.id().clone(), commit5.id().clone(), @@ -1557,7 +1557,7 @@ fn test_evaluate_expression_descendants() { // Can find descendants of children or children of descendants, which may be // optimized to single query assert_eq!( - resolve_commit_ids(mut_repo, &format!("({}+):", commit1.id().hex())), + resolve_commit_ids(mut_repo, &format!("({}+)::", commit1.id().hex())), vec![ commit6.id().clone(), commit5.id().clone(), @@ -1567,7 +1567,7 @@ fn test_evaluate_expression_descendants() { ] ); assert_eq!( - resolve_commit_ids(mut_repo, &format!("({}++):", commit1.id().hex())), + resolve_commit_ids(mut_repo, &format!("({}++)::", commit1.id().hex())), vec![ commit6.id().clone(), commit5.id().clone(), @@ -1577,7 +1577,7 @@ fn test_evaluate_expression_descendants() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("(({}|{}):)+", commit4.id().hex(), commit2.id().hex()), + &format!("(({}|{})::)+", commit4.id().hex(), commit2.id().hex()), ), vec![ commit6.id().clone(), @@ -1588,7 +1588,7 @@ fn test_evaluate_expression_descendants() { assert_eq!( resolve_commit_ids( mut_repo, - &format!("(({}|{})+):", commit4.id().hex(), commit2.id().hex()), + &format!("(({}|{})+)::", commit4.id().hex(), commit2.id().hex()), ), vec![ commit6.id().clone(), @@ -2052,7 +2052,7 @@ fn test_evaluate_expression_merges() { ); // Searches only among candidates if specified assert_eq!( - resolve_commit_ids(mut_repo, &format!(":{} & merges()", commit5.id().hex())), + resolve_commit_ids(mut_repo, &format!("::{} & merges()", commit5.id().hex())), vec![commit5.id().clone()] ); } @@ -2328,7 +2328,7 @@ fn test_evaluate_expression_union() { assert_eq!( resolve_commit_ids( mut_repo, - &format!(":{} | :{}", commit4.id().hex(), commit5.id().hex()) + &format!("::{} | ::{}", commit4.id().hex(), commit5.id().hex()) ), vec![ commit5.id().clone(), @@ -2345,7 +2345,7 @@ fn test_evaluate_expression_union() { resolve_commit_ids( mut_repo, &format!( - "(:{} ~ :{}) | :{}", + "(::{} ~ ::{}) | ::{}", commit4.id().hex(), commit2.id().hex(), commit5.id().hex() @@ -2366,7 +2366,7 @@ fn test_evaluate_expression_union() { resolve_commit_ids( mut_repo, &format!( - "(:{} ~ :{}) | {}", + "(::{} ~ ::{}) | {}", commit4.id().hex(), commit2.id().hex(), commit5.id().hex(), @@ -2400,7 +2400,7 @@ fn test_evaluate_expression_intersection() { assert_eq!( resolve_commit_ids( mut_repo, - &format!(":{} & :{}", commit4.id().hex(), commit5.id().hex()) + &format!("::{} & ::{}", commit4.id().hex(), commit5.id().hex()) ), vec![ commit2.id().clone(), @@ -2437,7 +2437,7 @@ fn test_evaluate_expression_difference() { // Difference from all assert_eq!( - resolve_commit_ids(mut_repo, &format!("~:{}", commit5.id().hex())), + resolve_commit_ids(mut_repo, &format!("~::{}", commit5.id().hex())), vec![commit4.id().clone(), commit3.id().clone()] ); @@ -2445,28 +2445,28 @@ fn test_evaluate_expression_difference() { assert_eq!( resolve_commit_ids( mut_repo, - &format!(":{} ~ :{}", commit4.id().hex(), commit5.id().hex()) + &format!("::{} ~ ::{}", commit4.id().hex(), commit5.id().hex()) ), vec![commit4.id().clone(), commit3.id().clone()] ); assert_eq!( resolve_commit_ids( mut_repo, - &format!(":{} ~ :{}", commit5.id().hex(), commit4.id().hex()) + &format!("::{} ~ ::{}", commit5.id().hex(), commit4.id().hex()) ), vec![commit5.id().clone()] ); assert_eq!( resolve_commit_ids( mut_repo, - &format!("~:{} & :{}", commit4.id().hex(), commit5.id().hex()) + &format!("~::{} & ::{}", commit4.id().hex(), commit5.id().hex()) ), vec![commit5.id().clone()] ); assert_eq!( resolve_commit_ids( mut_repo, - &format!(":{} ~ :{}", commit4.id().hex(), commit2.id().hex()) + &format!("::{} ~ ::{}", commit4.id().hex(), commit2.id().hex()) ), vec![commit4.id().clone(), commit3.id().clone()] ); @@ -2476,7 +2476,7 @@ fn test_evaluate_expression_difference() { resolve_commit_ids( mut_repo, &format!( - ":{} ~ {} ~ {}", + "::{} ~ {} ~ {}", commit4.id().hex(), commit2.id().hex(), commit3.id().hex() @@ -2494,7 +2494,7 @@ fn test_evaluate_expression_difference() { resolve_commit_ids( mut_repo, &format!( - "(:{} ~ :{}) ~ (:{} ~ :{})", + "(::{} ~ ::{}) ~ (::{} ~ ::{})", commit4.id().hex(), commit1.id().hex(), commit3.id().hex(), @@ -2662,7 +2662,7 @@ fn test_evaluate_expression_file() { assert_eq!( resolve_commit_ids_in_workspace( mut_repo, - &format!(r#"{}: & file("added_modified_clean")"#, commit2.id().hex()), + &format!(r#"{}:: & file("added_modified_clean")"#, commit2.id().hex()), &test_workspace.workspace, Some(test_workspace.workspace.workspace_root()), ), @@ -2671,7 +2671,7 @@ fn test_evaluate_expression_file() { // empty() revset, which is identical to ~file(".") assert_eq!( - resolve_commit_ids(mut_repo, &format!("{}: & empty()", commit1.id().hex())), + resolve_commit_ids(mut_repo, &format!("{}:: & empty()", commit1.id().hex())), vec![commit4.id().clone()] ); }