Skip to content

Commit

Permalink
Rename conflict revset to conflicts.
Browse files Browse the repository at this point in the history
See discussion thread in linked issue.

With this PR, all revset functions in [BUILTIN_FUNCTION_MAP](https://github.com/martinvonz/jj/blob/8d166c764251042287626ab37a1148386cef8371/lib/src/revset.rs#L570)
that return multiple values are either named in plural or named in a difficult-to-misused manner (e.g. `reachable`)

Fixes: #4122
  • Loading branch information
essiene committed Sep 17, 2024
1 parent 6d0a092 commit a12adc2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
commit to commit. It now either follows the flags `--edit|--no-edit` or it
gets the mode from `ui.movement.edit`.

* `conflict` revset has been renamed to `conflicts`. With this, all revsets that
could potentially return multiple results are named in the plural.

### Deprecations

* `jj untrack` has been renamed to `jj file untrack`.
Expand Down
5 changes: 5 additions & 0 deletions cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,11 @@ pub struct RevisionArg(Cow<'static, str>);
impl RevisionArg {
/// The working-copy symbol, which is the default of the most commands.
pub const AT: Self = RevisionArg(Cow::Borrowed("@"));

pub warn_deprecated(&self) {
let _ = Self(self);
}

}

impl From<String> for RevisionArg {
Expand Down
2 changes: 1 addition & 1 deletion docs/revsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ given [string pattern](#string-patterns).
For example, `diff_contains("TODO", "src")` will search revisions where "TODO"
is added to or removed from files under "src".

* `conflict()`: Commits with conflicts.
* `conflicts()`: Commits with conflicts.

* `present(x)`: Same as `x`, but evaluated to `none()` if any of the commits
in `x` doesn't exist (e.g. is an unknown bookmark name.)
Expand Down
4 changes: 4 additions & 0 deletions lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ static BUILTIN_FUNCTION_MAP: Lazy<HashMap<&'static str, RevsetFunction>> = Lazy:
function.expect_no_arguments()?;
Ok(RevsetExpression::filter(RevsetFilterPredicate::HasConflict))
});
map.insert("conflicts", |function, _context| {
function.expect_no_arguments()?;
Ok(RevsetExpression::filter(RevsetFilterPredicate::HasConflict))
});
map.insert("present", |function, context| {
let [arg] = function.expect_exact_arguments()?;
let expression = lower_expression(arg, context)?;
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/test_revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,7 @@ fn test_evaluate_expression_conflict() {

// Only commit4 has a conflict
assert_eq!(
resolve_commit_ids(mut_repo, "conflict()"),
resolve_commit_ids(mut_repo, "conflicts()"),
vec![commit4.id().clone()]
);
}
Expand Down

0 comments on commit a12adc2

Please sign in to comment.