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

155 commits

Author SHA1 Message Date
Martin von Zweigbergk
ed0b23d009 cli: include commit id from build in version
This changes the version number reported by `jj version` from "0.7.0"
to something like
"0.7.0-24a512683bc921699575b6a953624b05c068d544a". The hash is added
if running in a jj repo or a git repo.
2023-04-07 17:33:44 -07:00
Ilya Grigoriev
233dda1057 cmd: prohibit creating branches at the root commit
Such branches lead to confusing errors on git expoert or push.
2023-04-03 23:51:47 -07:00
Ilya Grigoriev
31f7c806e2 squash/amend: Add -m argument to set description
This prevents an editor opening, and is useful in scripts/tests.
2023-04-03 23:51:15 -07:00
Yuya Nishihara
6c5947181d cli: reimplement "debug resolverev" as command to debug print revset
Also removed -r/--revision and the default "@" as it is a debug command.
2023-04-02 22:54:46 +09:00
Yuya Nishihara
5a771c913b cli: unify "bench revset"/"revsets" commands 2023-04-01 22:52:11 +09:00
Yuya Nishihara
6c6fdae88d cli: allow to run "jj bench revset" for more than one revsets 2023-04-01 11:13:05 +09:00
Yuya Nishihara
a27fb79e96 cli: fix completion of "jj bench revsets FILE" argument 2023-04-01 11:13:05 +09:00
Yuya Nishihara
4ff5c52edc cli: expose some criterion options as bench command args
I want to adjust --sample-size while running slow revset benchmarks. The
baseline option seems also useful.

Short options are derived from Criterion::configure_from_args().
2023-04-01 11:13:05 +09:00
Yuya Nishihara
8a796cd98c cli: copy color output option to Criterion 2023-04-01 11:13:05 +09:00
Yuya Nishihara
9f1dc8f67c cli: remove excessive newline from "jj bench revset(s)" output 2023-04-01 11:13:05 +09:00
Yuya Nishihara
a03e9c41a3 cli: run revset bench with fresh (but index-preloaded) repo instance
Some benchmark numbers in the following order:
- original
- fresh repo, BatchSize::SmallInput
- fresh but index-preloaded repo, BatchSize::SmallInput
- fresh but index-preloaded repo, BatchSize::LargeInput

    % cargo run --release --features bench -- bench revset ':main'
    revsets/:main           time:   [271.49 µs 271.74 µs 272.07 µs]
    revsets/:main           time:   [754.17 µs 758.22 µs 764.02 µs]
    revsets/:main           time:   [367.11 µs 372.65 µs 381.99 µs]
    revsets/:main           time:   [341.76 µs 342.98 µs 344.35 µs]

    % cargo run --release --features bench -- bench revset 'author(martinvonz)'
    revsets/author(martinvonz)
                            time:   [767.43 µs 770.52 µs 775.59 µs]
    revsets/author(martinvonz)
                            time:   [31.960 ms 31.984 ms 32.011 ms]
    revsets/author(martinvonz)
                            time:   [31.478 ms 31.538 ms 31.615 ms]
    revsets/author(martinvonz)
                            time:   [31.503 ms 31.526 ms 31.550 ms]

I think the fresh but index-preloaded repo is close to the practical
evaluation environment. With BatchSize::SmallInput, it appears to consume
~600MB (RES) memory (compared to ~50MB in LargeInput.) I don't think that's
huge, but it might affect cache usage, so I chose LargeInput.

https://docs.rs/criterion/latest/criterion/enum.BatchSize.html
2023-03-30 19:13:11 +09:00
Yuya Nishihara
db516081de cli: leverage bench_with_input() to make revset expression opaque to optimizer
I don't think this would matter since the revset evaluation is behind virtual
dispatch, but let's follow the general guideline.

https://bheisler.github.io/criterion.rs/book/user_guide/benchmarking_with_inputs.html#benchmarking-with-one-input
2023-03-30 19:13:11 +09:00
Yuya Nishihara
ce1f9ab9e5 cli: extract helper for revset benchmark
The benchmark ids slightly changed, but I think it's better to share the
target/criterion/revsets directory.
2023-03-30 19:13:11 +09:00
Martin von Zweigbergk
f7dbade07a cli: add a command for benchmarking many revsets
This command is similar to Mercurial's revset benchmarking command. It
lets you pass in a file containing revsets. I also included a file
with some revsets to test on the git.git repo. I put it in `testing/`,
which doesn't seem perfect. I'm happy to hear suggestions for better
places, or we can move it later if we find a better place.

Note that these tests don't clear caches between each run (or even
between tests), so revsets that rely on filtering commit data that's
not indexed appear faster than they typically are in reality.
2023-03-28 10:21:10 -07:00
Martin von Zweigbergk
7249be33b0 cli: replace jj bench walkrevs by generic jj bench revset
I suspect the `jj bench walkrevs` command was from before we had
support for revsets. Now there doesn't seem to be any reason to have a
specific command for only range revsets (`foo..bar`), so let's replace
it by a command for benchmarking an arbitrary revset.
2023-03-28 10:21:10 -07:00
Martin von Zweigbergk
327deeb0c4 cli: move jj bench commands to new module, hide behind feature flag
The `jj bench` commands are mostly meant for developers, so lets hide
the command from help and behind a `bench` feature flag. The feature
flags avoids bloating the binary with the `criterion` dependencies,
which was the reason I removed the command in 18c0b97d9d.
2023-03-28 10:21:10 -07:00
Martin von Zweigbergk
48fbf7e1bd cli: revive jj bench command
This just backs out commit 18c0b97d9d without making any changes,
except for resolving conflicts.

I want a way to benchmark different revsets on e.g. the Git Core repo
or the Linux repo.
2023-03-28 10:21:10 -07:00
Martin von Zweigbergk
bac2de6ac6 cli: add hint about testing with ssh -F /dev/null on SSH errors 2023-03-24 22:16:50 -07:00
Martin von Zweigbergk
a5b79f9b0e index: make topo_order() return commit ids instead of index entries
`IndexEntry` is specific to the default index store; we don't want it
in the interface.
2023-03-24 10:09:40 -07:00
Martin von Zweigbergk
75605e36af revset: iterate over commit ids instead of index entries
There are no remaining places where we iterate over a revset and need
the `IndexEntry`s, so we can now make `Revset::iter()` yield
`CommitId`s instead.
2023-03-23 21:58:15 -07:00
Martin von Zweigbergk
9ed537b3e8 cli: leverage RevsetIteratorExt::commits() in jj log
I'm trying to remove uses of `IndexEntry`.
2023-03-23 04:50:33 -07:00
Yuya Nishihara
2a87e1f95a cli: call RevsetExpression::evaluate() directly if no symbol resolution needed
There should be no problem to evaluate revset against base_repo and collect
commit objects from (mut_)repo, but it seemed a bit odd.

In rebase examples other than the "new --insert-after", we could switch to
tx.repo(). However, I think the use of tx.base_repo() makes it clear that
there's no data dependency on the previous mutation.
2023-03-23 01:15:31 +09:00
Martin von Zweigbergk
5f74dd5db3 repo: implement Repo on ReadonlyRepo instead of its Arc
I'd like to be able to pass a `self` of `type `&ReadonlyRepo` to
functions that take a `&dyn Repo`. For that, we need `ReadonlyRepo`
itself to implement `Repo` instead of having `Arc<ReadonlyRepo>`
implement it. I could have solved it in a different way, but the `Arc`
requirement seems like an unnecessary constraint.
2023-03-21 21:43:44 -07:00
Martin von Zweigbergk
58e153af19 cli: use Transaction::repo() instead of base_repo() when possible
In most cases, we just need to access the commit backend and then the
shorter `base()` works. I noticed because I wanted to implement `Repo`
on `ReadonlyRepo` instead of on `Arc<ReadonlyRepo>` and then these
uses failed.
2023-03-21 21:43:44 -07:00
Martin von Zweigbergk
01d7239732 revset: make graph iterator yield commit ids (not index entries)
We only need `CommitId`s, and `IndexEntry` is specific to the default
index implementation.
2023-03-20 01:45:54 -07:00
Martin von Zweigbergk
2f876861ae graphlog: key by commit id (not index position)
The index position is specific to the default index implementation and
we don't want to use it in outside of there. This commit removes the
use of it as a key for nodes in the graphlog.

I timed it on the git.git repo using `jj log -r 'all()' -T commit_id`
(the worst case I can think of) and it slowed down from ~2.02 s to
~2.20 s (~9%).
2023-03-20 01:45:54 -07:00
Martin von Zweigbergk
fc84c02c8e cli: add jj describe --no-edit to not open editor 2023-03-19 00:48:05 -07:00
Martin von Zweigbergk
3bacc367cd cli: add jj describe --reset-author
I think requests to reset the author came up twice in the last week,
so let's just add support for it. I copied git's behavior of resetting
the name, email, and timestamp. The flag name is also from git.
2023-03-19 00:48:05 -07:00
Martin von Zweigbergk
2495c8f27e cargo: update MSRV to 1.64
We need 1.64 to bump `clap` to `4.1`. We don't really need to upgrade
to that, but being on an older version causes minor confusions like
#1393. Rust 1.64 is very close to 6 months old at this point.
2023-03-17 22:44:29 -07:00
Martin von Zweigbergk
ac23395ea1 cli: pass revset expression by value to evaluate_revset()
The callers don't need to hold on to the revset expression once it's
been evaluated, and having an owned expression (well, an expression
with shared ownership) will avoid a clone in the next commit.
2023-03-17 22:42:41 -07:00
Martin von Zweigbergk
e2b4d7058d cli: move some debug commands to new (non-hidden) support group
The `jj debug` commands are hidden from help and are described as
"Low-level commands not intended for users", but e.g. `jj debug
completion` is intended for users, and should be visible in the help
output.
2023-03-17 06:50:55 -07:00
Martin von Zweigbergk
ce098a729a cli: remove jj hide as alias for jj abandon
I haven't heard of anyone using this alias, so let's remove it. It's
easy for users to add it as their own alias if they really want it.
2023-03-17 06:50:55 -07:00
Martin von Zweigbergk
fb7b680d1f cli: don't hide jj commit from help output
The command is not only useful for new users, it's also useful as a
combination of `jj describe` and `jj new`.
2023-03-17 06:50:55 -07:00
Martin von Zweigbergk
0899260f0c cli: try to clarify the help texts for jj op commands a little 2023-03-16 08:00:05 -07:00
Martin von Zweigbergk
3871efd2f9 revset: move ReverseRevsetGraphIterator into revset module
The iterator is not specific to the implementation in
`revset_graph_iterator`, so it belongs in the standard `revset`
module.
2023-03-14 05:32:02 -07:00
Martin von Zweigbergk
f62fac24ac revset: move graph iteration onto Revset trait
We want to allow custom revset engines define their own graph
iterator. This commit helps with that by adding a
`Revset::iter_graph()` function that returns an abstract iterator.

The current `RevsetGraphIterator` can be configured to skip or include
transitive edges. It skips them by default and we don't expose option
in the CLI. I didn't bother including that functionality in the new
`iter_graph()` either. At least for now, it will be up to the
implementation whether it includes such edges (it would of course be
free to ignore the caller's request even if we added an option for it
in the API).
2023-03-14 05:32:02 -07:00
Martin von Zweigbergk
82101bc7e0 cli: let graphlog provide a default node symbol
I'm about to make the default (non-working-copy) node symbol be a
unicode symbol, but we only want that when using a unicode graph, so
users with a terminal that doesn't support unicode can get plain ASCII
output by setting e.g. `ui.graph.style = "ascii"`.
2023-03-12 23:21:05 -07:00
Martin von Zweigbergk
efc9cc9885 cli: avoid a call to Index::num_commits()
I'm trying to remove the function from the trait.
2023-03-12 22:08:31 -07:00
Martin von Zweigbergk
8c5c0f0e83 cli: make jj debug index get stats from specific implementation
We don't want custom index implementations to have to conform to the
same kind of stats as the default implementation. This commit also
makes the command error out on non-default index types.
2023-03-12 22:08:31 -07:00
Martin von Zweigbergk
504a2b3fd0 cli: add test of jj debug reindex, do full reindexing
I broke the commands in a27da7d8d5 and thought I just fixed it in
c7cf914694a8. However, as I added a test, I realized that I made it
only reindex the commits since the previous operation. I meant for the
command to do a full reindexing of th repo. This fixes that.
2023-03-12 22:08:31 -07:00
Martin von Zweigbergk
63b3c0899a index: make jj debug reindex actually reindex
I broke `jj debug reindex` in a27da7d8d5. From that commit, we no
longer delete the pointer to the old index, so nothing happens when we
reload the index. This commit fixes that, and also makes the command
error out if run on a repo with a non-default index type.
2023-03-12 03:23:59 -07:00
Martin von Zweigbergk
d2457d3f38 index: wrap ReadonlyIndex in new type, hiding Arc
Not all index implementations may want to store the readonly index
implementation in an Arc. Exposing the Arc in the interface is also
problematic because `Arc<IndexImpl>` cannot be cast to `Arc<dyn
Index>`.
2023-03-11 22:22:46 -08:00
Martin von Zweigbergk
e5ba9d9e42 index: move current implementation to default_index_store.rs
The idea is that `index.rs` contains the interface, similar to
`backend.rs` for commits, and `op_store.rs` for operations.
2023-03-11 22:22:46 -08:00
Yuya Nishihara
904e9c5520 cli: add ui.log-word-wrap option
Unlike Mercurial, this isn't a template keyword/function, but a config knob.
Exposing graph_width to templater wouldn't be easy, and I don't think it's
better to handle terminal wrapping in template.

I'm not sure if patch content should be wrapped, so this option only applies
to the template output for now.

Closes #1043
2023-03-11 12:01:17 +09:00
Yuya Nishihara
82604eda02 cli: extract complete_newline() to text_util module
I'll add more text formatting functions there.
2023-03-10 16:07:55 +09:00
Martin von Zweigbergk
e509a299e5 cli: print commands in alphabetical order
Until https://github.com/clap-rs/clap/issues/1553 is fixed, I don't
think we can do better than alphabetical order (without a lot of
work).
2023-03-06 21:35:34 -08:00
Samuel Tardieu
decca920c7 git push: do not consider @- if @ has non-empty content or description 2023-03-05 23:50:20 +01:00
Samuel Tardieu
5ecdeed606 git: only consider references matching globs when fetching 2023-03-02 10:09:08 +01:00
Samuel Tardieu
0ca4e2dad2 git: absence of globs is None rather than &[]
In `git_fetch()`, any glob present in `globs` is an "allow" mark. Using
`&[]` to represent an "allow-all" may be misleading, as it could
indicate that no branch (only the git HEAD) should be fetched.

By using an `Option<&[&str]>`, it is clearer that `None` means that
all branches are fetched.
2023-03-02 10:09:08 +01:00
Samuel Tardieu
6fd65cca30 git: use &[&str] instead of &[String]
Using &[String] forces the caller to materalize owned strings if they
have only references, which is costly. Using &[&str] makes it cheap
if the caller owns strings as well.
2023-03-02 10:09:08 +01:00