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

1568 commits

Author SHA1 Message Date
Yuya Nishihara
90791216c5 cli: move revset-related contexts to WorkspaceCommandEnvironment
This makes it clear that RevsetParseContext doesn't depend on repo view.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
9ca6c99508 cli: extract WorkspaceCommandEnvironment that doesn't depend on a repo
Some "operation" commands need a workspace, plus multiple repo views. We
currently load WorkspaceCommandHelper twice for that reason. It works, but
would be messy if "op log" loaded WorkspaceCommandHelper for each log entry.

This patch starts splitting non-repo data from WorkspaceCommandHelper. The
workspace object isn't owned by the environment object so the object can be
freely discarded.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
54443c9a8d cli: remove unneeded &mut Ui requirement from WorkspaceCommandHelper
These functions just print messages, and never change Ui state such as
pagination.
2024-09-10 07:06:43 +09:00
Martin von Zweigbergk
f36f4ad257 cli: make paths to auto-track configurable, add jj track
It's a pretty frequent request to have support for turning off
auto-tracking of new files and to have a command to manually track
them instead. This patch adds a `snapshot.auto-track` config to decide
which paths to auto-track (defaults to `all()`). It also adds a `jj
track` command to manually track the untracked paths.

This patch does not include displaying the untracked paths in `jj
status`, so for now this is probably only useful in colocated repos
where you can run `git status` to find the untracked files.

#323
2024-09-09 07:49:55 -07:00
Yuya Nishihara
653e8087da workspace: make workspace_root() and repo_path() return slice &Path
It's common to return &PathBuf as &Path.
2024-09-08 05:40:52 +09:00
Yuya Nishihara
47307556dd working_copy: pass SnapshotOptions by reference
Though SnapshotOptions can be cheaply cloned, it doesn't make much sense that
snapshot() consumes a settings-like object.
2024-09-08 04:51:21 +09:00
Martin von Zweigbergk
0b6714a33c workspace: take old repo path as separate argument
As I mentioned in recent patches, I'm about to remove
`ReadonlyRepo::repo_path()`.
2024-09-07 12:20:02 -07:00
Martin von Zweigbergk
bfb16a4c54 cli: get repo path from WorkspaceCommandHelper, not from ReadonlyRepo
I'd like to remove `ReadonlyRepo::repo_path()` since it doesn't make
sense when the repo is stored in a database.
2024-09-07 12:20:02 -07:00
Martin von Zweigbergk
8d090628c3 transaction: rename mut_repo() to idiomatic repo_mut()
We had both `repo()` and `mut_repo()` on `Transaction` and I think it
was easy to get confused and think that the former returned a
`&ReadonlyRepo` but both of them actually return a reference to
`MutableRepo` (the latter obviously returns a mutable reference). I
hope that renaming to the more idiomatic `repo_mut()` will help
clarify.

We could instead have renamed them to `mut_repo()` and
`mut_repo_mut()` but that seemed unnecessarily long. It would better
match the `mut_repo` variables we typically use, though.
2024-09-07 10:51:43 -07:00
Martin von Zweigbergk
e5e95225d4 cleanup: inline some short single-use mut_repo variables 2024-09-07 10:51:43 -07:00
Martin von Zweigbergk
5fbc819fc1 cleanup: avoid some unnecessary uses of mutable repo reference 2024-09-07 10:51:43 -07:00
Yuya Nishihara
5bae3eaa74 cli: remove unneeded Display for SparseInheritance
Since it's a ValueEnum, clap knows how to stringify the default value.
2024-09-07 10:17:37 +09:00
Yuya Nishihara
b263882e4b config-schema: add signing.backend=none to the list of enum variants 2024-09-07 10:17:08 +09:00
Yuya Nishihara
c3ed3e3781 evolog: use predecessor_ids() where commit object isn't needed 2024-09-07 09:09:27 +09:00
Yuya Nishihara
25819dd1c9 evolog: inline show_predecessor_patch() 2024-09-07 09:09:27 +09:00
Yuya Nishihara
03487af192 diff: extract inter-diff helper
This isn't as primitive as show_diff() or show_patch(), but there are three
callers. Let's add a helper method to remove repo argument.
2024-09-07 09:09:27 +09:00
Yuya Nishihara
f473d7bb7e op diff: pass merged repo in to DiffRenderer
Since DiffRenderer borrows a repo, it shouldn't be constructed from the base
WorkspaceCommandHelper.
2024-09-07 09:09:27 +09:00
Yuya Nishihara
b7caaf586b op diff: pass DiffRenderer in to show_op_diff() by reference
show_op_diff() doesn't need an ownership of renderer.
2024-09-07 09:09:17 +09:00
Yuya Nishihara
5bff5cdef0 op diff: create formatter by show_op_diff() callers
This will help embed operation diffs in "op log".
2024-09-07 09:09:17 +09:00
Yuya Nishihara
ea8f543d5a op show: accept root operation by mapping empty parents to root
I'm thinking of adding an option to embed operation diffs in "op log", and
"op log" shouldn't fail at the root operation. Let's make "op diff"/"show"
also work for consistency.
2024-09-07 09:09:17 +09:00
Austin Seipp
a31fe7f6d6 cli: implement workspace add --sparse-patterns
This flag implements three modes:

- `copy`: copy sparse patterns from parent
- `full`: do not copy sparse patterns from parent
- `empty`: clear all paths, equal to `set --clear`

This is useful for various tooling like tools that want to run a parallel
process that queries the build system (without running into locks/blocking.)

I think continuing to copy sparse patterns makes sense as the default behavior.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-09-06 16:22:47 -05:00
Danny Hooper
bf543402cc cli: fix: add --include-unchanged-files flag to allow fixing as yet unchanged files
This enables workflows like "insert a commit that reformats the code in one of
my project directories".

`jj fix --include-unchanged-files` is an easy way to fix everything in the repo.

`jj fix --include-unchanged-files <file...>` fixes all of the `<files>` even if they are
unchanged.

This is mostly orthogonal to other features, so not many tests are added.

This is a significant and simple enough improvement that I think it's
appropriate to make it here instead of waiting for a `jj run`-based solution.
2024-09-06 13:50:28 -05:00
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