Commit graph

3925 commits

Author SHA1 Message Date
Yuya Nishihara
73a4b7f5bf repo: extract add_heads() that can import commits from multiple heads
This allows us to reorder commits to be indexed in bulk.

The incremental update optimization is applied only for a single head. This
could be tried for multiple heads, but it's unlikely that every head has
a single new commit for each.
2023-08-14 07:48:55 +09:00
Yuya Nishihara
157a0e748b git: add separate step to apply HEAD@git change
I'm going to extract a step to import new commits all at once.
2023-08-14 07:48:55 +09:00
Yuya Nishihara
359c871545 git: remove redundant id.clone() from diff_refs_to_import() 2023-08-14 07:48:55 +09:00
Waleed Khan
b837e88757 merge_tools: extract external merge tool functions 2023-08-13 16:51:42 -04:00
Waleed Khan
4bb40bbf10 merge_tools: create merge_tools directory
The intention is to put the internal and external merge tool implementations in different files.
2023-08-13 16:21:05 -04:00
Piotr Kufel
a8b02de5c3 Allow editing user-specific config file outside of a repo
This addresses #2054.
2023-08-13 11:35:56 -07:00
Vamsi Avula
bc57754c58 cli: add support for setting default description
That is, jj will use ui.default_description as a starting point when
user is about to describe an empty change.

I think it might be confusing to do this with -m / --stdin (violates
WYSIWYG), so I'm only doing this when jj invokes an editor.

Also, this could evolve into a proper template in the future instead of
just plain text, to allow inheriting from parent change(s), for example.

Partially addresses #1354.
2023-08-13 23:59:15 +05:30
Martin von Zweigbergk
28182dbd8e docs: correct stale info about which backends are dynamically chosen 2023-08-13 14:15:09 +00:00
Martin von Zweigbergk
e414f3b73c cleanup: use fs:read() instead of File::open().read_to_end() 2023-08-13 14:04:59 +00:00
Vamsi Avula
b8cc6fc3c8 cli: trim the description from editor before using it
We anyway trim the newlines eventually and this just does that eagerly
so we output the "correct" description back to stdout (on describe for
example, we'd now print the first non empty line).
2023-08-13 15:47:16 +05:30
Martin von Zweigbergk
0b3b62a777 conflicts: remove redundant num_removes argument from parse_conflict()
Merges always have exactly one more "adds" than "removes" these days.
2023-08-13 09:54:16 +00:00
Yuya Nishihara
72271c0d1f repo: micro-optimize add_head() to not instantiate indexed commit object 2023-08-13 18:52:17 +09:00
Yuya Nishihara
15fb8b95b0 index: rewrite topological sort by leveraging dag_walk function
This is similar to what mut_repo.add_head() does.

I'm going to adjust the visiting order so the bulk-imported history preserves
chronological order. It might be a small adjustment on the current DFS
approach, or new function based on Kahn's algorithm. Either way, it's important
that both "jj git import" and "jj debug reindex" use the same underlying
function.
2023-08-13 18:52:17 +09:00
Yuya Nishihara
8652bae925 index: add tracing output to "jj debug reindex" path 2023-08-13 18:52:17 +09:00
Zachary Dremann
062f7a252b cli: Allow repeated -m options for multi-paragraph descriptions
Emulates git's behavior:
https://www.git-scm.com/docs/git-commit#Documentation/git-commit.txt--mltmsggt
2023-08-13 05:06:35 -04:00
Waleed Khan
c572c1a331 merge_tools: rename MergeTool -> ExternalMergeTool 2023-08-13 01:21:57 -04:00
Emily Fox
c2979e849f docs: disambiguate link to user config info 2023-08-13 05:08:45 +00:00
Emily Fox
6245181597 docs: fix typo in operation-log.md 2023-08-13 05:08:45 +00:00
Waleed Khan
4c7b4a8bcc docs: add diff-instructions to config schema 2023-08-13 01:07:40 -04:00
Martin von Zweigbergk
00d2d2d4fc cli: indicate empty files in default diff format
Empty files can be confusing in diff output. For example:


```
Added regular file file1:
Added regular file file2:
        1: foo
```

This commit adds an "(empty)" placeholder instead. Since it's not
colored, and doesn't have line numbers, it will hopefully not be
mistaken for a file with the contents "(empty)".
2023-08-13 01:51:43 +00:00
Martin von Zweigbergk
f9e0feaaf8 working_copy: return early from write_path_to_store() for non-files
Almost the entire method deals with `FileType::Normal`, so we can
reduce indentation and repeated matching on the file type by doing it
early and returning in the non-normal-file cases.
2023-08-13 01:00:31 +00:00
Martin von Zweigbergk
23f54b8151 working_copy: propagate errors when reading conflicted file 2023-08-13 01:00:31 +00:00
Martin von Zweigbergk
33a93b6d2d working_copy: reduce scope of a content variable
This also avoids reading non-file conflict from disk.
2023-08-13 01:00:31 +00:00
Martin von Zweigbergk
585c212617 working_copy: reduce scope of an executable variable 2023-08-13 01:00:31 +00:00
Martin von Zweigbergk
2102de94b0 working_copy: inline write_conflict_to_store()
For tree-level conflicts, we're eventually not going to have
`ConflictId`. We'd want to make `write_conflict_to_store()` take a
`Merge<Option<TreeValue>>` and return an updated such value. That
would leave very little logic in the function, so let's just inline it
instead.
2023-08-13 01:00:31 +00:00
Yuya Nishihara
d57237af5d cli: on "git clone --colocate", set up .git/info/exclude to ignore .jj dir 2023-08-13 06:56:44 +09:00
Yuya Nishihara
5c6ef75b2b cli: move add_to_git_exclude() helper to commands.git module
I'm going to add a call site to the git module, and I think it's better to
host the helper function there instead of importing from the super module.
2023-08-13 06:56:44 +09:00
Yuya Nishihara
8b5ff20874 cli: discard "unborn" default branch before checking out fetched head
AFAIK, we can't make HEAD detached in an empty Git repository, so we need
to temporarily switch to the new default branch before checking out.

Fixes #2047
2023-08-13 06:44:50 +09:00
Yuya Nishihara
28633bb754 cli: fix --no-pager to persist across layered config loading 2023-08-12 13:47:31 +09:00
Martin von Zweigbergk
1d4b5d04fa windows: disable pagination by default (#2040)
Windows environments typically don't have a good pager, it seems, so
let's disable pagination for now.
2023-08-12 04:37:39 +00:00
Martin von Zweigbergk
3b164c69a2 merge_tools: postpone writing conflict object a little longer
This gets us a tiny bit closer to being able to write tree-level
conflicts in this code.
2023-08-11 23:59:44 +00:00
Martin von Zweigbergk
4c46398b1c conflicts: make update_from_content() write resolved content to store
`update_from_content()` already writes file content for each term of
an unresolved merge, so it seems consistent for it to also write the
file content for resolved merges. I think this should simplify further
refactoring for tree-level conflicts and for preserving the executable
bit.
2023-08-11 23:59:44 +00:00
Martin von Zweigbergk
0b85f06e3d conflicts: make update_from_content() work with only FileIds
Since `update_from_contents()` only works with file contents and not
the executable or other kinds of paths, I think it makes more sense
for it to deal with `FileId`s instead of `TreeValue`s.
2023-08-11 23:59:44 +00:00
Martin von Zweigbergk
94c14d454a tests: levarage the materialize_conflict_string() helper in more places 2023-08-11 23:59:44 +00:00
Martin von Zweigbergk
adf9679d4c tree: inline simplify_conflict()
The function is just a few lines now. I don't think we need the long
documentation in it either since that's now in
docs/technical/conflicts.md.
2023-08-11 21:11:25 +00:00
Martin von Zweigbergk
d4e755b4e4 merged_tree: rename some symbols away from "conflict"
There were still many instances of `conflict` left from before we
renamed `Conflict<T>` to `Merge<T>`. I decided to rename many of them
based on the type parameter instead of the container. I think that
made it more readable in many cases.
2023-08-11 21:11:25 +00:00
Martin von Zweigbergk
a995c66635 merge: move some methods back to conflicts as free functions
I think I moved way too many functions onto `Merge<Option<TreeValue>>`
in 82883e648d. This effectively reverts almost all of that
commit. The `Merge<T>` type is simple container and it seems like it
should be at fairly low level in the dependency graph. By moving
functions off of it, we can get rid of the back-depdencies from the
`merge` module to the `conflict` module that I introduced when I moved
`Merge` to the `merge` module. I'm thinking the `conflict` module can
focus on materialized conflicts.
2023-08-11 21:11:25 +00:00
Ben Saunders
e563d60e64 Update docs and errors to use XDG config path 2023-08-11 13:21:44 -07:00
Yuya Nishihara
925d54614d revset: remove round-trip conversion from heads() evaluation
This wouldn't matter much in practice, but I think it's better to stick to
low-level index primitives during revset evaluation.
2023-08-12 02:16:29 +09:00
Matt Stavola
4760b565c5 configs: add the ability to disable paging via ui.paginate 2023-08-11 12:45:53 -04:00
dependabot[bot]
083e971dfb cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [rustix](https://github.com/bytecodealliance/rustix).

- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.7...v0.38.8)

---
updated-dependencies:
- dependency-name: rustix
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-11 15:36:19 +00:00
Austin Seipp
1abd36725a envrc: use nix-direnv instead of default direnv nix support
Summary: It releases more frequently and tends to fix more bugs frequently than
direnv; it also seems to (in my experience) behave better with caching in flake
and non-flake scenarios.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I39f08cd691eeac8e243c2e059edfaa9c
2023-08-11 04:06:48 -05:00
Austin Seipp
8b2801887e nix: 'nix flake update'
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I164d8a6679516dbf1e5ef726d341ec41
2023-08-11 04:06:48 -05:00
Martin von Zweigbergk
d1dbe6de98 git: propagate errors for missing commits when importing refs 2023-08-11 05:06:36 +00:00
Yuya Nishihara
0cbee40aec cli: attach stderr stream of external diff command to pager
It's messy if pager and child output are interleaved as the pager controls
the tty.

Windows code is untested. I think the underlying I/O behavior is similar, but
I don't have expertise.
2023-08-11 13:47:13 +09:00
Yuya Nishihara
4c9c923258 cli: show warning if external diff generator exited with non-zero status 2023-08-11 13:47:13 +09:00
Yuya Nishihara
9dbadda150 cli: pass ui in to merge_tools::generate_diff()
Two things will be added:
a. show warning if child exited with non-zero status
b. attach pager stdin to stderr of child process

I think (a) could be propagated from generate_diff() as an error variant, but
for (b), it makes sense to pass ui down to the function.
2023-08-11 13:47:13 +09:00
Ilya Grigoriev
6fa8a25839 cli templates: include branches in short commit description
They are shown next to the change and commit id, since they are other names the
commit can be referred by. 

The description is separated from the branches by a ` | ` when there are
branches, so that one can tell the branches from the description without color.

The result looks like this: ![image](https://github.com/martinvonz/jj/assets/4123047/a38aff7b-2b47-49e6-8461-c42e8eb535a4)
2023-08-10 20:58:40 -07:00
Ilya Grigoriev
355b93fdd6 cli branch list: use separate short commit template
We will shortly add branches to the short commit template, but that is undesireable
for `jj branch list`.
2023-08-10 20:58:40 -07:00
Yuya Nishihara
17b45d642f cli: add "--limit N" option to log-like commands
Copied from Mercurial. This isn't a revset predicate since our revset is
conceptually unordered.
2023-08-11 10:40:40 +09:00