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

1999 commits

Author SHA1 Message Date
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]
6ae6b5d1a5 cargo: bump clap from 4.0.23 to 4.0.24
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.23 to 4.0.24.
- [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.0.23...v4.0.24)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-15 08:47:38 -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
13d7594e85 changelog: fix typo ("he" instead of "the") 2022-11-14 10:12:53 -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
dependabot[bot]
12b2218a04 cargo: bump clap from 4.0.22 to 4.0.23
Bumps [clap](https://github.com/clap-rs/clap) from 4.0.22 to 4.0.23.
- [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.0.22...v4.0.23)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-14 09:34:40 -08:00
dependabot[bot]
4d5ec02051 cargo: bump predicates from 2.1.2 to 2.1.3
Bumps [predicates](https://github.com/assert-rs/predicates-rs) from 2.1.2 to 2.1.3.
- [Release notes](https://github.com/assert-rs/predicates-rs/releases)
- [Changelog](https://github.com/assert-rs/predicates-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/assert-rs/predicates-rs/compare/v2.1.2...v2.1.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-14 09:34:17 -08:00
dependabot[bot]
1c76ea198f github: bump github/codeql-action from 2.1.31 to 2.1.32
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.31 to 2.1.32.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](c3b6fce4ee...4238421316)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-14 09:33:48 -08:00
Martin von Zweigbergk
50ba571527 log: move commit ID off to the right
We have talked about showing the commit ID only for divergent changes
because it's generally easier to work with the change ID, and it's
less likely to result in a divergent change. However, it's useful to
have the commit ID available for pasting into e.g. a commit message or
the GitHub UI. To try to steer users towards using the change ID, this
commit moves the commit ID off to the right in the log output.

I put it just after the "divergent" field, because that makes it close
to how I imagine it would look if we decided to hide the commit ID
except for divergent changes. I was thinking that could be rendered as
"divergent (abc123)". So if we add config to hide the commit ID, then
it would be rendered almost the same for divergent commits (just with
the added parentheses). It would also make sense to replace the
"divergent" field by a question mark on the change ID, since change
IDs basically behave like branches. If we do that, then the placement
of the commit ID I picked in this commit does not make sense.
2022-11-14 07:49:52 -08:00
Martin von Zweigbergk
f86455a452 demos: allow running without ui.allow-init-native = true
We need to use the native backend here because of #27, but we
shouldn't require the user running the script to have it in their
config.
2022-11-14 00:25:24 -08:00
Martin von Zweigbergk
31368551b7 tutorial: add a few missing "(no description set)" 2022-11-14 00:24:10 -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
2ae2010007 cleanup: replace an assert! by assert_eq!
As pointed out by IntelliJ.
2022-11-13 20:24:24 -08:00
Martin von Zweigbergk
4ec2092e57 templates: allow using string in if-condition; use in default template
Given how easy this was, I can't believe I didn't make the change
sooner.

I haven't updated the screenshots in the readme because I plan to make
some further changes to the default template. I'll update them after
those changes.
2022-11-13 20:24:24 -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
e084956858 test_git_push: create Git repo using jj commands
Since we don't have the `git` binary available in the test
environment, it's just easier to use `jj` commands to create Git
repos.
2022-11-13 15:29:48 -08: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
f40c8d86a1 tests: add more tests of working copy colocated with Git
We had very little testing of the colocated case, so let's add a bit
more before I start working on this code in coming patches. This
includes a test for #463.
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
Martin von Zweigbergk
eb89f6b6ca tests: consistently import create_random_tree()
These calls often appear in expressions long enough that not having to
qualify it means that we can sometimes avoid wrapping a line. I
noticed because IntelliJ told me that `test_git.rs` had some
unnecessary qualificiations (the function was already imported there).
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
4ee261717e simple_op_store: replace Protobuf by Thrift
As mentioned in the previous commit, we need to remove the Protobuf
dependency in order to be allowed to import jj into Google's
repo. This commit makes `SimpleOpStore` store its data using Thrift
instead of Protobufs. It also adds automatic upgrade of existing
repos. The upgrade process took 18 s in my repo, which has 22k
operations. The upgraded storage uses practically the same amount of
space. `jj op log` (the full outut) in my repo slowed down from 1.2 s
to 3.4 s. Luckily that's an uncommon operation. I couldn't measure any
difference in `jj status` (loading a single operation).
2022-11-13 11:39:33 -08:00
Martin von Zweigbergk
8acb54b26e op_store: extract current Protobuf-based implementation to separate file
In order to allow building jj inside of Google, our Protobuf team
doesn't want to us to use a Google-unsupported implementation. Since
there is no supported implementation in Rust, we have to migrate off
of Protobufs. I'm starting with the operation store. This commit moves
the current implementation to a separate file so it can easily be
disabled by a Caargo feature.
2022-11-13 11:39:33 -08:00
Benjamin Saunders
c3bfe72754 local_backend: use ContentHash rather than hashing protos
Insulates identifiers from the unstable serialized form.
2022-11-12 21:40:36 -08:00
Benjamin Saunders
2447dfeed8 simple_op_store: hash view/operation data directly
Decouples view/operation IDs from serialized forms, which are not
necessarily stable. Not breaking as these IDs are persistent, never
recomputed or used for integrity checking.
2022-11-12 21:40:36 -08:00
Martin von Zweigbergk
92f6571b31 cli: use "hint" style for hint about using --git-repo=. 2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
7ce8138794 cli: use separate hint for errors from jj branch 2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
698bba387f cli: separate out hint in untrack message 2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
6a15cc02bf cli: print hints using "hint" style, not "error" style
Several lines of red text can be overwhelming, and makes it harder to
tell the hint from the error. Let's separate the hint from the error
instead. This matches what hg does. Having the hints separated out
also means that we could have a single config to turn them off.
2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
2a17bb76e9 cli: add factory function for CommandError::UserError
I want to add a separate field for a hint, so that can be printed in a
different color (than red). Having a factory function is useful then,
since most call sites don't want to pass a hint. Also, by using a
factory function instead of using the constructor directly means that
we can accept `&str` arguments instead of forcing the caller to
convert a string literal to `String`.
2022-11-12 17:58:22 -08:00
Yuya Nishihara
eb790760a2 repo: simplify unsafe cast of view reference 2022-11-12 01:03:48 +09:00
Yuya Nishihara
2c042cee75 repo: extract unsafe view handling bits to separate struct
This should help us reason about the safety implication. New inner module
is added to encapsulate unsafe access.

DirtyCell provides .with_ref(callback) instead of .borrow(). This isn't
strictly needed, but should clarify the intent of the temporary reference.
This also allows us to rewrite DirtyCell without unsafe code, if needed,
by leveraging OnceCell<T> x RefCell<Option<T>> pair.
2022-11-12 01:03:48 +09:00