ok/jj
1
0
Fork 0
forked from mirrors/jj
Commit graph

1546 commits

Author SHA1 Message Date
Martin von Zweigbergk
fee706dfea signing: allow disabling by setting backend to "none"
We don't seem to have a way to override the config to disable
signing. This patch lets you do that by setting
`signing.backend="none"`.
2024-09-05 21:02:22 -07:00
Yuya Nishihara
6ea46b930b op diff: resolve GraphStyle by caller, remove &CommandHelper argument
show_op_diff() has many arguments. Let's make it a bit less.
2024-09-06 09:51:10 +09:00
Yuya Nishihara
dda0980c4d graphlog: inline node_template_for_key()
It's easier to follow than function call with 3 string parameters.
2024-09-06 09:51:10 +09:00
Yuya Nishihara
36ab165b57 cli: parse graph node settings strictly 2024-09-06 09:51:10 +09:00
Yuya Nishihara
406ead241b graphlog: load settings by caller
I'll make it error out if the style name is invalid.
2024-09-06 09:51:10 +09:00
Yuya Nishihara
bd7cbaaffb graphlog: add enum describing graph style 2024-09-06 09:51:10 +09:00
Yuya Nishihara
3ad54ad38d settings: move graph node helpers to CLI
I'm going to add enum GraphStyle, and it's specific to the CLI.
node_template_for_key() will be inlined later.
2024-09-06 09:51:10 +09:00
Yuya Nishihara
058249cc57 cli: update docs URLs to point to https://martinvonz.github.io/jj/latest/ 2024-09-06 09:22:04 +09:00
Martin von Zweigbergk
a0fae76622 cli: rename obslog to evolution-log/evolog
It seems everyone agrees that `obslog` is not an intuitive name. There
was some discussion about alternatives in #3592 and on #4146. The
alternatives included `evolution`, `evolutionlog`, `evolog`,
`rewritelog`, `revlog`, and `changelog`. It seemed like
`evolution-log`/`evolog` was the most popular option. That also
matches the command's current help text ("Show how a change has
evolved over time").
2024-09-05 13:45:17 -07:00
Martin von Zweigbergk
ce04e61dd4 tests: set $COLUMNS when running CLI tests
As reported in #4394, at least `test_show_command::test_show_basic`
can fail when run with a narrow terminal. This patch sets
`COLUMNS=100` in the environment when running tests so the CLI uses
that value instead of using the width of the user's terminal.
2024-09-05 08:56:04 -07:00
Ilya Grigoriev
6f44ed4f51 cli squash: explain --into in error message for merge commits 2024-09-04 21:38:55 -07:00
Martin von Zweigbergk
4a8d250f2c store: make write_file() async 2024-09-04 18:34:11 -07:00
Martin von Zweigbergk
8eb3d85b1c backend: make write methods async
This doesn't provide any benefit yet bit I think we've known for a
while that we want to make the backend write methods async. It's just
not been important to Google because we have the local daemon process
that makes our writes pretty fast. Regardless, this first commit just
changes the API and all callers immediately block for now, so it won't
help even on slow backends.
2024-09-04 18:34:11 -07:00
Kaleb Pace
dbb579adec cli/build-rs: remove metadata command dependency in favor of env vars
When building this project with [Nix/Crane](https://github.com/ipetkov/crane/discussions/693), if the `jj-cli` dependency is specified in `Cargo.toml` as a git-based crate, `cargo vendor` splits this workspace up into sub-crate directories, which causes `cargo metadata` to fail when searching for relative deps in the workspace root.

This commit simply changes how the crate version is determined, using Cargo's built-in environment variable [`CARGO_PKG_VERSION`](https://doc.rust-lang.org/cargo/reference/environment-variables.html)
2024-09-03 22:31:17 -07:00
Scott Taylor
52499e84cc config: add color for renamed and copied in summary
Right now, renamed and copied files don't have any color in the output
of `jj status`, and it makes them stand out. I think it's reasonable to
color renamed files the same as modified files, since renaming is like
modifying the path, and to color copied files the same as added files,
since they're basically just added files that happen to have similar
contents to an existing file.
2024-09-03 21:33:29 -05:00
Martin von Zweigbergk
6fdef8bf67 cli: make WorkspaceCommandHelper keep a CommandHelper
This avoids cloning `UserSettings` and some other data. I haven't
attempted to measure the performance impact (I expect it's tiny); this
is more about clarifying that there are not multiple different
versions of these fields.
2024-09-03 08:41:24 -07:00
Martin von Zweigbergk
34425a2501 cli: make CommandHelper cheaply cloneable
This wraps all the fields in `CommandHelper` in an `Rc` so
`CommandHelper` itself becomes cheap to clone (thanks to @yuja for the
idea). I'll use that next to avoid some cloning in
`WorkspaceCommandHelper`.
2024-09-03 08:41:24 -07:00
Martin von Zweigbergk
cc15ecf7c7 op log: change "resolve concurrent" to "reconcile divergent"
"Concurrent" operations are not necessarily actually concurrent, so
"divergent" seems like a better name. And "reconcile" seems like a
better term for merging them, though we also sometimes use "merge".
2024-08-30 21:56:11 -07:00
dploch
f963af3f16 workspace: turn WorkspaceLoader into a trait
Like https://github.com/martinvonz/jj/pull/4189, this allows extensions the ability to load the repo in an environment where the local filesystem is not accessible. This change allows such extensions to exist at the CLI layer where jj is invoked as a subprocess, rather than a library (common in testing).
2024-08-30 13:35:52 -04:00
Yuya Nishihara
d99a8508e4 rewrite: pass old parent ids in to mut_repo.new_parents() by slice 2024-08-29 08:59:22 +09:00
Yuya Nishihara
5af906d924 cli: change default inline threshold of color-words diffs
I played with max-inline-alternation = 3 for a couple of weeks, and it's pretty
good. I think somewhere between 2 and 4 is good default because one or two
remove + add sequences are easy to parse.
2024-08-28 10:33:33 +09:00
Yuya Nishihara
9c9e564dc4 conflicts: pass around conflict contents without materialization
We haven't decided how conflict diffs should be rendered, but whatever style
we'll choose, we'll need raw unmaterialized conflict contents.
2024-08-28 10:23:57 +09:00
Yuya Nishihara
73a8b13e4c conflicts: split materialized value to FileConflict and OtherConflict
FileConflict will be changed to not materialize Merge<BString>. I also updated
the revset engine to ignore non-file conflict. It doesn't make sense to grep
conflict description.
2024-08-28 10:23:57 +09:00
Yuya Nishihara
0c14a0a9ca conflicts: make describe() simply return string
I'll add more callers of id.describe(), and the output size wouldn't be large
enough to avoid allocation by using Write API.
2024-08-28 10:23:57 +09:00
Yuya Nishihara
1ba581b37c conflicts: replace ContentHunk with BString
ContentHunk is basically a nice wrapper around Vec<u8>. I think it would give
little benefit for type safety.
2024-08-28 10:23:57 +09:00
Austin Seipp
d928e43073 cli: add name() and about() methods to CliRunner
Useful for third party tools to override, along with the version.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-08-25 12:24:02 -05:00
Yuya Nishihara
6b65f8abec cli: move "untrack" to "file" subcommand
I don't think "jj untrack" is frequently used, and I think it is a "file"
command rather than "workspace".
2024-08-26 01:19:15 +09:00
Yuya Nishihara
3c15f8106a cli: add deprecation comment to cat, chmod, and files 2024-08-26 01:19:15 +09:00
Yuya Nishihara
3762f890f6 cli: extract helper that issues deprecation warning and invoke command fn 2024-08-26 01:19:15 +09:00
Yuya Nishihara
3b0b70a451 cli: fix default value of ui.allow-filesets in config schema
It's been enabled since 8fec7500c3 "cli: enable fileset by default."
2024-08-25 23:16:29 +09:00
Essien Ita Essien
f9dc0589c1 next/prev: update error message when no movement targets are found.
If movement commands don't find a target commit, they fail. However,
it's usually not intuitive why they fail because in non-edit mode the
start commit is the parent of the working commit.

Adding the start commit change hash to the error message makes it easier
for the user to figure out what is going on.

Also, specifying 'No **other** descendant...' helps make it clear what
`jj` is really looking for.

Part of #3947
2024-08-25 09:58:04 +01:00
Yuya Nishihara
8d166c7642 templater: integrate copy tracking in commit.diff() template 2024-08-24 15:47:08 +09:00
Martin von Zweigbergk
b78c83e9fe status: report copies and renames 2024-08-23 18:51:02 -07:00
Yuya Nishihara
f1be5c59f3 cleanup: consistently import std::fmt 2024-08-23 13:05:27 +09:00
Yuya Nishihara
87fb169266 cleanup: remove redundant ::{self} from use declarations 2024-08-23 13:05:27 +09:00
Yuya Nishihara
4ffd3a3055 diff: pass tree diff stream in to inner show_*() functions as before 2024-08-23 10:29:12 +09:00
Yuya Nishihara
f5187fa063 copies: determine copy/rename operation by CopiesTreeDiffStream
Not all callers need this information, but I assumed it's relatively cheap to
look up the source path in the target tree compared to diffing.

This could be represented as Regular(_)|Copied(_, _)|Renamed(_, _), but it's
a bit weird if Copied and Renamed were separate variants. Instead, I decided
to wrap copy metadata in Option.
2024-08-23 10:29:12 +09:00
Yuya Nishihara
08262eb152 copies: extract (source, target) path pair to separate type
This patch adds accessor methods as I'm going to change the underlying data
types. Since entry values are consumed separately, these methods are implemented
on CopiesTreeDiffEntryPath, not on *TreeDiffEntry.
2024-08-23 10:29:12 +09:00
Yuya Nishihara
43bf195314 merged_tree: rename diff entry field from "value" to "values"
It seems a slightly better, and aligns with the local variable name in
materialized_diff_stream().
2024-08-23 10:29:12 +09:00
Matt Kulukundis
ac7fa1abb9 docs: improve md format for jj fix 2024-08-22 16:03:44 -04:00
Matt Kulukundis
8ead72e99f formatting only: switch to Item level import ganularity 2024-08-22 14:52:54 -04:00
Yuya Nishihara
352a4a0eea copies: filter rename source entries by CopiesTreeDiffStream 2024-08-22 20:17:19 +09:00
Yuya Nishihara
7684ab5994 diff: omit rename source entries from color-words diffs
Rename source entries will be handled by CopiesTreeDiffStream.
2024-08-22 20:17:19 +09:00
Yuya Nishihara
2cffcc9323 copies: provide source path mapping by CopyRecords
All for/has_source/target() combinations are added for API consistency.
2024-08-22 20:17:19 +09:00
Yuya Nishihara
5e356ffd24 diff: filter out uninteresting copy records by matcher
Git reports a rename source as deleted if the rename target is excluded. I
think that's because Git restricts the search space to the specified paths. For
example, Git doesn't also recognize a rename if the source path is excluded
whereas jj does.

I don't think we need to copy the exact behavior of Git, so this patch just
moves matcher application to earlier stage. This change will help remove
collect_copied_sources().

The added get_copy_records() helper could be moved to jj_lib, but we'll probably
want a stream version of this function in library, and writing a stream adapter
isn't as simple as iterator.
2024-08-22 20:17:19 +09:00
Yuya Nishihara
d85e66bbb4 copies: turn add_records() into non-stream API, block_on_stream() by caller
This is simpler, and I think it's generally better to not spawn executor in
library code.
2024-08-22 20:17:19 +09:00
Yuya Nishihara
a83dadd5a9 diff: add option to display complex color-words diffs without inlining
In this patch, I use the number of adds<->removes alternation as a threshold,
which approximates the visual complexity of diff hunks. I don't think user can
choose the threshold intuitively, but we need a config knob to try out some.
I set `max-inline-alternation = 3` locally. 0 and 1 mean "disable inlining"
and "inline adds-only/removes-only lines" respectively.

I've added "diff.<format>" config namespace assuming "ui.diff" will be
reorganized as "ui.diff-formatter" or something. #3327

Some other metrics I've tried:
```
// Per-line alternation. This also works well, but can't measure complexity of
// changes across lines.
fn count_max_diff_alternation_per_line(diff_lines: &[DiffLine]) -> usize {
    diff_lines
        .iter()
        .map(|line| {
            let sides = line.hunks.iter().map(|&(side, _)| side);
            sides
                .filter(|&side| side != DiffLineHunkSide::Both)
                .dedup() // omit e.g. left->both->left
                .count()
        })
        .max()
        .unwrap_or(0)
}

// Per-line occupancy of changes. Large diffs don't always look complex.
fn max_diff_token_ratio_per_line(diff_lines: &[DiffLine]) -> f32 {
    diff_lines
        .iter()
        .filter_map(|line| {
            let [both_len, left_len, right_len] =
                line.hunks.iter().fold([0, 0, 0], |mut acc, (side, data)| {
                    let index = match side {
                        DiffLineHunkSide::Both => 0,
                        DiffLineHunkSide::Left => 1,
                        DiffLineHunkSide::Right => 2,
                    };
                    acc[index] += data.len();
                    acc
                });
            // left/right-only change is readable
            (left_len != 0 && right_len != 0).then(|| {
                let diff_len = left_len + right_len;
                let total_len = both_len + left_len + right_len;
                (diff_len as f32) / (total_len as f32)
            })
        })
        .reduce(f32::max)
        .unwrap_or(0.0)
}

// Total occupancy of changes. Large diffs don't always look complex.
fn total_change_ratio(diff_lines: &[DiffLine]) -> f32 {
    let (diff_len, total_len) = diff_lines
        .iter()
        .flat_map(|line| &line.hunks)
        .fold((0, 0), |(diff_len, total_len), (side, data)| {
            let l = data.len();
            match side {
                DiffLineHunkSide::Both => (diff_len, total_len + l),
                DiffLineHunkSide::Left => (diff_len + l, total_len + l),
                DiffLineHunkSide::Right => (diff_len + l, total_len + l),
            }
        });
    (diff_len as f32) / (total_len as f32)
}
```
2024-08-21 17:48:52 +09:00
Yuya Nishihara
be9b7ed88f diff: pad last newline by show_color_words_diff_line()
Though this is needed only for the last line, checking it for each line is
cheap. As I'm going to add another rendering style, the condition to pad "\n"
would become more complicated.
2024-08-21 17:48:52 +09:00
Yuya Nishihara
bb686c1459 diff: extract helper that prints color-words line numbers 2024-08-21 17:48:52 +09:00
Yuya Nishihara
6b2e191b2b diff: extract helpers that process word-level diffs without interleaving
These functions will be reused by non-inline version of color-words diffs.
2024-08-21 17:48:52 +09:00