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

961 commits

Author SHA1 Message Date
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
Martin von Zweigbergk
780d7fb59c backend: rename NormalFile to just File
There are no "non-normal" files, so "normal" is not needed. We have
symlinks and conflicts, but they are not files, so I think just "file"
is unambiguous.

I left `testutils::write_normal_file()` because there it's used to
mean "not executable file" (there's also a `write_executable_file()`).

I left `working_copy::FileType::Normal` since renaming `Normal` there
to `File` would also suggest we should rename `FileType`, and I don't
know what would be a better name for that type.
2022-11-14 23:36:43 -08:00
Martin von Zweigbergk
2cf99d1e35 cargo: upgrade chrono to version 0.4.23 2022-11-14 13:18:36 -08:00
Martin von Zweigbergk
9502d84872 operations: make hostname and username configurable
We currently get the hostname and username from the `whoami` crate. We
do that in lib crate, without giving the caller a way to override
them. That seems wrong since it might be used in a server and
performing operations on behalf of some other user. This commit makes
the hostname and username configurable, so the calling crate can pass
them in. If they have not been passed in, we still default to the
values from the `whoami` crate.
2022-11-14 10:02:04 -08:00
Martin von Zweigbergk
5b10c9aa0a local_backend: switch from Protobuf to Thrift
This migrates the native backend from Protobuf to Thrift since
Google's Protobuf team does let us import jj into Google's monorepo if
it uses a third-party Protobuf library.

Since the native backend is not supported, I didn't write any
migration code for it.

We can't remove `lib/src/protos/store.proto` yet, because it's also
used by the Git backend (only the `predecessors` and `change_id`
fields).
2022-11-13 21:55:41 -08:00
Martin von Zweigbergk
43cfb98f78 transaction: store full OperationMetadata instead of parts
We already store the description, start time, and tags. It's easier to
store the whole struct.
2022-11-13 19:06:11 -08:00
Martin von Zweigbergk
4aa4b838b4 op_store: move logic out of OperationMetadata
`OperationMetadata` is a data type used in the interface. It seems
wrong for it to know where to get data from.
2022-11-13 19:06:11 -08:00
Martin von Zweigbergk
9f0ae4586b repo: pass in OperationMetadata to OpHeadsStore::init()
Just a little refactoring to prepare for being able to get the
username and hostname from config.
2022-11-13 19:06:11 -08:00
Yuya Nishihara
e0fe3ffd7d simple_op_store: create temporary Thrift store in .jj/repo directory
Otherwise rename() would fail if /tmp is on different device.
2022-11-14 11:13:41 +09:00
Martin von Zweigbergk
26a554818a git: update our record of Git branches on export
When we export branches to Git, we didn't update our own record of
Git's refs. This frequently led to spurious conflicts in these refs
(e.g. #463). This is typically what happened:

 1. Import a branch pointing to commit A from Git
 2. Modify the branch in jj to point to commit B
 3. Export the branch to Git
 4. Update the branch in Git to point to commit C
 5. Import refs from Git

In step 3, we forgot to update our record of the branch in the repo
view's `git_refs` field. That led to the import in step 5 to think
that the branch moved from A to C in Git, which conflicts with the
internal branch target of B.

This commit fixes the bug by updating the refs in the `MutableRepo`.

Closes #463.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
9cf8a3684b git: make export_refs() act on mutable repo
When exporting refs, we should update our record of Git's refs. For
that, we need a mutable repo.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
5eba305844 git: when exporting, skip conflicted branches 2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
759ddd1e60 git: on initial export, export all branches
As I said in the previous patch, I don't know why I made the initial
export to Git a no-op. Exporting everything makes more sense to
(current-)me. It will make it slightly easier to skip exporting
conflicted branches (#463). It also lets us remove a `jj export` call
from `test_templater.rs`.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
2172887876 git: don't detach head if the ref already points to the right place
The first time we export to Git, we don't actually export
anything. That's a little weird and I don't know why I did it that
way. It seems more natural to export the current state. I'd like to
change it to do that. However, that currently means we'll detach the
current HEAD if it points to any of the branches we export. This patch
restructures the code a bit and skips the detach step if the target
branch already points to the right commit.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
f3f41cc2cc git: write view object - not operation ID - to disk on export
We could write the view object to the operation store instead, but
then we would need to make sure we don't GC it (once we add support
for GC of the operation store).
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
10343876fa cli: include message from GitExportError to user
I'm going to add other error variants for when we fail to read/write
to disk, and I don't think we need to have a custom message for each
in the CLI crate. It's easier to pass along the message from the lib
crate.

(`ConflictedBranch`, on the other hand, is an expected error so I
think we should continue to let let the CLI crate define the error
message for it.)
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
80aaf6c0e0 git: pass old and new view - not full repo - into export function
In order to fix #463, I'm going to make us export to Git a little
earlier, before finishing the transation. That means we won't have an
operation yet, but we don't need that anyway.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
979b46b006 tests: test exporting to Git after deleting a branch 2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
ebfe0a4823 tests: add test for export of conflicted branches
To fix #463, I think we want to skip conflicted branches when we
export instead of erroring out. It seems we didn't have test case for
the current behavior, so let's add one.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
18a25a7c2b tests: demonstrate spurious branch conflict after git export
This is a test case for #463. It's not exactly the same case, but I'm
confident that the root cause is the same (that the
`.jj/repo/git_export_operation_id` doesn't include the git refs we
just updated).
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
ec46ae11ad tests: extract function for getting git Oid from jj Commit 2022-11-13 15:06:10 -08:00