Commit graph

2232 commits

Author SHA1 Message Date
Waleed Khan
af55d17a25 git_backend: propagate various errors
I needed this in the course of debugging an error. Before this commit, the error looked like this:

```
Error: Unexpected error from backend: Object not found
```

After this commit, it looks like this:

```
Error: Unexpected error from backend: Object with CommitId 8f59646bc9bb6bb44b5624f1248f4a708f37003c not found: object not found - no match for id (8f59646bc9bb6bb44b5624f1248f4a708f37003c); class=Odb (9); code=NotFound (-3)
```
2023-01-02 12:28:51 -06:00
Waleed Khan
9f8d78c57d working_copy: propagate error source for SourceNotFound errors
Might as well while I'm here.
2023-01-02 12:28:51 -06:00
Waleed Khan
e299963fae backend: remove PartialEq/Eq implementations
As soon as we start tracking the `#[source]` for error variants, we won't be able to rely on the presence of `Eq` implementations.
2023-01-02 12:28:51 -06:00
Waleed Khan
67cb20611e cli_util: fix typo in From<BackendError>
This error message was confusing because I thought the error was coming directly from the store, not via the backend.
2023-01-02 12:28:51 -06:00
Waleed Khan
456be4cc73 backend: create BackendError::InvalidHashLength
Strictly speaking, we could rely on e.g. `git2::Oid::from_str` to produce an error, but I figure that having an explicit error for a mismatching hash length might demystify some error condition in the future, since commit IDs and change IDs and potentially other backends' IDs may have different lengths, so this could flag a mismatch earlier/more obviously.
2023-01-02 12:28:51 -06:00
Waleed Khan
7f8a196ab2 backend: create ObjectId trait
This lets us operate over various kinds of objects polymorphically (e.g. call `.hex()` on any kind of object hash).
2023-01-02 12:28:51 -06:00
Ilya Grigoriev
9974d67da2 Test jj log for divergent commits
It turns out we did not have tests that would catch `jj log` failing
to mark divergent commits.
2023-01-02 00:08:55 -08:00
Ilya Grigoriev
265fa7f7c7 cargo +nightly clippy --fix --workspace 2023-01-02 00:08:55 -08:00
Yuya Nishihara
6586a756c1 cli: inline create_ui(), use ? to handle config error 2023-01-02 14:14:50 +09:00
Yuya Nishihara
1b45c5fe8e cli: use ui.reset() to process --config-toml arguments
This should also fix handling of --config-toml 'colors...'. Before, the color
table wouldn't be updated without mode change.
2023-01-02 14:14:50 +09:00
Yuya Nishihara
fa68a21bd1 cli: create default ui, then reconfigure with loaded user settings
This function will probably be used to apply settings loaded from
.jj/repo/config.toml.
2023-01-02 14:14:50 +09:00
Yuya Nishihara
da95ae65be cli: extract Ui::new() that creates ui with default config
Since ui object is needed to report read_config() error, it makes sense to
create ui first without fallible user configuration. Ui::for_terminal() will
be replaced with this function and ui.reset(read_config()?).

Default::default() is also added to silence clippy. If we prefer, Ui::new()
can be replaced with Ui::default().
2023-01-02 14:14:50 +09:00
Philip Metzger
48356817ba [Docs]: Add some more documentation on how to work with github.
The document roughly describes some workflows, which help new users
to start with github.
2023-01-01 16:36:09 +01:00
Martin von Zweigbergk
d6fcf4c7b2 repo: load correct OpHeadsStore depending on repo's type
We forgot to actually call `StoreFactories::load_op_heads_store()` to
load the right type of `OpHeadsStore` depending on the contents of
`.jj/repo/op_heads/type`. That shouldn't have any effect yet since we
only have one type so far, and there are no out-of-tree types yet
either (clearly, since they would not work).
2022-12-31 01:22:29 -08:00
Waleed Khan
cf8c2b0717 cli_util: fix typo 2022-12-31 02:57:26 -06:00
dependabot[bot]
f05c6fc6fd cargo: bump once_cell from 1.16.0 to 1.17.0
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.16.0 to 1.17.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.16.0...v1.17.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-30 09:38:30 -08:00
dependabot[bot]
d7c335d6b2 cargo: bump predicates from 2.1.4 to 2.1.5
Bumps [predicates](https://github.com/assert-rs/predicates-rs) from 2.1.4 to 2.1.5.
- [Release notes](https://github.com/assert-rs/predicates-rs/releases)
- [Changelog](https://github.com/assert-rs/predicates-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/predicates-rs/compare/v2.1.4...v2.1.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-30 09:38:14 -08:00
Augie Fackler
f64d8f45ae Commands: Alias commit to ci for cvs/mercurial/svn compatability
As far as I can tell it won't hurt anyone to have this alias exist, but will
help those of us with old muscle memory.
2022-12-30 09:26:55 -05:00
Yuya Nishihara
b3fa9e5b6c matchers: rename Dirs to RepoPathTree as it no longer represents directory 2022-12-30 14:15:27 +09:00
Yuya Nishihara
4f875ff9b7 matchers: leverage Dirs tree to test prefix matches, no .to_vec() in loop
No special case for prefix.is_root() is needed since the root entry can
also be flagged as a file.
2022-12-30 14:15:27 +09:00
Yuya Nishihara
996ac22921 matchers: simplify FilesMatcher::new() to take slice of paths 2022-12-30 14:15:27 +09:00
Yuya Nishihara
c7eaee3d86 matchers: remove redundant files set from FilesMatcher, use Dirs 2022-12-30 14:15:27 +09:00
Yuya Nishihara
2fb0363c03 matchers: add method to create visit sets from Dirs, remove separate getters
We might also want to eliminate .collect()/clone() here, but that's not
considered yet.
2022-12-30 14:15:27 +09:00
Yuya Nishihara
ba632e6ef6 matchers: build tree of Dirs so prefix match works out of the box
A file entry is represented as a Dirs of is_file flag set. This might seem
odd at this point, but allows us to remove special case from PrefixMatcher.
PrefixMatcher::new(&[RepoPath::root()]) will set is_file to the root entry.
2022-12-30 14:15:27 +09:00
dependabot[bot]
37fa7c39d4 cargo: bump whoami from 1.2.3 to 1.3.0
Bumps [whoami](https://github.com/ardaku/whoami) from 1.2.3 to 1.3.0.
- [Release notes](https://github.com/ardaku/whoami/releases)
- [Changelog](https://github.com/ardaku/whoami/blob/stable/CHANGELOG.md)
- [Commits](https://github.com/ardaku/whoami/compare/v1.2.3...v1.3.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-29 07:39:59 -08:00
David Barnett
e824c491bf Add a "config" command with "get" and "list" subcommands
Partially fixes #531.
2022-12-27 16:59:20 -06:00
dependabot[bot]
9bf5f1c430 cargo: bump serde from 1.0.151 to 1.0.152
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.151 to 1.0.152.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.151...v1.0.152)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-27 14:18:35 -08:00
Martin von Zweigbergk
d86ba708a3 repo: add MutableRepo::rewrite_commit() returning CommitBuilder
Same reasoning as the previous commit.
2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
812ef97adb repo: add MutableRepo::new_commit() returning CommitBuilder
Since `CommitBuilder` now has a reference to `MutableRepo`, it's
convenient to create instances of it by calling a method on
`MutableRepo`.
2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
f3208f59c4 store: propagate error from Backend::write_commit() 2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
f1d7bbe508 testutils: create a function for writing a random commit to MutableRepo
We already have `create_random_commit()`, which returns a
`CommitBuilder`. Most callers directly write that to a
`MutableRepo`. That currently returns a `Commit`, but I'm about to
make it propagate errors from the backend. That would add an
`unwrap()` to this sequence, making it longer. Let's create a simple
helper for these callers to simplify this common pattern.
2022-12-26 23:30:52 -08:00
Martin von Zweigbergk
49b2f3b6ca commit_builder: keep MutableRepo reference
When you're done with the `CommitBuilder`, you're going to have to
call `write_to_repo()`, passing it a mutable `MutableRepo`
reference. It's a bit simpler to pass that reference when we create
the `CommitBuilder` instead, so that's what this patch does.

A drawback of passing in the mutable reference when we create the
builder is that we can't have multiple unfinished `CommitBuilder`
instance live at the same time. We don't have any such use cases yet,
and it's not hard to work around them, so I think this change is worth
it.
2022-12-26 23:30:52 -08:00
dependabot[bot]
70a6798d76 cargo: bump pest_derive from 2.5.1 to 2.5.2
Bumps [pest_derive](https://github.com/pest-parser/pest) from 2.5.1 to 2.5.2.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.5.1...v2.5.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-26 15:20:38 +00:00
Yuya Nishihara
d89619c9c6 git: diff refs to export without building dummy view 2022-12-25 00:11:14 +09:00
Martin von Zweigbergk
5cb3807b26 colors: move defaults from source to file 2022-12-24 07:07:37 -08:00
Martin von Zweigbergk
6514ab2e3a cli: when config is invalid, use default config
When we fail to read the user's config, it seems obviously better to
use the default config than to not use it. It doesn't matter yet, but
it will matter when I've moved color configs out of `formatter.rs` and
into a `.toml` file. Without this change, we'd lose the default
coloring of the error message for config errors.
2022-12-24 07:07:37 -08:00
Martin von Zweigbergk
462f696e4e config: add a README to explain that the config files are not installed 2022-12-24 07:07:37 -08:00
Martin von Zweigbergk
b22a6db7e7 config: move default merge-tool config into config/ directory
I'm about to add more default configs, so it will be good to collect
them in one directory.
2022-12-24 07:07:37 -08:00
dependabot[bot]
db0a524f7b cargo: bump clap_complete from 4.0.6 to 4.0.7
Bumps [clap_complete](https://github.com/clap-rs/clap) from 4.0.6 to 4.0.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.0.6...clap_complete-v4.0.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-23 23:31:08 +00:00
dependabot[bot]
72ed6676bb cargo: bump clap from 4.0.30 to 4.0.32
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.30 to 4.0.32.
- [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.30...v4.0.32)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-23 15:18:36 -08:00
dependabot[bot]
77b7884464 cargo: bump clap_mangen from 0.2.5 to 0.2.6
Bumps [clap_mangen](https://github.com/clap-rs/clap) from 0.2.5 to 0.2.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/clap_mangen-v0.2.5...clap_mangen-v0.2.6)

---
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-12-23 09:25:15 -08:00
dependabot[bot]
481f87abd3 cargo: bump pest from 2.5.1 to 2.5.2
Bumps [pest](https://github.com/pest-parser/pest) from 2.5.1 to 2.5.2.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.5.1...v2.5.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-23 09:24:57 -08:00
Tal Pressman
cc40740fa2 Update cargo installation instructions 2022-12-24 02:24:23 +09:00
Yuya Nishihara
587e42d65d backend: deduplicate id type declarations by using declarative macro 2022-12-23 23:52:03 +09:00
Yuya Nishihara
b07c0db56b backend: deduplicate id type impls by using declarative macro
It's unlikely we'll need to customize these impls per type, so let's ensure
that these newtypes have identical implementations. This commit also adds
from_hex() to FileId, SymlinkId, and ConflictId.
2022-12-23 23:52:03 +09:00
Ilya Grigoriev
5a681d31d0 cmd jj log: Move divergent label next to the change id
The divergent label is most relevant when the user is about to
refer to a commit by its change id.

It's also good to put it far from the `conflicts` label, to
reduce confusion between very different concepts that have
similar names.

Finally, I think it is a feature rather than a bug that the
`divergent` label now upsets the alignment of different lines
of `jj log`.
2022-12-22 17:25:16 -08:00
Benjamin Saunders
d99e85269f cli: fix core.excludesFile default when XDG_CONFIG_HOME is set 2022-12-22 10:03:20 -08:00
Yuya Nishihara
48cf32f559 cli: simply assign result of if expression in cmd_describe() 2022-12-23 00:47:22 +09:00
Yuya Nishihara
2550dcae4c cli: include diff summary in commit/describe editor content 2022-12-23 00:47:22 +09:00
Yuya Nishihara
d438f43224 cli: rephrase diff summary header so it can be reused for commit/describe 2022-12-23 00:47:22 +09:00