Commit graph

59 commits

Author SHA1 Message Date
Yuya Nishihara
6286cde543 index: import commits in chronological order
This basically means that heads in a filtered graph appear in reverse
chronological order. Before, "jj log -r 'tags()'" in linux-stable repo would
look randomly sorted once you ran "jj debug reindex" in it.

With this change, indexing is more like breadth-first search, and BFS is
known to be bad at rendering nice graph (because branches run in parallel.)
However, we have a post process to group topological branches, so we don't
have this problem. For serialization formats like Mercurial's revlog iirc,
BFS leads to bad compression ratio, but our index isn't that kind of data.

Reindexing gets slightly slower, but I think this is negligible.

  (in Git repository)
  % hyperfine --warmup 3 --runs 10 "jj debug reindex --ignore-working-copy"
  (original)
  Time (mean ± σ):      1.521 s ±  0.027 s    [User: 1.307 s, System: 0.211 s]
  Range (min … max):    1.486 s …  1.573 s    10 runs
  (new)
  Time (mean ± σ):      1.568 s ±  0.027 s    [User: 1.368 s, System: 0.197 s]
  Range (min … max):    1.531 s …  1.625 s    10 runs

Another idea is to sort heads chronologically and run DFS-based topological
sorting. It's ad-hoc, but worked surprisingly well for my local repositories.
For repositories with lots of long-running branches, this commit will provide
more predictable result than DFS-based one.
2023-08-15 15:03:45 +09:00
Martin von Zweigbergk
f1b817e8ca cleanup: fix warnings from nightly clippy 2023-08-14 22:11:56 -07:00
Martin von Zweigbergk
9a2a8f85a7 cli: leverage Merge::map() in jj chmod 2023-08-14 18:15:34 -07:00
Martin von Zweigbergk
725f79cd65 cli: in jj chmod, check if all sides are files first
This is mostly to allow us to simplify the code that comes after in
the next commit.
2023-08-14 18:15:34 -07:00
Martin von Zweigbergk
a80259c7d3 cli: say that jj chmod errors out if there are any non-file sides
`jj chmod` won't operate on conflicts involving non-files on the
positive sides. However, the error message says "None of the sides of
the conflict are files", which is not correct.
2023-08-14 18:15:34 -07:00
Tal Pressman
32fef364ef add error message when running from a non-existent directory 2023-08-15 09:00:42 +09:00
Martin von Zweigbergk
af145e8ea5 cli: include hint when push is not fast-forward 2023-08-14 07:31:13 -07:00
Waleed Khan
9ea9c068ed merge_tools: move symbols to external.rs 2023-08-14 00:02:11 -04: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
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
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
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
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
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
Matt Stavola
4760b565c5 configs: add the ability to disable paging via ui.paginate 2023-08-11 12:45:53 -04: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
Yuya Nishihara
fb41ef4fa0 cli: handle invalid ui.editor configuration 2023-08-11 08:09:41 +09:00
Martin von Zweigbergk
a367f13c72 configs: use Notepad as default editor on Windows 2023-08-10 17:09:07 +00:00
Martin von Zweigbergk
32b07d6b79 cli: move default editor (pico) definition to config file 2023-08-10 17:09:07 +00:00
Yuya Nishihara
b2101d15c8 cli: detect .git symlink as a colocated workspace
Maybe we could load GitBackend without resolving .git symlink, but that would
introduce more subtle bugs. Instead, we calculate the expected Git workdir path
from the canonical ".git" path.

Fixes #2011
2023-08-10 14:53:54 +09:00
Yuya Nishihara
900300cf5f cli: do not panic if clone destination directory can't be created
wc_path.canonicalize() can also fail, but that's probably because of racy
clone and the directory creation would have effectively failed.
2023-08-10 07:18:06 +09:00
Yuya Nishihara
97b6eb2684 cli: clean up .git directory if "jj git clone --colocate" failed 2023-08-10 07:18:06 +09:00
Yuya Nishihara
6625e91a4b cli: send "Failed to clean up" message to stderr 2023-08-10 07:18:06 +09:00
Yuya Nishihara
d039008db8 cli: add tests for failed "jj git clone"
Perhaps, the message "(os error 39)" isn't portable, but I don't care since
it will be fixed by later patch.
2023-08-10 07:18:06 +09:00
Martin von Zweigbergk
56472297f0 git: add support for SSH authentication with ed25519 or ed25519-sk
This makes it possible to use ed25519 and ed25519-sk keys by trying
them one at a time. However, it still fails if one of them is
password-protected; we don't try the next key in that case.
2023-08-09 03:44:03 +00:00
Martin von Zweigbergk
1d2324ae5c git: refactor SSH key callbacks to allow multiple keys
This is to prepare for adding support for checking other keys than
just id_rsa.
2023-08-09 03:44:03 +00:00
Benjamin Saunders
7cf518a530 cli: don't call a safe function 'unsafe' 2023-08-08 20:42:19 -07:00
Ilya Grigoriev
a9e5e97025 test_git_push: Test git.push-branch-prefix config 2023-08-07 19:10:10 -07:00
Ilya Grigoriev
add867cfae test_git_push: use -c instead of --change occasionally 2023-08-07 19:10:10 -07:00
Ilya Grigoriev
74d9970908 config: Rename push.branch-prefix option to git.push-branch-prefix
This is for consistency with other `git.` options. See also
https://github.com/martinvonz/jj/pull/1962#discussion_r1282605185
2023-08-07 19:10:10 -07:00
Ilya Grigoriev
9e08b52d55 merge_tools: make dirs readonly for external difftool
As far as I understand, the difftool is supposed to be readonly,
so let's encourage people to no edit the files being diffed.
2023-08-07 17:17:35 -07:00