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

3994 commits

Author SHA1 Message Date
Martin von Zweigbergk
c43a3067eb revset: pass all context arguments to parse() via an object
`revset::parse()` already has a `RevsetWorkspaceContext` argument, so
I think it makes sense to put that and the other context arguments
into a larger `RevsetParseContext` object.
2023-08-20 21:30:06 -07:00
Martin von Zweigbergk
5f3df4aaea revset: resolve "@" symbol's workspace id earlier (while parsing)
We resolve file paths into repo-relative paths while parsing the
revset expression, so I think it's consistent to also resolve which
workspace "@" refers to while parsing it. That means we won't need the
workspace context both while parsing and while resolving symbols.

In order to break things like `author("martinvonz@")` (thanks to @yuja
for catching this), I also changed the parsing of working-copy
expressions so they are not allowed to be
quoted. `author(martinvonz@)` will therefore be an error now. That
seems like a small improvement anyway, since we have recently talked
about making `root` and `[workspace]@` not parsed as other symbols.
2023-08-20 17:57:18 -07:00
Martin von Zweigbergk
f9b3211d58 revset: drop an unnecessary return keyword 2023-08-20 17:57:18 -07:00
Preston Van Loon
ac5d8eb784 Add UTC format for timestamp formats. Thanks to @rauljordan for these changes.
Add tests for new UTC timestamp format

Add documentation for timestamp utc

Update CHANGELOG.md
2023-08-20 17:24:09 -05:00
Oscar Bonilla
5bd726f77d Add jj diffs --stat option 2023-08-19 23:49:16 -07:00
Martin von Zweigbergk
c3d9ba9ca9 cli: let custom binaries add extra default configs
Custom binaries will often want to provide e.g. additional command
aliases, additional revset aliases, custom colors, etc. This adds a
mechanism for them to do that.
2023-08-19 06:48:29 -07:00
Yuya Nishihara
b6794ca04a revset: rename literal:"" prefix to exact:""
Per discussion in #2107, I believe "exact" is preferred.

We can also change the default to exact match, but it doesn't always make
sense. Exact match would be useful for branches(), but not for description().
We could define default per predicate function, but I'm pretty sure I cannot
remember which one is which.
2023-08-19 11:33:57 +09:00
Yuya Nishihara
ebdc22a65e revset: add support for explicit substring:"..." prefix
git-branchless calls it a substring, so let's do the same.

FWIW, I copied literal:_ from Mercurial, but it's exact:_ in git-branchless.
I have no idea which one is preferred. Since this feature isn't released, we
can freely change it if exact:_ makes more sense.

https://github.com/arxanas/git-branchless/wiki/Reference:-Revsets#patterns
2023-08-19 10:32:59 +09:00
Emily Fox
2062abdc9d templates: replace empty name and email strings with placeholders
New placeholders say "(no name availalbe)" and "(no email available)",
because empty strings aren't _necessarily_ a configuration issue.
2023-08-18 17:22:59 -05:00
Emily Fox
3f8ac2198d commits: use empty strings instead of placeholders for missing name or email
This commit replaces the functions `UserSettings::user_name_placeholder()`` and
`UserSettings::user_email_placeholder()` with `const` `&str`s to emphasize that
the placeholder strings must not be changed to support commits without
names or email addresses made before this change.
2023-08-18 17:22:59 -05:00
Emily Fox
2c88da02b4 git: teach backend to handle empty name and email strings 2023-08-18 17:22:59 -05:00
Emily Fox
95dcb9a224 docs: use nextest with insta in example commands 2023-08-18 17:13:45 -05:00
Emily Fox
fde6e43aa8 CHANGELOG: more precise description of mine() 2023-08-18 17:13:45 -05:00
Alexander Potashev
7837ec1f62 docs: Fix missed paths from src->cli/src move 2023-08-18 14:35:19 +02:00
Vamsi Avula
956bd02977 templates: add placeholder label for no description 2023-08-18 11:14:45 +05:30
Benjamin Saunders
4bd05e8285 tests: hack around broken lint 2023-08-17 19:29:38 -07:00
Benjamin Saunders
417035cb20 tests: validate snapshot.max-new-file-size behavior 2023-08-17 19:29:38 -07:00
Benjamin Saunders
54f1d310c4 testutils: propagate snapshot errors 2023-08-17 19:29:38 -07:00
Benjamin Saunders
6c4b8a7383 settings: support human-readable byte sizes for max-new-file-size 2023-08-17 19:29:38 -07:00
Ben Saunders
351e7feef5 working_copy: don't snapshot new files larger than 1MiB by default 2023-08-17 19:29:38 -07:00
dependabot[bot]
32d622863a cargo: bump the cargo-dependencies group with 4 updates
Bumps the cargo-dependencies group with 4 updates: [anyhow](https://github.com/dtolnay/anyhow), [clap](https://github.com/clap-rs/clap), [thiserror](https://github.com/dtolnay/thiserror) and [tokio](https://github.com/tokio-rs/tokio).


Updates `anyhow` from 1.0.74 to 1.0.75
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.74...1.0.75)

Updates `clap` from 4.3.21 to 4.3.22
- [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/v4.3.21...v4.3.22)

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

Updates `tokio` from 1.31.0 to 1.32.0
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.31.0...tokio-1.32.0)

---
updated-dependencies:
- dependency-name: anyhow
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: clap
  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
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-17 15:37:47 +00:00
Martin von Zweigbergk
7ad2270c05 working_copy: pass Merge, not ConflictId, to write_conflict()
This is another small step towards making this code work with
tree-level conflicts.
2023-08-16 22:59:12 -07:00
Martin von Zweigbergk
1571541214 working_copy: combine blocks for updating added/modified paths
There's a lot of duplication between the blocks of code for updating
modified and added paths. This commit combines them.
2023-08-16 22:59:12 -07:00
Martin von Zweigbergk
01a6578ada working_copy: move up special case for exec-bit-only change
This is also just to make the next change simpler.
2023-08-16 22:59:12 -07:00
Martin von Zweigbergk
8ded5ae03b working_copy: convert Diff into Options for matching
This just a little refactoring to make the next step of sharing code
between `Modified` and `Added` simpler.
2023-08-16 22:59:12 -07:00
Martin von Zweigbergk
5b8c1e013f working_copy: add a helper for getting the current tree
The code for getting the current tree object was repeated a few times
over. I'm going to soon make it return a `MergedTree` and I don't want
to repeat that code (it's more complicated than the current code).
2023-08-16 22:59:12 -07:00
Ilya Grigoriev
863f1760f9 log template: make root commit green instead of bright green
Bright green really pops on my screen, and I don't think there is a reason
for the root commit to be attention-grabbing.

This follows up on https://github.com/martinvonz/jj/pull/2084.
2023-08-16 17:26:36 -07:00
Yuya Nishihara
4c3265477b revset: remove unused MineWithoutUserName error variant
user_email is always available to the revset parser.
2023-08-17 07:49:24 +09:00
Yuya Nishihara
810d4eeef2 revset: use exact match for mine() 2023-08-17 07:42:12 +09:00
Yuya Nishihara
7da7356ef7 revset: add fast path to look up branches by literal name 2023-08-17 07:42:12 +09:00
Yuya Nishihara
81f1ae38b3 revset: add literal:"string" pattern syntax
The syntax is slightly different from Mercurial. In Mercurial, a pattern must
be quoted like "<kind>:<needle>". In JJ, <kind> is a separate parsing node, and
it must not appear in a quoted string. This allows us to report unknown prefix
as an error.

There's another subtle behavior difference. In Mercurial, branch(unknown) is
an error, whereas our branches(literal:unknown) is resolved to an empty set.
I think erroring out doesn't make sense for JJ since branches() by default
performs substring matching, so its behavior is more like a filter.

The parser abuses DAG range syntax for now. It can be rewritten once we remove
the deprecated x:y range syntax.
2023-08-17 07:42:12 +09:00
Yuya Nishihara
5b3c73dfc4 revset: insert StringPattern enum to add support for other kind of matching 2023-08-17 07:42:12 +09:00
Benjamin Brittain
313670d3c2 Fixed missing quote in "jj config set" help 2023-08-16 14:57:48 -04:00
Emily Fox
9ba9ecd708 revset: add function mine() 2023-08-16 11:00:14 -05:00
dependabot[bot]
4dde810cd0 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [serde_json](https://github.com/serde-rs/json).

- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.104...v1.0.105)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-16 15:44:06 +00:00
Alexander Potashev
2d81cf9156 Fix build when bstr is also imported.
Add type annotation to `vec` to avoid the following build error if you
additionally import `bstr`:

```
~/jj> cargo test
   Compiling jj-lib v0.8.0 (/home/aspotashev/jj/lib)
warning: unused import: `bstr`
  --> lib/src/default_index_store.rs:30:5
   |
30 | use bstr;
   |     ^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0282]: type annotations needed
   --> lib/src/default_index_store.rs:564:14
    |
564 |             .as_mut()
    |              ^^^^^^
565 |             .write_u32::<LittleEndian>(parent_overflow.len() as u32)
    |              --------- type must be known at this point
    |
help: try using a fully qualified path to specify the expected types
    |
563 |         <[u8] as AsMut<T>>::as_mut(&mut buf[parent_overflow_offset..parent_overflow_offset + 4])
    |         +++++++++++++++++++++++++++++++                                                        ~

For more information about this error, try `rustc --explain E0282`.
warning: `jj-lib` (lib) generated 1 warning
error: could not compile `jj-lib` (lib) due to previous error; 1 warning emitted
```

Reason to support `bstr` being imported: in a Bazel environment where
crates are imported with certain features enabled, jj-lib may pull in
bstr as part of the following dependency chain:
  jj-lib -> insta -> similar -> bstr.
2023-08-15 22:47:56 +02:00
Martin von Zweigbergk
873634a80e cli: when splitting change without description, skip it on second part
One use case for `jj split` is when creating a new commit from some of
the changes in the working copy. If there's no description on the
working-copy commit in that case, it seems better to not ask the user
to provide one when they're splitting the commit either.
2023-08-15 10:12:12 -07:00
dependabot[bot]
2685d4a64a cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [anyhow](https://github.com/dtolnay/anyhow) and [thiserror](https://github.com/dtolnay/thiserror).


Updates `anyhow` from 1.0.72 to 1.0.74
- [Release notes](https://github.com/dtolnay/anyhow/releases)
- [Commits](https://github.com/dtolnay/anyhow/compare/1.0.72...1.0.74)

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

---
updated-dependencies:
- dependency-name: anyhow
  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>
2023-08-15 09:13:33 -07:00
Vamsi Avula
3869b7c2ac cli: refactor default_description to UserSettings 2023-08-15 21:25:50 +05:30
Vamsi Avula
72d6e20a08 cli: replace CommandHelper with UserSettings where sufficient 2023-08-15 21:25:50 +05:30
Vamsi Avula
088cc787b8 cli: respect ui.default-description in split as well
#2062 missed this. Partially addresses #1354.
2023-08-15 21:25:50 +05:30
Anton Bulakh
dc6e1d7dee cli: hide irrelevant information about root commit in default log templates
I've extracted the `builtin_log_root` template for users to customize the
default templates without fully overriding them, for example I would remove
the change_id/commit_id for myself - and we discussed in Discord that leaving
those makes sense for the user to be reminded/teached that the root commit has
a change id made from z's.
2023-08-15 18:54:59 +03:00
Anton Bulakh
82923afcc5 templater: add root keyword
Similar to other boolean flags, such as "working_copy" or "empty".
We could test something like
`"0000000000000000000000000000000000000000".contains(commit_id)`
like I did for myself, but first of all this is ugly, and secondly the root
commit id is not guaranteed to be 40 zeroes as custom backend implementations
could have some other root.
2023-08-15 18:54:59 +03:00
Martin von Zweigbergk
9138bb5517 working_copy: use MergedTree for current tree when snapshotting
We now have all the pieces in place to read the current tree as a
`MergedTree` when snapshotting the working copy. For now, it's still
always a legacy tree. We'll need to update the working copy state file
to support storing multiple trees before we can create a `MergedTree`
with multiple sides here.
2023-08-15 07:56:55 -07:00
Martin von Zweigbergk
c126e75b2b working_copy: make write_path_to_store() work with merged values
For tree-level conflicts, we're going to be getting
`Merge<Option<TreeValue>>` from the current tree and produce a new
such value if contents changes on disk. This commit gets us a little
closer to that by passing in a value of that type into
`write_path_to_store()`.

This seems to have a small but measurable performance
impact. Snapshotting the working copy in the git repo with all files
`touch`ed went from 2.36 s to 2.43 s (3%). I think that's okay,
especially since most files' mtimes rarely change, and we only pay the
price when it has.
2023-08-15 07:56:55 -07:00
Martin von Zweigbergk
1d55a404cc merged_tree: add path_value() 2023-08-15 07:56:55 -07:00
Martin von Zweigbergk
2238c87da1 merged_tree: import create_tree() in tests to reduce line wrapping 2023-08-15 07:56:55 -07:00
Martin von Zweigbergk
3f97a6da78 working_copy: avoid adding unchanged values to tree builder
If the value at a path hasn't changed, there's no need to send it over
the channel and have the receiver add it to `TreeBuilder`. I couldn't
measure any performance impact.

Now we should no longer send `TreeValue::Conflict` variants over the
tree entry channel.
2023-08-14 23:32:52 -07:00
Martin von Zweigbergk
eacdad3ebd working_copy: move writing of conflicts to receiver side of channel
When writing tree-level conflicts, we're going to be writing multiple
tree (maybe using some new `MergedTreeBuilder`), so we'll need the
full `Merge<Option<TreeValue>>` object. This gets us closer to that by
sending such objects over the channel and having the receiver write
the conflict object.

Note that we still sometimes send `TreeValue::Conflict` variants over
the channel. That only happens if they're unchanged.
2023-08-14 23:32:52 -07:00
Martin von Zweigbergk
03f00bbf30 working_copy: return Merge<Option<TreeValue>> over channel
When writing tree-level conflicts, we won't pass `TreeValue::Conflict`
over the `tree_entries` channel. Instead, we're going to pass possibly
unresolved `Merge<Option<TreeValue>>` instances. This commit prepares
for that by changing the type even though we'll only pass
`Merge::normal()` over the channel at this point.

I did this partly to see what the performance impact is. I tested that
by touching all files in the git.git repo to force the trees (and
files) to be rewritten. There was no measurable impact at all
(best-of-10 time was 2.44 s before and 2.40 s after, but I assume that
was a fluke).
2023-08-14 23:32:52 -07:00