Commit graph

3677 commits

Author SHA1 Message Date
Yuya Nishihara
d29b10a8dd simple_op_store: rewrite RefTarget deserialization to work with Option<_>
.unwrap() calls will be removed if we migrate RefTarget to new Conflict-based
type. Some of them were previously .unwrap_or_default(), but they would panic
anyway inside ref_target_from_proto().
2023-07-17 01:13:21 +09:00
Yuya Nishihara
75429293f2 simple_op_store: rewrite RefTarget serialization to work with Option<_>
is_none()/is_some() are wrapped as is_absent()/is_present() respectively.
If we see new RefTarget as a Conflict, an "absent" target isn't an emptyish
value like None, but an add of single [None]. It seemed a bit weird to call
such target is_none().
2023-07-17 01:13:21 +09:00
Yuya Nishihara
5d87f372d8 refs: rewrite classify_branch_push_action() without using pattern matching
RefTarget type will be a wrapper around Conflict<Option<CommitId>>, and the
match arms would be more verbose. Fortunately, new code looks simpler since
we can merge non-conflicting cases.
2023-07-17 01:13:21 +09:00
Yuya Nishihara
a1e92563ae refs: add constructor of Some(RefTarget::Conflict { .. })
It's named after Conflict::from_legacy_form(). If RefTarget is migrated to
new Conflict type, from_legacy_form([], [add]) will create a normal target,
and from_legacy_form([], []) will be equivalent to the current None target.
That's why this function isn't named as RefTarget::conflict().
2023-07-17 01:13:21 +09:00
Yuya Nishihara
e55c533add refs: add constructor of Some(RefTarget::Normal(id))
If RefTarget is migrated to new Conflict type, this function will create
RefTarget(Conflict::resolved(Some(id))).

We still need some .unwrap() to insert Option<RefTarget> into map, but maps
will be changed to store new RefTarget type, and their mutation API will
guarantee that Conflict::resolved(None) is eliminated.
2023-07-17 01:13:21 +09:00
Austin Seipp
e212e10dee feat(nix): use mold by default for linking inside 'nix develop'
Summary: Pure QOL improvement, not that this was too awful as it stood. But this
ultimately makes all builds faster, effectively for free; on my Linux machine,
debug link time for jj-cli goes from 3s to 1s.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I5a0d516363635710733e8bee8f208050
2023-07-14 20:29:16 -05:00
Austin Seipp
154ab9e283 chore(nix): run 'nix flake update'
Summary: This is needed to pick up a bugfix to the 'mold' package in nixpkgs,
used in a follow up diff.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I1128164faed93921f84c35189a012152
2023-07-14 20:29:16 -05:00
Yuya Nishihara
5ed070a78a view: use get_git_ref(name) where extra .clone() wouldn't matter
Perhaps, all view.get_<kind>(name) functions can return reference, but I'm
not willing to change the interface at this point. I'll revisit this after
migrating Option<RefTarget> to new Conflict-based type.
2023-07-15 05:57:49 +09:00
Yuya Nishihara
005f3b90ee view: make set_or_remove_ref() simply delegate to setters, rename accordingly 2023-07-15 05:57:49 +09:00
Yuya Nishihara
d80a719042 view: unify set/remove_local_branch() functions to take Option<RefTarget> 2023-07-15 05:57:49 +09:00
Yuya Nishihara
78eea06c36 view: unify set/remove_remote_branch() functions to take Option<RefTarget> 2023-07-15 05:57:49 +09:00
Yuya Nishihara
fc609a6d8d view: unify set/remove_tag() functions to take Option<RefTarget> 2023-07-15 05:57:49 +09:00
Yuya Nishihara
3be462266c view: unify set/remove_git_ref() functions to take Option<RefTarget>
New function takes name by reference since it doesn't always need an owned
String.
2023-07-15 05:57:49 +09:00
Yuya Nishihara
5218591a82 view: unify set/clear_git_head() functions to take Option<RefTarget>
If we migrate RefTarget to new Conflict-based type, it won't store
Conflict<CommitId>, but Conflict<Option<CommitId>>. As the Option will
be internalized, new RefTarget type will also represent an absent target.
The 'target: Option<RefTarget>' argument will be replaced with new RefTarget
type.

I've also renamed the function for consistency with the following changes.
It would be surprising if set_local_branch(name, target) could remove the
branch. I feel the name set_local_branch_target() is less confusing.
2023-07-15 05:57:49 +09:00
Waleed Khan
6d7998f8c5 working_copy: return Result from WorkingCopy::tree_state/WorkingCopy::tree_state_mut 2023-07-14 13:45:40 -07:00
Waleed Khan
60f1d7e307 working_copy: create and propagate TreeStateError 2023-07-14 13:03:57 -07:00
dependabot[bot]
1e58c3e397 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [toml_edit](https://github.com/toml-rs/toml).

- [Commits](https://github.com/toml-rs/toml/compare/v0.19.12...v0.19.13)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-15 01:52:50 +09:00
Martin von Zweigbergk
152a0683e2 github: enable the watchman feature in pre-built binaries 2023-07-12 17:51:38 +01:00
dependabot[bot]
ddd6c3b27b cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [serde_json](https://github.com/serde-rs/json).

- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.100...v1.0.102)

---
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>
2023-07-12 16:25:25 +00:00
Austin Seipp
c780e6bc1f chore(github): migrate nix workflow to use nix-installer & magic-nix-cache
Summary: The Determinate Systems Nix installer is fast and importantly includes
Flake support by default on new installs.

Magic Nix Cache will help ease the build time a little by making sure things
like downloads from crates.io remain cached between builds; in the future if we
ever need to add any custom builds to the Nix expression it will come really in
handy. But in my experience I don't think it should slow down much, and might
speed some things up a whole lot.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I56e1592cbaa6c7a43b5bd57972b98ada
2023-07-12 17:07:38 +01:00
Austin Seipp
3e23155b10 fix(github): run 'nix build' as part of CI, too
Summary: While I was developing #1846, I found a case where `nix flake check`
succeeded but `nix build` on the jujutsu expression failed, which was confusing
to me. If it had been merged, it would have broke the ability to use Nix to
install things.

Let's try to attack this, and punch a parallel job into the build matrix;
hopefully running the two jobs concurrently can help catch this without
making build time much worse.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: If2520d69492fa6abe499c1cb1d51d6e1
2023-07-12 17:07:38 +01:00
Yuya Nishihara
ab2fa35a71 refs: stick to Option<CommitId> type while merging ref targets
This might look more complicated than the original code, but it clarifies
that we always eliminate a (remove, add) pair. The behavior slightly changed
since an absent ref (i.e. None) in "removes" can now be paired with an "add"
even if "removes" contained other ids. Before, it was possible only when
removes.is_empty().
2023-07-12 21:29:41 +09:00
Yuya Nishihara
424786def1 refs: leverage Conflict::flatten() and simplify() to premerge ref targets
The order of conflicted ids slightly changed since Conflict::simplify()
tries to preserve diff pairs. It shouldn't matter so long as the result is
stable.
2023-07-12 21:29:41 +09:00
Yuya Nishihara
ddaf226108 tests: make RefTarget::Conflict { .. } assertion not rely on id order
Here we don't need to care about the order at all. We have test_refs.rs
to ensure that the order is stable.
2023-07-12 21:29:41 +09:00
Yuya Nishihara
9f06bf8be5 repo: do not discard old working-copy commit if it's pointed by local branch
It would be confusing if a branch moved backwards by checking out unrelated
commit.

#1854
2023-07-12 21:29:11 +09:00
Austin Seipp
0184413a86 chore(nix): nix flake update
Summary: I need this for another change I'm playing around with, because the
newer nixpkgs snapshot has a newer version of a tool. Just do a quick update to
get it out of the way.

Maybe one day, Dependabot can help solve this issue...

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I803f72da8666ed75018f51ebe511737d
2023-07-12 06:48:17 -05:00
dependabot[bot]
78e9a1b34d cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [rustix](https://github.com/bytecodealliance/rustix).

- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.3...v0.38.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-11 19:24:06 +02:00
Ilya Grigoriev
df6d953116 cli: render HEAD@git in green instead of bright green
To me, green looks less distracting. Also, we mostly use bright colors for
the working copy commit.

This follows up on #1844.
2023-07-11 08:04:46 -05:00
Yuya Nishihara
2bed9c9112 rewrite: do not insert "removed" refs to reverse branch lookup table
It should no longer be needed since e3254fa5c4 "rewrite: don't rewrite
the "removed" side of a branch conflict."
2023-07-11 19:42:40 +09:00
Yuya Nishihara
f5f61f6bfe revset: resolve "HEAD@git" just like other pseudo @git branches
I don't think this would be practically useful, but consistent UX is
important.

Fixes #1843
2023-07-11 16:29:27 +09:00
Yuya Nishihara
79955d9cb3 git: do not import/export local branch named "HEAD"
Git CLI rejects it (though the data model would probably work fine with
"HEAD" branch.) This ensures that HEAD@git in JJ world is not an exported
branch named "HEAD".
2023-07-11 16:29:27 +09:00
Yuya Nishihara
c1b87d4721 git: add logic to prevent invalid branch name from being exported
I also made remote HEAD branch banned to keep it sync with parse_git_ref().
2023-07-11 16:29:27 +09:00
mlcui
2c7de2045c git-comparison: update git's "remove file" command 2023-07-11 15:42:45 +10:00
mlcui
2756f2f3da git-comparison: add more diff commands
`jj diff` works a bit differently to `git diff`, so add more examples of
`jj diff` using `--from`.
2023-07-11 15:42:19 +10:00
Austin Seipp
5c82100ef0 fix(config): by default, render git refs as green instead of magenta
Summary: Someone on Discord mentioned that while using branches, they could
switch between branches like `m1` and `main`, but not `HEAD@git`, even though it
was color coded the same and located right next to the other branch names in the
default `jj log` output.

This confused me too at first, until I realized `jj` was telling me that the
given commit was the `HEAD` reference in the colocated git repo. Let's just
color these references differently in the default schema, to try and hint that
these aren't the same. `bright green` is arbitrary, but helps stand out; and
`green` was only picked because both it and `git` start with "g".

GitHub Issue: #1843

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I66d53ea2b9155db1fec6cae8ba8cbd0f
2023-07-10 22:33:02 -05:00
Austin Seipp
7acdc8f011 feat(cargo): improve --release binary size
Summary: On x86_64-linux, these options reduce the total number of bytes in the
`jj` binary by 40 percent, from 16MiB to 9.8MiB, while having relatively minimal
impact on build time, going from 58s to 1m15s.

While `strip=debuginfo` is already the default, `codegen-units=1` is doing
all the work here, and seems to have a rather miraculous effect despite not
meaningfully hurting compile time too much for me at least. This actually
will probably improve performance in some cases too, but it's likely hard to
quantify.

Ultimately, with or without this change, the dominant entity taking up most
of the compile time for the whole project is `jj-lib` and `jj-cli` crates. A
`--timings` report with Cargo indicates almost all dependencies (on my machine)
compile within 30s whether or not this change is in play, so the remaining time
is all on us.

Various other changes, such as using `opt-level=z` or `lto=thin`, had no real
visible effect. `lto=fat` was pretty successful, reducing total bytes by over
50% (7.8MiB), but at a nearly 2x link-time cost.

It *might* be worth exploring if something like `lto=thin` could improve
performance since it didn't meaningfully impact compile time or size any
further, but that's TBD.

Note: these numbers were performed with a wiped `target/` directory after each
run, and so all dependencies were compiled from scratch, on my 12-core Ryzen
5600X.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ioyoulrmtwxypsrwwwysyylvmqxzttkmn
2023-07-10 19:05:38 -05:00
Austin Seipp
cd4637e51c feat(nix): enable watchman support in nix package
Summary: Nix packages tend to come "full extra pack of batteries"-included, so
adding watchman support makes sense. I'll also want it for my own experiments.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ia99757bf7a39814529525efe423d527b
2023-07-10 16:05:53 -05:00
Waleed Khan
6f15a27079 perf: add chrome tracing layer
This generates profiles in the Google Chrome JSON tracing format. They can be opened in Chrome's `chrome://tracing` page or in tools like https://ui.perfetto.dev. Enable by running e.g. `JJ_TRACE=1 cargo run -- status`.
2023-07-10 23:23:53 +03:00
dependabot[bot]
e618b2c14f cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [regex](https://github.com/rust-lang/regex), [serde](https://github.com/serde-rs/serde) and [tokio](https://github.com/tokio-rs/tokio).


Updates `regex` from 1.9.0 to 1.9.1
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.0...1.9.1)

Updates `serde` from 1.0.167 to 1.0.168
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.167...v1.0.168)

Updates `tokio` from 1.28.2 to 1.29.1
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.28.2...tokio-1.29.1)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-10 17:19:33 +01:00
Waleed Khan
e445d36824 fix(docs): fix protobuf job build 2023-07-10 18:56:34 +03:00
Waleed Khan
54dba51a08 docs: warn about missing docs for jj-lib crate 2023-07-10 18:28:59 +03:00
Waleed Khan
24c7b59a80 docs: add docstring for jj-lib crate 2023-07-10 18:28:59 +03:00
Waleed Khan
80b86e653d docs: add missing copyright header 2023-07-10 18:28:59 +03:00
Austin Seipp
f1e09e3f3f chore(github): reduce compile time in build, nix, and release workflows
Summary: When building in CI, we just build everything from scratch in the `dev`
profile, so just turn off debuginfo and incremental compilation data. These
aren't reused, but more importantly take up more space and CPU time to generate;
that's more expensive on slower machines and when using The Cloud(TM) to build.

Together, these take a fresh build (`rm -rf target/` ahead of time) from about
40s to 30s on my machine.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Id6e706634dbaf88f6ccd7f457409ad7c
2023-07-10 06:18:38 -05:00
Ilya Grigoriev
d81c599153 clippy: fix nightly clippy warnings *except* for needless_raw_string_hashes
This is (almost) a result of running

    cargo +nightly clippy --workspace --all-targets --fix \
      --  -A 'clippy::needless_raw_string_hashes'

with yesterday's nightly clippy.

https://github.com/mitsuhiko/insta/issues/389 causes numerous additional
`needless_raw_string_hashes` warnings, but it will hopefully be fixed soon.
For now, I recommend appending the second line to your invocations.
2023-07-09 22:28:22 -07:00
Yuya Nishihara
9aa308fb4a revset: include pseudo @git remote in suggestion
Since collect_branch_symbols() doesn't have to be fast, I made it simply
build a new branches map.
2023-07-10 06:17:44 +09:00
Yuya Nishihara
528f6e23c1 refs: simplify inner loop of find_pair_to_remove() too 2023-07-10 06:14:47 +09:00
Yuya Nishihara
fe3be99f0d refs: directly assign ancestor (index, id) pair in find_pair_to_remove() 2023-07-10 06:14:47 +09:00
Yuya Nishihara
9140e5b686 conflicts: relax from_legacy_form() to accept any iterable
This will help to rewrite refs::merge_ref_targets() to leverage Conflict
type. I'm not pretty sure if we'll want to do that, but this change seems
also good for the existing code.
2023-07-10 06:14:47 +09:00
Yuya Nishihara
afb1e1693e conflicts: simplify inner loop of simplify() a bit 2023-07-10 06:14:47 +09:00