Commit graph

6010 commits

Author SHA1 Message Date
dploch
0cef90f4f4 examples: simplify commit templater example with Default 2024-04-26 10:55:34 -04:00
dploch
bad9e9e3d7 revset: convert commit and change prefix resolvers into partial symbol resolvers 2024-04-26 10:55:34 -04:00
dploch
7bdf2b3945 revset: homogenize the logic of various symbol resolution steps into a common trait 2024-04-26 10:55:34 -04:00
dploch
cf78532bd8 revset: add two new error variants to support extensions 2024-04-26 10:55:34 -04:00
Martin von Zweigbergk
d13be927a8 cli: add global --ignore-immutable
Closes #3576
2024-04-26 06:13:15 -07:00
Yuya Nishihara
c267f55809 templates: remove implicit self dependency from description_placeholder alias
Spotted while experimenting with "jj tag list -T". The description_placeholder
alias could be changed to function taking a Commit object, but I feel it's odd.
Conceptually, the placeholder could also be used in "op log" templates.
2024-04-26 16:56:35 +09:00
Yuya Nishihara
dbc7ad2d8e templates: extract common parts from commit_summary templates
If "branch"/"tag list" are migrate to templates, the added alias function
will be called from these templates.
2024-04-26 16:56:35 +09:00
Yuya Nishihara
2bd6983003 templates: reimplement builtin_change_id_with_hidden_and_divergent_info alias
This helps extract commit_summary template as an alias function.
2024-04-26 16:56:35 +09:00
Théo Daron
2f45a482a6 fixed usage of old "checkout" command in contributing docs 2024-04-25 09:11:52 -07:00
Yuya Nishihara
a63dbcc329 templater: include actual type name in error messages 2024-04-26 00:57:26 +09:00
Yuya Nishihara
5394f342ce templater: add type_name() method to tagged property types
Suppose we add binary comparison operators, we'll probably need an easy way to
get (lhs, rhs) property types to produce a meaningful error message.
2024-04-26 00:57:26 +09:00
Yuya Nishihara
5b769c5c9e fileset, revset, templater: add support for single-quoted raw string literals
Since fileset/revset/template expressions are specified as command-line
arguments, it's sometimes convenient to use single quotes instead of double
quotes. Various scripting languages parse single-quoted strings in various ways,
but I choose the TOML rule because it's simple and practically useful. TOML is
our config language, so copying the TOML syntax would be less surprising than
borrowing it from another language.

https://github.com/toml-lang/toml/issues/188
2024-04-25 11:14:33 +09:00
Yuya Nishihara
a74bf89df5 revset: reuse parse_symbol_rule_as_literal() to parse string symbol
For the same reason as the previous commit. Single-quoted string literal will
be handled there.
2024-04-25 11:14:33 +09:00
Yuya Nishihara
37bd966357 fileset: extract inner function that parses string-like literal
I'm going to add single-quoted string literal.
2024-04-25 11:14:33 +09:00
dependabot[bot]
ca02141ba9 github: bump actions/checkout in the github-dependencies group
Bumps the github-dependencies group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 4.1.3 to 4.1.4
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](1d96c772d1...0ad4b8fada)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 13:23:17 -05:00
Martin von Zweigbergk
3dad9d4a98 docs: make "Arch Linux" a subheading under "Linux"
I think this is how it was supposed to be. The "From Source" section
applies to non-Arch Linuxes too.
2024-04-24 09:22:51 -07:00
Rowan Walsh
16ffe9408c Fixes grammar issues in docs 2024-04-24 09:12:37 -07:00
Rowan Walsh
f185a838d7 Fixes typo in 'jj git init' args 2024-04-24 09:12:37 -07:00
Rowan Walsh
742c3f6fea Fixes minor typo in script error message 2024-04-24 09:12:37 -07:00
Rowan Walsh
1490c0a196 Fixes typo in docs 2024-04-24 09:12:37 -07:00
dependabot[bot]
8069d5ef32 github: bump actions/upload-artifact in the github-dependencies group
Bumps the github-dependencies group with 1 update: [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/upload-artifact` from 4.3.2 to 4.3.3
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](1746f4ab65...65462800fd)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 04:53:17 +00:00
Yuya Nishihara
528ccb318e fileset: fall back to bare pattern/string if no operator-like character found
While I like strict parsing, it's not uncommon that we have to deal with file
names containing spaces, and doubly-quoted strings such as '"Foo Bar"' look
ugly. So, this patch adds an exception that accepts top-level bare strings.
This parsing rule is specific to command arguments, and won't be enabled when
loading fileset aliases.
2024-04-24 12:02:07 +09:00
dependabot[bot]
988ca2b23d cargo: bump rustix in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [rustix](https://github.com/bytecodealliance/rustix).


Updates `rustix` from 0.38.33 to 0.38.34
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.33...v0.38.34)

---
updated-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-04-23 18:29:00 +02:00
dependabot[bot]
36e51a580d github: bump EmbarkStudios/cargo-deny-action
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.2 to 1.6.3
- [Release notes](https://github.com/embarkstudios/cargo-deny-action/releases)
- [Commits](b01e7a8cfb...3f4a782664)

---
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-04-22 17:35:52 -05:00
dependabot[bot]
bb9d96c0c0 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [rustix](https://github.com/bytecodealliance/rustix) and [thiserror](https://github.com/dtolnay/thiserror).


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

Updates `thiserror` from 1.0.58 to 1.0.59
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.58...1.0.59)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-22 16:00:13 +00:00
Martin von Zweigbergk
9d7ed54f8e git_backend: add a README to conflicted commits
When you use e.g. `git switch` to check out a conflicted commit,
you're going to end up with the `.jjconflicts-*` directories in your
working copy. It's probably not obvious what those mean. This patch
adds a README file to the root tree to try to explain to users what's
going on and how to recover.

The authoritative information about conflicts is stored in the
`jj:trees` commit header. The contents of conflicted commits is only
used for preventing GC. We can therefore add contents to the tree
without much consequence.
2024-04-22 06:22:54 -07:00
Benjamin Tan
e14ee8b563 rebase: do not simplify ancestor merges 2024-04-22 21:05:49 +08:00
Benjamin Tan
3ee35e70e9 rebase: modify tests to avoid a future ancestor merge with root commit
I will be updating `rebase -r` to avoid simplifying ancestor merges in a
subsequent commit, which will cause existing tests to fail for the Git
backend due to ancestor merges with the root commit.
2024-04-22 21:05:49 +08:00
Benjamin Tan
fb7c91ffa8 rebase: rewrite rebase_revision to use transform_descendants 2024-04-22 21:05:49 +08:00
Yuya Nishihara
9f4a7318c7 tests: compare git refs loaded from disk, not in-memory cache values
This addresses the test instability. The underlying problem still exists, but
it's unlikely to trigger user-facing issues because of that. A repo instance
won't be reused after gc() call.

Fixes #3537
2024-04-22 18:46:28 +09:00
Yuya Nishihara
527713a851 tests: fix potential mtime flakiness in git gc tests
Apparently, these gc() invocations rely on that the previous "git gc" packed
all refs so there are no loose refs to compare mtimes. If there were new (or
remaining) loose refs, mtime comparison could fail. I also added +1sec to
effectively turn off the keep_newer option, which isn't important in these
tests.
2024-04-22 18:46:28 +09:00
Evan Mesterhazy
f9a3021a7a Simplify calls to CommitRewriter::replace_parents()
Now that it takes `IntoIterator` the caller doesn't need to clone
the input `CommitIds`.
2024-04-21 23:31:17 -04:00
Evan Mesterhazy
2b0aa84c9d CommitRewriter::rewrite_parents(): Take IntoIterator instead of &[CommitId]
CommitIds are often manipulated by reference, so this makes the API more
flexible for cases where the caller doesn't already have a Vec or array of
owned CommitIds.

In many cases `rewrite_parents()` does not even need to clone the input
CommitIds.  This refactor allows the clone to be avoided if it's unnecessary.

There might be other APIs that would benefit from a similar change. In general,
it seems like there are a lot of places where we're writing
`&[commit_x.id().clone, commit_y.id().clone()]` and similiar.

- [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/flexibility.html#functions-minimize-assumptions-about-parameters-by-using-generics-c-generic)
2024-04-21 23:31:17 -04:00
Anton Älgmyr
484097c873 cli: Clean up template to use coalesce where relevant.
Basically, clean up instances of `if\(([^,]+), \1,`.
Also fix one annoying comma without a following space.
2024-04-21 20:37:34 +02:00
Evan Mesterhazy
a2c49abbbe Add short a -e alias for --edit to prev and next
I'm not sure if this was an intentional omission, but I think it would be
useful to have `-e` as a short flag for `--edit`. I don't usually edit commits,
but I do use `prev` and `next` with edit to navigate to a commit that I want to
squash. Often this is easier than typing `--from` and `--into` plus the change
IDs.

If people want to edit commits we shouldn't stand in their way.
2024-04-21 13:58:38 -04:00
Evan Mesterhazy
e0c53bcfc0 Rewrite rebasing in jj split using transform_descendants()
This is following on the rewrite for `parallelize`.

- https://github.com/martinvonz/jj/pull/3521

Since rebase_descendants from rebase.rs is no longer used outside of that file,
it can be made private again.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
6d2884317a Add checks for stderr and stdout to jj split tests
This would have caught a bug in https://github.com/martinvonz/jj/pull/3550
that otherwise might have slipped through.
2024-04-21 12:21:39 -04:00
Ilya Grigoriev
77eaf67f96 revsets.md: document the all: prefix modifier for revsets
While this is arguably not part of the revset language, this
is a likely place for a user to look.

See https://discord.com/channels/968932220549103686/968932220549103689/1228065431281995837
2024-04-20 14:12:26 -07:00
Evan Mesterhazy
0fb582ed8f Implement advance-branches for jj new 2024-04-20 10:26:04 -04:00
Evan Mesterhazy
3f0e4de64a Allow advance_branches tests to be parameterized
In a future commit these tests will run with both `jj commit` and `jj new` since
both will have the same semantics for advancing the branch pointer.

Parameterizing the tests allows us to run both variants without duplicating the
test bodies. Since the commit IDs are different when `jj describe` + `jj new`
is used instead of `jj commit`, this commit also drops the commit IDs from the
test snapshots. This is fine because the commit IDs are not important for these
tests.
2024-04-20 10:26:04 -04:00
Evan Mesterhazy
bbd9c7c7cb Implement advance-branches for jj commit
## Feature Description

If enabled in the user or repository settings, the local branches pointing to the
parents of the revision targeted by `jj commit` will be advanced to the newly
created commit. Support for `jj new` will be added in a future change.

This behavior can be enabled by default for all branches by setting
the following in the config.toml:

```
[experimental-advance-branches]
enabled-branches = ["glob:*"]
```

Specific branches can also be disabled:
```
[experimental-advance-branches]
enabled-branches = ["glob:*"]
disabled-branches = ["main"]
```

Branches that match a disabled pattern will not be advanced, even if they also
match an enabled pattern.

This implements feature request #2338.
2024-04-20 10:26:04 -04:00
Yuya Nishihara
cce1b9f00a templates: use "+" instead of "#" to denote immutable node in ascii graph
Maybe it's personal preference, but the hash sign looks bigger compared to
the normal "o" nodes, and is slanted. This makes immutable commits stand out
too much. I think "+" is closer to the diamond character used in the unicode
template.
2024-04-20 13:31:09 +09:00
Yuya Nishihara
556747ad8c templater: cache immutable revset fn globally
Since we have two separate "immutable" calls in the builtin node template, and
user might add a few more to their text template, it seems reasonable to cache
the containing_fn globally.
2024-04-20 11:35:37 +09:00
Martin von Zweigbergk
8bb92fa6fa working_copy: allow load_working_copy() to return error
It's reasonable for a `WorkingCopy` implementation to want to return
an error. `LocalWorkingCopyFactory` doesn't because it loads all data
lazily. The VFS-based one at Google wants to be able to return an
error, however.
2024-04-19 15:22:37 -07:00
Austin Seipp
f58e69f6ca cli: add another test for snapshot.max-new-file-size
This one just tests with a larger value and a human-readable string (10KB).

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: If9e5d62146b369d3a1b7efe4e56a1b6b4338c720
2024-04-19 13:03:24 -05:00
Austin Seipp
1d99ff6aef cli: improve snapshot.max-new-file-size error message
For new users this results in a significantly better error output, that
actually shows them how to solve the problem, and why it happened.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ide0c86fdfb40d66f970ceaef7b60a71392d2cd4b
2024-04-19 13:03:24 -05:00
Austin Seipp
493020c0a6 docs: add an entry for snapshot.max-new-file-size
This was not documented, for some reason.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I01a86a2d62b225c0175ed690fe9966ed22c92745
2024-04-19 13:03:24 -05:00
Austin Seipp
ddfdf5e357 cli: allow snapshot.max-new-file-size to be a raw u64
Previously, this command would work:

    jj --config-toml='snapshot.max-new-file-size="1"' st

And is equivalent to this:

    jj --config-toml='snapshot.max-new-file-size="1B"' st

But this would not work, despite looking like it should:

    jj --config-toml='snapshot.max-new-file-size=1' st

This is extremely confusing for users.

This config value is deserialized via serde; and while the `HumanByteSize`
struct allegedly implemented Serde's `visit_u64` method, it was not called by
the deserialize visitor. Strangely, adding an `visit_i64` method *did* work, but
then requires handling of overflow, etc. This is likely because TOML integers
are naturally specified in `i64`.

Instead, just don't bother with any of that; implement a `TryFrom<String>`
instance for `HumanByteSize` that uses `u64::from_str` to try parsing the string
immediately; *then* fall back to `parse_human_byte_size` if that doesn't work.
This not only fixes the behavior but, IMO, is much simpler to reason about; we
get our `Deserialize` instance for free from the `TryFrom` instance.

Finally, this adjusts the test for `max-new-file-size` to now use a raw integer
literal, to ensure it doesn't regress. (There are already in-crate tests for
parsing the human readable strings.)

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I8dafa2358d039ad1c07e9a512c1d10fed5845738
2024-04-19 13:03:24 -05:00
dependabot[bot]
3eb5fe2485 github: bump actions/checkout in the github-dependencies group
Bumps the github-dependencies group with 1 update: [actions/checkout](https://github.com/actions/checkout).


Updates `actions/checkout` from 4.1.2 to 4.1.3
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](9bb56186c3...1d96c772d1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-19 18:16:42 +02:00
Philip Metzger
3ac61a4984 docs: Replace some mentions of jj co with jj new.
Also move some sentences away from "check out" to "create a new revision ...",
even if it isn't the phrasing we want.

Fixes #3487
2024-04-19 18:03:22 +02:00