Commit graph

5289 commits

Author SHA1 Message Date
Jonathan Tan
0bc1341fd0 revset: add count_estimate() to Revset trait
The count() function in this trait is used by "jj branch" to determine
(and then report) how many commits a certain branch is ahead/behind
another branch. This is currently implemented by walking all commits
in the revset, counting how many were encountered. But this could be
improved: if the number is large, it is probably sufficient to report
"at least N" (instead of walking all the way), and this does not scale
well to jj backends that may not have all commits present locally (which
may prefer to return an estimate, rather than access the network).

Therefore, add a function that is explicitly documented to be O(1)
and that can return a range of values if the backend so chooses.

Also remove count(), as it is not immediately obvious that it is an
expensive call, and callers that are willing to pay the cost can obtain
the exact same functionality through iter().count() anyway. (In this
commit, all users of count() are migrated to iter().count() to preserve
all existing functionality; they will be migrated to count_estimate() in
a subsequent commit.)

"branch" needed to be updated due to this change. Although jj
is currently only available in English, I have attempted to keep
user-visible text from being assembled piece by piece, so that if we
later decide to translate jj into other languages, things will be easier
for translators.
2024-01-22 15:07:00 -08:00
Jonathan Tan
08da40bc82 branch: refactor ahead/behind message
A subsequent commit will teach more variants of ahead/behind messages,
so refactor the existing code to avoid code duplication and a future
combinatorial explosion.
2024-01-22 15:07:00 -08:00
Daniel Ploch
22117171bd changelog: update changelog for next/prev changes 2024-01-22 13:58:45 -08:00
Daniel Ploch
32b982e507 next: support prompting for ambiguous commit targets
Resolves part of issue #2126
2024-01-22 13:58:45 -08:00
Daniel Ploch
deaea0732a testing: allow testing of commands that expect stdin 2024-01-22 13:58:45 -08:00
Daniel Ploch
b4b1a21e70 next: fix branching tests to actually test ambiguous targets 2024-01-22 13:58:45 -08:00
Daniel Ploch
f3edc75c81 ui: add helpers for prompting from a set of values
Prompts are barely used in the CLI currently but they are very useful in extensions with more complex workflows.
2024-01-22 13:58:45 -08:00
Daniel Ploch
5448a473ca ui: handle EOF on prompts 2024-01-22 13:58:45 -08:00
Daehyeok Mun
ad05a8750a Renaming \'BranchSubCommand\' and \'ConfigSubCommand\' 2024-01-22 10:12:00 -08:00
Daehyeok Mun
02f94653e6 Implement tag command. 2024-01-22 09:23:18 -08:00
dependabot[bot]
7f4f983e9e cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [regex](https://github.com/rust-lang/regex).


Updates `regex` from 1.10.2 to 1.10.3
- [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.10.2...1.10.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 16:02:04 +00:00
dependabot[bot]
97965339fa github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [EmbarkStudios/cargo-deny-action](https://github.com/embarkstudios/cargo-deny-action).


Updates `EmbarkStudios/cargo-deny-action` from 1.5.5 to 1.5.9
- [Release notes](https://github.com/embarkstudios/cargo-deny-action/releases)
- [Commits](1e59595bed...c9a2a63163)

---
updated-dependencies:
- dependency-name: EmbarkStudios/cargo-deny-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 07:56:38 -08:00
Austin Seipp
c8271f7617 nix: use mold linker on Linux
Summary: Pure QOL improvement, not that this was too awful as it stood. But this
ultimately makes all builds faster, effectively for free; on my Linux machine,
debug link time for jj-cli goes from 3s to 1s.

This was originally submitted as part of #1864, and backed out as part of #1982,
because the default `mold` package did not have the proper "wrapper script"
that allowed it to find the right external libraries. Using the `mold-wrapped`
package however fixes this.

On top of that, let's go ahead and make `mold` the default linker in the Nix
package/flake as well; this should improve the `nix build` speed since a lot of
tests need to be linked.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-01-21 23:23:54 -06:00
Martin von Zweigbergk
fc2b595098 git-comparison: explain why equivalent of git stash is not needed
Someone felt that our "Not needed" sounded dismissive. This patch
tries to clarify that it's the *command* (not the use case) we
consider not needed.
2024-01-21 21:13:19 -08:00
Ilya Grigoriev
0e817f7576 docs contributing.md: document using mold linker with nextest
On my machine, this halves the time taken by `cargo insta test --workspace
--test-runner nextest`.

I don't believe there would be a worthwhile improvement when not
using `nextest`. I also documented how to tell whether using `mold`
is worthwhile.

I was reminded of this by https://github.com/martinvonz/jj/pull/2858.
2024-01-21 19:28:37 -08:00
Austin Seipp
0af1a15162 cli: move RepoBranchName(Pattern) to crate::cli_utils
Needed in another upcoming diff, as Gerrit needs to parse remote names for
pushing refs.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-01-20 17:55:45 -06:00
Austin Seipp
bd110307ff cli: move some git utilities to new crate::git_utils
Gerrit also needs to be able to push low-level refs into upstream remotes, just
like `jj git push` does. Doing so requires providing callbacks e.g. for various
password entry mechanisms, which was private to the `git` command module.

Pull these out to a new module `git_utils` so we can reuse it across the two
call sites.

This also moves a few other strictly Git-related functions into `git_utils`
as well, just for the sake of consistency.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-01-20 15:58:37 -06:00
Martin von Zweigbergk
ed3c95cde6 docs: clarify that while named branches are not needed, they are supported
The "No need for branch names" can be interpreted as implying that we
don't support named branches, which is of course not true. Try to
clarify it.
2024-01-20 08:33:28 -08:00
Austin Seipp
8f05007759 cargo: run cargo update
A version of smallvec was yanked from crates.io, causing
failures like the one in #2848. This should fix that.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I02f8ec4d0dcdc7014caae89def27cf250dc846bd
2024-01-19 12:54:23 -06:00
dependabot[bot]
f79b83ef98 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [smallvec](https://github.com/servo/rust-smallvec).


Updates `smallvec` from 1.12.0 to 1.13.0
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.12.0...v1.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-19 10:30:12 -06:00
dependabot[bot]
6e5af06343 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/upload-artifact` from 4.1.0 to 4.2.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](1eb3cb2b3e...694cdabd8b)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-19 15:54:35 +00:00
dependabot[bot]
b0cc64b9a3 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [rayon](https://github.com/rayon-rs/rayon).


Updates `rayon` from 1.8.0 to 1.8.1
- [Changelog](https://github.com/rayon-rs/rayon/blob/master/RELEASES.md)
- [Commits](https://github.com/rayon-rs/rayon/compare/rayon-core-v1.8.0...rayon-core-v1.8.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-18 07:52:04 -08:00
Austin Seipp
dc8cbc8e60 chore: nix flake update
Summary: Includes a newer version of `cargo nextest`, which has
some nice little features (like the `binary_id()` filter.)

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ie6f822d3a5c16ec30e41bc830ee4b580a6547428
2024-01-17 21:11:31 -06:00
Austin Seipp
ff293bac2c github: remove nix-update-flake action
Summary: It needs new credentials to act as a robot account on my behalf, rather
than the 'github-actions' user, as that one can't be approved for security/legal
reasons from Google.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I72e303b5625a6417d3444fc65cb79a779a5d9d53
2024-01-17 15:45:19 -06:00
Daehyeok Mun
5b6ef63666 Support --user and --repo argument for config list command 2024-01-17 11:19:23 -08:00
dependabot[bot]
ba4bb928e4 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [clap](https://github.com/clap-rs/clap).


Updates `clap` from 4.4.17 to 4.4.18
- [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.4.17...v4.4.18)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-17 11:24:43 -06:00
Yuya Nishihara
c7be4d019c index: add all_heads_for_gc() that iterates heads of all indexed commits
GitBackend::gc() will recreate no-gc refs for the indexed heads. We could
collect all historical heads by traversing operation log, but it isn't enough
because there may be predecessor links to hidden commits, and "git gc" isn't
aware of predecessors.
2024-01-17 23:07:14 +09:00
Yuya Nishihara
afa72ff496 git_backend: inline prevent_gc() to bulk-update refs 2024-01-17 10:43:25 +09:00
Yuya Nishihara
96ee9bdb9f git_backend: ensure no-gc refs are created for all imported head commits
This also means that we can implement GC without taking care of extra
metadata. I haven't tried, but it wouldn't be easy to keep Git refs and extra
table in sync.
2024-01-17 10:43:25 +09:00
Yuya Nishihara
2e1aa6c49c git_backend: remove fast path testing imported commits, filter them by caller
The idea is that GC, if implemented, will clean up objects based on the Index
knowledge. It's probably okay to leave some extra metadata of unreachable
objects, but GC-ed refs should be recreated if the corresponding heads get
reimported. See also the next patch.
2024-01-17 10:43:25 +09:00
Yuya Nishihara
48c4985e34 git_backend: ensure that no-gc ref target never conflicts 2024-01-17 10:43:25 +09:00
Yuya Nishihara
f66c859fe4 git_backend: use lower-level API to create no-gc refs
This will allow us to issue multiple prevent_gc() requests all at once. It's
not important here, but will be unavoidable when implementing GC. Deleting
tons of refs from packed refs is super slow if the requests were processed one
by one.
2024-01-17 10:43:25 +09:00
Daehyeok Mun
4b224c45e0 Allow printing overridden config values via --include-overridden. 2024-01-16 13:36:50 -08:00
dependabot[bot]
25f9727e82 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [clap](https://github.com/clap-rs/clap) and [clap_complete](https://github.com/clap-rs/clap).


Updates `clap` from 4.4.16 to 4.4.17
- [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.4.16...v4.4.17)

Updates `clap_complete` from 4.4.6 to 4.4.7
- [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/clap_complete-v4.4.6...clap_complete-v4.4.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-16 07:58:58 -08:00
Martin von Zweigbergk
23a2e70625 github: avoid using tags in action version specifiers
The security scanner doesn't like depending on a tag version (because
tags can be moved).
2024-01-16 07:23:11 -08:00
Yuya Nishihara
34956f17e5 op_walk: assert that virtual root op is not reparented
This is enforced by the caller, but it's scary if it weren't.
2024-01-16 21:46:54 +09:00
Yuya Nishihara
c6b1ace9dd cli: use root operation id as the default lhs operand of range expression 2024-01-16 21:46:54 +09:00
Yuya Nishihara
fb3e006a45 op_store: add special case for root id resolution 2024-01-16 21:46:54 +09:00
Yuya Nishihara
660806ffed tests: set up unparented operations for id prefix tests
Otherwise we can't easily pick i to create operation id starting with "0".
2024-01-16 21:46:54 +09:00
Yuya Nishihara
df1be14aa8 tests: split op id resolution tests, don't require merged op for prefix tests
This makes it easy to set up crafted environment for prefix resolution tests.
2024-01-16 21:46:54 +09:00
Essien Ita Essien
dc074363d1 no-op: Move external git repo canonicalization into Workspace::init_git_external
* Move canonicalization of the external git repo path into the Workspace::init_git_external().
  This keeps necessary code together.
* Add a new variant of WorkspaceInitError for reporting path not found errors. The user error
  string is written to pass existing tests.
2024-01-16 10:46:02 +00:00
dependabot[bot]
45ad702eac github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [actions/upload-artifact](https://github.com/actions/upload-artifact).


Updates `actions/upload-artifact` from 4.0.0 to 4.1.0
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](c7d193f32e...1eb3cb2b3e)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 20:10:30 -08:00
dependabot[bot]
72dc89ef72 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [rustix](https://github.com/bytecodealliance/rustix) and [smallvec](https://github.com/servo/rust-smallvec).


Updates `rustix` from 0.38.28 to 0.38.30
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.28...v0.38.30)

Updates `smallvec` from 1.11.2 to 1.12.0
- [Release notes](https://github.com/servo/rust-smallvec/releases)
- [Commits](https://github.com/servo/rust-smallvec/compare/v1.11.2...v1.12.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-15 20:10:12 -08:00
Yuya Nishihara
da218d19db repo: optimize enforce_view_invariants() to not traverse ancestors until root
Because the default index cuts off the traversal at min(generations), including
the root id means all ancestors will be visited. This could be worked around at
the index side, but I think it's the repo/view's responsibility. That being
said, it's not uncommon to pad a revset with "root()", so it might make sense
for the index to special case the root id.

I also removed the redundant .clone().
2024-01-15 09:57:02 +09:00
Martin von Zweigbergk
b5343fb968 cli_util: remove handling of unrelated op logs
Any two operations should now have the root operation as common
ancestor. Otherwise there's a bug in the op store.
2024-01-14 10:15:14 -08:00
Martin von Zweigbergk
41db64e63c cli: give root operation special treatment in template (like root commit) 2024-01-14 10:15:14 -08:00
Martin von Zweigbergk
6e302bb3a2 op_store: add a virtual root operation, similar to root commit
It seems obvious in hindsight to have a virtual root operation just
like we have a virtual root commit. It removes the same kind of
problems by making sure there's always a common ancestor (or multiple)
between any two commits.

I think the reason I didn't add a root operation from the beginning
was that there used to be a mandatory working-copy commit in the view
(this was before support for multiple workspaces).

Perhaps we should remove the "initialize repo" operation now. The only
difference between their view objects is that the "initialize repo"
operation adds the root commit as a head. We could add that to the
root operation, but then the root operation's value depends on the
commit backend.
2024-01-14 10:15:14 -08:00
Martin von Zweigbergk
c9af8bf43a view: drop tracking of public heads
We've had the public_heads for as long as we've had the View object,
IIRC (I didn't check), but we still don't use it for anything. I don't
have any concrete plans for using it either. Maybe our config for
immutable commits is good enough, or maybe we'll want something more
generic (like Mercurial's phases). For now, I think we should simplify
by removing it the storage for public heads.
2024-01-13 22:23:57 -08:00
Yuya Nishihara
7e62d5ef36 cli: rename snapshot() to maybe_snapshot(), make inner function private
This function respects --ignore-working-copy and --at-op arguments, but the
name snapshot() sounds like it could forcibly trigger the snapshotting. Let's
clarify the actual behavior.

import_git_refs_and_head() and snapshot_working_copy() are unchecked functions,
and there are no external callers.
2024-01-13 11:47:42 +09:00
Yuya Nishihara
650c1f6521 cli: inline CommandHelper::workspace_helper_internal()
The control flow is pretty simple. We don't need a inner function that
implements the both.
2024-01-13 11:47:42 +09:00