ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

952 commits

Author SHA1 Message Date
Noah Mayr
88a4a8281f cli: add better error message when immutable_heads() cannot be resolved 2024-04-03 07:58:00 +02:00
Noah Mayr
b79984884d cli: only use default log revset when neither path nor revset is provided 2024-04-03 07:57:06 +02:00
Ilya Grigoriev
670e6ac62b cmd squash: alias --to for the --into flag
I keep typing `--to` since I'm used to `jj move` interface. It is
also shorter.

Currently, if I type `--to`, clap unhelpfully suggests whether I
meant `--tool`.
2024-04-02 18:32:39 -07:00
Yuya Nishihara
bb87fac1a4 revset: parse "all:" prefix rule by pest
I had to use negative lookahead !":" because we still support a dummy ":"
operator to provide a suggestion.
2024-04-03 08:59:42 +09:00
Yuya Nishihara
acf8a8e1b2 cli: unblock "branch list --all-remotes" with name patterns
Like -r/--revisions, it should be okay to filter synced/non-tracking remote
branches by name.

conflicts_with_all = "tracked" is redundant, so removed as well. The tracked
field declares that it conflicts with --all-remotes.
2024-04-03 08:59:29 +09:00
Yuya Nishihara
a5abd98076 cli: inline resolve_revset() to caller
There's only one caller, and the implementation is straightforward.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
5d09234839 cli: don't check duplicates in revisions prefixed with "all:"
Since "all:" implies that the user doesn't care about the order of the
revisions within that argument, it should be okay if two "all:" sets overlapped.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
c3fa13e761 cli: inline resolve_revset_default_single() 2024-04-02 15:17:12 +09:00
Yuya Nishihara
4f0c52d828 cli: extract parsing part of resolve_single_rev_with_hint_about_all_prefix()
Yet another step towards inlining resolve_revset_default_single(). I'll
reimplement parse_revset_with_all_prefix() later to be pest-based.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
a8c4e0ecbd cli: move resolve_multiple_nonempty_revsets_default_single() to command helper
resolve_revset_default_single() will be inlined instead. Since "default_single"
evaluation can return multiple revisions, the CLI interface usually accepts
multiple arguments. This suggests that there would be no external callers of
the singular resolve_revset_default_single().
2024-04-02 15:17:12 +09:00
Yuya Nishihara
0c4f4c8767 cli: extract evaluation part of resolve_single_rev_with_hint_about_all_prefix()
I'm going to reorganize "single"/"default_single" revset functions in a way
that resolve_single_rev_with_hint_about_all_prefix() is inlined.
evaluate_revset_to_single_commit() could be a private method of
WorkspaceCommandHelper, but I want to minimize the code that has to be hosted
there.
2024-04-02 15:17:12 +09:00
Yuya Nishihara
f04402e3c7 cli: extract function that creates "not a single revision" error
This function isn't small, so let's split up into two parts. The extracted
function is the part which depends on the commit summary template.
2024-04-02 15:17:12 +09:00
Evan Mesterhazy
ebe8e6adba Update jj split tests to show what happens to branches
When a commit is split, any branches pointing to it are moved to the second
commit created by the split. This is true even if the --siblings option is
used.


#3419
2024-04-01 21:19:29 -04:00
Evan Mesterhazy
976320726d Add a --siblings option to the jj split command
If the --siblings option is used, the target commit is split into two sibling
commits instead of parent and child commits. Any children of the original
commit will have both siblings as their new parents.


#2274
2024-04-01 19:22:47 -04:00
Evan Mesterhazy
c3ee86d92a Split rebase_descendants into two functions
This refactor will allow us to reuse new `rebase_descendants` function for the
`jj split --siblings` feature (#2274) and later possibly for `jj parallelize`
(#1079).
2024-04-01 19:22:47 -04:00
Martin von Zweigbergk
7b3f8e8cb6 resolve: remove --quiet flag, rely on global one 2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
adf3b50209 cli: add a global --quiet flag, which silences status messages
Note that `jj resolve` already had its own `--quiet` flag. The output
with `--quiet` for that command got a lot quieter with the global
`--quiet` also taking effect. That seems reasonable to me.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
4962d9af3b ui: make hint_*() methods return Option
Same reasoning as the previous patch: we can avoid doing work when
`--quiet` is passed.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
e38e2904bb ui: make status() return a dyn Write, add status_formatter()
When the caller needs a formatter, it's because they're doing
something non-trivial. When the user passed `--quiet` (see upcoming
patch), we should ideally skip doing related work for print the
formatting output. It helps if the `Ui` object doesn't even return a
`Formatter` then, so the caller is forced to handle the quiet case
differently.

Thanks to Yuya for the suggestion.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
b940f1a092 errors: don't use the ui.hint*() helpers
I'm about to make hints not get printed with `--quiet`, but error
hints are probably still useful to get. They shouldn't be a problem
for scripts since the script would have to deal with the error anyway.
2024-04-01 13:00:27 -07:00
Martin von Zweigbergk
aeaab8aad3 cli: add a Ui::status() helper for writing non-error to stderr
This clarifies that status messages are not errors, and allows us to
implement a global `--quiet` flag for silencing status messages.
2024-04-01 13:00:27 -07:00
Simon Wollwage
320f50e00f cli: rename --all to --all-remotes for branch list 2024-04-01 10:12:13 +09:00
Yuya Nishihara
6004efb3b2 cli: replace last use of evaluate_revset() with evaluate_programmatic()
evaluate_programmatic() should be allowed here. AFAIK, the contract is that
the expression should never contain any bare symbols and "fallible" symbol-like
expressions, which doesn't apply to branches() and remote_branches() functions.

evaluate_revset() is removed because there are no callers. However, it's simple
and basic function, so we might want to reintroduce it if needed.
2024-04-01 10:08:44 +09:00
Yuya Nishihara
b3d3b26656 cli: make check_rewritable() not evaluate revset to commit objects 2024-04-01 10:08:44 +09:00
Yuya Nishihara
784d735ecc cli: add convenient method to intersect user revset with other expression
This pattern is common, and most callers of evaluate_revset() can now be
migrated to the wrapper API.
2024-04-01 10:08:44 +09:00
Yuya Nishihara
690270670e cli: add convenient wrapper for user revset evaluation
Many callers of resolve_revset() and evaluate_revset() will be migrated to
this wrapper. "single" and "default_single" APIs won't be replaced because
they require more contexts to construct error messages.

id_prefix_context() now uses bare revset::parse() to avoid dependency cycle.
2024-04-01 10:08:44 +09:00
Evan Mesterhazy
75e938c6b8 Fix the description of the --source arg in the jj rebase --help docs 2024-03-31 16:42:38 -04:00
Simon Wollwage
8eed08b8b6 cli: allow branch list to combine -r and -a 2024-03-31 23:37:22 +09:00
Yuya Nishihara
a6615bf36d cli: render string pattern suggestion as a hint
Templater doesn't have the one yet, but I think it belongs to the same
category.

For clap::Error, we could use clap's own mechanism to render suggestions as
"tip: ...", but I feel "Hint: ..." looks better because our error/hint message
is capitalized.
2024-03-30 23:53:17 +09:00
Yuya Nishihara
d759ba11f1 revset: don't stringify StringPatternParseError
This helps to add hint at the CLI layer.
2024-03-30 23:53:17 +09:00
Yuya Nishihara
339b199ee3 templater: merge ParseIntError into generic Expression error
It was only needed to attach the source error object, which is now handled
by the outer error type.
2024-03-30 23:53:17 +09:00
Yuya Nishihara
76f3b80e8a templater: consolidate "unexpected expression" error constructors
I also renamed "UnexpectedExpression" to just "Expression" because "unexpected"
doesn't apply to "immutable" revset parse/evaluation errors.
2024-03-30 23:53:17 +09:00
Yuya Nishihara
b09732f4f8 revset, templater: split parse error constructor that sets source error object
I'm going to add RevsetParseError constructor for InvalidFunctionArguments,
with/without a source error, and I don't want to duplicate code for all
combinations. The templater change is just for consistency.

I couldn't find a good naming convention for the builder-like API, so it's
called .with_source(mut self, _). Another option was .source_set(source).
Apparently, it's not uncommon to name consuming constructor as
with_<something>().
2024-03-30 23:53:17 +09:00
Yuya Nishihara
db15571eca cli: simplify check for non-empty revisions with/without "all:"
If "all:" is specified, an empty set should be allowed within that expression.
So the additional check we need here is to ensure that the resulting set is not
empty.
2024-03-30 22:40:05 +09:00
Yuya Nishihara
05242c95cd cli: don't silently omit root parent by "jj new --insert-before"
Spotted by Benjamin Tan.
2024-03-30 22:40:05 +09:00
Yuya Nishihara
73b60903ce tree: flatten TreeMergeError into BackendError 2024-03-30 22:40:05 +09:00
Yuya Nishihara
08b5b66ad4 cli: let backend decide whether merge with root can be performed
One less CLI revset helper. It might look odd that "jj rebase" says "Merge
failed" whereas "jj new" doesn't, but that depends on where the BackendError
is detected.
2024-03-30 11:14:25 +09:00
Yuya Nishihara
f20004fffe git_backend: classify "merge with root" as user error
Perhaps, there will be more error types that hold BackendError internally, but
this change is good enough to handle a merge error.
2024-03-30 11:14:25 +09:00
Yuya Nishihara
91ff1fdd1e cli: extract CommandError::with_message() constructor 2024-03-30 11:14:25 +09:00
Yuya Nishihara
1e83faf4f8 tree: remove useless "Backend error" message from TreeMergeError
I don't think it adds any contextual information. TreeMergeError is somewhat
similar to BackendError.
2024-03-30 11:14:25 +09:00
Evan Mesterhazy
dd1def02e4 Move parse_string_pattern in cli to StringPattern::parse in lib
This commit moves the parse_string_pattern helper function into the
str_util module in jj lib and adds tests for it.

I'd like to reuse this code in a function defined by `UserSettings`, which is
part of the jj lib crate and cannot use functions from the cli crate.
2024-03-29 08:48:09 -04:00
Yuya Nishihara
f83d1a840e templater: don't panic on PropertyPlaceholder unset error
The idea is that, if .extract() succeeded in static context, it means the
property can be evaluated as constant. This will potentially eliminate
expect_string_literal_with(), though I'm not too sure if it's a good idea.
If needed, maybe we can extend the idea to suppress type/name resolution errors
by "if(some_static_config_knob, x, y)".
2024-03-29 19:15:02 +09:00
Yuya Nishihara
32b623db67 templater: propagate error from formatted string property 2024-03-29 19:15:02 +09:00
Yuya Nishihara
71c2006c9b templater: introduce Formatter wrapper to switch strict/lax evaluations
This allows us to propagate property evaluation error to a string property. For
instance, "s.contains(x ++ y)" will be an error if "y" failed to evaluate,
whereas bare "x ++ y" shouldn't.

The other implementation ideas:

 a. add Template::into_string_property() to enable strict evaluation
    => it's tedious to implement it for each printable type
 b. pass (formatter, error_handler) arguments separately
    => works, but most implementors don't need error_handler argument
 c. pass strict=bool flag around build_*() functions
    => didn't tried, but it would be more complicated than this patch

Because Template trait is now implementation detail of the templater, it
should be okay to use a non-standard formatter wrapper.
2024-03-29 19:15:02 +09:00
Benjamin Tan
e7edafc924 rebase: do not modify commit IDs if commit is unchanged after rebase 2024-03-29 15:22:50 +08:00
Yuya Nishihara
dcf75788e0 sparse: extract "set --reset" to subcommand
Since --reset conflicts with the other flags, "set --reset" seems odd.
2024-03-29 11:02:31 +09:00
Yuya Nishihara
db94848341 sparse: deduplicate edited patterns
Since "set --add" removes duplicated patterns, it makes sense for "edit" to do
the same thing.
2024-03-29 11:02:31 +09:00
Yuya Nishihara
28e4331787 sparse: extract "set --edit" to subcommand
Even though --edit can be combined with --add/--remove/--clear/--reset, I don't
think it's practically useful.
2024-03-29 11:02:31 +09:00
Yuya Nishihara
0711ac30c3 sparse: extract helper that updates sparse patterns within workspace lock
I assumed locked_wc.sparse_patterns() is cheap operation. If it isn't, a
locked_ws/wc should be passed to the callback instead.
2024-03-29 11:02:31 +09:00
Yuya Nishihara
fff852f136 sparse: parse and print patterns as workspace-relative paths
Per comment in
https://github.com/martinvonz/jj/pull/3379#pullrequestreview-1963841604

Though cwd-relative path might be useful for --remove, I don't think that's
the common use case. The new behavior is consistent with --edit.
2024-03-29 11:02:31 +09:00