Commit graph

3584 commits

Author SHA1 Message Date
Waleed Khan
23a4124d20 feat(revset): suggest similar branch names 2023-06-05 11:11:17 -05:00
Waleed Khan
f61cbae022 refactor(revset): move collect_similar from cli_util to revset 2023-06-05 11:11:17 -05:00
Waleed Khan
0fff404fb2 cleanup: fix clippy issues 2023-06-05 11:11:17 -05:00
Martin von Zweigbergk
7f3d07e35f cli: add jj git push -r for pushing branches pointing to revset
I think I will find this useful in at least two cases:

1. When you already have a branch pointing to some commit, it's easier
   to do `jj git push -r xyz` than `jj git push --branch
   push-xyzxyzyxzxyz`.

2. When you have a stack of changes, it's useful to be able to push
   all of them at once.

I think we should also update the default behavior of `jj git push` to
be `jj git push -r 'remote_branches()..@'` or something like
that. That removes the ugliness of having a default behavior that the
user can't reproduce using flags. I'll leave that change for a
separate PR.
2023-06-04 20:50:11 -07:00
Martin von Zweigbergk
9f7180ff55 cli: use | for combining a few match patterns 2023-06-04 20:50:11 -07:00
Martin von Zweigbergk
abcfebf1e2 cli: allow jj git push --change xyz --branch foo
This was pretty simple. I simplified a bit by making the transaction
description mention only branches, not changes. It still mentions the
branches created for the changes, however. Also, since the operation
"tags" contain the full command line, I think it'll still be
relatively easy for the user to understand what the operation was
about.
2023-06-04 20:50:11 -07:00
Martin von Zweigbergk
ac8313f119 cli: in jj git push, create transaction in a single place
I added a function for updating the description on an existing
transaction. That way we can create the transaction earlier. I'll try
to make `--change` and `--branch` not mutually exclusive next.
2023-06-04 20:50:11 -07:00
Ilya Grigoriev
d82266887c SECURITY.md: show the email plainly
Previously, the link wasn't working from Github's rendered markdown.

Another alternative is to add `malto:` to the link, which would make it work. However, I thought that since the email is the most important piece of information in the entire file, we should just write it out.
2023-06-04 17:03:25 -07:00
Martin von Zweigbergk
29b676f24f store: do conversion to/from backend::Conflict
We now convert to/from `backend::Conflict` right before/after calling
the `Store` methods, so we can simplify by having the `Store` do the
conversion.
2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
594734dbc9 cli: replace use of backend::Conflict when listing paths with conflicts 2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
43c55fcbc9 tree: replace uses of backend::Conflict 2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
c378503991 conflicts: replace remaining uses of backend::Conflict 2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
9907cccf37 conflicts: use an early return to reduce indentation
Thanks to @ilyagr for the suggestion.
2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
f4499aa65e conflicts: fix bug when modifying modify/delete conflicts
Currently, if the user modifies a modify/delete conflict, we always
consider the result resolved. That happens because we materialize the
missing side of the conflict as an empty string but when we parse the
conflict, we expect only the number of sides in the input
conflict. For example, if the input is a regular modify/delete
conflict with one remove and one add, the materialized markers will
have one remove and two adds (one of them empty), but when we try to
parse it, we expect one remove and only one add. When we fail to parse
it, we consider it resolved.

This commit fixes the bug by using
`conflicts::Conflict<Option<TreeValue>>` and keeping track of which
sides were supposed to be empty. We could have fixed the bug without
switching to `conflicts::Conflict`, but we want to switch anyway, and
the fix happens naturally when switching.
2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
1fdc25fe45 conflicts: replace backend::Conflict in materialize_conflict() 2023-06-04 06:48:34 -07:00
Martin von Zweigbergk
5733e3a442 conflicts: introduce generic type for conflicts
For support for tree-level conflicts (#1624), I'm probably going to
introduce a `MergedTree` type representing a set of trees to
merge. That will be similar to `Tree`, but instead of having values of
type `TreeValue`, it will have values that can represent a single
state or a conflict. The `TreeValue` type itself will eventually lose
its `Conflict` variant.

To prepare for that, this commit introduces a `Conflict<T>` type. That
type is intended to be close to what the future
`MergedTree::path_value()`, `MergedTree::entries()`, etc. The next few
commits will replace most current uses of `backend::Conflict` by this
new `conflicts::Conflict` type. They will use `Option<TreeValue>` as
type parameter. Unlike the current `backend::Conflict` type, the
explicit tracking of `None` values will let us better preserve the
ordering and tying it to the tree-level conflict's order.
2023-06-04 06:48:34 -07:00
Yuya Nishihara
78a64edb22 dag_walk: rename bfs() to dfs() because it's depth-first
No callers appear to rely on traversal order, so let's just fix the function
name. Maybe it was a typo.
2023-06-04 11:47:49 +09:00
Yuya Nishihara
d5d1dbcd3e dag_walk: reorder and adjust signature of neighbors_fn for consistency 2023-06-04 11:47:49 +09:00
Yuya Nishihara
a28e672633 dag_walk: unbox topo_order_reverse() callback 2023-06-04 11:47:49 +09:00
Yuya Nishihara
3ba544414c dag_walk: unbox bfs() callback, use iter::from_fn() to implement iterator
I just wanted to remove syntactic noise from callers. iter::from_fn() helps
to avoid declaring struct with lots of type parameters.
2023-06-04 11:47:49 +09:00
Yuya Nishihara
522308bb9c dag_walk: simply pass callback function by value 2023-06-04 11:47:49 +09:00
Martin von Zweigbergk
864c17b8c4 changelog: consider renamed jj debug commands a breaking change
I think I originally didn't consider changing debug commands as a
breaking change, but it's better to be conservative.
2023-06-03 19:21:43 -07:00
Martin von Zweigbergk
e86f339863 changelog: removing the jj hide alias is a breaking change 2023-06-03 19:21:43 -07:00
dependabot[bot]
60812f8346 cargo: bump clap from 4.3.0 to 4.3.1
Bumps [clap](https://github.com/clap-rs/clap) from 4.3.0 to 4.3.1.
- [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.3.0...clap_complete-v4.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-02 16:23:30 +00:00
dependabot[bot]
2ca42ada12 cargo: bump clap_complete from 4.3.0 to 4.3.1
Bumps [clap_complete](https://github.com/clap-rs/clap) from 4.3.0 to 4.3.1.
- [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.3.0...clap_complete-v4.3.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-02 16:11:16 +00:00
Yuya Nishihara
6872051270 tree_builder: populate base trees by recursion
Suppose many override entries share the same parent directories, it should
be cheaper to look up the tree_cache from leaf than root. I also think
recursion is easier to follow than for loop.
2023-06-02 12:23:37 +09:00
Yuya Nishihara
941f41e62e tree_builder: initialize base trees with the root entry
This helps to rewrite populate_trees() as recursive function call.
2023-06-02 12:23:37 +09:00
Yuya Nishihara
7cf96bcae0 tree_builder: ensure override file path never points to root tree 2023-06-02 12:23:37 +09:00
Yuya Nishihara
f475122b7e tree_builder: simply map Tree to backend::Tree in later pass
I'll rewrite populate_trees() as a recursive function, so I want to minimize
the objects to be passed to the function.
2023-06-02 12:23:37 +09:00
Yuya Nishihara
0846d7fc8b tree_builder: remove unneeded "mut" self 2023-06-02 12:23:37 +09:00
dependabot[bot]
633236701d github: bump github/codeql-action from 2.3.5 to 2.3.6
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.3.5 to 2.3.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](0225834cc5...83f0fe6c49)

---
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>
2023-06-01 09:20:29 -07:00
dependabot[bot]
59ee431467 cargo: bump criterion from 0.4.0 to 0.5.1
Bumps [criterion](https://github.com/bheisler/criterion.rs) from 0.4.0 to 0.5.1.
- [Changelog](https://github.com/bheisler/criterion.rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bheisler/criterion.rs/compare/0.4.0...0.5.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 09:20:14 -07:00
Yuya Nishihara
3d449c55b7 tree_builder: do not omit file entry which was previously a directory 2023-06-01 09:38:06 +09:00
Yuya Nishihara
68a30c934d tree_builder: when writing trees, rely on lexicographical order of RepoPath 2023-06-01 09:38:06 +09:00
Yuya Nishihara
ae9f7aba52 tests: add test for file-directory-file transition
TreeBuilder fails to handle directory-file transition right now, and leaves
the dirty file as "clean".
2023-06-01 09:38:06 +09:00
Martin von Zweigbergk
3a69fa48f6 conflicts: delete unused conflict_to_materialized_value() 2023-05-31 17:31:08 -07:00
Martin von Zweigbergk
35b19b1e28 cargo: upgrade clap from to 4.1.11 to 4.3.0
I changed `test_early_args` because the first line no longer has a
redundant color reset, so now we test the `Commands:` line instead,
which has actual color (well, bold+underline anyway).
2023-05-31 12:32:26 -07:00
dependabot[bot]
581b6ef28c cargo: bump chrono from 0.4.25 to 0.4.26
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.25 to 0.4.26.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.25...v0.4.26)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-31 16:10:03 +00:00
Martin von Zweigbergk
5653827101 cli: add pointer from error message to docs about stale working copy 2023-05-31 06:32:40 -07:00
Martin von Zweigbergk
fb17e6a50e revset: use different errors for ambiguous commit/change IDs
I made a typo and got something like this:

```
Error: Commit or change id prefix "wl" is ambiguous
```

Since we can tell commit ids from change ids these days, let's make
the error message say which kind of id it is. Changing that also kind
of forced me to make a special error for empty strings. Otherwise we
would have to arbitrarily say that an empty string is a commit id or
change id. A specific error message for empty strings seems helpful,
so that's probably for the better anyway.
2023-05-31 06:28:32 -07:00
Martin von Zweigbergk
97b81a0f12 working_copy: get conflict id from the current tree
This prepares for allowing the base tree to be a conflict at the
root-tree level (#1624).

We could remove the `Conflict` variant completely. I tried doing that
and it slowed down `jj diff` by ~3% in the Linux repo with a clean
working copy with only mtime bumped on all files.
2023-05-31 06:28:15 -07:00
Martin von Zweigbergk
a5883eba15 merge: make trivial_merge() return a reference
I don't know why I made it return an owned value. It seems like an
unnecessary restriction that the value implements `Clone`, so let's
return a reference instead.
2023-05-31 06:28:01 -07:00
Martin von Zweigbergk
3ca42908ee cleanup: avoid some unnecessary uses of Cursor
Most of our uses of `Cursor` can be replaced by just mutable slices,
which seems simpler, so I guess that's preferred.
2023-05-30 21:06:24 -07:00
Martin von Zweigbergk
a5ef4f0f40 merge_tools: avoid re-reading edited file, read from buffer instead
I suspect this was just because it wasn't obvious to the author how to
get a `Read` from an in-memory buffer (I know it wasn't to me).
2023-05-30 21:06:24 -07:00
dependabot[bot]
04a107babf cargo: bump once_cell from 1.17.1 to 1.17.2
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.17.1 to 1.17.2.
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.17.1...v1.17.2)

---
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-05-29 20:26:10 +02:00
dependabot[bot]
f27fef09d9 cargo: bump chrono from 0.4.24 to 0.4.25
Bumps [chrono](https://github.com/chronotope/chrono) from 0.4.24 to 0.4.25.
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.24...v0.4.25)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 20:25:38 +02:00
dependabot[bot]
b9f2f634be cargo: bump git2 from 0.17.1 to 0.17.2
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.17.1 to 0.17.2.
- [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.17.1...0.17.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-29 20:25:04 +02:00
Yuya Nishihara
f27ac22ba4 index: unify evaluate_revset() implementations
The lifetime is a bit tricky since CompositeIndex is a reference wrapper
whereas Index trait has no notion about ownership.
2023-05-29 08:15:40 +09:00
Yuya Nishihara
b7b9b8c88e index: pass only CompositeIndex to default_revset_engine::evaluate() 2023-05-29 08:15:40 +09:00
Yuya Nishihara
cf5cb380bb index: implement Index for CompositeIndex
We can't get rid of the other "impl Index"es because .as_composite() must
return a real reference type. Maybe we could turn CompositeIndex into an
owned wrapper, but I don't know if that would be worth the effort.
2023-05-29 08:15:40 +09:00