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

2767 commits

Author SHA1 Message Date
Yuya Nishihara
7ee2ff862f templater: rename Property enum to CoreTemplatePropertyKind
I'll add CommitTemplatePropertyKind.
2023-02-19 11:31:22 +09:00
Yuya Nishihara
5474268d22 templater: parameterize property type 2023-02-19 11:31:22 +09:00
Yuya Nishihara
907bddaf1e templater: add conversion trait for common template types
Maybe we can split traits per type (such as IntoTemplate), but a single
trait should be good enough to abstract "Property" enums.
2023-02-19 11:31:22 +09:00
Yuya Nishihara
2be34ab552 templater: proxy Property::<variant>() wrapping through language trait
The idea is that a derived language will do wrap_<core_type>() as
DerivedProperty::Core(CoreProperty::<Type>(property)). This could be dealt
with some From<CoreProperty> trait impls, but the resulting code looked
a mess, and compile errors would be cryptic. I think this is somewhat similar
to serde::Serializer API.

I also rejected the idea of abstracting property types over Box<dyn>. Maybe
it's okay for method dispatching and extraction of some basic types, but it
wouldn't work if we want to implement comparison operators for any compatible
types.

wrap_commit_or_change_id() and wrap_shortest_id_prefix() will be moved to
the CommitTemplateLanguage. I'll add impl_wrap_fns() macro after splitting
the modules.
2023-02-19 11:31:22 +09:00
Yuya Nishihara
52df6f2e81 templater: proxy build_core_method() through language trait
The "core" template parser wouldn't know how to dispatch property of types
added by a derived language. For example, CommitOrChangeId/ShortestIdPrefix
will be moved to the "commit" templater.
2023-02-19 11:31:22 +09:00
Yuya Nishihara
3361130df4 templater: introduce trait that abstracts property kind and keywords
This trait will provide ways to dispatch keyword/method nodes, and wrap
TemplateProperty object with a dedicated "Property" enum.

build_keyword() and context parameter "I"/"C" have been migrated to it.
2023-02-19 11:31:22 +09:00
Martin von Zweigbergk
92f9fe5a1b tree: make conflict_term_to_conflict() take a TreeValue
The function only needs the `TreeValue` so it makes more sense this
way, I think. That will also let the caller keep the rest of the
`Conflict` value owned (though there is nothing but the `value` field
in it right now).
2023-02-18 00:09:51 -08:00
Martin von Zweigbergk
cf672de792 tree: avoid some cloning by passing by value 2023-02-18 00:09:51 -08:00
Martin von Zweigbergk
a87125d08b backend: rename ConflictPart to ConflictTerm
It took a while before I realized that conflicts could be modeled as
simple algebraic expressions with positive and negative terms (they
were modeled as recursive 3-way conflicts initially). We've been
thinking of them that way for a while now, so let's make the
`ConflictPart` name match that model.
2023-02-17 23:28:50 -08:00
Martin von Zweigbergk
e48ace56d1 conflicts: replace missing files by empty in materialized conflict
When we materialize modify/delete conflicts, we currently don't
include any context lines. That's because modify/delete conflicts have
only two sides, so there's no common base to compare to. Hunks that
are unchanged on the "modify" side are therefore not considered
conflicting, and since they they don't contribute new changes, they're
simply skipped (here:
3dfedf5814/lib/src/files.rs (L228-L230)).

It seems more useful to instead pretend that the missing side is an
empty file. That way we'll get a conflict in the entire file.

We can still decide later to make e.g. `jj resolve` prompt the user on
modify/delete conflicts just like `hg resolve` does (or maybe it
actually happens earlier there, I don't remember).

Closes #1244.
2023-02-17 22:19:04 -08:00
Martin von Zweigbergk
e1d71c3713 conflicts: add test for materializing modify/delete conflict 2023-02-17 22:19:04 -08:00
Martin von Zweigbergk
dfcc7a9cee conflicts: merge modify/delete and delete/modify tests
The two tests only differ in the order of the changes in the input, so
let's reuse some of the setup code.
2023-02-17 22:19:04 -08:00
Martin von Zweigbergk
af3f8b6cfd conflicts: create a helper for creating a ConflictPart in test 2023-02-17 22:19:04 -08:00
Martin von Zweigbergk
7f334656b1 tree: return early when trying to resolve modify/delete conflict
Modify/delete conflicts cannot be automatically resolved, so there's
no point in wasting resources calculating the diff(s).
2023-02-17 22:05:44 -08:00
Isabella Basso
3dfedf5814 docs/config.md: add example for using pipes
As discussed on issue #1273, pipe usage on the jj config differs from
git and hg.

Signed-off-by: Isabella Basso <isabbasso@riseup.net>
2023-02-17 08:35:35 -08:00
Yuya Nishihara
4b00fb70d0 templater: extract function that dispatches method call by property type
A derived template language (e.g. commit template) will forward method calls
of the core types to this function.
2023-02-18 01:16:43 +09:00
Yuya Nishihara
7784768dc6 templater: inline PropertyAndLabels into Expression::Property()
It's no longer used at type position.
2023-02-18 01:16:43 +09:00
Yuya Nishihara
84ad048f24 templater: move initial labeling out of keyword function
I'm going to extract functions specific to commit templates, and auto labeling
feature should be a part of the core template language.
2023-02-18 01:16:43 +09:00
Martin von Zweigbergk
8966580ba4 revset: clean up 'revset lifetimes on dyn Revset
If I understand correctly, the 'revset lifetimes on `Box<dyn
Revset<'index> + 'revset>` are not constrained by the lifetime of a
revset; we don't have any revsets that borrow data from other
revsets. Instead, they're all about constraining a boxed revset to the
index's lifetime. Without the lifetime annotation, it would default to
'static, and the borrow-checker doesn't like `dyn Revset<'index> +
'static`, since the revset could then live longer than the index it
borrows.
2023-02-17 07:52:17 -08:00
Martin von Zweigbergk
0159092c31 revset: elide lifetime parameter on iter()
The self-lifetime is the default when elided.
2023-02-17 07:52:17 -08:00
Martin von Zweigbergk
53565a816c revset: rename 'repo lifetime to the more accurate 'index 2023-02-17 07:52:17 -08:00
Martin von Zweigbergk
9fc879747f release: build Linux (musl) release using vendored OpenSSL
The 0.7.0 release build failed because it didn't find OpenSSL. I don't
know much about musl, but I think we added it in order to get a single
binary without dependencies, so I think vendoring is what we want.
2023-02-16 15:52:00 -08:00
Martin von Zweigbergk
eb79a21cc0 release: release version 0.7.0
It's been about 10 weeks and 730 commits since 0.6.0, compared to
about 7 weeks and 350 commits between 0.5.0 and 0.6.0, so it's time
for a new release. There's been significant user-visible changes and
code-quality improvements. Thanks, everyone!
2023-02-16 12:50:52 -08:00
Ilya Grigoriev
e7bd7a635a config.md: Add a link to TOML syntax guide 2023-02-16 09:56:57 -08:00
Ilya Grigoriev
6cc7aa72e8 config.md: expand on equivalence of headers and dotted keys
Now that we use headers to define `[template-aliases]`, I thought we should explain how they are also equivalent to dotted keys.

Alternatively, we could rewrite them all in the dotted style, but it would look awkward.
2023-02-16 09:56:57 -08:00
dependabot[bot]
78cdf71d9a cargo: bump insta from 1.26.0 to 1.28.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.26.0 to 1.28.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/compare/1.26.0...1.28.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-16 16:53:47 +00:00
dependabot[bot]
034dd3528d github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from 0a1713a447f74360b294fd86bc56dc23af3a9d3e to 52e69531e6f69a396bc9d1226284493a5db969ff.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](0a1713a447...52e69531e6)

---
updated-dependencies:
- dependency-name: dtolnay/rust-toolchain
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-16 08:39:18 -08:00
Ilya Grigoriev
e4aa2cb2e5 Rename ui.relative-timestamps to ui.oplog-relative-timestamps 2023-02-15 21:26:14 -08:00
Ilya Grigoriev
859b0f680c Make ui.relative-timestamps default to true
This seems like a better default for `jj op log`, which is now the only thing
this option affects.
2023-02-15 21:26:14 -08:00
Ilya Grigoriev
bb6bad18ad Update docs/config.toml with new way to show relative timestamps 2023-02-15 21:26:14 -08:00
Martin von Zweigbergk
d8997999f2 repo: replace RepoRef by Repo trait 2023-02-15 19:15:17 -08:00
Martin von Zweigbergk
f6a4cb57da repo: extract a Repo trait for Arc<ReadonlyRepo> and MutableRepo
This will soon replace the `RepoRef` enum, just like how the `Index`
trait replaced the `IndexRef` enum.
2023-02-15 19:15:17 -08:00
Martin von Zweigbergk
b7dad291df repo: make all base_repo() functions return &Arc<ReadonlyRepo>
This is to prepare for a `Repo` trait implemented for
`Arc<ReadonlyRepo>` (not for `ReadonlyRepo` itself).
2023-02-15 19:15:17 -08:00
Martin von Zweigbergk
8a067282c8 repo: make ReadonlyRepo::index() return a &dyn Index
This is just a little preparation for extracting a `Repo` trait that's
implemented by both `ReadonlyRepo` and `MutableRepo`. The `index()`
function in that trait will of course have to return the same type in
both implementations, and that type will be `&dyn Index`.
2023-02-15 19:15:17 -08:00
Yuya Nishihara
3c61e9239c config: remove ui.log-author-format in favor of template alias 2023-02-16 11:43:17 +09:00
Yuya Nishihara
6316ec7442 config: migrate log/show timestamp format away from config knob
Since oplog still relies on ui.relative-timestamps, this config key
isn't removed.
2023-02-16 11:43:17 +09:00
Yuya Nishihara
a00767bc0f config: remove ui.unique-prefixes/log-id-preferred-length in favor of alias 2023-02-16 11:43:17 +09:00
Yuya Nishihara
7913f90869 templater: remove "brackets" short id style in favor of template alias
Though .prefix() + .rest() has to call .shortest() twice, I don't think
the added cost would be significant.
2023-02-16 11:43:17 +09:00
Yuya Nishihara
ffa690abec docs: document default template aliases instead of config knobs
I'm going to remove the corresponding config knobs.

As an example of "brackets" short id, I put a simplified version. It's
unlikely that the "rest()" gets empty for hashes of 12-char long.
2023-02-16 11:43:17 +09:00
Yuya Nishihara
ed4a696dea templater: add shortest().prefix()/rest() accessors
This ensures that the "brackets" style can be emulated by a template
expression.
2023-02-16 11:43:17 +09:00
Martin von Zweigbergk
29792dab9b cli: avoid a closure in op log code for printing timestamp
I find it easier to read the code without the closure and the extra
indentation. Instead, leverage `formatter.labeled()`.
2023-02-15 09:46:38 -08:00
dependabot[bot]
2217a78df3 github: bump dtolnay/rust-toolchain
Bumps [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain) from 25dc93b901a87e864900a8aec6c12e9aa794c0c3 to 0a1713a447f74360b294fd86bc56dc23af3a9d3e.
- [Release notes](https://github.com/dtolnay/rust-toolchain/releases)
- [Commits](25dc93b901...0a1713a447)

---
updated-dependencies:
- dependency-name: dtolnay/rust-toolchain
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-15 08:49:33 -08:00
Martin von Zweigbergk
e76492b5e9 demos: minor changes to operation log demo 2023-02-15 00:25:56 -08:00
Yuya Nishihara
1bdee80a0d cli: remove attempt to detect EPIPE caused by bad pager configuration
It turned out bad idea because EPIPE (or SIGPIPE) is kind of a successful
termination. We could show some warning based on pager exit code, but let's
avoid messing up again.

io::Error occurred in handle_command_result() is still mapped to a BrokenPipe.
panic()-ing there should be wrong.
2023-02-15 15:36:23 +09:00
Martin von Zweigbergk
91775fc4f6 demos: update with recent changes
I had to modify the operation log a bit to fit on my scren with #1221
fixed.

Closes #1221.
2023-02-14 22:12:23 -08:00
Martin von Zweigbergk
73ce048256 demos: add blank line at the end
This makes it slightly easier to take a screenshot without getting the
cursor character from the shell input line just below.
2023-02-14 22:12:23 -08:00
Martin von Zweigbergk
d87f49ce5f demos: remove unnecessary sleeps 2023-02-14 22:12:23 -08:00
Martin von Zweigbergk
54156335e4 cli: don't print error about broken pipe
`jj log | head` consistently prints "Error: Broken pipe" for me. I
don't know how the output gets printed after the pipe has been closed,
but neither `git` nor `hg` prints an error, so I think we shouldn't
either.
2023-02-14 21:29:02 -08:00
Yuya Nishihara
0abf9ce8cd cli: move default "show" template to alias
I'm not pretty sure if this is structurally good, but 'jj log -T show'
is useful.
2023-02-15 01:44:33 +09:00
dependabot[bot]
65ff1afb0d cargo: bump once_cell from 1.17.0 to 1.17.1
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.17.0 to 1.17.1.
- [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.17.0...v1.17.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-14 16:23:42 +00:00