From 3ff1ab520b5cacf2f82cb56e6bf3716c031752b3 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 28 Mar 2023 10:15:07 -0700 Subject: [PATCH] revset: remove `public_heads()` The `public_heads()` revset only contains the root commit in practice. I'm not sure what we want to do about phases, but since we don't have any real support for them yet, let's just remove this revset. I didn't update the changelog because we don't seem to have documented the revset function (and it seems unlikely that users who found out about it found it useful enough to use it when they could just use `root`). --- lib/src/default_revset_engine.rs | 4 ---- lib/src/revset.rs | 10 ---------- lib/tests/test_revset.rs | 33 -------------------------------- 3 files changed, 47 deletions(-) diff --git a/lib/src/default_revset_engine.rs b/lib/src/default_revset_engine.rs index b4891866f..c94c94fa2 100644 --- a/lib/src/default_revset_engine.rs +++ b/lib/src/default_revset_engine.rs @@ -612,10 +612,6 @@ fn internal_evaluate<'index>( } Ok(Box::new(EagerRevset { index_entries })) } - RevsetExpression::PublicHeads => Ok(revset_for_commit_ids( - repo, - &repo.view().public_heads().iter().cloned().collect_vec(), - )), RevsetExpression::Latest { candidates, count } => { let candidate_set = internal_evaluate(repo, candidates)?; Ok(take_latest_revset(repo, candidate_set.as_ref(), *count)) diff --git a/lib/src/revset.rs b/lib/src/revset.rs index 4459a806e..8aeedb963 100644 --- a/lib/src/revset.rs +++ b/lib/src/revset.rs @@ -223,7 +223,6 @@ pub enum RevsetExpression { Heads(Rc), Roots(Rc), VisibleHeads, - PublicHeads, Branches(String), RemoteBranches { branch_needle: String, @@ -271,10 +270,6 @@ impl RevsetExpression { Rc::new(RevsetExpression::VisibleHeads) } - pub fn public_heads() -> Rc { - Rc::new(RevsetExpression::PublicHeads) - } - pub fn branches(needle: String) -> Rc { Rc::new(RevsetExpression::Branches(needle)) } @@ -803,10 +798,6 @@ static BUILTIN_FUNCTION_MAP: Lazy> = Lazy: let candidates = parse_expression_rule(arg.into_inner(), state)?; Ok(candidates.roots()) }); - map.insert("public_heads", |name, arguments_pair, _state| { - expect_no_arguments(name, arguments_pair)?; - Ok(RevsetExpression::public_heads()) - }); map.insert("branches", |name, arguments_pair, state| { let ([], [opt_arg]) = expect_arguments(name, arguments_pair)?; let needle = if let Some(arg) = opt_arg { @@ -1154,7 +1145,6 @@ fn try_transform_expression_bottom_up( RevsetExpression::Roots(candidates) => { transform_rec(candidates, f)?.map(RevsetExpression::Roots) } - RevsetExpression::PublicHeads => None, RevsetExpression::Branches(_) => None, RevsetExpression::RemoteBranches { .. } => None, RevsetExpression::Tags => None, diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index 05ea39608..fa54bb3ff 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -1192,39 +1192,6 @@ fn test_evaluate_expression_visible_heads(use_git: bool) { ); } -#[test_case(false ; "local backend")] -#[test_case(true ; "git backend")] -fn test_evaluate_expression_public_heads(use_git: bool) { - let settings = testutils::user_settings(); - let test_repo = TestRepo::init(use_git); - let repo = &test_repo.repo; - - let root_commit = repo.store().root_commit(); - let mut tx = repo.start_transaction(&settings, "test"); - let mut_repo = tx.mut_repo(); - let mut graph_builder = CommitGraphBuilder::new(&settings, mut_repo); - let commit1 = graph_builder.initial_commit(); - let commit2 = graph_builder.initial_commit(); - - // Can get public heads with root commit as only public head - assert_eq!( - resolve_commit_ids(mut_repo, "public_heads()"), - vec![root_commit.id().clone()] - ); - // Can get public heads with a single public head - mut_repo.add_public_head(&commit1); - assert_eq!( - resolve_commit_ids(mut_repo, "public_heads()"), - vec![commit1.id().clone()] - ); - // Can get public heads with multiple public head - mut_repo.add_public_head(&commit2); - assert_eq!( - resolve_commit_ids(mut_repo, "public_heads()"), - vec![commit2.id().clone(), commit1.id().clone()] - ); -} - #[test_case(false ; "local backend")] #[test_case(true ; "git backend")] fn test_evaluate_expression_git_refs(use_git: bool) {