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

use ancestors(x, depth) in tests and default revset #2228

Merged
merged 2 commits into from
Sep 8, 2023
Merged
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
5 changes: 2 additions & 3 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,8 @@ struct StatusArgs {}
/// Show commit history
#[derive(clap::Args, Clone, Debug)]
struct LogArgs {
/// Which revisions to show. Defaults to the `revsets.log` setting,
/// or `@ | (remote_branches() | tags()).. | ((remote_branches() |
/// tags())..)-` if it is not set.
/// Which revisions to show. Defaults to the `revsets.log` setting, or
/// `@ | ancestors((remote_branches() | tags()).., 2)` if it is not set.
#[arg(long, short)]
revisions: Vec<RevisionArg>,
/// Show commits modifying the given paths
Expand Down
2 changes: 1 addition & 1 deletion cli/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"log": {
"type": "string",
"description": "Default set of revisions to show when no explicit revset is given for jj log and similar commands",
"default": "@ | (remote_branches() | tags()).. | ((remote_branches() | tags())..)-"
"default": "@ | ancestors((remote_branches() | tags()).., 2)"
},
"short-prefixes": {
"type": "string",
Expand Down
19 changes: 2 additions & 17 deletions lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4685,20 +4685,8 @@ mod tests {
"###);

// Ancestors of empty generation range should be empty.
// TODO: rewrite these tests if we added syntax for arbitrary generation
// ancestors
let empty_generation_ancestors = |heads| {
Rc::new(RevsetExpression::Ancestors {
heads,
generation: GENERATION_RANGE_EMPTY,
is_legacy: false,
})
};
insta::assert_debug_snapshot!(
optimize(empty_generation_ancestors(
RevsetExpression::symbol("foo".to_owned()).ancestors()
)),
@r###"
optimize(parse("ancestors(ancestors(foo), 0)").unwrap()), @r###"
Ancestors {
heads: CommitRef(
Symbol(
Expand All @@ -4711,10 +4699,7 @@ mod tests {
"###
);
insta::assert_debug_snapshot!(
optimize(
empty_generation_ancestors(RevsetExpression::symbol("foo".to_owned())).ancestors()
),
@r###"
optimize(parse("ancestors(ancestors(foo, 0))").unwrap()), @r###"
Ancestors {
heads: CommitRef(
Symbol(
Expand Down
5 changes: 1 addition & 4 deletions lib/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ impl UserSettings {
// For compatibility with old config files (<0.8.0)
self.config
.get_string("ui.default-revset")
.unwrap_or_else(|_| {
"@ | (remote_branches() | tags()).. | ((remote_branches() | tags())..)-"
.to_string()
})
.unwrap_or_else(|_| "@ | ancestors((remote_branches() | tags()).., 2)".to_string())
})
}

Expand Down