From 35a712cc48ee524a5bdc7445717a11e1ec77bc3c Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 11 Dec 2021 23:56:37 -0800 Subject: [PATCH] revsets: change Git-like range operator `,,,` operator to `..` (#46) --- docs/tutorial.md | 10 +++++----- lib/src/revset.pest | 8 ++++++-- lib/tests/test_revset.rs | 10 +++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/tutorial.md b/docs/tutorial.md index 9b365d318..7f209cd87 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -169,13 +169,13 @@ It's the root commit of every repo. The `root` symbol in the revset matches it.) There are also operators for getting the parents (`foo~`), children (`foo+`), ancestors (`:foo`), descendants (`foo:`), DAG range (`foo:bar`, like -`git log --ancestry-path`), range (`foo,,,bar`, like Git's `foo..bar`). There -are also a few more functions, such as `heads()`, which filters out -revisions in the input set if they're ancestors of other revisions in the set. -Let's define an alias based on that by adding the following to `~/.jjconfig`: +`git log --ancestry-path`), range (`foo..bar`, same as Git's). There are also a +few more functions, such as `heads()`, which filters out revisions in the +input set if they're ancestors of other revisions in the set. Let's define an +alias based on that by adding the following to `~/.jjconfig`: ``` [alias] -l = ["log", "-r", "(heads(remote_branches()),,,@):"] +l = ["log", "-r", "(heads(remote_branches())..@):"] ``` The alias lets us run `jj l` to see the commits we have created between public diff --git a/lib/src/revset.pest b/lib/src/revset.pest index f2a8a5bfc..652cd1619 100644 --- a/lib/src/revset.pest +++ b/lib/src/revset.pest @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -identifier = @{ (ASCII_ALPHANUMERIC | "_" | "@" | "/" | ".")+ } +non_period_identifier = @{ (ASCII_ALPHANUMERIC | "_" | "@" | "/")+ } +identifier = @{ + (non_period_identifier+ ~ ".")+ ~ non_period_identifier+ + | non_period_identifier+ +} symbol = { identifier | literal_string @@ -28,7 +32,7 @@ children_op = { "+" } ancestors_op = { ":" } descendants_op = { ":" } dag_range_op = { ":" } -range_op = { ",,," } +range_op = { ".." } union_op = { "|" } intersection_op = { "&" } diff --git a/lib/tests/test_revset.rs b/lib/tests/test_revset.rs index b77f7ad10..b879ce74a 100644 --- a/lib/tests/test_revset.rs +++ b/lib/tests/test_revset.rs @@ -651,7 +651,7 @@ fn test_evaluate_expression_range(use_git: bool) { // The range from the root to the root is empty (because the left side of the // range is exclusive) assert_eq!( - resolve_commit_ids(mut_repo.as_repo_ref(), "root,,,root"), + resolve_commit_ids(mut_repo.as_repo_ref(), "root..root"), vec![] ); @@ -659,7 +659,7 @@ fn test_evaluate_expression_range(use_git: bool) { assert_eq!( resolve_commit_ids( mut_repo.as_repo_ref(), - &format!("{},,,{}", commit1.id().hex(), commit3.id().hex()) + &format!("{}..{}", commit1.id().hex(), commit3.id().hex()) ), vec![commit3.id().clone(), commit2.id().clone()] ); @@ -668,7 +668,7 @@ fn test_evaluate_expression_range(use_git: bool) { assert_eq!( resolve_commit_ids( mut_repo.as_repo_ref(), - &format!("{},,,{}", commit3.id().hex(), commit1.id().hex()) + &format!("{}..{}", commit3.id().hex(), commit1.id().hex()) ), vec![] ); @@ -677,7 +677,7 @@ fn test_evaluate_expression_range(use_git: bool) { assert_eq!( resolve_commit_ids( mut_repo.as_repo_ref(), - &format!("{},,,{}", commit1.id().hex(), commit4.id().hex()) + &format!("{}..{}", commit1.id().hex(), commit4.id().hex()) ), vec![ commit4.id().clone(), @@ -690,7 +690,7 @@ fn test_evaluate_expression_range(use_git: bool) { assert_eq!( resolve_commit_ids( mut_repo.as_repo_ref(), - &format!("{},,,{}", commit2.id().hex(), commit3.id().hex()) + &format!("{}..{}", commit2.id().hex(), commit3.id().hex()) ), vec![commit3.id().clone()] );