3833 Commits

Author SHA1 Message Date
Martin von Zweigbergk
103d05149d cli: add "$schema" line when creating new config file
It seems like a small usability improvement if users don't need to
enter the "$schema" link manually when they create a new config file.

This doesn't help existing users.
2025-05-04 17:14:10 +00:00
Yuya Nishihara
105c892ce4 tests: do not shell out taplo to gather forgotten test files
It would be annoying if forgotten tests wouldn't be reported locally.
2025-04-27 01:33:23 +00:00
Martin von Zweigbergk
13477940af local_working_copy: avoid a block_on() in already async function 2025-04-26 02:22:23 +00:00
Martin von Zweigbergk
d41c83e96a merged_tree: make merge_trees() async
`merge_tree_values()` was already marked async, but it was calling the
blocking `merge_trees()`, so it could still block.
2025-04-24 16:29:24 +00:00
Jonas Greitemann
7bb8e17e88 tests: factor out utility function is_external_tool_installed
A pattern has emerged where a integration tests check for the
availability of an external tool (`git`, `taplo`, `gpg`, ...) and skip
the test (by simply passing it) when it is not available. To check this,
the program is run with the `--version` flag.

Some tests require that the program be available at least when running
in CI, by calling `ensure_running_outside_ci` conditionally on the
outcome. The decision is up to each test, though, the utility merely
returns a `bool`.
2025-04-24 15:48:08 +00:00
Jonas Greitemann
8882f0016d tests: allow multiple integration tests in check for forgotton test files
The previous implementation of `assert_no_forgotten_test_files`
hard-coded the name of the `runner` integration test and required all
other source files to appear in matching `mod` declarations. Thus, this
approach cannot handle multiple integration tests.

However, additional integration tests may be desirable
- to support tests using a custom test harness (see upcoming commits)
- to balance the trade-off between test run time and compile time as
  the test suite grows in the future.

The new implementation first uses `taplo` to parse the `[[test]]`
sections of the manifest to identify integration test main modules,
and then searches in those for `mod` declarations. This is then compared
to the list of source files in the tests directory. Like the previous
implementation, the new one does not attempt to recurse into submodules
or to handle directory-style modules; just like before it only treats
source files without a module declaration as an error and relies on the
compiler to complain about the other way around.

When `taplo` is not installed, the check is skipped unless it is running
in CI where we require `taplo` to be available.
2025-04-24 15:48:08 +00:00
Yuya Nishihara
757a08cd21 cli: rebase: consolidate call sites of move_commits() 2025-04-24 13:16:33 +00:00
Yuya Nishihara
0e17c0e17d copies: ignore existing tree when testing copy/rename operation type
In this context, a tree value should be considered absent.
2025-04-22 00:44:13 +00:00
Yuya Nishihara
b6a861b529 git_backend: do not include renamed trees in copy records
We could instead make CopiesTreeDiffStream reject bad copy records, but it's
pretty much wrong to construct a FileId for tree.

Fixes #6390
2025-04-22 00:44:13 +00:00
Martin von Zweigbergk
5ccd0dbe32 merge: make to_tree_merge() read trees concurrently 2025-04-21 13:31:45 +00:00
Yuya Nishihara
fc5f90c4ac annotate: reorganize functions as restartable process
I don't have any plan to implement incremental UI for file annotation, but I
think the new API is nicer in that they have fewer function arguments.

Note that this wouldn't help implement interactive UI to go ancestor annotation
by clicking annotated line. To achieve that cheaply, we'll need weave-like data.
2025-04-21 12:38:38 +00:00
Yuya Nishihara
5feed28f49 annotate: reorganize initialization of state to make process restartable 2025-04-21 12:38:38 +00:00
Yuya Nishihara
4a8074759c annotate: leave unresolved commits in commit_source_map
We can visit ancestors from these commits to continue annotation process.
2025-04-21 12:38:38 +00:00
Yuya Nishihara
00dd6df4d9 annotate: pack intermediate state into struct 2025-04-21 12:38:38 +00:00
Martin von Zweigbergk
3c84a23b13 merge: add and use a function for mapping async functions concurrently
This adds `Merge::try_map_async()` and adds some callers.
2025-04-20 06:44:00 +00:00
Martin von Zweigbergk
ed99e21bc4 revset: rename StoreError variants to Backend
I haven't checked, but I think "store" is a holdover from a long time
ago.
2025-04-20 02:28:36 +00:00
Yuya Nishihara
39f481f2da absorb: add basic support for file deletion
This works if the file was added and wasn't modified within the destination
range.

Closes #6140
2025-04-17 18:10:23 +00:00
Martin von Zweigbergk
e61971c1f3 repo: propagate error from edit() in update_wc_commits() 2025-04-17 14:41:50 +00:00
Martin von Zweigbergk
5ad7ea24d3 repo: propagate erros from update_heads() 2025-04-17 12:20:29 +00:00
Martin von Zweigbergk
4a8cbe43a2 repo: mark view dirty after setting local bookmark target
We were not calling `view.mark_dirty()` after adding heads, which
means that we would not enforce the usual view invariants, such that
ancestors of heads should not also be in the set of heads. This patch
fixes that and updates the test (which actually shows the broken
invariant in its current form).
2025-04-17 03:25:29 +00:00
Yuya Nishihara
81344e6828 merge: clarify expectation of with_new_file_ids() 2025-04-15 15:08:47 +00:00
Martin von Zweigbergk
7cab444313 repo_path: remove assertion from constructors
We ran into a crash on our server at Google today because we
accidentally called `RepoPathBuf::from_internal_string()` with a
string starting with a '/', which resulted in a the assertion in that
function failing. This patch changes that constructor and its siblings
to return a `Result` instead.
2025-04-15 14:42:23 +00:00
Martin von Zweigbergk
f0545ee25c test: introduce test helpers for creating repo path types
I'm about to make the constructors return a `Result`. The helpers will
hide the unwrapping.
2025-04-15 14:42:23 +00:00
Martin von Zweigbergk
094ab0b2bb tree: delete entries() method, update MergedTree test
`Tree::entries()` was only used in one test case. We can just as well
use `MergedTree::entries()` there.
2025-04-15 13:14:46 +00:00
Martin von Zweigbergk
0f92978231 tree: delete unused entry() method 2025-04-15 13:14:46 +00:00
Yuya Nishihara
26ffaf4ac2 repo: reimplement merge of working-copy commits in the same way as other refs
I don't think we need to optimize it for new_id == self_id, so I implemented the
fallback path as precise as the documentation.
2025-04-14 01:07:30 +00:00
Yuya Nishihara
a1d88980a9 revset: compare conflict file contents without materializing as conflicts
The logic is similar to the color-words diff's. We first resolve trivial
conflicts, then compare each hunk of Merge<&BStr> type. We also apply the same
optimization as the resolved case to minimize lines to be merged and diffed.
2025-04-14 01:07:24 +00:00
Winter
f3c4cc2155 cli: duplicate: add setting for templating the new commit descriptions
This allows the customization of the duplicated commit descriptions.

An ideal use case for this is emulating `git cherry-pick -x`, as
illustrated in the tests.
2025-04-13 21:49:47 +00:00
Gaëtan Lehmann
ee0e86fa63 lib: only allow non-trailer when the trailers contain a git generated trailer
namely Signed-off-by and cherry-pick trailers. The cherry-pick trailer
doesn't appear in the parsed trailer though, to match the
`git interpret-trailers` implementation.

see https://github.com/git/git/blob/master/trailer.c for reference
2025-04-13 20:36:11 +00:00
Gaëtan Lehmann
3c233c0f45 lib: add trailer module for commit trailers
To be used for parsing `Change-Id`, `Signed-off-by` and other
`Co-authored-by` trailers from commits

Co-authored-by: Austin Seipp <aseipp@pobox.com>
2025-04-13 20:36:11 +00:00
Martin von Zweigbergk
c259eb7413 revset: don't crash if revset engine returns non-BackendError
We call `RevsetEvaluationError::expect_backend_error()` in lots of
places. If the revset engine had returned a non-`BackendError`, it
would result in a panic. For example, a revset engine might return
something like `RevsetEvaluationError::Other("not supported".into())`
for some revsets. We shouldn't crash when this happens.

We may want to create some higher-level `RepoError` to return here,
but for now let's just avoid the crash.
2025-04-13 18:50:39 +00:00
Emily
af67d1d8c4 git: work around gix global remote configuration issue
Closes: #6324
2025-04-13 13:55:09 +00:00
Yuya Nishihara
a2bd7b30ad merge: remove redundant .clone() from .simplify()
It no longer makes sense that .simplify() requires ownership. It clones values
internally.
2025-04-13 05:18:16 +00:00
Yuya Nishihara
b28bc420ab merge: do not map absent tree entry to non-executable
We're going to make "jj resolve" error out on exec bit conflict. This behavior
should be more consistent with tree::try_resolve_file_conflict(), which exits
early if the tree value had absent entries.

Since unchanged exec bit shouldn't be lost when resolving change-delete content
conflict, the resolution function falls back to the original state if the
exec-bit conflict is resolved to None.
2025-04-13 02:02:58 +00:00
Yuya Nishihara
ecee441fb3 merge: use .try_map() internally to transform Merge<TreeValue>
This seems a bit easier to follow than nesting Option types.
try_resolve_file_conflict() doesn't have this problem, but it is the only caller
of maybe_map(), so I've gone ahead and replaced it, too.

The return type is unchanged because it looked equally bad if to_tree_merge()
returned Result<Result<Merge<Tree>, ()>, BackendError>.
2025-04-13 02:02:58 +00:00
Nils Koch
fbaa51b4ce revset: add signed function 2025-04-12 14:14:26 +00:00
Yuya Nishihara
d2caf6f1d9 cli: resolve: use try_materialize_file_conflict_value()
The executable bit handling will be a bit more involved in order to get around
#6250.
2025-04-12 08:58:05 +00:00
Yuya Nishihara
e4bbb5b14d conflicts: store unsimplified file ids in MaterializedFileConflictValue 2025-04-12 08:58:05 +00:00
Yuya Nishihara
a856494ab4 conflicts: extract function that materializes file conflict
This will be used in "jj resolve".
2025-04-12 08:58:05 +00:00
Yuya Nishihara
f047addfe0 conflicts: pack MaterializedTreeValue::FileConflict fields into struct
I'll add a function that returns Option<MaterializedFileConflictValue> instead
of MaterializedTreeValue.
2025-04-12 08:58:05 +00:00
Yuya Nishihara
8bcb806eed op_store: attach path context to read/write errors
This will probably help debug weird problem like #6287. File names are a bit
redundant for ReadObject errors (which include ObjectId), but that should be
okay.
2025-04-12 06:56:13 +00:00
Yuya Nishihara
5c6ab172b8 transaction: propagate error from tx.write()
#6287
2025-04-12 06:56:13 +00:00
Yuya Nishihara
3d98f59215 transaction: narrow scope of local variables needed to create Operation object
I feel this is easier to follow.
2025-04-12 06:56:13 +00:00
Yuya Nishihara
f587374d37 transaction: wrap tx.commit() error in enum
This helps propagate error from tx.write(). I made the error variants
non-transparent because it's easier than manually implementing From<> that maps
each inner error to the other inner error.
2025-04-12 06:56:13 +00:00
Yuya Nishihara
1305912fcf git_backend: load "git gc" executable name from settings 2025-04-12 01:43:35 +00:00
Yuya Nishihara
bae809a572 git_backend: pass GitSettings in to GitBackend::new()
The GitSettings object is passed by value as we're going to extract
executable_path from it, and GitBackend::new() is private.
2025-04-12 01:43:35 +00:00
Yuya Nishihara
60b96122f2 cleanup: use new array methods instead of .collect_tuple()/.next_tuple()
It's more obvious that the element types are the same.
2025-04-12 00:58:14 +00:00
Yuya Nishihara
5dd64ae978 git_backend: minor cleanup in tests
We don't have to create separate temporary directories.
2025-04-10 05:10:47 +00:00
Yuya Nishihara
d16da967c9 git_backend: rename variables per git.write-change-id-header config name 2025-04-10 05:10:47 +00:00
Yuya Nishihara
c4767c3de4 git_backend: do not ignore config error at loading path 2025-04-10 05:10:47 +00:00