revsets: change Git-like range operator ,,, operator to .. (#46)

This commit is contained in:
Martin von Zweigbergk 2021-12-11 23:56:37 -08:00
parent 98659a16e1
commit 35a712cc48
3 changed files with 16 additions and 12 deletions

View file

@ -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+`), There are also operators for getting the parents (`foo~`), children (`foo+`),
ancestors (`:foo`), descendants (`foo:`), DAG range (`foo:bar`, like ancestors (`:foo`), descendants (`foo:`), DAG range (`foo:bar`, like
`git log --ancestry-path`), range (`foo,,,bar`, like Git's `foo..bar`). There `git log --ancestry-path`), range (`foo..bar`, same as Git's). There are also a
are also a few more functions, such as `heads(<set>)`, which filters out few more functions, such as `heads(<set>)`, which filters out revisions in the
revisions in the input set if they're ancestors of other revisions in the set. input set if they're ancestors of other revisions in the set. Let's define an
Let's define an alias based on that by adding the following to `~/.jjconfig`: alias based on that by adding the following to `~/.jjconfig`:
``` ```
[alias] [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 The alias lets us run `jj l` to see the commits we have created between public

View file

@ -12,7 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
identifier = @{ (ASCII_ALPHANUMERIC | "_" | "@" | "/" | ".")+ } non_period_identifier = @{ (ASCII_ALPHANUMERIC | "_" | "@" | "/")+ }
identifier = @{
(non_period_identifier+ ~ ".")+ ~ non_period_identifier+
| non_period_identifier+
}
symbol = { symbol = {
identifier identifier
| literal_string | literal_string
@ -28,7 +32,7 @@ children_op = { "+" }
ancestors_op = { ":" } ancestors_op = { ":" }
descendants_op = { ":" } descendants_op = { ":" }
dag_range_op = { ":" } dag_range_op = { ":" }
range_op = { ",,," } range_op = { ".." }
union_op = { "|" } union_op = { "|" }
intersection_op = { "&" } intersection_op = { "&" }

View file

@ -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 // The range from the root to the root is empty (because the left side of the
// range is exclusive) // range is exclusive)
assert_eq!( assert_eq!(
resolve_commit_ids(mut_repo.as_repo_ref(), "root,,,root"), resolve_commit_ids(mut_repo.as_repo_ref(), "root..root"),
vec![] vec![]
); );
@ -659,7 +659,7 @@ fn test_evaluate_expression_range(use_git: bool) {
assert_eq!( assert_eq!(
resolve_commit_ids( resolve_commit_ids(
mut_repo.as_repo_ref(), 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()] vec![commit3.id().clone(), commit2.id().clone()]
); );
@ -668,7 +668,7 @@ fn test_evaluate_expression_range(use_git: bool) {
assert_eq!( assert_eq!(
resolve_commit_ids( resolve_commit_ids(
mut_repo.as_repo_ref(), mut_repo.as_repo_ref(),
&format!("{},,,{}", commit3.id().hex(), commit1.id().hex()) &format!("{}..{}", commit3.id().hex(), commit1.id().hex())
), ),
vec![] vec![]
); );
@ -677,7 +677,7 @@ fn test_evaluate_expression_range(use_git: bool) {
assert_eq!( assert_eq!(
resolve_commit_ids( resolve_commit_ids(
mut_repo.as_repo_ref(), mut_repo.as_repo_ref(),
&format!("{},,,{}", commit1.id().hex(), commit4.id().hex()) &format!("{}..{}", commit1.id().hex(), commit4.id().hex())
), ),
vec![ vec![
commit4.id().clone(), commit4.id().clone(),
@ -690,7 +690,7 @@ fn test_evaluate_expression_range(use_git: bool) {
assert_eq!( assert_eq!(
resolve_commit_ids( resolve_commit_ids(
mut_repo.as_repo_ref(), mut_repo.as_repo_ref(),
&format!("{},,,{}", commit2.id().hex(), commit3.id().hex()) &format!("{}..{}", commit2.id().hex(), commit3.id().hex())
), ),
vec![commit3.id().clone()] vec![commit3.id().clone()]
); );