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

6967 commits

Author SHA1 Message Date
Austin Seipp
d730e6f085 config: introduce default at = @ revset alias
When using Windows, `@` is a bit of an annoyance to type in the terminal due
to Windows Terminal escape rules, so you actually have to write it with a
backtick in front. It's annoying to remember this and not possible to configure
a different behavior, as far as I can see.

However, there is a smart trick you can do to make this a lot easier: just alias
`@` to the name `at` and be happy. Because:

- It's short: sweet and easy to read, and requires no backticks.
- It's unambiguous: `a` is from commit alphabet, but `t` is from the change alphabet
- It can be typed without a huge loss in efficiency (and one hand, assuming QWERTY).

I believe it was Stephen Jennings who came up with this trick first in Discord,
and I have it in my aliases, but I run into it every time I try to use JJ on a
fresh Windows VM to test stuff. Let's make life a little easier for everyone and
just ship this by default.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-09-10 16:46:43 -05:00
Kevin Liao
69edc7f2df Update jj edit <commit> to add commit into view heads if not already
`jj new <commit>` automatically adds the checked out commits into the view head ids. However,
`jj edit` does not.

To reproduce:
```
jj git init test
cd test
jj commit -m "my commit"
jj log -r @- -T commit_id # Save the id
jj abandon -r @-
jj edit <saved_id>

jj log -r :: # Does not show the currently editing commit 
```
2024-09-10 11:01:49 -07:00
Yuya Nishihara
d04ff1213f op diff: set up diff/template context without using WorkspaceCommandHelper
I'll use a similar setup in "op log", but for each log entry. We might want to
extract some parts to helper function, but I don't have a good idea right now.

CommandHelper::operation_template_extensions() is removed because it's unlikely
to parse operation template without loading a workspace.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
1e17078eb5 op log: leverage WorkspaceCommandEnvironment to parse template
I'll add an option to include diffs in "op log", and workspace_env will be used
in order to set up diff/template contexts per operation.

cmd_op_log() is split because of owned/borrowed type differences.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
e0da3ec010 cli: move some template helpers to WorkspaceCommandEnvironment
These functions will be used by "op log"/"diff"/"show".

This patch also changed the error type as it's obvious that there are no other
errors to be returned.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
1da9ebcec1 cli: cache parsed revsets.short-prefixes expression
It doesn't make sense to reparse revset expression. Let's reuse the parse
result. This also simplifies error handling bits.

OnceCell is switched to the std one as we no longer need get_or_try_init().
2024-09-10 07:06:43 +09:00
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
Stephen Jennings
12ec2212fb faq: Add "Should I co-locate my repository?" 2024-09-09 09:42:02 -07: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
Austin Seipp
882d528718 gitignore: add /buck-out/ to ignore list
While working on the Buck branch, I have been bitten about a million times by
the following setup:

- Hack away
- Switch back to main
- Run `jj st` after editing a file
- `/buck-out` gets snapshotted, because it isn't ignored
- Trip max snapshot filesize error
- Pain

There are a few ways to skin the cat but this is simplest. It's an incredibly
small addition and it may be all for naught in the long run, but this will stem
the bleeding, at least.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-09-07 21:07:18 -05:00
Yuya Nishihara
cf4a7e34b9 tests: remove temporary copy of workspace.repo_path() from TestWorkspace 2024-09-08 05:40:52 +09: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
4fb7dba73d repo: remove repo_path from ReadonlyRepo and RepoLoader
When loading repos on a server, there is no repo path. We currently
use a placeholder at Google. This patch will let us not do that.

I think we can remove the paths from `Workspace` too, but I'll leave
that for later, if at all.
2024-09-07 12:20:02 -07: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
19f383ffdd tests: avoid ReadonlyRepo::repo_path() 2024-09-07 12:20:02 -07:00
Martin von Zweigbergk
a06c393716 tests: use canonicalized paths in TestBackend
In `TestBackend`, we simply use the path as key to look up the storage
in memory. That means we can't rely on the file system to look find
the same path given two different representaitons of the same path. We
therefore need to canonicalize the paths if we want to allow the
caller to pass in different paths for the same real path.
2024-09-07 12:20:02 -07:00
Martin von Zweigbergk
0a94dcc5e3 repo: rename RepoLoader::init() to init_from_file_system()
`RepoLoader` can be used on a server. You would then call
`RepoLoader::new()`. Let's clarify what `init()` does by renaming it
and documenting it.

I think `WorkspaceLoader`, OTOH, is only useful for loading a
workspace from disk. I also documented that.
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
b22d8fefd9 local_working_copy: pass max file size to snapshot directly
We were passing the max file size to snapshot to
`WorkingCopy::snapshot()` via `UserSettings`. It's simpler and more
flexible to set it  on `SnapshotOptions` instead.
2024-09-07 11:33:05 -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
e385653064 chore: nix flake update
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-09-06 17:43:05 -05: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
Austin Seipp
a677d2adfa security: cargo update with vuln fix for gix-path < 0.10.11
Go ahead and do a blanket update while we're here.

Advisory: <https://github.com/martinvonz/jj/security/dependabot/33>
GHSA ID: GHSA-m8rp-vv92-46c7

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-09-06 15:17:25 -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
dependabot[bot]
24c4d431db cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [insta](https://github.com/mitsuhiko/insta), [pest](https://github.com/pest-parser/pest) and [pest_derive](https://github.com/pest-parser/pest).


Updates `insta` from 1.39.0 to 1.40.0
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.39.0...1.40.0)

Updates `pest` from 2.7.11 to 2.7.12
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.11...v2.7.12)

Updates `pest_derive` from 2.7.11 to 2.7.12
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.11...v2.7.12)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-06 17:55:09 +02:00
Martin von Zweigbergk
3133534b32 conflicts: don't panic when a conflict marker is missing removes
Closes #2611
2024-09-05 22:09:55 -07:00
Martin von Zweigbergk
4f656f3e02 tests: test parsing conflicts with missing removes (#2611) 2024-09-05 22:09:55 -07: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
Ilya Grigoriev
8f603f1a9c demos: fixup, working_copy.png wasn't regenerated properly
The "redacted output" wasn't properly redacted.

Also removed extraneous comment, and added a comment since
the new PNGs are larger than I expected.
2024-09-05 20:04:43 -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
Ilya Grigoriev
42dee7d08c demos: generate pngs 2024-09-05 17:33:46 -07:00