Commit graph

5760 commits

Author SHA1 Message Date
Yuya Nishihara
15ff7dfd48 cli: indent commits summary in single revset resolution hint
This is the same formatting as "jj abandon" output. It should improve the
discoverability of the trailing hint.
2024-03-25 11:15:28 +09:00
Yuya Nishihara
65ef700f94 cli: format single revset resolution hint with reused template instance
I'm going to introduce two changes: 1. indent commit summary, 2. colorize
output. The former can be implemented without using the templater API, but the
latter can't.
2024-03-25 11:15:28 +09:00
Yuya Nishihara
96e0bc0bdd templater: turn logical && and || into short-circuiting operators
Since the context (or self) property is no longer passed by argument, it's easy
to implement short-circuiting behavior.
2024-03-25 11:15:18 +09:00
Yuya Nishihara
df7be43ab6 templater: update comment why Template isn't TemplateProperty<Output = ..>
They are similar in a way that both of them can represent dynamic/static
evaluation, but their behaviors are different in error handling.
2024-03-25 11:15:09 +09:00
Yuya Nishihara
577e030db2 templater: remove unused context parameter from Template<C>
IntoTemplate will be cleaned up later. Perhaps, the lifetime parameter can be
removed at this point, but I'm planning to remove the IntoTemplate trait at all.
2024-03-25 11:15:09 +09:00
Yuya Nishihara
24ab8f7011 templater: turn Root/PlaceholderTemplate into non-Template type
The type parameter 'C' will be removed from the Template trait, making it
represent a printable type or compiled template.

TemplateRenderer now holds Box<dyn _> template because it's unlikely that the
inner template type can be statically determined.
2024-03-25 11:15:09 +09:00
Yuya Nishihara
f312307cbf git-push: process --change branches first to avoid pushing old branch state
This fixes --change/--branch conflicts by making --change precede --branch. I
don't think this is the most obvious behavior, but it's the easiest workaround.
2024-03-24 16:20:26 +09:00
Yuya Nishihara
538bfbc8a4 git-push: filter out duplicated branch names by caller
This is the common pattern among other classify() loops. I also changed the
set to hold &str as it doesn't need owned strings.
2024-03-24 16:20:26 +09:00
Yuya Nishihara
d749ef0195 git-push: extract function that updates push-{change_id} branches 2024-03-24 16:20:26 +09:00
Yuya Nishihara
620f0cd35f git-push: check duplicated --change branch prior to recording branch_updates
It could be moved before set_local_branch_target() to not update the local
branch, but it seemed weird that --change is silently ignored. This
inconsistency will be addressed later.
2024-03-24 16:20:26 +09:00
Yuya Nishihara
f88679bb45 tests: run "git push" with both --change and --branch arguments
It's unclear whether --change should precede or not, but it's wrong to try to
push the same branch twice.
2024-03-24 16:20:26 +09:00
Yuya Nishihara
e50d96e01d cli: split single revset resolution hint to paragraphs
Perhaps, this makes it slightly easier to spot the last "Hint:" line. We can
also render "Error:" and "Hint:" prefixes in different color/style.
2024-03-24 10:45:52 +09:00
Yuya Nishihara
b77a110e8a cli: remove less-frequently-used user_error factories 2024-03-24 10:45:52 +09:00
Yuya Nishihara
2523dc188c cli: allow to attach multiple hints to CommandError
Even though the number of the hints is usually 0 or 1, this simplifies the
API and hints handling.
2024-03-24 10:45:52 +09:00
Yuya Nishihara
bb0dcc059c cli: extract helper that prints error message, sources, and hint 2024-03-24 10:45:52 +09:00
Yuya Nishihara
aeb3470b5d cli: reorganize CommandError as (kind, err, hint) tuple
This helps to implement CommandError::add_hint(). The inner errors could be
embedded in the enum as before, but they're mostly of the same type. And I think
it's okay to use downcast_ref() to deal with the clap::Error special case.
2024-03-24 10:45:52 +09:00
Yuya Nishihara
7a2077a434 cli: extract clap::Error handling to function 2024-03-24 10:45:52 +09:00
Yuya Nishihara
c333481496 cli: add more CommandError factory functions, consolidate inner type
I'm going to reorganize CommandError as (kind, err, hints) tuple so that we
can add_hint() to the constructed error object.

Some config error messages are slightly adjusted because the inner error is
now printed in separate line.
2024-03-24 10:45:52 +09:00
Yuya Nishihara
c311131ee2 log: encode elided node as None
Since elided graph entry has no associated commits, it makes some sense to
represent as None?
2024-03-24 10:32:15 +09:00
Yuya Nishihara
2fc7febaef commit_templater: teach elidable (or optional) commit
I think Option<Commit> is the simplest encoding of the log node.

The behavior of an Option type is closer to nullable types rather than the
Option in Rust. I don't think we would want to write opt.map(|x| x.f()) or
opt.unwrap().f(). We can of course add opt?.f() syntax, but it will be a short
for "if(opt, opt.f())"?
2024-03-24 10:32:15 +09:00
Austin Seipp
2afd341f7b cargo: run bulk cargo update
Studies show that children raised in households that run `cargo update`
regularly report greater self-esteem, recompile more often, have better
dependency hygiene than their peers, and are less likely to hit dependency hell,
run into vulnerable outdated code, or go back to C++.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I254001e554629b3665061238fe24cc9914a6aba0
2024-03-23 13:45:35 -05:00
Austin Seipp
44108ab3a3 cargo: downgrade gix to 0.61.0
The latest version `0.61.1` was yanked, and there hasn't been an update yet.

This should unblock the CI system.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I70d73ac297d7fc055d2d6551e581c6767b3db597
2024-03-23 13:45:35 -05:00
Simon Wollwage
63771d6e84 cli: add option to list only conflicted branches
As requested in #1471, I added a new flag for `jj branch list` to only show branches that are conflicted.

Adds a unit test to check for listing only conflicted branches and regenerates the cli output to incorporate the new flag.

Closes #1471

reformat
2024-03-23 22:04:14 +09:00
Benjamin Tan
3034dbba3f git-push: Display messages from remote
The implementation of sideband progress message printing is aligned with
Git's implementation. See
43072b4ca1/sideband.c (L178).

Closes #3236.
2024-03-23 20:17:04 +08:00
Benjamin Tan
2831459a95 ui: Remove &mut requirement for prompt functions 2024-03-23 20:17:04 +08:00
Yuya Nishihara
fad712811c templater: leverage TemplateProperty::map/and_then() helpers 2024-03-23 16:22:17 +09:00
Yuya Nishihara
a3d44485f4 templater: add helper methods to map property like Option/Result
These two are common when implementing methods. Fortunately, the
"return-position impl Trait in traits" feature is stabilized in Rust 1.75.0,
so we don't need another variant of TemplateFunction.
2024-03-23 16:22:17 +09:00
Ilya Grigoriev
02a04d0d37 test_conflicts and test_resolve_command: use indoc! to indent conflict markers in tests
Apart from (IMO) looking nicer, this will also sidestep the potential problem
that if the file contains actual jj conflict markers (`>>>>>>>` in the beginning
of a line, for example), jj would currently have trouble materializing and
subsequently parsing conflicts in the file if it actually became conflicted.

I'll demo this bug in either this or a subsequent PR. It's the kind of bug that
sounds serious in theory but might never cause a problem in practice.

After this PR, only `docs/tutorial.md` has a conflict marker that's not indented.
There's only one there, so hopefully it won't be too much of a pain to deal with.

I also indented other strings in `test_conflicts.rs`. IMO, this looks nice and
more consistent with the `insta::assert_snapshot` output. I didn't spend the
time to do the same for `test_resolve_command`.
2024-03-22 23:27:25 -07:00
Aleksey Kuznetsov
d8c84940d9 cli: avoid bad hint "Prefix the expression with 'all'..."
There is no point of showing the hint for non-existent revision.

Also appends ':' to the 'all' to make the hint more precise.

#2451
2024-03-23 10:05:18 +05:00
Yuya Nishihara
00285be7a7 formatter: use write!() or writeln!() thoroughly, remove .write_str()
One less Formatter API.
2024-03-23 10:43:38 +09:00
Aleksey Kuznetsov
011b20fdac changelog: fix a typo move than -> more than 2024-03-22 22:56:11 +05:00
dependabot[bot]
0fcb6f8ef0 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [gix](https://github.com/Byron/gitoxide).


Updates `gix` from 0.61.0 to 0.61.1
- [Release notes](https://github.com/Byron/gitoxide/releases)
- [Changelog](https://github.com/Byron/gitoxide/blob/main/CHANGELOG.md)
- [Commits](https://github.com/Byron/gitoxide/compare/gix-v0.61.0...gix-v0.61.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-22 11:48:53 -05:00
dependabot[bot]
c326ea7893 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.1 to 1.6.2
- [Release notes](https://github.com/embarkstudios/cargo-deny-action/releases)
- [Commits](64015a69ee...b01e7a8cfb)

---
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-22 11:48:37 -05:00
Yuya Nishihara
911cf4b8f6 templater: remove Context type from TemplateLanguage/Property
Now a compiled template doesn't have a static Context type internally. A
property is basically of "Fn() -> Result<O, _>" type, and a type-erased "self"
variable will be injected as needed.

Template<C> types will be refactored separately.
2024-03-22 11:51:15 +09:00
Yuya Nishihara
0fad9c9795 templater: remove now unused TemplatePropertyFn wrapper 2024-03-22 11:51:15 +09:00
Yuya Nishihara
cecae849aa templater: don't define TemplateLanguage::Context statically
In short, this enables compilation of template of e.g. Vec<Commit> type by
using CommitTemplateLanguage.

A Template<C> was originally compiled for a specific type C, and invoked as
"Fn(&C) -> _". It was simple and intuitive, but we had to define the context
type C statically. Things got even worse by extensions support because we had
to provide object-safe hook point for each context type C.

This patch basically removes the Context type from compiled templates. The
"self" variable is injected through RefCell<Option<C>> placeholder. A compiled
template knows its "self" type, but the type can be decided per instance, not
per TemplateLanguage type. A drawback is that the "self" variable will have to
be cloned one more time.

The Template<C> abstraction no longer makes sense, and will be split to inner
Template<()> implementations (which usually represent printable types) and the
outer Template<C>.
2024-03-22 11:51:15 +09:00
Yuya Nishihara
7b641c0236 templater: add Template<C> adapter that evaluates Template<()> with value of C
The idea is basically the same as list.map(|x| ...) template. It compiles the
inner template with a placeholder variable of type 'C', and evaluate it for
each instance variable by injecting the variable through RefCell.
2024-03-22 11:51:15 +09:00
Yuya Nishihara
017026148b generic_templater: clone &Context to Self_ property like other languages
This prepares for removal of TemplateLanguage::Context type. "C: Clone" trait
bounds looked messy, but they can be removed soon.
2024-03-22 11:51:15 +09:00
Yuya Nishihara
915e75efc0 generic_templater: remove &language argument from keyword functions
Because GenericTemplateLanguage doesn't support any global resources, it no
longer makes sense to pass the language instance around to 0-ary keyword
functions.
2024-03-22 11:51:15 +09:00
Yuya Nishihara
2916bbbec5 templater: allow use of wrap_<type>() functions without borrowing &language
These .wrap_<type>() functions aren't supposed to capture resources from the
language instance. It was convenient that wrap_() could be called without fully
spelling the language type, but doing that would introduce lifetime issue in
later patches.

I added type alias L to several places because the language type is usually
called L in generic code.
2024-03-22 11:51:15 +09:00
Anton Älgmyr
e2eb5bddf9 Make node symbols templatable in the graphs.
Adds config options
* templates.log_graph_node
* templates.log_graph_node_elided
* templates.op_log_graph_node
2024-03-21 17:41:31 +01:00
dependabot[bot]
9b1a8e2480 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [smallvec](https://github.com/servo/rust-smallvec).


Updates `smallvec` from 1.13.1 to 1.13.2
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.13.1...v1.13.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-21 11:18:39 -05:00
Steve Klabnik
e699e9da93 Fix link to my tutorial
2d62f22de1 reorganized some things, and so this link became broken
2024-03-20 14:56:28 -05:00
dependabot[bot]
ac3d1a87b2 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [git2](https://github.com/rust-lang/git2-rs) and [rustix](https://github.com/bytecodealliance/rustix).


Updates `git2` from 0.18.2 to 0.18.3
- [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-0.18.2...git2-0.18.3)

Updates `rustix` from 0.38.31 to 0.38.32
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.31...v0.38.32)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-20 12:46:23 -05:00
dploch
9380f9d529 rewrite: move handling of simplified ancestry into rebase_commit_with_options
It seems incorrect that `simplify_ancestor_merge` is ignored when it's part of the helper's input.
2024-03-20 11:57:54 -04:00
Martin von Zweigbergk
e51878f4fd cli: show timestamp in local timezone and without millis and offset
As discussed in #2900, the milliseconds are rarely useful, and it can
be confusing with different timezones because it makes harder to
compare timestamps.

I added an environment variable to control the timestamp in a
cross-platform way. I didn't document because it exists only for tests
(like `JJ_RANDOMNESS_SEED`).

Closes #2900
2024-03-20 07:54:08 -07:00
Ilya Grigoriev
4fbe6aecc9 clippy: remove some unused code beta clippy/rustc compain about
There are still some warnings from (seemingly) clippy bugs. Quoting
myself from Discord:

> PSA: the latest beta cargo clippy (from Rust 1.78) has some problems
> that affect jj: https://github.com/rust-lang/rust-clippy/issues/12467
> and https://github.com/rust-lang/rust-clippy/issues/12377.  You could
> disable clippy::assigning_clones and clippy::empty_docs as a workaround.
> VS Code can disable them in rust-analyzer, you can also use
> https://github.com/ericseppanen/cargo-cranky (you can put Cranky.toml in
> the per-user gitignore).
2024-03-19 18:33:29 -07:00
Chris Krycho
1ec6a8f92d Add @chriskrycho's YouTube series to the README 2024-03-19 10:42:14 -06:00
Matthew Davidson
e4053ead64 docs: Add missing "jj" to swap rebase example
`jj rebase -r C -d A; rebase -s B -d C` is missing the second jj.

Although it would be cool if jj had syntax to chain commands like this, so I could write a "swap" alias.
2024-03-19 05:58:52 -07:00
Martin von Zweigbergk
f865c1bc5d index: print a milder "Reindexing..." message on version mismatch
Closes #3323.
2024-03-18 13:50:14 -07:00