Commit graph

2979 commits

Author SHA1 Message Date
Martin von Zweigbergk
dddba4675d dag_walk: heads: use bfs and terminate if frontier has single item
We use `heads_ok()` for finding the head operations when there are
multiple current op heads. The current DFS-based algortihm needs to
always walk all the way to the root. That can be expensive when the
operations are slow to retrieve. In the common case where there are
two operations close to each other in the graph, we should be able to
terminate the search once we've reached the common ancestor. This
patch replaces the DFS by a BFS and adds the early termination.
2024-06-25 05:59:20 +09:00
Martin von Zweigbergk
22217424f5 dag_walk: heads: rename reachable to heads
The name `reachable` feels backwards to me since it keeps track of
inputs that are not reachable from other inputs.
2024-06-25 05:59:20 +09:00
James Sully
f8e106a194 cli: git: add jj git remote set-url command 2024-06-23 12:31:43 +10:00
Philip Metzger
0d9000271e lib: Add RevsetExpression::filtered().
This allows users to easily filter a commit range by conflicts, which will be needed for `next/prev`
further down in the next commit. Users which benefit from it were also migrated.
2024-06-20 23:29:41 +02:00
Matt Kulukundis
c9b3d64ce5 Add background snapshotting info to debug watchman status. 2024-06-20 16:09:06 -04:00
Martin von Zweigbergk
494de23ea5 revset: clarify error about missing working-copy commit for workspace
The error message that says something like 'Workspace "default"
doesn't have a working copy' confused me when I saw it. The problem
it's describing is that the repo view doesn't have a working-copy
commit for the given workspace id. Saying "working-copy commit"
instead of "working copy" hopefully clarifies it a bit.
2024-06-20 16:21:58 +09:00
Yuya Nishihara
f8b87f6499 diff: rewrite find_line/nonword_ranges() by using iterator adapters
I don't think .scan() is descriptive name, but it looks slightly better than
placing accumulator out of the closure.
2024-06-20 08:46:26 +09:00
Yuya Nishihara
5f2f13a876 diff: simply pass tokenizer Fn by value 2024-06-20 08:46:26 +09:00
Matt Kulukundis
3e7ad4d23c Add jj debug snapshot command and use it in trigger
The command only takes a snapshot and avoids other overhead, so it can
be used as a target for the watchman trigger that gets installed.
2024-06-19 11:30:27 -04:00
Matt Kulukundis
95fbf9f3d0 Switch from a private extension to the newly release 0.9.0 2024-06-18 23:14:22 -04:00
Yuya Nishihara
2de73f57fc conflicts: remove redundant information from ReadFile error
The ReadFile error message already says "when reading file content for file
{path}..".
2024-06-17 15:36:06 +09:00
Martin von Zweigbergk
f8a5ad0c7a conflicts: propagate error from conflict materialization 2024-06-17 14:33:29 +09:00
Martin von Zweigbergk
66e45a7a17 conflicts: inline materialize()
The function has no callers outside the module anymore (probably since
`MaterializeTreeValue` but I haven't checked). Inlining it will help
keep error handling simple in the next commit. Otherwise we'd need to
have it return an error type wrapping both `BackendError` and
`io::Error`.
2024-06-17 14:33:29 +09:00
Martin von Zweigbergk
ca1f19736c working_copy: drop "Internal backend error" message from error
I don't think the message adds anything over what the `BackendError`
itself provides, so let's use `transparent` instead.

I also dropped the `Internal` prefix from the variant because that
also didn't seem to add anything.
2024-06-17 14:33:29 +09:00
Matt Kulukundis
8aa71f58f3 feat: add an option to monitor the filesystem asynchronously
- make an internal set of watchman extensions until the client api gets
  updates with triggers
- add a config option to enable using triggers in watchman

Co-authored-by: Waleed Khan <me@waleedkhan.name>
2024-06-16 23:24:22 -04:00
Yuya Nishihara
059fc26df1 revset: forward RevsetExpression::parents()/children() to inner functions 2024-06-15 10:14:55 +09:00
Benjamin Tan
716ec37560 test_local_working_copy: add test for snapshotting of edited materialized simplified conflict 2024-06-15 06:05:06 +08:00
Benjamin Tan
9be33724dc conflicts: materialize simplified file conflicts 2024-06-15 06:05:06 +08:00
Benjamin Tan
7106f6fd49 conflicts: handle parsing of simplified conflicts 2024-06-15 06:05:06 +08:00
Benjamin Tan
0e472166f1 merge: add get_simplified_mapping and update_from_simplified methods 2024-06-15 06:05:06 +08:00
Benjamin Tan
f74991c2e1 tests: add tests showing that individual file conflicts are not simplified/deduplicated 2024-06-15 06:05:06 +08:00
Yuya Nishihara
a7bff04af8 revset, templater: implement arity-based alias overloading
Still alias function shadows builtin function (of any arity) by name. This
allows to detect argument error as such, but might be a bit inconvenient if
user wants to overload heads() for example. If needed, maybe we can add some
config/revset syntax to import builtin function to alias namespace.

The functions table is keyed by name, not by (name, arity) pair. That's mainly
because std collections require keys to be Borrow, and a pair of borrowed
values is incompatible with owned pair. Another reason is it makes easy to look
up overloads by name.

Alias overloading could also be achieved by adding default parameters, but that
will complicate the implementation a bit more, and can't prevent shadowing of
0-ary immutable_heads().

Closes #2966
2024-06-14 23:11:29 +09:00
Yuya Nishihara
d38c9e86e8 revset, templater: include parameter names in AliasId
I'm going to add arity-based alias overloading, and we'll need function
(name, arity) pair to identify it in alias expansion stack. The exact parameter
names aren't necessary, but they can be embedded in error messages.
2024-06-14 23:11:29 +09:00
Kyle J Strand
03a0921e12 give descendants a range arg 2024-06-13 18:54:57 -06:00
Jonathan Tan
4cca84515a In lib, make "testing" feature depend on "git"
If not, `cargo build --no-default-features --features testing` will fail.
2024-06-11 17:14:57 -07:00
Martin von Zweigbergk
0fd1969e8f lib: make git support optional via crate feature
I've wanted to make the Git support optional for a long time. However,
since everyone uses the Git backend (and we want to support it even in
the custom binary at Google), there hasn't been much practical reason
to make Git support optional.

Since we now use jj-lib on the server at Google, it does make sense to
have the server not include Git support. In addition to making the
server binary smaller, it would make it easier for us (jj team at
Googlle) to prove that our server is not affected by some libgit2 or
Gitoxide vulnerability. But to be honest, neither of those problems
have come up, so it's more of an excuse to make the Git support
optional at this point.

It turned out to be much simpler than I expected to make Git support
in the lib crate optional. We have done a pretty good job of keeping
Git-related logic separated there.

If we make Git support optional in the lib crate, it's going to make
it a bit harder to move logic from the CLI crate into the lib crate
(as we have planned to do). Maybe that's good, though, since it helps
remind us to keep Git-related logic separated.
2024-06-11 22:03:20 +09:00
Martin von Zweigbergk
bfa0573cab repo/workspace: drop support for old repo formats
It's been more than 6 months since we added support for dynamically
selecting the working copy implementation. This patch drops support
for selecting the default implementation of that and other stores.
2024-06-11 22:03:20 +09:00
Yuya Nishihara
556c7291c1 revset: migrate syntactic tests to AST-based
This will hopefully help remove PartialEq from RevsetExpression. Some assertions
are duplicated so that AST->RevsetExpression transformation is covered by tests.
2024-06-11 20:00:47 +09:00
Yuya Nishihara
538701429a revset: backport parsing test helpers from templater and fileset 2024-06-11 20:00:47 +09:00
Yuya Nishihara
53fa95d73e fileset, templater: in tests, make parse_normalized() unwrap result
It's unlikely that we'll use "normalized" result to compare Err variants.
2024-06-11 20:00:47 +09:00
Yuya Nishihara
e7e06b6f8c fileset: use parse_into_kind() to test parse errors
parse_normalized() will be changed to unwrap the result.
2024-06-11 20:00:47 +09:00
Martin von Zweigbergk
65a988e3d2 merged_tree: make tree builder attempt to resolve conflicts
As we discovered in the `jj fix` tests,
`MergedTreeBuilder::write_tree()` doesn't try to resolve conflicts,
not even trivial ones. This patch fixes that.
2024-06-08 20:29:30 +09:00
Martin von Zweigbergk
2e6a0f9e96 merged_tree: make resolve() also simplify the result
This changes the documented behavior of `resolve()` since it was
previously documented to not change the arity unless all conflicts
were resolved.

I plan to use `resolve()` from `MergedTreeBuilder::write_tree()`.
2024-06-08 20:29:30 +09:00
Martin von Zweigbergk
776b2d981f merged_tree: make resolve() return a MergedTree
It seems like a method on `MergedTree` should return another
`MergedTree` when reasonable. I'm not sure why I made it return a
`Merge<Tree>` instead.
2024-06-08 20:29:30 +09:00
Martin von Zweigbergk
6ab9d7bdc7 merged_tree: make resolve() on legacy tree an error
The current implementation of `resolve()` on legacy trees just
pretended any conflicts were regular files. It's better to error
out. The function is only used in tests so far.
2024-06-08 20:29:30 +09:00
Yuya Nishihara
660a917aaa revset: remove deprecated "program" rule, rename "program_with_modifier" 2024-06-08 12:48:46 +09:00
Yuya Nishihara
eda7069aee revset: represent program modifier as AST node
The goal is to remove special case from parsing functions and provide slightly
better error message. I don't know if we'd want to use "all:" in aliases, but
there are no strong reasons to disable it.
2024-06-08 12:48:46 +09:00
Yuya Nishihara
3c1f6d5b5d revset: insert AST-level representation of program modifier 2024-06-08 12:48:46 +09:00
Yuya Nishihara
8745c01f98 revset: rename parse_expression_rule() to lower_expression()
As I said, revset has another symbol resolution stage. That's why this function
isn't called resolve_expression().
2024-06-05 10:39:32 +09:00
Yuya Nishihara
9f33d13dfd revset: replace ParseState with &RevsetParseContext
There's no longer a mutable state to be tracked.
2024-06-05 10:39:32 +09:00
Yuya Nishihara
cbffa17bf0 revset: move primitive typed expression helpers to parser module 2024-06-05 10:39:32 +09:00
Yuya Nishihara
e383d41d22 revset: rename typed expression helpers
This is the naming convention we use in templater. These helper functions no
longer requires the passed node is a function argument.
2024-06-05 10:39:32 +09:00
Yuya Nishihara
b281bcd5cb revset: inline invalid_arguments() constructor
There are only two callers, and this change might help if we want to extract
parse_function_call_node() to dsl_util.
2024-06-05 10:39:32 +09:00
Yuya Nishihara
14421ac126 revset: omit function name from type error messages
This simplifies the interface of helper functions. While revset doesn't have
top-level string pattern or integer literal, these parsing helpers could be
used to parse array subscript or n-th parent operator if any.
2024-06-05 10:39:32 +09:00
Martin von Zweigbergk
650eeb8935 cli: add jj fix proof of concept 2024-06-04 14:28:21 -05:00
Yuya Nishihara
3a4258916c revset: inline parse_function_call_args()
The separate function looked rather verbose.
2024-06-04 09:56:21 +09:00
Yuya Nishihara
8a4abee87d revset: insert named "function" rules
This patch copies function rule processing from templater and fileset. Since
function and identifier rules are quite different, it's better to not rely on
the subtle difference between identifier and function_name tokens.
2024-06-04 09:56:21 +09:00
Yuya Nishihara
127e4d3455 revset: flatten symbol rule
This makes it clear that the identifier node is special. For the other
constructs, we don't distinguish between bare symbol and quoted string.
2024-06-04 09:56:21 +09:00
Yuya Nishihara
674d897352 revset: inline trivial parsing functions to eliminate obvious assertions 2024-06-04 09:56:21 +09:00
Yuya Nishihara
2c9132adfc revset: remove RevsetExpression::StringPattern hack
It's no longer needed since we have proper AST tree now.
2024-06-02 10:28:54 +09:00