Commit graph

5767 commits

Author SHA1 Message Date
Martin von Zweigbergk
ce44d46583 squash: make -r argument optional in clap
I'm soon going to make `jj squash` accept either `-r` or
`--from/--to`, which means `-r` will then be optional. This patch
prepares for that already, since it also simplifies the code a little
(and improves it so we warn if the user does `jj squash -r @
nonexistent`).
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
e1997f6c9a move: record both source and destination as predecessors
This matches what we do for `jj squash`, whether it's a
full or partial move.

I didn't add a test since we're planning to deprecate `jj move`, and
this will soon be tested via the `jj squash` tests.
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
018a871ce9 move: extract bulk of logic to function for reuse by jj squash 2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
7f101c4023 move: don't use transient commit in operation description
The `destination` variable we use when creating the operation log may
have been replaced earlier in the code. I think this was a regression
when I moved the setting of the description from `start_transaction()`
to `finish_transaction()` a while ago.
2024-03-10 21:17:08 -07:00
Martin von Zweigbergk
4d42604913 git_backend: write trees involved in conflict in git commit header
We haven't used custom Git commit headers for two main reasons:

1. I don't want commits created by jj to be different from any other
   commits. I don't want Git projects to get annoyed by such commit
   and reject them.

2. I've been concerned that tools don't know how to handle such
   headers, perhaps even resulting in crashes.

The first argument doesn't apply to commits with conflicts because
such commits would never be accepted by a project whether or not they
use custom commit headers. The second argument is less relevant for
conflicted commits because most tools will be confused by such commits
anyway.

Storing conflict information in commit headers means that we can
transfer them via the regular Git wire protocol. We already include
the tree objects nested inside the root-level tree, so they will also
be transferred.

So, let's start by writing the information redundantly to the commit
header and to the existing storage. That way we can roll it back if we
realize there's a problem with using commit headers.
2024-03-10 20:51:05 -07:00
Martin von Zweigbergk
ea5a208ca5 cli: make *Args::tool fields non-public, except for DiffFormatArgs
Probably just a bad copy&paste.
2024-03-10 20:37:44 -07:00
Aleksey Kuznetsov
cd3d75ebf6 revset: introduce more performant way to check if a commit is in a revset
Initially we were thinking to have `Revset` return something like
`CachedRevset`:

```
pub trait CachedRevset {
  fn iter(&self) -> Box<dyn Iterator<Item = Commit>>;
  fn contains(&self, &CommitId) -> bool;
}
```

But we weren't sure what use case for `iter` would be, so we dropped the `iter`
method. `CachedRevset` with single `contains` method needed a better name. We
weren't able to come up with one, so we decided instead to have a method on
`Revset` that returns a closure to check if a commit is in a revset.
2024-03-11 08:27:35 +05:00
Yuya Nishihara
8a406358af index: migrate RevWalkRevset to be based off new RevWalk trait
"for<'index> RevWalk<CompositeIndex<'index>, .." works as of now, but it won't
be composed well. So I'll turn CompositeIndex<'_> into &CompositeIndex in the
next batch, and remove "for<'index>".
2024-03-11 11:25:54 +09:00
Yuya Nishihara
4107cad80e index: migrate RevWalkDescendants to new RevWalk trait
Just for consistency. Descendants are always evaluated eagerly, so this change
isn't strictly needed.
2024-03-11 11:25:54 +09:00
Yuya Nishihara
b6cbd8b90b index: add trait and adaptor types to detach index from RevWalk*
This eliminates lifetimed fields from RevWalk objects, and the RevWalk object
will be embedded directly in RevWalkRevset.

This patch adds two separate iterator adapters. They are identical at this
point, but I'm going to add detach/reattach methods only to the borrowed
version. I'm also planning to change CompositeIndex<'_> to &CompositeIndex
to get around higher-ranked trait bound restrictions.
2024-03-11 11:25:54 +09:00
Yuya Nishihara
d780910bec index: make RevWalk yield IndexPosition instead of IndexEntry
This simplifies the RevWalkIndex API. It would probably add fractional msecs of
overhead per next() call, but I don't see significant difference in revset
benches.
2024-03-11 11:25:54 +09:00
Martin von Zweigbergk
6d78d92d91 cli: move jj amend/unamend aliases to config
The `amend/unamend` aliases exist for smoothen onboarding for
Git/Mercurial users; I don't think we should recommend that users use
them, so I think it's fine if users override them as they
like. Therefore, I think they belong in the config.
2024-03-09 22:43:50 -08:00
Anton Älgmyr
099f06bf71 Add configuration options for node symbols in the graphs. 2024-03-09 21:16:58 +01:00
Yuya Nishihara
f51c5d7e57 index: consistently use IntoIterator in RevWalk builder API
Since the return type is no longer "impl Iterator<..>", there isn't lifetime
issue anymore.
2024-03-10 01:45:30 +09:00
Yuya Nishihara
2615fed5be index: handle cut-off position of RevWalk by queue
I'm going to make CompositeIndex<'_> detachable from the RevWalk, and
"F: Fn(CompositeIndex) -> Box<dyn Iterator<..>>" of RevWalkRevset<F> will
be replaced with "W: RevWalk<CompositeIndex>". This will simplify the code
structure, but also means that we can no longer apply .take_while() here and
convert it back to RevWalk. Fortunately, ancestors_until_roots() is the only
function I need to reimplement.
2024-03-10 01:45:30 +09:00
Yuya Nishihara
34fbaaaad6 index: construct RevWalk queue after item type is settled
It doesn't make sense to build BinaryHeap with intermediate type, and I'm
going to reimplement take_until_roots() in a way that the queue drops
uninteresting items.
2024-03-10 01:45:30 +09:00
Yuya Nishihara
8480ee9e05 index: migrate RevWalk constructors to builder API
The current RevWalk constructors insert intermediate items to BinaryHeap
and convert them as needed. This is redundant, and I'm going to add another
parameter that should be applied to the queue first. That's why I decided
to factor out a builder type. I considered adding a few set of factory
functions that receive all parameters, but they looked messy because most of
the parameters are of [IndexPosition] type.

This patch also adds must_use to the builder and its return types, which are
all iterator-like.
2024-03-10 01:45:30 +09:00
Yuya Nishihara
008adecf23 index: rename ancestors iterators from RevWalk* to RevWalkAncestors*
I'm planning to add RevWalk trait, and this patch frees up the name. It seems
also good for consistency as we have RevWalkDescendants*.
2024-03-10 01:45:30 +09:00
Yuya Nishihara
fa60026f25 repo_path: don't panic on invalid UTF-8 path component
Although watchman client appears to fail at decoding non-UTF-8 path (somewhere
in serde), jj shouldn't panic if watchman could deal with that.

The outer error message "path not in the repo" would sounds odd, but I think
that's okay because 1. it's unlikely that a user input is not UTF-8, and 2.
it's technically correct that a non-UTF-8 path is not contained in the repo.
2024-03-09 11:01:43 +09:00
Yuya Nishihara
a224d0f172 repo_path: show more detailed error if filesystem path failed to parse
This should address both use cases:
 1. If from_relative_path() is directly called, the error says ".." shouldn't
    be included in the (normalized) relative path.
 2. If parse_fs_path() is used, the error message contains paths relative to
    cwd. #3216
2024-03-09 11:01:43 +09:00
Martin von Zweigbergk
2df977b221 docs: say that we support $GIT_DIR/info/exclude
We have had support for `GIT_DIR/info/exclude` since 8336c48 (almost
exactly two years ago).
2024-03-08 09:59:10 -08:00
Martin von Zweigbergk
98baaf23d5 changelog: clarify that commit signing support is partial 2024-03-08 09:00:32 -08:00
Yuya Nishihara
6498a0cf8a cli: propagate type error of "ui.default-command" 2024-03-08 23:57:59 +09:00
Austin Seipp
7e28e19945 changelog: put entry in the right version section
Commit b4c4d911 introduced this entry in the changelog, but put it in the 0.15.0
section rather than the new unreleased section.

This was probably just because the original commit was authored before the
0.15.0 release, but merged after. Such is life.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-03-07 23:24:43 -06:00
Yuya Nishihara
a76f716cd1 index: remove RevWalk newtypes that were necessary to hide impl types/traits
Some of the RevWalk methods could be generalized, but I decided to not try that
for now. I'll probably need to do more cleanup to (hopefully) remove 'index
lifetime from these types.
2024-03-08 10:07:40 +09:00
Yuya Nishihara
8451453f3a index: hide walk_revs() and related types
They are now implementation details of the default index backend.
2024-03-08 10:07:40 +09:00
Yuya Nishihara
f5eb172769 tests: remove last use of walk_revs() from integration tests 2024-03-08 10:07:40 +09:00
Martin von Zweigbergk
663e35255f cli: move jj co alias to config file, so it can be overridden
This way users can override `jj co` to mean `jj new` if they want to
get rid of the warning.
2024-03-07 09:46:34 -08:00
dependabot[bot]
037c4d0fe0 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.5.1 to 4.5.2
- [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.5.1...v4.5.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-07 16:09:00 +00:00
dploch
b4c4d91190 cli_util: support multiple cli arguments for ui.default-command 2024-03-07 09:34:18 -05:00
Martin von Zweigbergk
bf76080f42 release: release version 0.15.1
This release is just so we can publish the crates to crates.io. We
couldn't publish the 0.15.0 crates because `jj-lib-proc-macros` had
`publish = false`.
2024-03-06 20:35:38 -08:00
Martin von Zweigbergk
5ce5022ee9 cargo: mark the jj-lib-proc-macros crate for publish
I don't think we can publish a new version of the other crates without
publishing `jj-lib-proc-macros`.
2024-03-06 20:35:38 -08:00
Martin von Zweigbergk
462c19736a release: release version 0.15.0
Thanks to everyone who's contributed!
2024-03-06 14:10:58 -08:00
Martin von Zweigbergk
4d5d5c4ac2 tests: avoid deprecated jj co 2024-03-06 10:19:46 -08:00
Martin von Zweigbergk
1ee6b595a8 cargo: upgrade chrono from 0.4.34 to 0.4.35 2024-03-06 09:20:23 -08:00
dependabot[bot]
6626c93d38 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [EmbarkStudios/cargo-deny-action](https://github.com/embarkstudios/cargo-deny-action).


Updates `EmbarkStudios/cargo-deny-action` from 1.6.0 to 1.6.1
- [Release notes](https://github.com/embarkstudios/cargo-deny-action/releases)
- [Commits](c3a7e67839...64015a69ee)

---
updated-dependencies:
- dependency-name: EmbarkStudios/cargo-deny-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-06 08:52:57 -08:00
Yuya Nishihara
4cb457eddb cli: leverage TypedValueParser::map() to implement RevisionArg parser
I just found there's a utility for that.
2024-03-07 00:36:19 +09:00
Yuya Nishihara
4dfded2ab7 cli: move join_message_paragraphs() to description_util 2024-03-07 00:33:28 +09:00
Aleksey Kuznetsov
38d14eafe2 cli: enrich the error about required template value with a hint
Several `jj` commands accept `--template <TEMPLATE>` argument. When the argument
is empty, `jj` will show the list of defined template aliases.
2024-03-06 08:12:40 +05:00
Yuya Nishihara
8c0f6a53c5 cli: colorize output of "config list" 2024-03-06 11:38:57 +09:00
Yuya Nishihara
7ca6744432 cli: add "config list --template" support
There's a caveat: "jj config list -Tname" will concatenate all names in a
single line. That's correct but useless. We might want some option or config
knob to complete missing "\n". This also applies to "log --no-graph".
2024-03-06 11:38:57 +09:00
Yuya Nishihara
56f1b36990 templater: unimplement Default for TestTemplateEnv
It was Default just because the implementation could be derived at that point.
Using Default no longer makes sense.
2024-03-06 11:38:57 +09:00
Yuya Nishihara
4c62f46c03 templater: leverage GenericTemplateLanguage in tests 2024-03-06 11:38:57 +09:00
Yuya Nishihara
d0168199f0 templater: add general-purpose template engine for value types
This serves the role of the formatter in Mercurial, but the provided features
are rather restricted compared to mercurial.formatter. That's because both
implementation language "Rust" and jj's template language are statically typed.

The current implementation works well for simple commands like "config list -T",
but it might be not okay for "branch list -T". If we implement branch templating
by using the generic mechanism, the commit summary part would have to be
evaluated as a separate template:

  -T 'branch_name ++ target_commit_summary' (target_commit_summary: Template)

instead of

  -T 'branch_name ++ commit_summary(target_commit)' (target_commit: Commit)

where the branch template language is a superset of the commit template
language.
2024-03-06 11:38:57 +09:00
dependabot[bot]
fb5fe5cc26 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [EmbarkStudios/cargo-deny-action](https://github.com/embarkstudios/cargo-deny-action).


Updates `EmbarkStudios/cargo-deny-action` from 1.5.15 to 1.6.0
- [Release notes](https://github.com/embarkstudios/cargo-deny-action/releases)
- [Commits](68cd9c5e3e...c3a7e67839)

---
updated-dependencies:
- dependency-name: EmbarkStudios/cargo-deny-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-05 10:31:52 -06:00
Thomas Castiglione
d661f59f9d working_copy: implement symlinks on windows with a helper function
enables symlink tests on windows, ignoring failures due to disabled developer mode,
and updates windows.md
2024-03-05 15:16:38 +08:00
Thomas Castiglione
fed682a430 tests: fix some failures on windows due to a missing TEMP environment variable 2024-03-05 15:16:38 +08:00
Anton Älgmyr
38b27de8e3 Add --context flag for diffs.
Allows specifying the number of lines of context to show around diffs.
The logic was already in place, just some plumbing was needed.
2024-03-05 07:48:23 +01:00
Yuya Nishihara
59a61a26d9 cli: reuse commit summary template and formatter in a loop
The performance wouldn't matter, but the new code doesn't look bad either.
2024-03-05 12:12:34 +09:00
Yuya Nishihara
749ef4584d templater: inline commit/operation_templater::parse(), add command helper fns
I'm going to add generic templating support for basic value types, and
"jj config list -T" will use CommandHelper::parse_template().
CommandHelper::load_template_aliases() is made private instead.
2024-03-05 12:12:34 +09:00