Commit graph

5281 commits

Author SHA1 Message Date
Yuya Nishihara
b7eb551cf7 index: fix reindexing to scan all referenced commits such as hidden remote refs
Since hidden commits can be looked up by remote_branches() revset for example,
reindexing should traverse ancestors from all named refs in addition to the
visible heads.
2024-01-12 12:53:16 +09:00
Yuya Nishihara
faa9b8d77f cli: run "op abandon" without loading repo, reject --at-op
If indexing failed due to missing commit objects, the repo won't be loadable
without --ignore-working-copy (at least in colocated environment.) In that
case, we can use "op abandon" to recover, but we had to work around the failed
index loading by --ignore-working-copy. Since "op abandon" isn't a repo-level
command, it's better to bypass working-copy snapshot and import of git refs at
all.

--at-op is rejected because it's useless and we'll need extra care for "@"
expression resolution and working-copy updates.
2024-01-12 08:01:13 +09:00
Yuya Nishihara
f70107dad9 tests: ensure that operation id is updated by "op abandon" command
Before, the test passed even if "op abandon" didn't remap the working-copy
operation id.
2024-01-12 08:01:13 +09:00
Yuya Nishihara
805046ceba op_walk: extract function that resolves op expression with preloaded head op
I'm going to make "op abandon" not load the repo, and this function will
be used there instead of resolve_op_with_repo().
2024-01-12 08:01:13 +09:00
Yuya Nishihara
83ede241e3 op_walk: don't resolve heads beyond @ operation
Since `jj undo --at-op=OP @` resolves @ to OP, I think OP should be the head
in that context, and the descendants of OP shouldn't be accessible by @+.
2024-01-12 08:01:13 +09:00
Yuya Nishihara
ba42b37a67 operation: remove operation::View wrapper in favor of view::View
view::View doesn't track ViewId, but there are no callers of cheap Eq/Hash
functions.
2024-01-12 08:01:02 +09:00
dependabot[bot]
04c43a19c6 build(deps-dev): bump jinja2 from 3.1.2 to 3.1.3
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-11 21:28:38 +00:00
Valentin Gatien-Baron
f0dd311354 docs: add git comparison for jj workspace root
To make the jj command more discoverable.
2024-01-11 07:45:13 -05:00
Yuya Nishihara
4fed19361a cli: include branches and tags in default "show" template
The formatting is closer to hg than git just because it's easier to
conditionalize the whole line per keyword. Our template language doesn't
have infix logical operators.

Unlike the other default templates, all remote branches are displayed because
it's "detailed" output.

Closes #2509
2024-01-11 15:47:09 +09:00
Yuya Nishihara
bde9cda915 cli: colorize local/remote_branches keywords
This is a follow up for 0e14a1f04d "templater: add local/remote_branches
keywords."
2024-01-11 15:47:09 +09:00
Yuya Nishihara
3357882496 cli: group diff formatting options in help
Since DiffFormatArgs is flattened into log args, it's a bit hard to reason about
what --color-words means for example.
2024-01-11 15:46:58 +09:00
Yuya Nishihara
9b5439256f cli: leverage next_help_heading attribute to deduplicate "Global Options"
It's scoped to the GlobalArgs and the flattened EarlyArgs.
https://docs.rs/clap/latest/clap/_derive/index.html#command-attributes
2024-01-11 15:46:58 +09:00
Yuya Nishihara
5047e114ea cli: run "debug index" without loading repo
This is the command to dump the current state. I don't think we'll want to
merge the concurrent operations.
2024-01-11 09:15:19 +09:00
Yuya Nishihara
180ea49fda cli: run "debug reindex" without loading repo
If the existing index was corrupt, it would have to be rebuilt while loading a
repo (at least in colocated environment.) Then, the index will be rebuilt again.
2024-01-11 09:15:19 +09:00
Valentin Gatien-Baron
6caeacf29e cli: fix missing word in help of --ignore-working-copy 2024-01-10 12:30:23 -08:00
Yuya Nishihara
d5a98df046 git_backend: teach "format.tree-level-conflicts" config by constructor
Since GitBackend constructors now depend on &UserSettings, it makes sense to
initialize the formatting options there.
2024-01-10 08:57:51 +09:00
dependabot[bot]
1c82ccf689 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.4.13 to 4.4.14
- [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/v4.4.13...v4.4.14)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-09 10:19:42 -08:00
Yuya Nishihara
e5286aed08 index: move lifetimed change_id_index() to MutableIndex, rename 'static version
change_id_index() is only used by Readonly/MutableRepo, so we don't need an
abstraction at Index. evaluate_revset() is somewhat similar, but the callers
rely on &dyn Repo.
2024-01-09 10:38:00 +09:00
Yuya Nishihara
dc68f1eeb2 revset: remove unused lifetime parameter from Revset<'index> 2024-01-09 10:37:43 +09:00
Yuya Nishihara
e9d31177cb op_store: implement GC of unreachble operations and views
Since new operations and views may be added concurrently by another process,
there's a risk of data corruption. The keep_newer parameter is a mitigation
for this problem. It's set to preserve files modified within the last 2 weeks,
which is the default of "git gc". Still, a concurrent process may replace an
existing view which is about to be deleted by the gc process, and the view
file would be lost.

#12
2024-01-09 10:37:03 +09:00
Yuya Nishihara
7cfd32bac1 cli: disallow gc run from non-head operation
It doesn't make sense to do gc from a non-head operation because that means
either the head operation would be corrupted or the --at-op argument is
ignored.
2024-01-09 10:37:03 +09:00
Yuya Nishihara
5894f3dfba operation: add shorthand for &store_operation().view_id 2024-01-09 10:37:03 +09:00
dependabot[bot]
535c56354b cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [libc](https://github.com/rust-lang/libc) and [serde](https://github.com/serde-rs/serde).


Updates `libc` from 0.2.151 to 0.2.152
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.151...0.2.152)

Updates `serde` from 1.0.194 to 1.0.195
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.194...v1.0.195)

---
updated-dependencies:
- dependency-name: libc
  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
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-08 16:07:05 +00:00
vwkd
e41ef56e83 docs: update CLI output in Tutorial 2024-01-08 19:59:59 +04:00
Martin von Zweigbergk
c98b0d76af index: move Revset::change_id_index() to Index
We current have `Revset::change_id_index()` for creating a
`ChangeIdIndex` for a given revset. I think it will be hard to make it
performant for general revsets, especially in very large repos and
with custom index implementations, like the one we have at Google. If
we instead restrict it to including all ancestors of a set of heads, I
think it will be much easier to implement. We only use
`Revset::change_id_index()` with revsets including all visible commits
today, so we won't lose any current functionality by making it more
restricted.
2024-01-08 06:06:47 -08:00
Martin von Zweigbergk
2f4594540a tests: move ChangeIdIndex test from test_revset to test_index 2024-01-08 06:06:47 -08:00
Martin von Zweigbergk
1508f28567 tests: update ChangeIdIndex test to include ancestors in set
I plan to replace `Revset::change_id_index()` by
`Index::change_id_index(heads)`, but one of the tests currently uses a
set of commits that does not include ancestors. This patch updates it
to include ancestors (and changes the set of heads to keep the set
small enough for the test).
2024-01-08 06:06:47 -08:00
Martin von Zweigbergk
f9dc00704d index: specialize evaluate_revset_static() to change_id_index_static()
I'd like to move `change_id_index()` from `Revset` to `Index` (and
make it take the set of visible heads as argument). We currently use
`evaluate_revset_static()` only to get a `ChangeIdIndex`, so a good
place to start is to convert that into `change_id_index_static()`.
2024-01-08 06:06:47 -08:00
Martin von Zweigbergk
b549090acc index: adopt ChangeIdIndex and relatives from revset module
The `ChangeIdIndex` type is currently in defined in the `revset`
module because that's the only placed it's used. However, I'd like to
start using it directly from `index`. The idea is to make it possible
to create a `ChangeIdIndex` given a set of heads, without first
creating a `Revset`.
2024-01-08 06:06:47 -08:00
Philip Metzger
e79fd2e81c docs: Make the website's theme adjustable.
The website will also adjust to the system default theme now. 
I mostly did this because I am a darkkmode user and we didn't provide it yet.
2024-01-07 22:07:24 +01:00
Ilya Grigoriev
54a967a1b3 docs: update mkdocs-material to 9.5
This will allow for better toggles in
https://github.com/martinvonz/jj/pull/2783
2024-01-07 12:45:45 -08:00
Essien Ita Essien
08d1809dc1 Issue warning if renaming branch with a remote tracking branch. 2024-01-07 18:04:38 +00:00
Essien Ita Essien
5ad7b2bc08 Also ignore *.snap* files created by insta crate. 2024-01-07 17:48:42 +00:00
Ilya Grigoriev
0a005a6c6e GitHub workflow: document how one can install old Poetry locally
This is quite minor, but it took me a few minutes to figure out
the correct command.

It might be slightly better to print this text inside the build
logs, where people will be looking for certain if the CI fails,
but I didn't immediately find a good way to do so without
complicating the config too much.
2024-01-07 05:53:28 -08:00
Martin von Zweigbergk
f0182ad4b8 default_index: adopt revset engine and graph iterator modules
The revset engine and the graph iterator are specific to the default
index implementation, so they belong in the same module.
2024-01-07 05:37:47 -08:00
Martin von Zweigbergk
0046af8d4c cli: allow non-static version strings from custom binaries
We would like to use a non-static version string at Google. We have a
workaround using Lazy, but it seems unfortunate to have to do
that. Using dynamic strings requires Clap's `string` feature, which
increases the binary size by 140 kiB (0.6%).
2024-01-06 16:24:55 -08:00
Ilya Grigoriev
e354816236 Cargo.toml: update documentation site
I considered also updating the "homepage", but I think it's nice that
it points to the README.

This complements @PhilipMetzger's suggestion from
https://discord.com/channels/968932220549103686/1167230861448581167/1192559848777334834
2024-01-06 10:17:37 -08:00
dependabot[bot]
546fe73304 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.4.12 to 4.4.13
- [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/v4.4.12...v4.4.13)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-05 15:38:16 +00:00
Yuya Nishihara
a6616e9cea object_id: don't allow ObjectId::from_hex() a dynamically allocated string
This isn't technically needed, but it prevents API misuse. Another option
is to do some compile-time substitution, but most callers are tests and the
runtime performance wouldn't matter.
2024-01-06 00:26:36 +09:00
Yuya Nishihara
837ac15052 op_store: add resolve_operation_id_prefix() trait method that uses readdir()
The OpStore backends should have a better way to look up operation by id than
traversing from the op heads. The added method is similar to the commit Index
one, but returns an OpStoreResult because the backend operation can fail.

FWIW, if we want .shortest() in the op log template, we'll probably need a
trait method that returns an OpIndex instead.
2024-01-05 23:36:57 +09:00
Yuya Nishihara
95ea352b0a object_id: add fallible version of ObjectId::from_hex() 2024-01-05 23:36:57 +09:00
Yuya Nishihara
95d83cbfe5 object_id: make ObjectId constructors non-trait methods
I'm going to add try_from_hex(), which requires Self: Sized. Such trait bound
could be added, but I don't think we'll need abstracted ObjectId constructors
at all.
2024-01-05 23:36:57 +09:00
Yuya Nishihara
31b236a70d object_id: move HexPrefix and PrefixResolution from index module 2024-01-05 10:20:57 +09:00
Yuya Nishihara
fa5e40719c object_id: extract ObjectId trait and macros to separate module
I'm going to add a prefix resolution method to OpStore, but OpStore is
unrelated to the index. I think ObjectId, HexPrefix, and PrefixResolution can
be extracted to this module.
2024-01-05 10:20:57 +09:00
Yuya Nishihara
dbaee198e6 hex_util: move common_hex_len() from backend module
This function predates the hex_util module. If there were hex_util, I would
add it there.
2024-01-05 10:20:57 +09:00
dependabot[bot]
329e128099 cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [pest](https://github.com/pest-parser/pest), [pest_derive](https://github.com/pest-parser/pest) and [serde_json](https://github.com/serde-rs/json).


Updates `pest` from 2.7.5 to 2.7.6
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.5...v2.7.6)

Updates `pest_derive` from 2.7.5 to 2.7.6
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.5...v2.7.6)

Updates `serde_json` from 1.0.110 to 1.0.111
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.110...v1.0.111)

---
updated-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
- 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-01-04 07:18:46 -08:00
Yuya Nishihara
f169c99fb4 cli: add "op abandon root..head" command that "reparents" operations
In order to implement GC (#12), we'll need to somehow prune old operations.
Perhaps the easiest implementation is to just remove unwanted operation files
and put tombstone file instead (like git shallow.) However, the removed
operations might be referenced by another jj process running in parallel. Since
the parallel operation thinks all the historical head commits are reachable, the
removed operations would have to be resurrected (or fix up index data, etc.)
when the op heads get merged.

The idea behind this patch is to split the "op log" GC into two steps:
 1. recreate operations to be retained and make the old history unreachable,
 2. delete unreachable operations if the head was created e.g. 3 days ago.
The latter will be run by "jj util gc". I don't think GC can be implemented
100% safe against lock-less append-only storage, and we'll probably need some
timestamp-based mechanism to not remove objects that might be referenced by
uncommitted operation.

FWIW, another nice thing about this implementation is that the index is
automatically invalidated as the op id changes. The bad thing is that the
"undo" description would contain an old op id. It seems the performance is
pretty okay.
2024-01-04 11:44:36 +09:00
Yuya Nishihara
e5255135bb op_walk: add function that reparents (and abandons) operation range
This will be used in "jj op abandon ..op_id" command. The "op_id..@" range will
be reparented onto the root operation.

The current implementation is good enough for local repos, but it won't scale.
We might want to extract it as a trait method or introduce OpIndex for
efficient DAG operation.
2024-01-04 11:44:36 +09:00
Yuya Nishihara
392e83be42 op_heads: ensure that update_op_heads([id], id) fails
The doc states it's invalid, but I made such bug.
2024-01-04 11:44:36 +09:00
Matt Stark
3f0a49dafe Ensure you never drop the working commit with --skip-empty
See #2766 for discussions
2024-01-04 13:33:24 +11:00