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

5693 commits

Author SHA1 Message Date
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
dependabot[bot]
965e0e8957 cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [async-trait](https://github.com/dtolnay/async-trait), [syn](https://github.com/dtolnay/syn) and [tracing-chrome](https://github.com/thoren-d/tracing-chrome).


Updates `async-trait` from 0.1.77 to 0.1.78
- [Release notes](https://github.com/dtolnay/async-trait/releases)
- [Commits](https://github.com/dtolnay/async-trait/compare/0.1.77...0.1.78)

Updates `syn` from 2.0.52 to 2.0.53
- [Release notes](https://github.com/dtolnay/syn/releases)
- [Commits](https://github.com/dtolnay/syn/compare/2.0.52...2.0.53)

Updates `tracing-chrome` from 0.7.1 to 0.7.2
- [Release notes](https://github.com/thoren-d/tracing-chrome/releases)
- [Commits](https://github.com/thoren-d/tracing-chrome/compare/v0.7.1...v0.7.2)

---
updated-dependencies:
- dependency-name: async-trait
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: syn
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: tracing-chrome
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-18 09:26:53 -07:00
Yuya Nishihara
7355559f55 cargo: bump gix to 0.61.0
Fixes #3301
2024-03-18 23:52:42 +09:00
Yuya Nishihara
54bb3b4114 cli: remove last use of resolve_multiple_nonempty_revsets() from cmd_run() 2024-03-18 18:23:03 +09:00
Tom Ward
933150d819 cli: allow colors in form #rrggbb
Changes the formatter to accept not only existing color names (such as "red" or
"green") but also those in the form #rrggbb, where rr, gg, and bb are two-digit
hexadecimal numbers. This allows much finer control over colors used.
2024-03-18 08:03:31 +00:00
Yuya Nishihara
3ffe3d9ed8 git-push: warn unmatched revision set per "-rREVISIONS" argument
If -rREVISIONS is specified, the user would probably expect the set contains
at least one local branch.
2024-03-18 09:32:43 +09:00
Yuya Nishihara
8de3932bda git-push: narrow search space of -rREVISIONS 2024-03-18 09:32:43 +09:00
Yuya Nishihara
bc7a42a00e git-push: do not error out on empty revision set
"-r REVISIONS" here specifies the search space of the branches to push, and
warned if no branches are found in that space. I don't think an empty set
should be an error, but a warning for consistency. The warning message will be
improved by the subsequent patches.
2024-03-18 09:32:43 +09:00
Yuya Nishihara
02c0927734 git-push: extract function that looks up branches by revisions
cmd_git_push() is large. Let's split it up.
2024-03-18 09:32:43 +09:00
Yuya Nishihara
4e9d35d049 cli: make "abandon" not fail with empty revset
This command belongs to the same category as "duplicate".

We might want a plural version of resolve_revset(), but I'm not sure whether
it should return Vec<Commit> or Revset. Let's revisit it later when we get
more callers.
2024-03-18 09:32:35 +09:00
Yuya Nishihara
f678ba08cf cli: make "duplicate none()" exit successfully
Per discussion in
https://github.com/martinvonz/jj/pull/3311#discussion_r1527171058

We can also rely on the default "Nothing changed." handling, but it seems
better to state the input set is empty.
2024-03-18 09:32:35 +09:00
Yuya Nishihara
f46b738f6e cli: include root() in the heads node of the immutable set expression
It helps to optimize '~immutable()' to '(immutable_heads() | root())..'.
2024-03-17 14:50:48 +09:00
Yuya Nishihara
50363419fb revset: substitute '~(::x)' to 'x..'
Suppose we have an alias 'immutable()' = '::immutable_heads()', user can
express (visible) mutable set as '~immutable()'. 'immutable_heads()..' can
terminate early, but a generic difference 'all() & ~immutable()' can't.
2024-03-17 14:50:48 +09:00
Yuya Nishihara
9207314173 revset: add substitution rule for "::x & ~(::y-)"
Suppose the generation value is usually small, it should be faster to do
bounded range look up first 'y-', then walk ancestors with the unwanted set
'y-..x'.
2024-03-17 14:50:48 +09:00
Yuya Nishihara
39a460a077 revset: extract helper function that substitutes "::x & ~(::y)"
I'm going to add a similar substitution rule for "~(::y)".
2024-03-17 14:50:48 +09:00
Yuya Nishihara
3f9ac78215 revset: update legacy range syntax in comment 2024-03-17 14:50:48 +09:00
Yuya Nishihara
a777cfe98e index: remove topo_order() which is no longer used
The same thing can be achieved by evaluating the input as a revset.
2024-03-17 11:44:41 +09:00
Yuya Nishihara
b2194d7d2b cli: use present tense "duplicate" in transaction description 2024-03-17 11:44:41 +09:00