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

1274 commits

Author SHA1 Message Date
Samuel Tardieu
d4b13d7495 git: use our own default refspec 2023-03-02 10:09:08 +01:00
Samuel Tardieu
5ecdeed606 git: only consider references matching globs when fetching 2023-03-02 10:09:08 +01:00
Samuel Tardieu
182919ff6f git: add function to import a selection of the git refs 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
Martin von Zweigbergk
bbd6ef0c7b revset: remove filter_by_diff(), have caller intersect expression
To be able to make e.g. `jj log some/path` perform well on cloud-based
repos, a custom revset engine needs to be able to see the paths to
filter by. That way it is able pass those to a server-side index. This
commit helps with that by effectively converting `jj log -r foo
some/path` into `jj log -r 'foo & file(some/path)'`.
2023-02-28 17:45:34 -08:00
dependabot[bot]
26597ba61a cargo: bump prost-build from 0.11.7 to 0.11.8
Bumps [prost-build](https://github.com/tokio-rs/prost) from 0.11.7 to 0.11.8.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits/v0.11.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-28 16:13:14 +00:00
Martin von Zweigbergk
fd6c7f3bb3 op_heads_store: let caller create initial operation
It makes the APIs much simpler if we don't have to pass in information
about the initial operation when we create the `OpHeadsStore`. It also
makes the alternative `OpHeadsStore` implementations simpler since we
move some logic into a shared location (`ReadonlyRepo::init()`).

This effectively undoes ec07104126. Maybe some further refactoring
made it possible to move it back as I'm doing in this commit?
2023-02-28 08:08:31 -08:00
dependabot[bot]
7de17ce4e7 cargo: bump tempfile from 3.3.0 to 3.4.0
Bumps [tempfile](https://github.com/Stebalien/tempfile) from 3.3.0 to 3.4.0.
- [Release notes](https://github.com/Stebalien/tempfile/releases)
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/NEWS)
- [Commits](https://github.com/Stebalien/tempfile/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-27 11:06:51 -08:00
dependabot[bot]
b34daa9423 cargo: bump prost from 0.11.7 to 0.11.8
Bumps [prost](https://github.com/tokio-rs/prost) from 0.11.7 to 0.11.8.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits/v0.11.8)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-27 10:59:19 -08:00
Martin von Zweigbergk
4c5695f0cd index_store: take OperationId when writing new index
By taking an `OperationId` argument to `IndexStore::write_index()`, we
can remove `associate_file_with_operation()` from the trait. That
simplifies the interace a little bit. The reason I noticed this was
that I'm trying to extract a trait for `IndexStore`, and the word
"file" in it is too specific for e.g. a cloud-based implementation.
2023-02-27 09:44:28 -08:00
Martin von Zweigbergk
346e3c849b repo: propagate error when failing to look up backend type 2023-02-27 09:44:28 -08:00
Martin von Zweigbergk
011d9e3486 workspace: make WorkspaceLoader::load() return WorkspaceLoadError
I plan to make `RepoLoader::init()` return a `Result`, which means
that `WorkspaceLoader::load()` will need to return more kinds of
errors. Making it return `WorkspaceLoadError` is a good start. By also
extracting a function for converting `WorkspaceLoadError` to
`CommandError`, we can reuse a the handling of `PathError` in
`cli_util`.
2023-02-27 09:44:28 -08:00
Martin von Zweigbergk
491ecc6b2e repo: replace load_at_head() by helper in tests
I'm about to make `RepoLoader::init()` return a `Result`, and I don't
want to have to wrap that in a new error in
`ReadonlyRepo::load_at_head()` since that's only used in tests.
2023-02-27 09:44:28 -08:00
Yuya Nishihara
0b083b2ddb conflicts: in materialize_merge_result(), always use adds.get(index)
I don't think this is more readable than the original code, but it gives
diff1/right1 and diff2/right2 pairs consistent names.
2023-02-24 19:58:10 +09:00
Yuya Nishihara
410be93339 conflicts: in materialize_merge_result(), borrow both adds/removes sides
Just for consistency.
2023-02-24 19:58:10 +09:00
Yuya Nishihara
da16bf340c conflicts: fix off-by-one error in materialize_merge_result()
This should fix #1304. I think the added test simulates the behavior of
multiple rebase conflicts, but I don't have expertise around this.

add_index could be replaced with a peekable iterator, but the iterator version
wouldn't be as readable as the current implementation.
2023-02-24 19:58:10 +09:00
dependabot[bot]
0224b52ffc cargo: bump prost-build from 0.11.6 to 0.11.7
Bumps [prost-build](https://github.com/tokio-rs/prost) from 0.11.6 to 0.11.7.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-24 11:55:41 +09:00
dependabot[bot]
bd16e96693 cargo: bump prost from 0.11.6 to 0.11.7
Bumps [prost](https://github.com/tokio-rs/prost) from 0.11.6 to 0.11.7.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-23 15:32:35 +00: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
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
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
Ilya Grigoriev
39dd1a99c1 Add comment for topo_order 2023-02-20 00:36:32 -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
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
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
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
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
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
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
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