Commit graph

2906 commits

Author SHA1 Message Date
Ilya Grigoriev
49fd177c47 templater: Allow separate styling for change and commit ids 2023-02-21 22:50:27 -08:00
Ilya Grigoriev
00b18bcd18 templater: Upper and lowercase ids and strings 2023-02-21 22:50:27 -08:00
Ilya Grigoriev
643fe9a218 Remove no longer needed clippy bug workaround 2023-02-21 18:33:40 -08:00
Ilya Grigoriev
30d03a66e6 cmd: --branch option for git fetch.
Thanks to @samueltardieu for noticing a subtle bug in the refspecs, providing
the fix, as well as the two `conflicting_branches` tests.
2023-02-21 18:33:40 -08:00
Ilya Grigoriev
cd8a18daf8 test_git_fetch.rs: Move some helper methods 2023-02-21 18:33:40 -08:00
dependabot[bot]
c53544aecf cargo: bump slab from 0.4.7 to 0.4.8
Bumps [slab](https://github.com/tokio-rs/slab) from 0.4.7 to 0.4.8.
- [Release notes](https://github.com/tokio-rs/slab/releases)
- [Changelog](https://github.com/tokio-rs/slab/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/slab/compare/v0.4.7...v0.4.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-20 13:03:41 -08:00
Yuya Nishihara
4ec0bfb8f7 cli: rename op "head" color label to "current_operation"
FWIW, this change means a boolean "current_operation" keyword will be
highlighted even if it's false.
2023-02-21 00:24:58 +09:00
Yuya Nishihara
4f36367aee cli: rename "op-log" color label to "op_log"
Per discussion in #1289.
2023-02-21 00:24:58 +09:00
Samuel Tardieu
e9009cf21e style: simplify topo_order()
- Calling `.into_iter()` on an iterator is a no-op.
- There is no need to wrap index entries into another type to unwrap
  them right after sorting.
2023-02-20 11:05:54 +01:00
Yuya Nishihara
c2df989fe9 cli: add "op log -T" option and basic tests for template keywords 2023-02-20 18:20:41 +09:00
Yuya Nishihara
b5f1728ffb templater: migrate op log to template language
The outermost "op-log" label isn't moved to the default template. I think
it belongs to the command's formatter rather than the template.

Old bikeshedding items:
- "current_head", "is_head", or "is_head_op"
  => renamed to "current_operation"
- "templates.op-log" vs "templates.op_log" (the whole template is labeled
  as "op-log")
  => renamed to "op_log"
- "template-aliases.'format_operation_duration(time_range)'"
  => renamed to 'format_time_range(time_range)'
2023-02-20 18:20:41 +09:00
Yuya Nishihara
eafbd977a3 templater: add TimestampRange type, migrate operation time to it 2023-02-20 18:20:41 +09:00
Yuya Nishihara
da3c1d2286 templater: extract helpers to build expression of specific types 2023-02-20 18:20:41 +09:00
Yuya Nishihara
c2e0ebca12 templater: implement .into_template() helper on formattable property
So that I can blindly write property.into_template() to convert any property
type to template.
2023-02-20 18:20:41 +09:00
Yuya Nishihara
854a3e64fa templater: split IntoTemplate trait
The next commit will implement .into_template() on Box<dyn TemplateProperty>,
so I want a trait for this particular method.
2023-02-20 18:20:41 +09:00
Ilya Grigoriev
9c51d74b2c cmd: Allow multiple -b for jj rebase
This also makes `rebase_branch` reuse `rebase_descendants`.

This addresses a portion of #1158
2023-02-20 00:36:32 -08:00
Ilya Grigoriev
f04458a245 cmd: Allow multiple -s for jj rebase
This addresses a portion of #1158

One application (not the prettiest, but useful until we have `jj sync`):

    jj rebase -s oldmain+~:main -d main -L
2023-02-20 00:36:32 -08:00
Ilya Grigoriev
39dd1a99c1 Add comment for topo_order 2023-02-20 00:36:32 -08:00
Ilya Grigoriev
53476a77f7 cmd: Make jj restore work if @ is a merge commit
To be clear, this applies to `jj restore` without any arguments.

Fixes #1228
2023-02-19 22:55:53 -08:00
Martin von Zweigbergk
bc9f66dad3 revset: replace RevsetIterator wrapper by extension
The type doesn't seem to provide any benefit. I don't think I had a
good reason for creating it in the first place; it was probably just
unfamiliarity with Rust.
2023-02-19 21:37:26 -08:00
Martin von Zweigbergk
91e56c7f2f revset: add type parameters to remaining iterator adapters
This is another step towards removing `RevsetIterator`. These types
are private, so someone using the library can't accidentally create a
`UnionRevsetIterator` with inputs in different order, for example.
2023-02-19 21:37:26 -08:00
Martin von Zweigbergk
44e6ef9bae revset: make into_predicate_fn() a free function
I'm about to convert `RevsetIterator` to a trait and I don't want
`into_predicate_fn()` on it.
2023-02-19 21:37:26 -08:00
Martin von Zweigbergk
36aa6e0be6 revset: add type parameter in commit iterator adapters
The standard way of creating iterator adapters seems to have the input
iterator type by a parameter to the function, so let's follow that
pattern.
2023-02-19 21:37:26 -08:00
Martin von Zweigbergk
30160f4d20 revset: pass revset, not iterator, into RevsetGraphIterator
I was thinking of replacing `RevsetIterator` by a regular
`Iterator<Item=IndexEntry>`. However, that would make it easier to
pass in an iterator that produces revisions in a non-topological order
into `RevsetGraphIterator`, which would produce unexpected results (it
would result in nodes that are not connected to their parents, if
their parents had already been emitted). I think it makes sense to
instead pass in a revset into `RevsetGraphIterator`.

Incidentally, it will also be useful to have the full revset available
in `RevsetGraphIterator` if we rewrite the algorithm to be more
similar to Mercurial's and Sapling's algorithm, which involves asking
the revset if it contains parent revisions.
2023-02-19 21:37:26 -08:00
Yuya Nishihara
a3efb74cfc commit_templater: make commit/change_id typed again
This basically undoes d6c6cdb45c "templater: store type-erased version of
commit/change id." Since they are looked up differently, they should preserve
the original types.
2023-02-20 13:41:44 +09:00
Samuel Tardieu
863a6e6d09 git push: add --deleted option 2023-02-19 18:18:53 +01:00
Yuya Nishihara
4f9e75c7d1 templater: use macro to implement property kind wrappers 2023-02-19 16:18:39 +09:00
Yuya Nishihara
aaae90a599 commit_templater: turn property structs into functions 2023-02-19 16:18:39 +09:00
Yuya Nishihara
cf1b609de2 commit_templater: rename 'repo lifetime for clarity
FWIW, I'm thinking of making the repo parameter generic over Arc<ReadonlyRepo>
and &MutableRepo. It will allow us cache a parsed commit_summary template.
2023-02-19 16:18:39 +09:00
Yuya Nishihara
c5ddd14c13 commit_templater: extract runtime objects from templater.rs
This should reduce future merge conflicts around use statements.
2023-02-19 16:18:39 +09:00
Yuya Nishihara
c396b4cecf commit_templater: extract parsing functions from template_parser.rs
parse_commit_template() is renamed to commit_templater::parse().
2023-02-19 16:18:39 +09:00
Yuya Nishihara
73b7954060 templater: make common parser types and utility functions public
So the commit templater can be extracted to new module.
2023-02-19 16:18:39 +09:00
Ilya Grigoriev
4059fe77fd operation-log.md: Give a brief description of @, +, - 2023-02-18 22:42:51 -08:00
Ilya Grigoriev
385429446b config.md: Additional changes to the section about TOML
Based on @martinvonz 's suggestion from https://github.com/martinvonz/jj/pull/1263.
2023-02-18 22:40:23 -08:00
Ilya Grigoriev
9df7919763 config.md: Fixup to complicated dotted example from 6cc7aa7
Added @martinvonz 's suggestion from https://github.com/martinvonz/jj/pull/1263.
2023-02-18 22:40:23 -08:00
Martin von Zweigbergk
f70e6987b5 conflicts: preserve order of adds in materialized conflict
We write conflict to the working copy by materializing them as
conflict markers in a file. When the file has been modified (or just
the mtime has changed), we parse the markers to reconstruct the
conflict. For example, let's say we see this conflict marker:

```
<<<<<<<
+++++++
b
%%%%%%%
-a
+c
>>>>>>>
```

Then we will create a hunk with ["a"] as removed and ["b", "c"] as
added.

Now, since commit b84be06c08, when we materialize conflicts, we
minimize the diff part of the marker (the `%%%%%%%` part). The problem
is that that minimization may result in a different order of the
positive conflict terms. That's particularly bad because we do the
minimization per hunk, so we can end up reconstructing an input that
never existed.

This commit fixes the bug by only considering the next add and the one
after that, and emitting either only the first with `%%%%%%%`, or both
of them, with the first one in `++++++++` and the second one in
`%%%%%%%`.

Note that the recent fix to add context to modify/delete conflicts
means that when we parse modified such conflicts, we'll always
consider them resolved, since the expected adds/removes we pass will
not match what's actually in the file. That doesn't seem so bad, and
it's not obvious what the fix should be, so I'll leave that for later.
2023-02-18 22:01:25 -08:00
Martin von Zweigbergk
975350f73b conflicts: demo bad roundtripping of conflict 2023-02-18 22:01:25 -08:00
Martin von Zweigbergk
fe0eb9137c conflicts: use snapshot testing for conflict-parsing 2023-02-18 22:01:25 -08:00
Yuya Nishihara
a28396fc86 templater: extract "commit" property variants to separate enum
Now it's ready to split template_parser/templater into base template functions
and "commit" templater. I think Signature and Timestamp are basic types, so
they aren't moved to CommitTemplatePropertyKind. Perhaps, a duration type from
OpTemplate will also be added to CoreTemplatePropertyKind.
2023-02-19 11:31:22 +09:00
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