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

981 commits

Author SHA1 Message Date
Yuya Nishihara
7fbd7b48e5 revset: highlight whole function expression on substitution failed
The error may be caused by arguments passed in to the alias function.
2022-11-29 04:17:12 +09:00
Yuya Nishihara
70292f79b7 revset: implement function alias expansion
Function parameters are processed as local symbols while substituting
alias expression. This isn't as efficient as Mercurial which caches
a tree of fully-expanded function template, but that wouldn't matter in
practice.
2022-11-29 04:17:12 +09:00
Martin von Zweigbergk
d8feed9be4 copyright: change from "Google LLC" to "The Jujutsu Authors"
Let's acknowledge everyone's contributions by replacing "Google LLC"
in the copyright header by "The Jujutsu Authors". If I understand
correctly, it won't have any legal effect, but maybe it still helps
reduce concerns from contributors (though I haven't heard any
concerns).

Google employees can read about Google's policy at
go/releasing/contributions#copyright.
2022-11-28 06:05:45 -10:00
dependabot[bot]
a7ff8d5ee3 cargo: bump insta from 1.21.1 to 1.21.2
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.21.1 to 1.21.2.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.21.1...1.21.2)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-28 05:29:03 -10:00
Yuya Nishihara
e40c041384 revset: merge AmbiguousChange/CommitIdPrefix error into one
Follows up c5ed3e1477. Now change/commit ids are resolved at the same
precedence, which means there are at least three types of ambiguity.
I don't think we would need to discriminate these.
2022-11-28 22:49:07 +09:00
Yuya Nishihara
c5ed3e1477 revset: for short hash, look up both commit and change ids to disambiguate
Because the use of the change id is recommended, any operation should abort
if a valid change id happens to match a commit id. We still try the commit
id lookup first as the change id lookup is more costly.

Ambiguous change/commit id is reported as AmbiguousCommitIdPrefix for now.
Maybe we can merge AmbiguousCommit/ChangeIdPrefix errors into one?

Closes #799
2022-11-28 17:30:53 +09:00
Yuya Nishihara
1fa0392a3e revset: wrap internal symbol resolution result with Option
Option<T> or Result<Option<T>, _> is easier to pattern match than testing
RevsetError::NoSuchRevision.
2022-11-28 17:30:53 +09:00
Benjamin Saunders
e1152c5846 git: revert change to SSH agent detection
84b924946f switched to requiring both
SSH_AUTH_SOCK and SSH_AGENT_PID for an agent to be used. This doesn't
seem to be a typical situation, so perhaps it was not intended.
2022-11-27 18:53:18 -08:00
Yuya Nishihara
11ee2f22c4 revset: implement simple symbol alias expansion
Since syntactic information like symbol or function name is lost after
parse(), alias substitution is inserted to the middle of the post-parsing
stage, not after the whole RevsetExpression tree is built. This is the main
difference from Mercurial. Mercurial also caches parsed aliases, but I don't
think that would have a measurable impact.
2022-11-27 20:12:22 +09:00
Yuya Nishihara
5df25cd834 revset: add origin field to RevsetParseError to chain alias errors
This could be embedded in a variant of RevsetParseErrorKind, but I want to
keep the enum comparable.
2022-11-27 20:12:22 +09:00
Yuya Nishihara
7632466cc0 revset: add table of symbol aliases and pass around parse functions
The CLI will load aliases from config, insert them one by one, and warn if
declaration part is invalid. That's why RevsetAliasesMap is a public struct
and needs to be instantiated by the caller.
2022-11-27 20:12:22 +09:00
Yuya Nishihara
f0b1221749 revset: pack parsing state into struct
I'll add aliases map, substitution stack (to detect recursion), and locals
(for function aliases) there. Fortunately, we can avoid shared mutables
so a copyable struct should be good.

parse_function_argument_to_string() doesn't need a workspace_ctx, but there
should be no reason to explicitly nullify it either.
2022-11-27 20:12:22 +09:00
Ruben Slabbert
01817e4321 feature: support relative timestamps as a config option 2022-11-27 08:35:17 +10:00
Martin von Zweigbergk
a90ef20976 git: on export, delete deleted refs before adding added refs
To reduce conflicts between branches like `main` and `main/sub`, it's
better to first delete refs in git that have been deleted in jj, and
then add/update refs that have been added/updated in jj.
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
4a03b94d65 git: on export, skip failed refs instead of failing whole export
Since we now write a (partial) view object of the exported branches to
disk (since 7904474320), we can safely skip exporting some
branches. We already skip conflicted branches. This commit makes us
also skip branches that we fail to write to the backing Git repo,
instead of failing the whole operation (after possibly updating some
Git refs).

I made the `export_refs()` function return the branches that
failed. We should probably make that a struct later and have a
separate field for branches that we skipped due to conflicts.

Closes #493.
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
8139a84b22 git: remove stale comment about first export being a no-op
This should have been part of commit 759ddd1e60.
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
0dbbd4266f git: update exported_view after updating in Git repo
When skipping branches we fail to update in the backing Git repo, we
must also skip updating the `exported_view` object, so we don't trick
ourselves into thinking the branch was already updated in the Git repo
on the next export.
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
a09763f340 git: in export code, work with branch names (not ref names) a bit longer
I'm going to make the export skip branches that we fail to update in
the Git repo. For that, we need to know the branch name while
interacting with the `git2::Repository` object. This little
refactoring prepares for that.
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
dbe5615260 git: update mostly incorrect comment in export function
The comment says that we collect the changes to make before making
them, in order to reduce the risk of making some changes before
failing. However, there is nothing in the code that collects changes
that can fail, and it's all doing comparisons in memory, so it should
be very fast. It's been like that since I added it in 47b3abd0f7. We
still need to preserve the structure to avoid mutating `mut_repo`
while iterating over branches, however, so I just updated the comment.
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
6a2f295ae4 git: add test for exporting refs that fail
This adds a test for attempting to export both a branch called `main`
and one called `main/sub` (#493), as well as for exporting a branch
with an empty string as name (reported directly to me by @lkorinth).
2022-11-26 06:05:29 -10:00
Martin von Zweigbergk
2a87815006 cleanup: remove a few unnecessary borrows, as reported by Clippy 2022-11-26 06:05:29 -10:00
Ruben Slabbert
84b924946f feature: add verbose logging for clone/fetch command 2022-11-26 10:58:00 +10:00
dependabot[bot]
68e9559caa cargo: bump pest_derive from 2.4.1 to 2.5.0
Bumps [pest_derive](https://github.com/pest-parser/pest) from 2.4.1 to 2.5.0.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.4.1...v2.5.0)

---
updated-dependencies:
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-25 06:09:37 -10:00
Ilya Grigoriev
0b528eb587 Fix some cargo +nightly clippy warnings 2022-11-24 20:29:17 -08:00
Yuya Nishihara
ce3397c2cb revset: combine operator parsing steps
I'm thinking of adding alias expansion at this stage, and it would be a bit
tedious to pass around mutable context by function parameter. So let's reduce
the number of the intermediate functions.

This also produces a better error message.
2022-11-25 11:01:15 +09:00
Yuya Nishihara
78e34d2f81 revset: migrate operator parsing to PrattParser 2022-11-25 11:01:15 +09:00
Yuya Nishihara
5491b5581f revset: decouple prefix/infix/postfix range operators
This unblocks the use of PrattParser, which builds an operator map keyed
solely by Rule, not by (Rule, prefix/infix/postfix) pair.
2022-11-25 11:01:15 +09:00
Yuya Nishihara
f8aa6b1deb revset: simplify range expression rule by grouping operators 2022-11-25 11:01:15 +09:00
Martin von Zweigbergk
802e21bf25 operations: allow overriding timestamps for tests
It would be nice to be able to use snapshot testing and not have to
parse the output of `jj op log`. This patch lets us do that by
providing a new environment variable and config for overriding the
timestamps. Unlike `operation.hostname` and `operation.username`,
these are only meant for tests.
2022-11-24 16:00:20 -10:00
Martin von Zweigbergk
8d7a9e729b tests: set test hostname and username for operation log
This makes the tests more hermetic, even though I don't think the
default values (taken from `whoami`) can break any tests (then we
would have already seen them break). Now we just need to make the
operation log's timestamps predictable and then we can start using
operation IDs in snapshot tests.
2022-11-24 16:00:20 -10:00
dependabot[bot]
90ce94e262 cargo: bump pest from 2.4.1 to 2.5.0
Bumps [pest](https://github.com/pest-parser/pest) from 2.4.1 to 2.5.0.
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.4.1...v2.5.0)

---
updated-dependencies:
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-24 05:34:57 -10:00
dependabot[bot]
20c7514649 cargo: bump serde_json from 1.0.88 to 1.0.89
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.88 to 1.0.89.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.88...v1.0.89)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-23 21:45:41 -10:00
dependabot[bot]
9b25d8df63 cargo: bump zstd from 0.11.2+zstd.1.5.2 to 0.12.0+zstd.1.5.2
Bumps [zstd](https://github.com/gyscos/zstd-rs) from 0.11.2+zstd.1.5.2 to 0.12.0+zstd.1.5.2.
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/commits)

---
updated-dependencies:
- dependency-name: zstd
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-23 21:29:45 -10:00
Ruben Slabbert
f0e4615e61 feature: add verbose flag and tracing library 2022-11-24 16:35:14 +10:00
Waleed Khan
94815a7cb5 log: warn if the provided path looks like a revset 2022-11-21 16:42:48 -08:00
dependabot[bot]
70182fbf7a cargo: bump bytes from 1.2.1 to 1.3.0
Bumps [bytes](https://github.com/tokio-rs/bytes) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/tokio-rs/bytes/releases)
- [Changelog](https://github.com/tokio-rs/bytes/blob/master/CHANGELOG.md)
- [Commits](https://github.com/tokio-rs/bytes/commits)

---
updated-dependencies:
- dependency-name: bytes
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-21 06:09:15 -10:00
Yuya Nishihara
a5297c0082 revset: add comment about subtle optimization issue regarding hidden commits
Per the discussion in #764.
2022-11-20 22:01:19 +09:00
Ruben Slabbert
68b77d123d feature: support git credential helpers 2022-11-19 22:06:27 -08:00
Yuya Nishihara
84efed420f revset: allow empty string literal "" 2022-11-20 13:11:28 +09:00
dependabot[bot]
928da6e363 cargo: bump serde_json from 1.0.87 to 1.0.88
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.87 to 1.0.88.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.87...v1.0.88)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-18 08:21:52 -08:00
dependabot[bot]
ec23c5a0be cargo: bump digest from 0.10.5 to 0.10.6
Bumps [digest](https://github.com/RustCrypto/traits) from 0.10.5 to 0.10.6.
- [Release notes](https://github.com/RustCrypto/traits/releases)
- [Commits](https://github.com/RustCrypto/traits/compare/digest-v0.10.5...digest-v0.10.6)

---
updated-dependencies:
- dependency-name: digest
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-17 07:57:06 -08:00
Yuya Nishihara
13bb53e839 revset: give higher precedence to intersection/difference operators
Just like hg revsets and major programming languages.
2022-11-17 01:11:08 +09:00
Yuya Nishihara
a90c9960ba revset: leverage PrattParser to parse infix (or set) expression
Apparently, this is new feature introduced in pest 2.4.0. It allows us to
easily enforce operator precedence. I think the whole expression post-parsing
can be migrated to PrattParser, but let's start small. We might want to
add a weird rule to the range_expression layer in future.

https://github.com/pest-parser/pest/releases/tag/v2.4.0
https://docs.rs/pest/latest/pest/pratt_parser/struct.PrattParser.html#example
2022-11-17 01:11:08 +09:00
Yuya Nishihara
1717690a64 revset: leverage SOI/EOI markers to detect incomplete parser input
The error message is still a bit cryptic, but I don't think it's worse than
the original "incomplete parse" error.

https://pest.rs/book/grammars/syntax.html#start-and-end-of-input
2022-11-17 01:11:08 +09:00
Yuya Nishihara
a81ebeb85e revset: add empty() predicate to find commits with no file change
The expression 'x ~ empty()' is identical to 'x & file(".")', but more
intuitive.

Note that 'x ~ empty()' is slower than 'x & file(".")' since the negative
intersection isn't optimized right now. I think that can be handled as
follows: 'x ~ filter(f)' -> 'x & filter(!f)' -> 'filter(!f, x)'
2022-11-16 08:50:33 +09:00
Yuya Nishihara
230ac043ff revset: extract helper function that tests diff from parent revision 2022-11-16 08:50:33 +09:00
Yuya Nishihara
c7145a2ed9 revset: unify constructors of RevsetExpression::Filter
Since filter predicates no longer take an optional candidates argument,
these .with_<predicate>() constructors aren't useful anymore.
2022-11-16 08:50:33 +09:00
Yuya Nishihara
19a3fb7d6c revset: flatten match arms of description|author|committer predicates
Since most of the code duplicates has been extracted to helper functions,
nested match statement looks more verbose.
2022-11-16 08:50:33 +09:00
dependabot[bot]
18feef3775 cargo: bump insta from 1.21.0 to 1.21.1
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.21.0 to 1.21.1.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/commits/1.21.1)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-15 08:47:56 -08:00
dependabot[bot]
7cec2afa58 cargo: bump uuid from 1.2.1 to 1.2.2
Bumps [uuid](https://github.com/uuid-rs/uuid) from 1.2.1 to 1.2.2.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/1.2.1...1.2.2)

---
updated-dependencies:
- dependency-name: uuid
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-15 08:47:13 -08:00