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

1183 commits

Author SHA1 Message Date
Ilya Grigoriev
e3bb825a21 jj git push: remove the NotFastForward error
Now that we always force push, it should not occur in practice.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
777da99533 jj git push: always force-push, all safety logic now in push_negotiation
This should be a no-op, though that is not necessarily obvious in corner
cases.

Note that libgit2 already performs the push negotiation even when
pushing without force (without `+` in the refspec).
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
8d3dd17b51 jj git push: safety checks in push negotiation, "force-with-lease"
As explained in the commit, our logic is a bit more complicated than
that of `git push --force-with-lease`. This is to match the behavior of
`jj git fetch` and branch conflict resolution rules.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
1e1507d5cb test_git_push: add a test for creating unexpectedly existing branch
This tests `git push` attempting to create a branch when the branch
already unexpectedly exists on the remote. This should (and does)
fail.

Also changes another test to use `jj_cmd_failure`.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
221cd44904 test_git_push: demo behavior we'd like to be safer
Adds two tests where pushing should fail, but currently succeeds.
2024-05-28 21:38:26 -07:00
Martin von Zweigbergk
35c7606350 diff_util: replace DiffWorkspaceContext by RepoPathUiConverter 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
1e3b49abf5 revset: use FsRepoPathUiConverter in RevsetWorkspaceContext 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
058461ebb1 fileset: replace FilesetParseContext by RepoPathUiConverter 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
3b702250a6 repo_path: add type for formatting and parsing RepoPath, use in CLI
We want to move UI-independent logic that's currently in `jj-cli` into
`jj-lib`. `WorkspaceCommandHelper` is perhaps the most important part
to start moving. As I was looking into what to move from
`WorkspaceCommandHelper`, the first thing I saw there was the
`cwd`. It might seem like a good candidate to start moving. However,
when running a server, you might be running operations on repos stored
in database, so `cwd` and the workspace root don't make sense then
(because the repo is not stored at a particular path).

So, instead, this patch starts abstracting out our uses of those two
paths by adding an enum for converting between `RepoPath` and paths as
they are presented in the UI. I added a variant for repos stored in a
file system, and made `WorkspaceCommandHelper` use that to show that
it works. We'll probably add a server variant later.

I put the new type in `repo_path.rs` because at least the
file-system-based implementation is closely related to
`RepoPath::parse_fs_path()`.
2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
7e6a968415 conflicts: consider the empty tree a non-legacy tree
Since we no longer depend on legacy trees being preserved when we
build new trees or merge trees, we can consider the root tree a
non-legacy tree.
2024-05-27 06:25:27 -07:00
Martin von Zweigbergk
8e6e04b929 conflicts: always use tree-level format for merged trees
It's been about six months since we started using tree-level conflicts
by default. I can't imagine we would switch back. So let's continue
the migration by always using tree-level conflicts when merging trees,
even if all inputs were legacy trees.
2024-05-27 06:25:27 -07:00
Yuya Nishihara
b31f75bc94 dsl_util: introduce visitor-based generic alias substitution
The original expand_node() body is migrated as follows:
- Identifier -> fold_identifier()
- FunctionCall -> fold_function_call()

expand_defn() now manages states stack by itself, which simplifies lifetime
parameters.
2024-05-26 11:21:45 +09:00
Yuya Nishihara
0efd2aa316 dsl_util: add trait for alias body parsing
This could be a closure argument passed to expand_aliases(), but it's nice
that the parsing function is constrained by the aliases map type.
2024-05-26 11:21:45 +09:00
Yuya Nishihara
7be4a0a560 dsl_util: add visitor-like API primarily designed for alias substitution
The templater implementation of FoldableExpression is a stripped-down version
of expand_node(). It's visitor-like because I'm going to write generic alias
substitution rules over abstract expression types (template, revset, fileset.)

Naming comes from rustc.
https://rust-unofficial.github.io/patterns/patterns/creational/fold.html
2024-05-26 11:21:45 +09:00
Yuya Nishihara
5061d4b831 dsl_util: add trait for alias substitution errors
This is basically the same as the previous patch, but for error types. Some
of these functions could be encoded as "E: From<AliasExpandError<'i>>", but
alias substitution logic is recursive, so it would have to convert E back and
force.
2024-05-26 11:21:45 +09:00
Yuya Nishihara
cf6357459d dsl_util: add trait that constructs ExpressionKind of basic AST node types
This isn't fancy, but we'll need some generic way to return either original
or substituted expression node. I think this is the simplest abstraction.
2024-05-26 11:21:45 +09:00
Martin von Zweigbergk
5dea2a9b9b cli: add space around = in jj config list output
I think this makes it more readable. It seems to be how most people
write TOML.
2024-05-24 19:35:45 -07:00
Yuya Nishihara
4478055e1d cli: don't abandon non-discardable old wc commit by import_git_head()
Perhaps, the original intent was to abandon non-empty working-copy commit
assuming it was rewritten by git (therefore it should be superseded by the
current working-copy content.) However, there are other reasons that could
make the HEAD out of sync (including concurrent jj operations), and abandoning
non-empty commit can be a disaster. This patch turns it to safer side, and let
user abandon non-empty commit manually.

Fixes #3747
2024-05-25 10:29:30 +09:00
Yuya Nishihara
02eb164dae config: migrate "config get"/"set" to TOML-based name argument parsing 2024-05-23 12:22:12 +09:00
Yuya Nishihara
97023b8da6 fileset, templater: extract basic AST node types
I'm going to extract generic alias substitution functions, and these AST types
will be accessed there. Revset parsing will also be migrated to the generic
functions.
2024-05-23 10:18:36 +09:00
Yuya Nishihara
0c05c541a1 fileset, templater: insert intermediate InvalidArguments error type
This will help extract common FunctionCallNode<'i, T> type. We don't need
freedom of arbitrary error type choices, but implementing From<_> is the
easiest option I can think of. Another option is to constrain error type by
the expression type T through "T::ParseError: ArgumentsParseError" or
something, but it seemed a bit weird that we have to use trait just for that.
2024-05-23 10:18:36 +09:00
Yuya Nishihara
82b0e88a21 config: add workaround for config path expression parsing
As of config 0.13.4, the path Expression type is private, and there's no escape
syntax. This patch adds a fallback to nested HashMap<String, Value> lookup.

https://github.com/mehcode/config-rs/blob/v0.13.4/src/path/mod.rs#L10
https://github.com/mehcode/config-rs/blob/v0.13.4/src/path/parser.rs

Fixes #1723
2024-05-23 10:18:17 +09:00
Yuya Nishihara
a127fd9c5d config: introduce newtype for dotted config name path
"config list NAME" argument is now parsed as TOML key, but it's still broken
since config.get() expects a query expression in different syntax.

The other config commands will be migrated later.
2024-05-23 10:18:17 +09:00
Martin von Zweigbergk
50dd78eb8f cargo: upgrade gix to version 0.63 2024-05-22 11:20:57 -07:00
Martin von Zweigbergk
ff4ea73ac0 cli: move a few functions in commands/config.rs to public places
Turns out we use some of the functions in `commands/config.rs` at
Google. (We use them for writing name and email if the user hasn't set
them.)
2024-05-22 07:47:57 -07:00
Martin von Zweigbergk
b227dde787 conflicts: indicate executable conflict in git-format diff 2024-05-22 06:46:58 -07:00
Martin von Zweigbergk
1970ddef15 tree: propagate errors from sub_tree()/path_value() 2024-05-22 06:46:38 -07:00
Yuya Nishihara
c9b088c795 templater: let caller specify function name and span of invalid arguments error
This will help extract interface of the error constructor without depending on
T: ExpressionKind type.
2024-05-22 10:18:05 +09:00
Yuya Nishihara
e5fca8fadd templater: add helper that maps FunctionCallNode to error 2024-05-22 10:18:05 +09:00
Yuya Nishihara
da005444e1 templater: forward expect_no_arguments() to expect_exact_arguments() 2024-05-22 10:18:05 +09:00
Yuya Nishihara
04efac3a51 templater: implement expect_*_arguments() as methods
I'm thinking of moving them to dsl_util, but we'll probably want to avoid
importing dsl_util at call sites.
2024-05-22 10:18:05 +09:00
Yuya Nishihara
06f488a8f6 cli: config: update default template for multi-line overridden values 2024-05-22 10:17:37 +09:00
Yuya Nishihara
ef8038f60f cli: config: leverage toml_edit::Value to serialize values
I use ValueKind::Ty(ref v) here because (*v).into() looked rather noisy.

Fixes #3374
2024-05-22 10:17:37 +09:00
Yuya Nishihara
d38c366a98 cli: config: use str.parse() to remove "use FromStr" 2024-05-22 10:17:37 +09:00
Yuya Nishihara
7b72e04206 cli: config: move helper functions to commands.config module
There are no external callers, so let's make them private.
2024-05-22 10:17:37 +09:00
Matt Stark
fa6f5e3880 Add the revsets mutable and immutable.
I add them as aliases, since a user may instead choose to define `immutable_heads()`, for example, as `heads(immutable())`, and the define `immutable()` instead.
2024-05-22 09:19:46 +10:00
dploch
a49da4ad01 revset: implement a 'reachable(src, domain)' expression
This revset correctly implements "reachability" from a set of source commits following both parent and child edges as far as they can go within a domain set. This type of 'bfs' query is currently impossible to express with existing revset functions.
2024-05-21 10:52:31 -04:00
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