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

2893 commits

Author SHA1 Message Date
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
Yuya Nishihara
68160a4e77 git_backend: forcibly invalidate in-memory packed-refs cache on gc()
gix 0.63 is now available.

#3537
2024-05-24 10:09:44 +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
f65ba88109 tree: take sub_tree_recursive() argument as &RepoPath
Since RepoPath is now a slice type, it can be constructed without cloning the
backing buffer. Let's simply use it instead of the iterator type.
2024-05-23 10:14:48 +09:00
Martin von Zweigbergk
cd5e82d0d3 tree: make sub_tree_recursive() public
These functions (in `Tree` and `MergedTree`) are safe to use. We have
a duplicate of these functions at Google, which would be nice to
avoid.
2024-05-22 11:21:18 -07:00
Martin von Zweigbergk
aecee1d6cc tree: make MergedTreeVal::to_merge() public
I don't think there's any harm in this function being public. We have
a duplicate of it at Google.
2024-05-22 11:20:43 -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
07bb1d81b7 tree_builder: propagate errors from write_tree() 2024-05-22 06:46:38 -07:00
Martin von Zweigbergk
1970ddef15 tree: propagate errors from sub_tree()/path_value() 2024-05-22 06:46:38 -07:00
Martin von Zweigbergk
facfb71f7b test_merged_tree: reduce duplication and wrapping with helper lambdas
I'm about to make `[Merged]Tree::path_value()` return a `Result`. This
will help even more then.
2024-05-22 06:46:38 -07:00
Yuya Nishihara
2143cc3686 fileset: consolidate signature of invalid arguments error constructors
For the same reason as the templater changes. These FunctionCallNode types will
be extracted as utility type.
2024-05-22 10:18:05 +09:00
Yuya Nishihara
7a230395c2 fileset: implement expect_no_arguments() as method 2024-05-22 10:18:05 +09: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
dploch
5125eab505 union_find: implement a library for the Union-Find algorithm 2024-05-21 10:52:31 -04:00
Thomas Castiglione
13c8f32ceb local_working_copy: fix some clippy lints that only show up on Windows 2024-05-21 14:37:17 +08:00
Thomas Castiglione
59d3a2c866 local_working_copy: when all sides of a conflict are executable, materialise the conflicted file as executable
Fixes #3579 and adds a testcase for an executable conflict treevalue.
2024-05-21 14:37:17 +08: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
2cbc4f9996 revset: extract generic dsl_util::AliasesMap<P> type
As I'm going to extract generic alias substitution helpers, there should be
a common map 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
3db1f9fe5d revset: extract aliases_map.function_names()
TemplateAliasesMap has a similar function for symbols, and I'm going to extract
a common aliases map type.
2024-05-20 10:32:18 +09:00
Philip Metzger
bbb9ca10cd lib: Add RevsetExpression::is_empty(), which filters out empty commits.
This is a useful helper for programmatic revsets. Users were also migrated.
2024-05-19 00:20:05 +02:00
Yuya Nishihara
3e51e93265 fileset: box FunctionCallNode to make enum smaller
For the same reason as the previous commit.
2024-05-18 09:53:52 +09:00
Martin von Zweigbergk
66aced5dc8 merge_view: remove heads removed by other side also in Google repos
When I addded the workaround in 256988de65, I missed the comment
just below explaining that heads removed by the other side were
already handled. Since that's not handled when using non-default
indexes now, we need to handle it in an `else` block.
2024-05-16 06:09:59 -07:00
Yuya Nishihara
c17a75624e signing: remove redundant "exit status" from SSH backend error
Follows up 550f44b7c1 "gpg: drop redundant "exit status" from error message."
2024-05-14 10:24:28 +09:00
Martin von Zweigbergk
550f44b7c1 gpg: drop redundant "exit status" from error message
Apparently we currently get things like "GPG failed with exit status
exit status: 2".
2024-05-13 08:30:00 -07: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
256988de65 repo: add a workaround for merging repo views with Google's index
We do a 3-way merge of repo views in a few different
scenarios. Perhaps the most obvious one is when merging concurrent
operations. Another case is when undoing an operation.

One step of the 3-way repo view merge is to find which added commits
are rewrites of which removed commits (by comparing change IDs). With
the high commit rate in the Google repo (combined with storing the
commits on a server), this step can get extremely slow.

This patch adds a hack to disable the slow step when using a
non-standard `Index` implementation. The Google index is the only
non-standard implementation I'm aware of, so I don't think this will
affect anyone else. The patch is also small enough that I don't think
it will cause much maintenance overhead for the project.
2024-05-12 08:59:44 -07:00
Yuya Nishihara
de4ea5bc5a revset: move basic argument helpers to separate module
parse_function_argument_to_file/string_pattern() functions aren't moved.
They are more like functions that transform parsed tree to intermediate
representation.
2024-05-11 16:50:14 +09:00
Yuya Nishihara
f82c946ebe revset: move parsing functions to separate module
These functions will be reimplemented, and they will return a parsed tree
instead of RevsetExpression tree.
2024-05-11 16:50:14 +09:00
Yuya Nishihara
e6aa8906f7 revset: move alias types to separate module
Alias expansion is purely substitution of parsed tree, which should belong to
the first parsing stage.
2024-05-11 16:50:14 +09:00
Yuya Nishihara
68db9c142c revset: extract parser types to separate module
I'm planning to rewrite the parser in a similar way to fileset/template parsing,
and the revset_parser module will host functions and types for the first stage.
I haven't started the rewrite, but it seems good to split the revset module
even if we reject the idea.
2024-05-11 16:50:14 +09:00
Yuya Nishihara
cfc18b0432 revset: make RevsetParser type private
It's unlikely that client codes and integration tests have to use the pest
API directly.
2024-05-11 16:50:14 +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
dploch
3a0929b876 index_store: add more scope to write_index()
This is more consistent with the other method and it makes some extension operations easier, by giving access to the OpStore and other relevant context for custom index extensions.
2024-05-10 09:22:09 -04:00
Martin von Zweigbergk
dbba2edc57 commit: add a helper for returning parent tree of Commit
The pattern of getting the parent tree of a commit gets repeated a
bit. Let's add a helper on `Commit`.
2024-05-07 19:35:03 -07:00
Martin von Zweigbergk
428e209304 cleanup: consistently use BackendResult
We have the type alias so we should use it consistently.
2024-05-07 19:35:03 -07:00
Martin von Zweigbergk
2e44741e02 repo: move new commit ids into RewriteType enum
`RewriteType::Rewritten` must have exactly one replacement. I think
it's better to encode that in the type by attaching the value to the
enum variant. I also renamed the type to just `Rewrite` since it now
has attached data and `Type` sounds like a traditional data-free enum
to me.
2024-05-06 12:58:40 -07:00
Martin von Zweigbergk
c6bb94de42 repo: make RewriteType private
Looks like I forgot this in some recent refactoring.

I don't really see any harm in making the type public later. I might
want to make `rebase_descendants()` not clear `parent_mapping` and
instead provide a way of accessing it afterwards (removing the need
for the `_return_map()` flavors).  We'll see if that ends up
happening. For now it can be private anyway.
2024-05-06 12:58:40 -07:00
dploch
20af8c79ef revset: support custom filter extensions 2024-05-06 10:42:01 -04:00
dploch
387ae9bce1 revset: support defining custom revset functions 2024-05-06 10:42:01 -04:00
dploch
cfa595199a revset: make a bunch of parsing types public 2024-05-06 10:42:01 -04:00
dploch
4e0abf0631 revset: make RevsetParseContext opaque 2024-05-06 10:42:01 -04:00
Ilya Grigoriev
70b517ca64 conflicts.rs: label conflict number and sides next to conflict markers
For example, 

```
<<<<<<< Conflict 1 of 3
+++++++ Contents of side #1
left 3.1
left 3.2
left 3.3
%%%%%%% Changes from base to side #2
-line 3
+right 3.1
>>>>>>>
```

or

```
<<<<<<< Conflict 1 of 1
%%%%%%% Changes from base to side #1
-line 3
+right 3.1
+++++++ Contents of side #2
left 3.1
left 3.2
left 3.3
>>>>>>>
```

Currently, there is no way to disable these, this is TODO for a future
PR. Other TODOs for future PRs: make these labels configurable. After
that, we could support a `diff3/git`-like conflict format as well, in
principle.

Counting conflicts helps with knowing whether you fixed all the
conflicts while you are in the editor.

While labeling "side #1", etc, does not tell you the commit id or
description as requested in #1176, I still think it's an improvement.
Most importantly, I hope this will make `jj`'s conflict format less
scary-looking for new users.

I've used this for a bit, and I like it. Without the labels, I would see
that the two conflicts have a different order of conflict markers, but I
wouldn't be able to remember what that means. For longer diffs, it can
be tricky for me to quickly tell that it's a diff as opposed to one of
the sides. This also creates some hope of being able to navigate a
conflict with more than 2 sides.

Another not-so-secret goal for this is explained in
https://github.com/martinvonz/jj/pull/3109#issuecomment-2014140627. The
idea is a little weird, but I *think* it could be helpful, and I'd like
to experiment with it.
2024-05-05 18:42:14 -07:00
Ilya Grigoriev
f43a810fe0 conflicts.rs: Teach jj to parse conflict markers that are followed by a label
The format is 7 characters of the separator followed by a space and arbitrary
text, followed by a newline. Separator followed by a newline is also allowed.
E.g.:

<<<<<<< Random text
%%%%%%% Random text
 line 2
-line 3
+left
 line 4
+++++++ Random text
right
%%%%%%% Random text
 line 2
+forward
 line 3
 line 4
>>>>>>> Random text

This commit only allows reading such conflicts.

I considered allowing longer separators (`<<<<<<<<<<<<<< Random text`), but we
wouldn't currently write them, so let's be strict for now.

7 characters if they are followed by a space and arbitrary text
2024-05-05 18:42:14 -07:00
Martin von Zweigbergk
3dab92d2e9 cli: move revsets.log default to config file 2024-05-05 09:08:14 -07:00
Martin von Zweigbergk
f958957f9e cli: drop support for old ui.default-revset config
We replaced it by `revsets.log` in 0.8.0, which is long enough that
users should have been able to switch.
2024-05-05 09:08:14 -07:00