Commit graph

6471 commits

Author SHA1 Message Date
Yuya Nishihara
f9a15ba542 diff: do not add excessive number of context lines to last unified-diff hunk
The last hunk could be truncated instead, but the .peekable() version is easier
to follow. If we truncated lines, we would have to adjust line ranges
accordingly.
2024-07-02 18:49:52 +09:00
Yuya Nishihara
ec709e7f8b diff: rely on emptiness of unified hunk lines whether to append "after" context
show_context_after was set once when DiffHunk::Different received, and was
never turned off. This means DiffHunk::Matching is not supposed to repeat.
Under this condition, we can assume that removed/added lines exist if lines
isn't empty.
2024-07-02 18:49:52 +09:00
Yuya Nishihara
318f594291 diff: simplify context line extraction by using DoubleEndedIterator 2024-07-02 18:49:52 +09:00
Yuya Nishihara
3d458c3e58 diff: extract helpers that push unified-diff hunk lines 2024-07-02 18:49:52 +09:00
Yuya Nishihara
a4f5462d07 tests: add test for leading/trailing diff context lines 2024-07-02 18:49:52 +09:00
Yuya Nishihara
5a85254bde docs: add customization example of color-words diff style
The default style is compatible with various terminal emulators, but I suspect
that many people wouldn't like underlines. Let's add an example to override it.
2024-07-02 18:47:36 +09:00
mlcui
3bca159b1a fake-editor: replace expectpath with dump-path
This allows us to assert the expected path in the test itself, rather
than in the fake editor.
2024-07-02 11:15:44 +10:00
Jonathan Tan
1eef1a4f55 workspace add: add filename context to FS error
At work, a user encountered a panic upon attempting to create a dir at
the line in the diff below, but it turned out to be difficult to debug
because I didn't know what the path was. There already is a mechanism to
add path context in the lib crate; make it available in the cli crate as
well, and use the mechanism to add path context to "workspace add".
2024-07-01 16:05:29 -07:00
Austin Seipp
f883ce92c6 github: publish binaries on push to main
These only occur on `main` pushes because we want to use --release binaries,
which will slow down the CI time a lot for integrating patches.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-07-01 10:01:51 -07:00
dependabot[bot]
7e1b162efb cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [clap](https://github.com/clap-rs/clap), [clap_complete](https://github.com/clap-rs/clap) and [serde_json](https://github.com/serde-rs/json).


Updates `clap` from 4.5.7 to 4.5.8
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.7...v4.5.8)

Updates `clap_complete` from 4.5.6 to 4.5.7
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.6...clap_complete-v4.5.7)

Updates `serde_json` from 1.0.118 to 1.0.119
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.118...v1.0.119)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-01 15:39:43 +00:00
Austin Seipp
a3ca701556 nix: remove a hack needed for nextest
The relevant upstream issue has been fixed since version 0.9.72,
as noticed by Emily.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-30 14:48:39 -05:00
Austin Seipp
fe40c9e364 nix: use -ld_new on macOS devshell
The new parallel macOS linker reduces link time for the debug `jj` binary from
3s to 0.7s on my M2 Macbook Air, which is a significant reduction for nearly
no cost at all. This only assumes that you have a new enough Xcode environment
as your default (where `/usr/bin/ld` resides.)

This change requires Sonoma and Xcode 15, but in theory I think we could target
a lower macOS SDK version in order to produce binaries that are more backwards
compatible, so the only real cost is that developers who also use Nix would
require Sonoma.
2024-06-30 14:48:39 -05:00
Philip Metzger
3b2197c74a docs: Add a Design Doc blueprint.
This should be the template for all new Design Docs, minor deviations aside.
Hopefully this makes the process a bit easier.
2024-06-30 15:37:40 +02:00
Philip Metzger
c4777e4721 docs: Formalize our design docs process a bit.
This adds the basic outline of _when_ a Design Doc should be written. See the next
commit in the stack for the blueprint. 

By adding this we hopefully can prevent unnecessary churn from new and longtime contributors, 
when they want to add a major feature or rewrite a core part of Jujutsu. The text is written
as a guideline, not a rule.
2024-06-30 15:37:40 +02:00
Yuya Nishihara
3792f4a019 templater: use .map_or() to silence clippy without sacrificing readability 2024-06-30 10:25:18 +09:00
Yuya Nishihara
0ca8502c5a diff: inline hunk processing in get_diff_stat()
This is simpler and more efficient. If we add word-diff to unified_diff_hunks(),
it will do more expensive work that isn't needed here.
2024-06-30 10:17:41 +09:00
Ilya Grigoriev
1b658ea80e lib id_prefix: look for divergent changes outside short prefix set
Fixes #2476.

Previously, if there was a change id match within the short prefix
lookup set, `jj` would not look for commits with that same change id
outside the short prefix set. So, it wouldn't find the conflicted
commits for a commit with a divergent (AKA conflicted) change id.
2024-06-29 11:44:26 -07:00
Ilya Grigoriev
360a2b6a8b lib id_prefix: demo bug #2476 in a test 2024-06-29 11:44:26 -07:00
Ilya Grigoriev
6d3d7c61f2 nightly clippy fixes
Includes a false-positive, https://github.com/rust-lang/rust-clippy/issues/13018.
2024-06-29 11:22:01 -07:00
Ilya Grigoriev
c563ea8b29 clippy: remove warning when not using watchman feature
I keep seeing the one in lib/ when running tests in VS Code, but I also
fixed the warnings in watchman.rs for good measure.
2024-06-29 11:22:01 -07:00
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Ilya Grigoriev
e21e5e69d2 cli chore: standardize subcommand function and argument type names
Now, the command for `jj git remote add` is `cmd_git_remote_add` and its
argument type is `GitRemoteAddArgs`. This should make it easier to find
the CLI docs and the implementation for commands.

This is how `jj branch` commands were already set up in this way. The
`jj op` commands were also already set up in this way, except the
functions are called e.g. `cmd_op_undo`, I kept this for simplicity.

I was mainly motivated by the `jj file` commands. Most other commands
had functions already named in the above pattern, but used to have
shorter argument type names.
2024-06-28 13:38:04 -07:00
dependabot[bot]
1273c05889 github: bump github/codeql-action in the github-dependencies group
Bumps the github-dependencies group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.25.10 to 3.25.11
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](23acc5c183...b611370bb5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-28 19:40:01 +02:00
Martin von Zweigbergk
eba9ac0b1b cli: add a debug command for generic working copy info
We have two other kinds of working copies at Google and it's sometimes
useful to get the basic information about operation id and tree id for
them, for exampel for debugging stale workspaces. This patch adds a
command for that.

We could instead have made the old `jj debug working-copy` command
work for all kinds of working copies (like the new command) and only
have extra information for the standard local-disk implementation. I
don't feel strongly either way and could do it other other way instead
if people prefer that.
2024-06-28 21:31:44 +09:00
Martin von Zweigbergk
8f9f46f18f cli: rename jj debug working-copy to jj debug local-working-copy
I'd like to add a more generic `jj debug working-copy` command that
prints the information that's shared across implementations.
2024-06-28 21:31:44 +09:00
Yuya Nishihara
af986a58ed cli: branch: assume deleted tracking branch name is still allocated
While explaining branch tracking behavior, I find it's bad UX that a deleted
branch can be re-"create"d with tracking state preserved. It's rather a "set"
operation. Since deleted tracking branch is still listed, I think it's better
to assume that the local branch name is reserved.

https://github.com/martinvonz/jj/discussions/3871

Renaming to deleted tracking branch is still allowed (with warning) because the
"rename" command can't handle tracked remotes very well. If it were banned, bad
rename couldn't be reverted by using "jj branch rename". It would be confusing
if "rename a b" succeeded with warning, but the following "rename b a" failed.
2024-06-28 19:36:09 +09:00
Yuya Nishihara
06813d9462 cli: branch: slightly update warning message about rename with tracked remotes
We use "tracked remote branches" in the doc, and hints are usually capitalized.
2024-06-28 19:36:09 +09:00
Yuya Nishihara
ce2e016e57 cli: branch: extract helper that checks if tracked remote branch exists 2024-06-28 19:36:09 +09:00
Yuya Nishihara
76ff35eba4 cli: branch: inline view.remove_branch() in cmd_branch_forget()
This API no longer makes sense, and we'll probably add some flags to forget
only tracked remotes for example.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
e7ea0d579a cli: branch: let find_*_branches() return (name, target) pairs
This will help inline view.remove_branch() in cmd_branch_forget(). I don't
care much about owned (String, _) vs (&str, _), but we can't simplify the
lifetime issue in find_forgettable_branches() anyway. So I made all callers
pass cloned Arc<ReadonlyRepo> and borrow (name, target) pairs from there.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
19904e9e00 cli: branch: inline make_branch_term(), use singular form
It's used only in transaction descriptions, and I think singular form works
at adjective position.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
c240313c4b view: remove has_branch() which is called only from tests
Since we've split (local, remotes) branches to (locals, remotes { branches }),
.has_branch() API no longer makes much sense. Callers often need to check if
a remote branch is tracked.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
9613ec4f82 revset: drop Eq/PartialEq from RevsetExpression and related types
It was convenient that expression nodes can be compared in tests, but no
equivalence property is needed at runtime. Let's remove Eq/PartialEq to
simplify the extension support.
2024-06-28 10:28:51 +09:00
Yuya Nishihara
8417ea79c5 revset: rewrite RevsetExpression equivalence tests to not rely on Eq
Most of the tests are migrated to insta::assert_debug_snapshot!(). Some of them
could use assert_matches!(), but the resulting code would look ugly because of
nested RC<_>s.
2024-06-28 10:28:51 +09:00
Yuya Nishihara
5abc87fdb6 tests: add word-level hunks and capture some colorized diff outputs 2024-06-27 12:00:08 +09:00
Yuya Nishihara
9b6ee8c9c6 tests: filter snapshots of fileset/revset expressions to save vertical space
I think the collapsed output is easier to follow.
2024-06-27 09:33:48 +09:00
Ilya Grigoriev
e6c2108d4d cli: rename jj file print (formerly jj cat) to jj file show
We now have two `cmd_show` in the repo. I think this one should become
`cmd_file_show`, but this should be done uniformly over all the commands
for consistency.

I did *not* keep `print` as an alias (I couldn't find a compelling
reason to do it), but let me know if anyone feels like keeping it.
2024-06-26 17:11:16 -07:00
Martin von Zweigbergk
848bb610cc cli: underline added/removed lines only in color-words diffs
We don't want e.g. `jj diff --git` to have underlined text because
it's redundant there. This patch fixes that by adding a new `token`
label used only in the color-words diff (for now - it may be used in
git diffs in the future).

This means we could remove the `line_number` label but I left it
because there's little harm in having it and it seems like it can
still be useful.

Thanks to @yuja for noticing and suggesting the fix.
2024-06-27 06:47:18 +09:00
dependabot[bot]
35e0e4d133 cargo: bump either from 1.12.0 to 1.13.0 in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [either](https://github.com/rayon-rs/either).


Updates `either` from 1.12.0 to 1.13.0
- [Commits](https://github.com/rayon-rs/either/compare/1.12.0...1.13.0)

---
updated-dependencies:
- dependency-name: either
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-26 19:16:33 +02:00
Martin von Zweigbergk
8d67b1412e cleanup: leverage BoxStream/BoxFuture type aliases
Thanks to @fowles for bringing these to my attention.
2024-06-26 11:34:52 +09:00
Austin Seipp
e2138ca2df nix: include watchman in dev shell
This is useful for testing locally even if you don't have `watchman` elsewhere
on your machine.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-25 17:18:09 -05:00
Austin Seipp
b0040830b1 nix: remove spurious rust-analyzer input
This is already included with the `ourRustVersion` expression since it includes
a complete Rust toolchain with all extensions.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-25 17:18:09 -05:00
Austin Seipp
f815afd6ab nix: remove spurious flake 'follow' directive
Apparently this isn't needed anymore.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-25 17:18:09 -05:00
Austin Seipp
829ba73664 nix: run nix flake update 2024-06-25 17:18:09 -05:00
Jonathan Tan
9e18a61550 diff: underline added/removed parts by default
This helps better visualize changes that contain leading and/or trailing
whitespace.
2024-06-25 13:08:47 -07:00
dependabot[bot]
310c9d53ae cargo: bump serde_json in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [serde_json](https://github.com/serde-rs/json).


Updates `serde_json` from 1.0.117 to 1.0.118
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.117...v1.0.118)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-25 13:58:50 -05:00
Ilya Grigoriev
40bb207747 docs: replace jj chmod -> jj file chmod
`jj chmod` is now deprecated
2024-06-24 21:01:55 -07:00
Ilya Grigoriev
46b37aca2f docs: replace jj files -> jj file list
`jj files` is now deprecated
2024-06-24 21:01:55 -07:00
Martin von Zweigbergk
5ba6078354 cli: add label for line numbers in --color-words diff
If you want to set a background color on added/removed lines, you
currently get the same style on the line numbers. This patch lets you
specify a different style by overriding it on the line numbers.
2024-06-25 11:57:31 +09:00
Yuya Nishihara
60b35f676e dag_walk: do one less clone() in heads_ok() 2024-06-25 11:54:03 +09:00