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

1146 commits

Author SHA1 Message Date
Ilya Grigoriev
84007075d9 jj config list: escape keys
Fixes #1322. There may be more places where keys need escaping, I'm not
completely sure.
2024-05-20 22:39:56 -07:00
Ilya Grigoriev
1f7c4ec60a conflicts: label closing delimeter with conflict number
This follows up on https://github.com/martinvonz/jj/pull/3459 and adds a
label to the closing delimeter of each conflict, e.g.  "Conflict 1 of 3
ends".

I didn't initially put any label at the ending delimeter since the
starting delimeter is already marked with "Conflict 1 of 3". However,
I'm now realizing that when I resolve conflicts, I usually go from top
to bottom. The first thing I do is delete the starting conflict
delimeter. It is when I get to the *end* of the conflict that I wonder
whether there are any more conflicts left in the file.
2024-05-20 18:36:51 -07:00
Yuya Nishihara
c04fb7d33a templater: migrate to generic dsl_util::AliasesMap type 2024-05-20 10:32:18 +09:00
Yuya Nishihara
6916fae853 revset, templater: extract trait that parses alias declaration
Revset/TempalteAliasesMap will be extracted as a generic map type over
P: AliasDeclarationParser.
2024-05-20 10:32:18 +09:00
Yuya Nishihara
467d73f1e6 revset: make .get_symbol/function() compatible with TemplateAliasesMap
These map types will be combined.
2024-05-20 10:32:18 +09:00
Yuya Nishihara
60c3f623ef tests: use get_branch_output() helper thoroughly in test_git_* 2024-05-19 22:45:32 +09:00
Yuya Nishihara
6d211c589c templater: consolidate node.span handling in expand_node()
I'll probably rewrite expand_aliases() in visitor-like interface, and tree
traversal logic will be implemented on ExpressionKind. That's why I made
expand_node() destructure ExpressionNode first.
2024-05-18 09:53:52 +09:00
Yuya Nishihara
6b9e5f7cd7 templater: attach alias traces to function parameter
This consolidates the type of substitution results. Before, symbol substitution
can return inner ExpressionKind internally, but function-parameter substitution
couldn't.
2024-05-18 09:53:52 +09:00
Yuya Nishihara
47d372b71e templater: attach alias traces to type errors
This should avoid regression caused by upcoming changes. An alias function
parameter will be wrapped with AliasExpanded, and type errors in it should
be reported with its alias expansion stack.
2024-05-18 09:53:52 +09:00
Yuya Nishihara
e87b49ccc1 templater: move boxing to ExpressionKind variants to make the enum smaller
I'm trying to extract generic alias substitution functions, and some of them
will take ExpressionKind or Box<FunctionCallNode> by value, then return it or
substituted value of the same type. The cost of moving values wouldn't matter
in practice, but I think it's better to keep the value types small.

Now ExpressionKind is 4-word long.
2024-05-18 09:53:52 +09:00
Martin von Zweigbergk
fe9daac483 tests: avoid deprecated jj init --git/--git-repo
I left the instances in `test_init_command.rs` alone since they're
about testing `jj init`.
2024-05-17 13:55:20 -07:00
jyn
0d3e949439 give a warning when trying to redefine a built-in command
previously, aliases to built-in commands were silently ignored. this matches git's behavior, but seems unhelpful, especially if the user doesn't know that a command with that name already exists.
give a warning rather than silently ignoring it.
2024-05-17 16:50:54 +01:00
Théo Daron
0a48ac63cb cli: make jj branch track show conflicts 2024-05-17 12:21:10 +02:00
Yuya Nishihara
b9039c3c2d cli: remove unneeded lifetime bound from check_rewritable() 2024-05-14 19:45:52 +09:00
Théo Daron
823041c795 cli: create new wc_commit when wc_commit become immuable 2024-05-14 08:53:11 +02:00
Yuya Nishihara
b0d17acb30 merge_tools: leverage Display for printing exit status
This should handle signal exits better. format_tool_aborted() is inlined
because it is more or less a string literal now.
2024-05-14 10:24:28 +09:00
Yuya Nishihara
a61f91b8cf templater: propagate error from commit.parents() method 2024-05-14 10:24:11 +09:00
Yuya Nishihara
1b6589a463 cli: add helper functions that set up diff renderer based on command args
Just for convenience. Even though WorkspaceCommandHelper is getting bloated,
I think it's okay to add thin wrapper functions there.
2024-05-14 09:36:13 +09:00
Yuya Nishihara
4d9c84a17e diff_util: remove WorkspaceCommandHelper dependency from show functions
I've added a wrapper struct in order to get around too many arguments warning.
It captures &dyn Repo as CommitTemplateLanguage would do. OTOH, &Ui is passed
by argument because the caller might need &mut Ui after the renderer object was
configured.
2024-05-14 09:36:13 +09:00
Yuya Nishihara
7341bff2f4 diff_util: remove WorkspaceCommandHelper dependency from inner show functions
I've added a struct similar to RevsetWorkspaceContext. It can be a closure,
but we'll need to duplicate format_file_path() function anyway if we add
commit.diff() template.
2024-05-14 09:36:13 +09:00
Yuya Nishihara
b6d95c3504 cli: use high-level show_diff() function in cmd_status()
As I'm going to remove &WorkspaceCommandHelper from these functions, it will
be a bit more verbose to call low-level show_*() functions.
2024-05-14 09:36:13 +09:00
Yuya Nishihara
13f10f6957 diff_util: pass repo in to inner show functions by argument
I'm going to remove &WorkspaceCommandHelper dependency. This is the easy part.
2024-05-14 09:36:13 +09:00
Yuya Nishihara
6e7c9f15fd diff_util: pass term_width() in to show_diff_stat() by argument
This patch removes ui dependency from show_diff_stat().
2024-05-14 09:36:13 +09:00
Yuya Nishihara
f614c96383 diff_util: remove CommandError dependency from show functions
Suppose we add commit.diff() template method, some of these show_*() functions
will be called from there. CommandError shouldn't appear in that layer.
2024-05-14 09:36:13 +09:00
Martin von Zweigbergk
ee9d3271c1 cleanup: propagate errors from Commit::predecessors() 2024-05-13 07:39:14 -07:00
Martin von Zweigbergk
0a758e7024 cleanup: propagate errors from Commit::parents()
The function now returns an iterator over `Result`s, matching
`Operation::parents()`.

I updated callers to also propagate the error where it was trivial.
2024-05-13 07:39:14 -07:00
Martin von Zweigbergk
677081ef71 rebase: avoid an unnecessary lookup of parent commits 2024-05-13 07:39:14 -07:00
Yuya Nishihara
728e9e0772 cli: reuse ConfigLevelArgs for "config list --user/--repo"
This is a bit tricky, but we can reconfigure group attributes by using
mut_group().

https://docs.rs/clap/latest/clap/struct.Command.html#method.mut_group
2024-05-12 23:15:58 +09:00
Yuya Nishihara
717b42245c cli: rename ConfigArgs to ConfigLevelArgs 2024-05-12 23:15:58 +09:00
Yuya Nishihara
95593598d5 cli: use command(flatten) instead of deprecated clap(..) 2024-05-12 23:15:58 +09:00
Yuya Nishihara
db75e19751 cli: insert tracing at editor/pager invocation
This should help debug Windows mess.
2024-05-12 23:06:14 +09:00
Yuya Nishihara
e3b3b5586f ui: add per-type FormatterFactory constructors, inline selection
This should be better than passing (bool, bool, bool) arguments.
2024-05-12 09:21:18 +09:00
Yuya Nishihara
46246a7734 ui: inline debug_color() and use_color() 2024-05-12 09:21:18 +09:00
Yuya Nishihara
46226a4c44 ui: forward .color() to FormatterFactory
This helps eliminate use_color() function.
2024-05-12 09:21:18 +09:00
Yuya Nishihara
0423e3e1ee ui: add helper function that sets up FormatterFactory
I'm going to split FormatterFactory::prepare() which takes 3 bool arguments,
and prepare() will be inlined there.
2024-05-12 09:21:18 +09:00
tinger
d0a29a831d cli: add ui.color = "debug"
When using `ui.color = "debug"`, changes in the output style
additionally include delimiters << and >>, as well as all active labels
at this point separated by ::. The output is otherwise unformatted and
the delimiters and labels inherit the style of the content they apply
to.
2024-05-11 10:16:09 +02:00
Yuya Nishihara
d6613304c9 cli: print deleted branch hints at end of "branch list" output
These hints shouldn't be interleaved in the template output. The new output
might look a little bit worse, but I don't think it's unacceptably bad.
2024-05-11 09:43:53 +09:00
Yuya Nishihara
2f3ac4e4d7 tests: snapshot both stdout and stderr in "branch list" tests 2024-05-11 09:43:53 +09:00
Yuya Nishihara
60825c4591 tests: use get_branch_output() at a few more places
Not all "branch list --all-remotes" callers are replaced because I'm going to
make get_branch_output() suppress hints by default, and there should be tests
for the hints.
2024-05-11 09:43:53 +09:00
Alexander Potashev
07559f24ec Refuse to split an empty commit with jj split.
Rationale: The user may be confused by the empty diff in the diff editor
tool if they accidentally run `jj split` on a wrong (empty) commit.
2024-05-10 19:37:28 +02:00
Yuya Nishihara
3307696ba8 cli: parse out redundant "all:" revset modifier in arguments and templates
This also means "all:" is allowed in default revsets (such as "revsets.log"),
but that seems okay. In revset aliases, "all:" isn't allowed because aliases
may be expanded to sub-expression position.

Closes #3654
2024-05-10 15:28:18 +09:00
Yuya Nishihara
ba73accac6 cli: use command helper to check if path argument is parsable as revset
There should be no reason to use low-level API.
2024-05-10 15:28:18 +09:00
Yuya Nishihara
12b873e1ef cli: port "branch list" to template
Perhaps, this can be used to generate parsable branches list.

The hint for deleted branches isn't migrated to the template. I'm thinking of
moving it out of the loop and printed once at the end. If we want to generate
a hint in template, we'll probably need local_ref.tracking_remote_refs(), etc.
that return a list of RefNames.
2024-05-10 08:36:38 +09:00
Yuya Nishihara
af9f9ba1e4 cli: filter out synced remote branches early
Perhaps, this make it a bit clearer when "deleted" local branches should be
displayed. In practice, this change is noop since remote_ref.target should
never be absent.
2024-05-10 08:36:38 +09:00
Yuya Nishihara
8e4f75552d templater: add tracking methods to remote RefName
More tests will be added later as "branch list" templates.

In "log" template, we might want to see the number of "local" commits ahead
of any tracked remotes. It can be implemented later in a similar way (or as a
nested remote_refs list.)
2024-05-10 08:36:38 +09:00
Yuya Nishihara
ccabb11890 templater: wrap RefName with Rc to copy OnceCell around
Because template is declarative language, and is evaluated as a tree, there
will be multiple copies of the same RefName object. This patch allows us to
cache ahead/behind counts which will be lazily calculated.
2024-05-10 08:36:38 +09:00
Yuya Nishihara
cb0964b1d0 templater: extract remote-only RefName constructor as well
I'm going to make these constructors return Rc<RefName>, and it seems better
to consolidate Rc wrapping functions.
2024-05-10 08:36:38 +09:00
Yuya Nishihara
e27421d2bd templater: extract trackable RefName constructors
They'll be called from cmd_branch_list().
2024-05-10 08:36:38 +09:00
Yuya Nishihara
9a5b001d58 templater: add SizeHint type to represent revset.count_estimate() value
We'll probably add binary comparison operators at some point, but this patch
also adds size_hint.zero() method. Otherwise, we'll have to write
"if(x.upper() && x.upper() == 0, ..)" to deal with None.

The resulting "branch list" template will look like:
```
separate(", ",
  if(!ref.tracking_ahead_count().zero(),
    if(ref.tracking_ahead_count().exact(),
      "ahead by " ++ ref.tracking_ahead_count().exact() ++ " commits",
      "ahead by at least " ++ ref.tracking_ahead_count().lower() ++ " commits")),
  if(!ref.tracking_behind_count().zero(),
    if(ref.tracking_behind_count().exact(),
      "behind by " ++ ref.tracking_behind_count().exact() ++ " commits",
      "behind by at least " ++ ref.tracking_behind_count().lower() ++ " commits")),
)
```
2024-05-09 08:51:34 +09:00
Yuya Nishihara
62decb76bc templater: add optional integer type
In order to port "branch list" to template, we need to somehow represent
revset.count_estimate() result as a template property. I'm going to add
SizeHint template type for that, and its .upper() and .exact() methods will
have to return optional integers.

Fortunately, the Integer type has no implicit conversion to bool, so
"if(optional_integer, ..)" is not ambiguous.
2024-05-09 08:51:34 +09:00