Commit graph

2992 commits

Author SHA1 Message Date
Jonathan Tan
1eef1a4f55 workspace add: add filename context to FS error
At work, a user encountered a panic upon attempting to create a dir at
the line in the diff below, but it turned out to be difficult to debug
because I didn't know what the path was. There already is a mechanism to
add path context in the lib crate; make it available in the cli crate as
well, and use the mechanism to add path context to "workspace add".
2024-07-01 16:05:29 -07:00
Ilya Grigoriev
1b658ea80e lib id_prefix: look for divergent changes outside short prefix set
Fixes #2476.

Previously, if there was a change id match within the short prefix
lookup set, `jj` would not look for commits with that same change id
outside the short prefix set. So, it wouldn't find the conflicted
commits for a commit with a divergent (AKA conflicted) change id.
2024-06-29 11:44:26 -07:00
Ilya Grigoriev
360a2b6a8b lib id_prefix: demo bug #2476 in a test 2024-06-29 11:44:26 -07:00
Ilya Grigoriev
6d3d7c61f2 nightly clippy fixes
Includes a false-positive, https://github.com/rust-lang/rust-clippy/issues/13018.
2024-06-29 11:22:01 -07:00
Ilya Grigoriev
c563ea8b29 clippy: remove warning when not using watchman feature
I keep seeing the one in lib/ when running tests in VS Code, but I also
fixed the warnings in watchman.rs for good measure.
2024-06-29 11:22:01 -07:00
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Yuya Nishihara
76ff35eba4 cli: branch: inline view.remove_branch() in cmd_branch_forget()
This API no longer makes sense, and we'll probably add some flags to forget
only tracked remotes for example.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
c240313c4b view: remove has_branch() which is called only from tests
Since we've split (local, remotes) branches to (locals, remotes { branches }),
.has_branch() API no longer makes much sense. Callers often need to check if
a remote branch is tracked.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
9613ec4f82 revset: drop Eq/PartialEq from RevsetExpression and related types
It was convenient that expression nodes can be compared in tests, but no
equivalence property is needed at runtime. Let's remove Eq/PartialEq to
simplify the extension support.
2024-06-28 10:28:51 +09:00
Yuya Nishihara
8417ea79c5 revset: rewrite RevsetExpression equivalence tests to not rely on Eq
Most of the tests are migrated to insta::assert_debug_snapshot!(). Some of them
could use assert_matches!(), but the resulting code would look ugly because of
nested RC<_>s.
2024-06-28 10:28:51 +09:00
Yuya Nishihara
9b6ee8c9c6 tests: filter snapshots of fileset/revset expressions to save vertical space
I think the collapsed output is easier to follow.
2024-06-27 09:33:48 +09:00
Martin von Zweigbergk
8d67b1412e cleanup: leverage BoxStream/BoxFuture type aliases
Thanks to @fowles for bringing these to my attention.
2024-06-26 11:34:52 +09:00
Yuya Nishihara
60b35f676e dag_walk: do one less clone() in heads_ok() 2024-06-25 11:54:03 +09:00
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