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

4806 commits

Author SHA1 Message Date
Yuya Nishihara
b7c7b19eb8 view: migrate in-memory structure to per-remote branches map
There's a subtle behavior change. Unlike the original remove_remote_branch(),
remote_views entry is not discarded when the branches map becomes empty. The
reasoning here is that the remote view can be added/removed when the remote
is added/removed respectively, though that's not implemented yet. Since the
serialized data cannot represent an empty remote, such view may generate
non-unique content hash.
2023-10-14 22:20:00 +09:00
Yuya Nishihara
3ec3cac90b revset: use op_store::View type to resolve branches()/remote_branches()
These functions depend heavily on the underlying data structure, and I haven't
decided abstract View API to access to per-remote data types. Let's use the
underlying data type for now.
2023-10-14 22:20:00 +09:00
Yuya Nishihara
0160eaefd9 view: add function that converts branches to/from per-remote view-like data 2023-10-14 22:20:00 +09:00
Yuya Nishihara
2b78275e22 view: add per-remote view types and iterator that reconstructs BranchTarget
I'm planning to add support for untracked remote branches, and under that
model, there will be many remote branches without local counterparts. That's
the main reason why remote branches are grouped by remote, not by branch name.

The added helper functions will be used by simple_op_store and view.
2023-10-14 22:20:00 +09:00
Austin Seipp
220292ad84 workspace: workspace forget multiple names at once
Summary: This allows `workspace forget` to forget multiple workspaces in a
single action; it now behaves more consistently with other verbs like `abandon`
which can take multiple revisions at one time.

There's some hoop-jumping involved to ensure the oplog transaction description
looks nice, but as they say: small conveniences cost a lot.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Id91da269f87b145010c870b7dc043748
2023-10-14 07:38:00 -05:00
dependabot[bot]
ec1015943a github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [DeterminateSystems/nix-installer-action](https://github.com/determinatesystems/nix-installer-action).

- [Release notes](https://github.com/determinatesystems/nix-installer-action/releases)
- [Commits](07ebb8d274...bc7b192574)

---
updated-dependencies:
- dependency-name: DeterminateSystems/nix-installer-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-13 12:00:57 -05:00
dependabot[bot]
378d527bd2 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [rustix](https://github.com/bytecodealliance/rustix) and [serde](https://github.com/serde-rs/serde).


Updates `rustix` from 0.38.18 to 0.38.19
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.18...v0.38.19)

Updates `serde` from 1.0.188 to 1.0.189
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](https://github.com/serde-rs/serde/compare/v1.0.188...v1.0.189)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-13 10:45:44 -05:00
Yuya Nishihara
198dfa5cbe view: extract remove_remote() from git module
This will be just self.data.remote_views.remove(remote_name), so I'm not gonna
refactor the implementation at this point.
2023-10-13 18:12:45 +09:00
Yuya Nishihara
1d3c830e85 view: rewrite get_branch() callers in tests, remove the method
get_branch() would need to reconstruct the remote_targets map if we migrate
the underlying data structure to per-remote views. Let's remove the method as
it is only used in tests.
2023-10-13 18:12:45 +09:00
Yuya Nishihara
3fb0a3b926 view: add has_branch(name), replace some of get_branch(name) callers
get_branch(name) will be removed soon.
2023-10-13 18:12:45 +09:00
Yuya Nishihara
d840610bad view: rewrite set_branch() callers in tests, remove the method
I'm going to reorganize the underlying data structure, and set_branch() won't
be as simple as it is now.
2023-10-13 18:12:45 +09:00
Benjamin Saunders
7e7735e6b5 cli: fix SSH key discovery on Windows
$HOME isn't set here, but `dirs` has suitable magic for us already.
2023-10-12 23:47:08 -07:00
Martin von Zweigbergk
0aa5f1ae10 working copy: rename working_copy_path() to just path()
It seems pretty clear from the context. Turns out we only use the
function in a test case. Maybe we don't even need it. It's easy to
provide it, though.
2023-10-12 16:10:38 -07:00
Martin von Zweigbergk
9e43207911 working copy: don't expose TreeStateError in LocalWorkingCopy API
The `TreeStateError` type is specific to the current local-disk
working-copy backend, so it should not be part of the generic
working-copy interface I'm trying to create.
2023-10-12 16:10:38 -07:00
Martin von Zweigbergk
0e09d53ce6 working copy: make some reset errors less specific
Same reasoning as the previous commits.
2023-10-12 16:10:38 -07:00
Martin von Zweigbergk
645be615b4 working copy: make some snapshot errors less specific
Same reasoning as the previous commit.
2023-10-12 16:10:38 -07:00
Martin von Zweigbergk
324c40d4c5 working copy: make some checkout errors less specific
I think some of the errors variants in `CheckoutError` are too
specific to the local-disk implementation. Let's merge them and make
them less specific, so it's easier to define a reasonable trait for
the working copy.
2023-10-12 16:10:38 -07:00
Martin von Zweigbergk
33d27ed09f working copy: start defining a working copy trait
This just extracts a trait for the trivial bits to start with.
2023-10-12 16:10:38 -07:00
Yuya Nishihara
69a30b47af refs: migrate classify_branch_push_action() to local/remote targets pair 2023-10-12 16:50:09 +09:00
Yuya Nishihara
68545a62b8 cli: inline find_branches_targeting() in a call site
We no longer have multiple callers, and the function signature looks rather
noisy.
2023-10-12 16:50:09 +09:00
Yuya Nishihara
420bf79217 view: add method to iterate local/remote pairs of certain remote
This is common operation, and we don't need a map of all remote targets
to calculate push action.
2023-10-12 16:50:09 +09:00
Austin Seipp
37f11c7d4e workspace: add '--revision' argument to 'workspace add'
Summary: Workspaces are most useful to test different versions (commits) of
the tree within the same repository, but in many cases you want to check out a
specific commit within a workspace.

Make that trivial with a `--revision` option which will be used as the basis
for the new workspace. If no `-r` option is given, then the previous behavior
applies: the workspace is created with a working copy commit created on top of
the current working copy commit's parent.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I23549efe29bc23fb9f75437b6023c237
2023-10-11 22:02:24 -05:00
Martin von Zweigbergk
ebec82ee0c cli: allow overwriting non-scalar with jj config set
Before this patch, it was an error to run `jj config set --user foo
'[1]'` twice. But it's only been broken since the previous commit
because '[1]' was interpreted as a string before then.
2023-10-11 07:40:08 -07:00
Martin von Zweigbergk
f654801c20 cli: accept TOML arrays and tables to jj config set 2023-10-11 07:40:08 -07:00
Yuya Nishihara
679a591a22 repo: rewrite diffing of named refs to compare each targets pair
As I'm going to split branches into per-remote map, .get_branch(name) will need
to gather remote branches by name to construct remote_targets map. Let's instead
iterate local/remote branches separately. I also migrated diffing of the other
kinds of refs to filter out unchanged entries upfront.
2023-10-11 19:24:24 +09:00
Yuya Nishihara
e6f49552d0 ui: remove write*() and flush() methods
This will force us to think about the output stream to print to. Typically
we'll use stdout_formatter() for data, and stderr() for the other messages.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
7a3e72415c cli: send status messages to stderr, specify stdout/stderr explicitly
Many of &mut UI can be changed to immutable borrows, but I'm not gonna
update them in this patch.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
58acc1d111 tests: replace jj_cmd_success() involving mutation to allow stderr output 2023-10-11 19:24:01 +09:00
Yuya Nishihara
98bf0836bf ui: move UiOutput definition close to stdout/stderr wrappers
UiStdout/Stderr wrappers are declared at top because they have macro. Let's
move UiOutput closer as it is quite similar to these wrappers.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
0e22a42a41 ui: add thin stdout/stderr wrappers to be used with write!() macros
I'm going to replace all ui.write*() callers with these wrappers. Status
messages will be sent to stderr.
2023-10-11 19:24:01 +09:00
Yuya Nishihara
95de0c8002 cli: add missing newline to debug watchman outputs 2023-10-11 19:24:01 +09:00
Yuya Nishihara
f397349db4 cli: make non-colocated repo also preserve git_refs on op undo/restore
Now we have a separate map for "git" tracking remote, we can always preserve
the last imported/exported git_refs. The option to restore git-tracking refs
has been removed. Perhaps, --what can be reorganized as --local and --remote
<NAME>.
2023-10-11 06:18:36 +09:00
Yuya Nishihara
6bc19bfa95 git: remove workaround for "branch forget && git fetch"
As we now diff incoming git refs against our known remote branches, the problem
described in the comment no longer occurs. test_branch_forget_fetched_branch()
passes, and the inline comments in the test are still valid.
2023-10-11 06:18:36 +09:00
Yuya Nishihara
7d78ef60d1 git: rewrite diffing of exportable branches to not re-lookup targets by name
As we need to build a set of all branch names anyway, we can also put old/new
targets there. InvalidGitName is moved to caller since the diff function no
longer converts RefName to "refs/" string.
2023-10-11 06:18:36 +09:00
Yuya Nishihara
6f5cc2fd32 git: on export_refs(), copy already-exported local branches to "git" remote
This ensures that our view of the "git" remote is updated even if the last
imported/exported git_refs were out of sync because of "op restore".
2023-10-11 06:18:36 +09:00
Yuya Nishihara
aaf1bbcb4a git: use HashMap to track failed branches internally in export_refs()
This helps to filter out unexported refs in the next commit.
2023-10-11 06:18:36 +09:00
Martin von Zweigbergk
4d2402831a cli: describe what workspaces are in jj workspace help 2023-10-10 16:08:20 -05:00
dependabot[bot]
4b84d3874a cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [insta](https://github.com/mitsuhiko/insta) and [regex](https://github.com/rust-lang/regex).


Updates `insta` from 1.33.0 to 1.34.0
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.33.0...1.34.0)

Updates `regex` from 1.9.6 to 1.10.0
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.9.6...1.10.0)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
- dependency-name: regex
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-10 16:12:46 +00:00
dependabot[bot]
73fc37a135 cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [libc](https://github.com/rust-lang/libc), [rustix](https://github.com/bytecodealliance/rustix) and [tokio](https://github.com/tokio-rs/tokio).


Updates `libc` from 0.2.148 to 0.2.149
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.148...0.2.149)

Updates `rustix` from 0.38.17 to 0.38.18
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.17...v0.38.18)

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

---
updated-dependencies:
- dependency-name: libc
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: rustix
  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-10-10 12:52:58 +00:00
dependabot[bot]
24abbc1368 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [ossf/scorecard-action](https://github.com/ossf/scorecard-action).

- [Release notes](https://github.com/ossf/scorecard-action/releases)
- [Changelog](https://github.com/ossf/scorecard-action/blob/main/RELEASE.md)
- [Commits](08b4669551...483ef80eb9)

---
updated-dependencies:
- dependency-name: ossf/scorecard-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-09 09:18:35 -07:00
Yuya Nishihara
e160970b79 git: migrate import_refs() to diffing git_refs and known remote refs 2023-10-09 22:31:20 +09:00
Yuya Nishihara
36ee24379b git: build separate lists of git/remote refs to be imported
The idea is that the "remote" refs could have been "op restore"-d whereas
view.git_refs() will never be. The next commit will update known_remote_refs
to be constructed from the current remote branches.

Instead of building these lists in a single loop, we could load new git_refs
to the view first, and then build diffs of the remote refs. I considered that,
but I feel it would be a bit awkward to update refs before importing commits
to the view.

The "remote" refs are stored in BTreeMap since merging order should be stable.
2023-10-09 22:31:20 +09:00
Yuya Nishihara
5bd2ab76f4 git: check reserved remote name while diffing
As I'm going to add separate lists of changed git_refs/remote_refs, it'll
become a bit unclear which one we should check for reserved remotes. The
diff might also be reorganized as a list of (remote, name, kind, old_target,
new_target) where remote == "git" means the git-tracking branch. In this
data structure, the notion of reserved remote name would be lost.
2023-10-09 22:31:20 +09:00
Yuya Nishihara
f062df6da7 git: rename local variables in import_refs()
I'm going to add separate lists of changes for git_refs and remote refs, and
the current changed_git_refs will be the list for the remote refs.
2023-10-09 22:31:20 +09:00
Martin von Zweigbergk
1b9a3e27e0 merged_tree: read before/after trees concurrently
I'm going to rewrite `TreeDiffIterator` to fetch one level (depth) of
the tree at a time and concurrently. One step towards that is to
convert the iterator to a `Stream`. I'd like to do that by making the
current `Iterator` implementation call the new `Stream`
implementation. However, we can't call `futures::executor::block_on()`
on a future that itself calls `futures::executor::block_on()` (as
`Store::read_tree()` does), so the first step is to bubble up the
async-ness a bit. This patch does that by fetching both sides of the
diff concurrently. That should give close to a 2x speedup on
high-latency backends. (It doesn't help with our backend at Google,
however, because we have a daemon process that does some speculative
prefetching that usually downloads the child trees anyway.)
2023-10-08 23:36:49 -07:00
Martin von Zweigbergk
815cf9bf07 merge: implement Default and Extend on MergeBuilder
`futures::stream::Stream::collect()` requires a collection that
implements `Default` and `Extend`, and I would like to to be able to
collect a stream of trees.
2023-10-08 23:36:49 -07:00
Martin von Zweigbergk
5174489959 backend: make read functions async
The commit backend at Google is cloud-based (and so are the other
backends); it reads and writes commits from/to a server, which stores
them in a database. That makes latency much higher than for disk-based
backends. To reduce the latency, we have a local daemon process that
caches and prefetches objects. There are still many cases where
latency is high, such as when diffing two uncached commits. We can
improve that by changing some of our (jj's) algorithms to read many
objects concurrently from the backend. In the case of tree-diffing, we
can fetch one level (depth) of the tree at a time. There are several
ways of doing that:

 * Make the backend methods `async`
 * Use many threads for reading from the backend
 * Add backend methods for batch reading

I don't think we typically need CPU parallelism, so it's wasteful to
have hundreds of threads running in order to fetch hundreds of objects
in parallel (especially when using a synchronous backend like the Git
backend). Batching would work well for the tree-diffing case, but it's
not as composable as `async`. For example, if we wanted to fetch some
commits at the same time as we were doing a diff, it's hard to see how
to do that with batching. Using async seems like our best bet.

I didn't make the backend interface's write functions async because
writes are already async with the daemon we have at Google. That
daemon will hash the object and immediately return, and then send the
object to the server in the background. I think any cloud-based
solution will need a similar daemon process. However, we may need to
reconsider this if/when jj gets used on a server with a custom backend
that writes directly to a database (i.e. no async daemon in between).

I've tried to measure the performance impact. That's the largest
difference I've been able to measure was on `jj diff
--ignore-working-copy -s --from v5.0 --to v6.0` in the Linux repo,
which increases from 749 ms to 773 ms (3.3%). In most cases I've
tested, there's no measurable difference. I've tried diffing from the
root commit, as well as `jj --ignore-working-copy log --no-graph -r
'::v3.0 & author(torvalds)' -T 'commit_id ++ "\n"'` (to test a
commit-heavy load).
2023-10-08 23:36:49 -07:00
Martin von Zweigbergk
bd5eef9c5e git_backend: rename some store variables backend in tests
This is to avoid confusion with instances of the `Store` type.
2023-10-08 23:36:49 -07:00
Ilya Grigoriev
f81c724822 README.md: "quite" -> "fairly" feature complete
This makes a one-word change suggested in
https://discord.com/channels/968932220549103686/968932220549103689/1160641833349689464

Thanks to @solson for the idea.
2023-10-08 21:29:04 -07:00
Austin Seipp
71a3045032 nix: merge (now redundant) flake check with normal build
Summary: Since 066032b6e6 was merged, the `nix flake check` build no longer
overrides the 'cargo test' profile explicitly, to save disk space. The CI seems
to be in a better spot. This will stem the tide for a while hopefully.

However, with that change in place, the `nix flake check` build was
essentially a redundant, nearly-identical copy of a normal `nix build` with no
differentiating features, except: `RUST_BACKTRACE` is set to 1.

Delete all this code, and remove it from the CI matrix, and instead just export
`RUST_BACKTRACE` on the `checkPhase` of the normal `nix build` instead, which is
functionally equivalent.

Also does some minor, no-functional-change touchups to `flake.nix` while I was
there (whitespace, etc.)

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I87336b16e2a0b973343ecbde8ffd7b8f
2023-10-07 22:20:20 -07:00