Commit graph

1608 commits

Author SHA1 Message Date
dependabot[bot]
b5e628ab07 cargo: bump pest from 2.3.1 to 2.4.0
Bumps [pest](https://github.com/pest-parser/pest) from 2.3.1 to 2.4.0.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.3.1...v2.4.0)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 08:56:24 -07:00
dependabot[bot]
c352deaa59 cargo: bump clap from 4.0.6 to 4.0.8
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.6 to 4.0.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/v4.0.6...v4.0.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 08:51:38 -07:00
dependabot[bot]
53fc4a179c cargo: bump test-case from 2.2.1 to 2.2.2
Bumps [test-case](https://github.com/frondeus/test-case) from 2.2.1 to 2.2.2.
- [Release notes](https://github.com/frondeus/test-case/releases)
- [Changelog](https://github.com/frondeus/test-case/blob/master/CHANGELOG.md)
- [Commits](https://github.com/frondeus/test-case/compare/v2.2.1...v2.2.2)

---
updated-dependencies:
- dependency-name: test-case
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-03 08:50:48 -07:00
Martin von Zweigbergk
0c8c33df73 readme: update asciinema links
As @huyz noticed, I accidentally lost the undo demo in 0d1bf7cb3b. I
also didn't update the working-copy demo. This patch fixes that by
updating all demos, so we also get the recent styling change from
af145c998ea4..
2022-10-02 21:55:26 -07:00
Yuya Nishihara
1800354465 working_copy: remove .clone() from TreeState proxy methods
Let the caller .clone() as needed.
2022-10-02 22:46:09 +09:00
Yuya Nishihara
786e6211d8 working_copy: use OnceCell for lazy instantiation of TreeState
Here OnceCell<T> serves as RefCell<Option<T>>, but it doesn't require runtime
Ref/RefMut wrapper. This allows us to get rid of some .clone() calls needed to
hide Ref<_> from public interface.
2022-10-02 22:46:09 +09:00
Yuya Nishihara
4f72ec142d cargo: bump once_cell, add explicit dependency 2022-10-02 22:46:09 +09:00
Tal Pressman
621caa4dcb add default log revset configuration setting 2022-10-02 16:56:18 +09:00
Yuya Nishihara
7faa3c8e81 cli: always call locked_wc.finish() after snapshotting working copy
Otherwise mtime information could be lost, and snapshot() would always
need to build a tree object for comparison.

Closes #554
2022-10-02 15:15:18 +09:00
Yuya Nishihara
dc9a9ed4c1 working_copy: on finish(), don't serialize checkout if operation_id is unchanged
Maybe it's okay to always save the checkout state, but let's apply the same
rule as the previous commit.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
a8a3a236b0 working_copy: on finish(), don't serialize tree_state if known to be clean
This allows us to call locked_wc.finish() no matter if the tree is changed
or not.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
e716fe7abf working_copy: remove return value from TreeState::snapshot()
I'll make TreeState::snapshot() return a boolean denoting whether tree_state
is updated or not. New tree_id can be obtained from TreeState, so let's
remove it from the return value.
2022-10-02 15:15:18 +09:00
Yuya Nishihara
9c33062d11 working_copy: clarify tree_state shouldn't be modified without mutable ref
While making tree_state() return RefMut<TreeState> instead of RefMut<Option<_>>,
I felt uncomfortable that tree_state(&self) returned a mutable reference. So
this patch splits it into tree_state() and tree_state_mut().
2022-10-02 15:15:18 +09:00
dependabot[bot]
750878a3fd github: bump github/codeql-action from 2.1.25 to 2.1.26
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.25 to 2.1.26.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](86f3159a69...e0e5ded33c)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-30 09:09:30 -07:00
dependabot[bot]
7e74a3b035 cargo: bump clap_mangen from 0.2.1 to 0.2.2
Bumps [clap_mangen](https://github.com/clap-rs/clap) from 0.2.1 to 0.2.2.
- [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_mangen-v0.2.1...clap_mangen-v0.2.2)

---
updated-dependencies:
- dependency-name: clap_mangen
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-30 09:08:57 -07:00
dependabot[bot]
1d4cb3399b cargo: bump clap from 4.0.4 to 4.0.6
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.4 to 4.0.6.
- [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.0.4...v4.0.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-30 09:08:29 -07:00
Martin von Zweigbergk
3b3f6129e6 backend: allow negative timestamps in commits and operations
I was reading a draft of "Git Rev News: Edition 91" [1] where Peff
mentions some unfinished patches to allow negative timestamps in
Git. So I figured I should add support for that before I forget. I
haven't checked if libgit2 supports it, so it might be that our Git
backend still doesn't support it after this patch.

 [1] https://github.com/git/git.github.io/blob/master/rev_news/drafts/edition-91.md
2022-09-30 00:50:17 -07:00
Martin von Zweigbergk
3fc7b549ec cleanup: rename some more variables from checkout_* to ~wc_ 2022-09-29 23:51:34 -07:00
Georges Dubus
5b5a85fe33 Change pkgconfig to pkg-config
`pkgconfig` has been a alias to `pkg-config` since 2021-01-18, and has started being an error since 2022-09-24.

This commit makes recent nixpkgs versions work, but might make version older than January 2021 break (which is probably not an issue).
2022-09-29 17:56:06 -07:00
Martin von Zweigbergk
89680b8df9 cli: update off of deprecated clap API 2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
b561a05d25 cargo: upgrade to clap 4.0.4
I changed the "GLOGAL OPTIONS" help heading to use title case, to
match clap's new help style.

I also removed our override of the help text for `-h, --help` because
the default text now includes "(use `-h` for a summary)" (and it's
harder override now).

Perhaps the most obvious difference to users will be the changed help
output
(https://epage.github.io/blog/2022/09/clap4/#polishing-help-output). It
no longer has color, and long lines are not wrapped. I suppose we
should wrap the text ourselves instead..
2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
1665e1dd21 cli: reuse default_app() in test 2022-09-29 17:53:36 -07:00
dependabot[bot]
c06fbfa603 cargo: bump insta from 1.20.0 to 1.21.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.20.0 to 1.21.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/commits)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 09:09:45 -07:00
dependabot[bot]
d51e23d2fa cargo: bump thiserror from 1.0.36 to 1.0.37
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.36 to 1.0.37.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.36...1.0.37)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 09:08:02 -07:00
dependabot[bot]
62103baa99 github: bump ossf/scorecard-action from 2.0.3 to 2.0.4
Bumps [ossf/scorecard-action](https://github.com/ossf/scorecard-action) from 2.0.3 to 2.0.4.
- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](865b409285...e363bfca00)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-28 09:01:07 -07:00
Martin von Zweigbergk
5e539771c5 git: include a hint about possible permission error when push fails
When the remote rejects a push, we now say something like this:

```
Remote rejected the update of some refs (do you have permission to push to ["refs/heads/main"]?)
```

That message could be formatted better, but this seems good enough for
now. We should probably have some more custom conversion from
`GitPushError` to `CommandError` in the CLI layer.
2022-09-27 02:23:05 -07:00
Martin von Zweigbergk
d1565fb6eb cli: on push, indicate which branches we're going to force-push 2022-09-27 02:23:05 -07:00
Martin von Zweigbergk
2d2ed53a34 tests: use different commit per branch in jj git push tests
I think I meant for this test to use different commits but because
they have the same content and metadata, they ended up with the same
hash.
2022-09-27 02:23:05 -07:00
Jason R. Coombs
c4b44500e4 Add hyperlink target for 405 2022-09-26 09:39:03 -07:00
dependabot[bot]
5f450e3531 cargo: bump thiserror from 1.0.35 to 1.0.36
Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.35 to 1.0.36.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.35...1.0.36)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 09:07:27 -07:00
dependabot[bot]
faf329f3f2 cargo: bump protobuf-codegen from 3.1.0 to 3.2.0
Bumps [protobuf-codegen](https://github.com/stepancheg/rust-protobuf) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/stepancheg/rust-protobuf/releases)
- [Changelog](https://github.com/stepancheg/rust-protobuf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stepancheg/rust-protobuf/compare/v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: protobuf-codegen
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 09:07:10 -07:00
Martin von Zweigbergk
4f0ccedd31 cli: don't call process::exit() in create_ui()
This patch move the call to `process::exit()` out of `create_ui()` by
letting that function return a `(Ui, Result<(), CommandError>)`.
2022-09-25 19:43:47 -07:00
Martin von Zweigbergk
cc30cb6ca8 aliases: when invalid command found, let clap handle it
When we resolve aliases and we try to resolve something that is not a
real command and not an alias, we currently replicate `clap`'s error
message. I don't know why I did that because it seems that we should
just stop resolving aliases and let `clap` try to parse what we have
resolved at that point. This patch makes that change, thereby removing
an additional call to `process::exit()`.
2022-09-25 19:40:06 -07:00
Martin von Zweigbergk
0484573a6d examples: show how to add a custom backend 2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
3e0d49e847 workspace: make capable of loading with out-of-tree backend 2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
87bcee6cf2 repo: make capable of loading repo with out-of-tree backend
This changes `RepoLoader` to take a map of functions that load a
specific type of backend, keyed by the backend type. The backend type
is read from `.jj/repo/store/backend`.
2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
de7b5cf8b0 repo: write format ("git" or "local") to disk on init
We currently determine if the repo uses the Git backend or the local
backend by checking for presence of a `.jj/repo/store/git_target`
file. To make it easier to add out-of-tree backends, let's instead add
a file that indicates which backend to use.
2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
c02f87170d repo: remove init_*() functions used only in tests
The `ReadonlyRepo::init_*()` functions were unused or used only in
tests. Let's remove them, thereby making the repo less aware of
specific backend implementations.
2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
e41acc1c16 workspace: avoid reloading stores when adding workspace
By calling `repo.loader()` on the existing repo, we reuse the same
commit store etc. That should make it easier to add out-of-tree
backends by removing one place we'd otherwise need to pass in a way of
creating a backend (now we reuse the instance that was already created
for the existing `repo`).
2022-09-25 09:40:42 -07:00
Martin von Zweigbergk
ea5aa0a96d cleanup: replace some PathBuf args by &Path
In many of these places, we don't need an owned value, so using a
reference means we don't force the caller to clone the value. I really
doubt it will have any noticeable impact on performance (I think these
are all once-per-repo paths); it's just a little simpler this way.
2022-09-25 09:40:42 -07:00
Yuya Nishihara
48a7378d9f commit: simplify parents() and predecessors() impl 2022-09-25 22:29:07 +09:00
Yuya Nishihara
c94f54689d commit: make predecessor_ids() return slice instead of cloned vec 2022-09-25 22:29:07 +09:00
Yuya Nishihara
3a6c6d8bf4 commit: make parent_ids() return slice instead of cloned vec
I feel it doesn't make sense for a simple getter function to create an
owned vec after 0108673087 "backend: let each backend handle root commit
on write."
2022-09-25 22:29:07 +09:00
Martin von Zweigbergk
18cf020f2f examples: show how to add custom CLI command
It's now pretty easy to add a custom command. Let's have an example to
show how to do it, and to protect against regressions.

It would be nice to also have some tests of the custom command, to
check that the command works, that other commands can be run, and that
`jj debug completion` includes the custom command. I'm not sure how to
do that, however.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
7a9f9a14db cli: extract a function for creating a default Ui
This will also be reused by binaries that want to add custom commands.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
a0dfd4a4a8 cli: extract function for top-level error reporting
This will also be reused by custom commands.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
a7f19b85f8 cli: move command-agnostic parts of dispatch() into cli_util
The idea is that these parts can be reused for custom commands.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
7f6cf1e6d9 cli: extract new cli_util module
This commit moves much of the `commands` module that isn't specific to
a particular command into a new `cli_util`.

Much of this is actually not even CLI-specific, so we should move that
further down into the library, but that can come later. That includes
the code in `WorkspaceCommandHelper` for snapshotting the working copy
and automatically importing/exporting to a colocated Git working copy.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
92d792f144 cli: add subcommands using clap's builder API
I want to make most of the `dispatch()` code unaware of which commands
exist, so it becomes easier to tweak that set of commands in a custom
binary.
2022-09-24 07:28:10 -07:00
Martin von Zweigbergk
d1f0008d32 cli: use the "dynamic" clap::Command while resolving aliases
I'm trying to make it easier to create a custom `jj` binary with
custom commands, without having to replace the `Args` type we parse
arguments into. For that to work, we need to resolve aliases using the
`clap::Command` type instead.
2022-09-24 07:28:10 -07:00