Commit graph

4352 commits

Author SHA1 Message Date
Martin von Zweigbergk
44eb902171 working_copy: don't crash when updating and tracked file exits on disk
Before this patch, when updating to a commit that has a file that's
currently an ignored file on disk, jj would crash. After this patch,
we instead leave the conflicting files or directories on disk. We
print a helpful message about how to inspect the differences between
the intended working copy and the actual working copy, and how to
discard the unintended changes.

Closes #976.
2023-10-07 14:02:31 -07:00
Martin von Zweigbergk
4601c87710 working_copy: move creation of parent dirs to one place
I'm about to add handling of parent dirs that are existing ignored
files, so it's better to have it in one place. The only functional
difference should be that we now create parent directories for git
submodules. I don't think that matters.
2023-10-07 14:02:31 -07:00
Yuya Nishihara
7f4fe22a98 tests: disable parsing of system CA certificates in CLI tests
On my Debian laptop, openssl_init() takes ~30ms to load the default CA
certificates serialized in PEM format, and the cost is added to each jj
invocation. This change saves 20s (of 50s) on my machine.

% wc -l /usr/lib/ssl/cert.pem
3517 /usr/lib/ssl/cert.pem
2023-10-08 02:41:20 +09:00
Yuya Nishihara
d94c325d6c tests: use if cfg!(..) instead of #[cfg(..)] to insert Windows-specific config
The code compiles on all platforms, so I think `if cfg!(..)` is better.
2023-10-08 02:41:20 +09:00
Yuya Nishihara
aea135cb8f cli: in colocated repo, don't restore view.git_head on undo
Otherwise, undone HEAD wouldn't be exported if we tried to preserve the
symbolic HEAD target (#2210). Unborn branch already has this problem.
2023-10-08 02:37:02 +09:00
Martin von Zweigbergk
187ba9430a working_copy: rename to local_working_copy
It's about time we make the working copy a pluggable backend like we
have for the other storage. We will use it at Google for at least two
reasons:

 * To support our virtual file system. That will be a completely
   separate working copy backend, which will interact with the virtual
   file system to update and snapshot the working copy.

 * On local disk, we need to tell our build system where to find the
   paths that are not in the sparse patterns. We plan to do that by
   wrapping the standard local working copy backend (the one moved in
   this commit), writing a symlink that points to the mainline commit
   where the "background" files can be read from.

Let's start by renaming the exising implementation to
`local_working_copy`.
2023-10-07 08:19:03 -07:00
Yuya Nishihara
1eb8b95a6c cli: rephrase @git branch with no local counterpart as "deleted"
Since forgotten branches are now removed at all, the only situation where @git
branch persists is that the branch got removed but is not exported yet.
2023-10-07 19:33:35 +09:00
Yuya Nishihara
28e5ee35aa cli: filter out branches to list without cloning the map 2023-10-07 19:33:35 +09:00
Yuya Nishihara
d0bc34e0f2 git: look up "git" remote branches normally 2023-10-07 19:33:35 +09:00
Yuya Nishihara
717d0d3d6d git: on deserialize/import/export, copy refs/heads/* to remote named "git"
I've added a boolean flag to the store to ensure that the migration never runs
more than once after the view gets "op restore"-d. I'll probably reorganize the
branches structure to support non-tracking branches later, but updating the
storage format in a single commit would be too involved.

If jj is downgraded, these "git" remote refs would be exported to the Git repo.
Users might have to remove them manually.
2023-10-07 19:33:35 +09:00
Yuya Nishihara
9407d4ecca view: on deserialize, remove reserved "git" remote refs stored by old jj
I'm going to migrate "refs/heads/" branches to .remote_targets["git"]. This
commit will simplify the story as we won't have to exclude "refs/remotes/git/"
refs when diffing or renaming/removing remote.
2023-10-07 19:33:35 +09:00
Yuya Nishihara
0e82e52c3a revset: remove extra step to resolve full commit id, use prefix matching
Since both has_id() and resolve_prefix() do binary search, their costs are
practically the same. I think has_id() would complete with fewer ops, but such
level of optimization wouldn't be needed here. More importantly, this ensures
that unreachable commits aren't imported by GitBackend::read_commit().
2023-10-07 02:08:36 +09:00
Yuya Nishihara
f0ad1f53ea git_backend: on read_commit(), fall back to importing extras as needed
One problematic scenario is that we have commits imported by old jj, and all
of their descendant commits are created by jj. Therefore import_head_commits()
wouldn't reach the old ancestor commits.

This change might bury a real bug, but I don't have a better alternative. Maybe
we can remove this hack after a couple of jj releases, and add a debug command
that imports all reachable Git commits from all historical heads.

Closes #2343
2023-10-07 02:08:36 +09:00
dependabot[bot]
b5722eb0a5 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [byteorder](https://github.com/BurntSushi/byteorder).

- [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/byteorder/compare/1.4.3...1.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-06 15:54:03 +00:00
Martin von Zweigbergk
2ccb17b7b3 cli: enable tree-level conflicts by default
I have used the tree-level conflict format for several weeks without
problem (after the fix in 51b5d168ae). Now - right after the 0.10.0
release - seems like a good time to enable the config by default.

I enabled the config in our default configs in the CLI crate to reduce
impact on tests (compared to changing the default in `settings.rs`).
2023-10-05 10:31:47 -07:00
Austin Seipp
d5b2f8e43f fix: run 'cargo test' under 'nix flake check' with a non-debug profile
Summary: The Nix CI has been failing recently due to (what I assume is) disk
space issues. But only the `flake check` step is failing. Right now, `nix flake
check` runs the Cargo tests with the debug profile to help get more debug info,
which is even heftier in terms of debug info than the normal 'test' profile. For
reference, a single build of 'cargo test' in a clean working copy results in a
15 gigabyte `target/` directory.

Turn off the debug profile for `nix flake check`, which should hopefully stem
the bleeding a bit. I believe the 'test' profile should still have enough
symbols for backtraces, so panics should still be useful.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Idde10ac15847a1ad1e6f4e48a2497eca
2023-10-05 11:48:46 -05:00
dependabot[bot]
066032b6e6 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [rustix](https://github.com/bytecodealliance/rustix).

- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.15...v0.38.17)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-05 09:29:04 -07:00
dependabot[bot]
32a1ae6ec8 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](65d7c888b2...07ebb8d274)

---
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-05 09:26:28 -07:00
Infra
56a1686925 Add build-essential to install instructions 2023-10-05 09:07:37 -07:00
Martin von Zweigbergk
ce933507df release: release version 0.10.0
Thanks to everyone who's contributed!
2023-10-04 16:45:45 -07:00
Yuya Nishihara
a302090de9 git: add hack to unset Git HEAD by using placeholder ref
As we can set HEAD to an arbitrary ref by using .reference_symbolic(), we don't
have to manage a ref that can also be valid as a branch name.

Fixes #1495
2023-10-05 01:32:48 +09:00
Ilya Grigoriev
048f993a17 docs index.md: explain that the website sidebar may be hidden
This happens on mobile browsers or when the browser window is too
narrow.
2023-10-04 05:25:37 -07:00
Ilya Grigoriev
7cfeb72328 docs index.md: Make README link a bit more reliable
The original link would likely be broken by the change to
the heading title in https://github.com/martinvonz/jj/pull/2273.
2023-10-04 00:22:12 -07:00
Ilya Grigoriev
6671971c8b demos: run run_scripts.sh to update demo PNGs
The changes to SVGs would be trivial, so they got
pushed to the previous commit.
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
25d65d0801 demos: changes related to the new default log revset
We remove some branches that would be shown by default and
remove `-r 'all()'` where it's no longer necessary.
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
a70ea9dfdc demos: rearrange and reword portions of demos
This is mainly to account for the fact that most commands now report
more information about the state of the repo.
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
0d8c5e12f8 demos: add demos/README.md and run scripts to generate SVGs
PNGs are updated in a descendant commit
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
5e697dc1f3 demos: make jj perform the line wrapping instead of term-transcript
Previously, `jj` couldn't determine the terminal widths inside demos.
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
926c117955 demos: run scripts in a fixed environment and record with term-transcript
Currently, there is no way provided to merely run scripts in
a fixed environment (without recording).

Short-term TODOs (done in descendant commits):
  - Fix the terminal width
  - Document the script
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
eae9e3408d demos: allow broken pipe when doing jj | head, fix opid
`jj | head` exits with non-zero code since `head` breaks the
pipe. Also, removed `--color=always` from that command as it
will shortly become unnecessary.

Previosly, this caused the script to stop since it's run with
`set -o pipefail`.

Also, the operation id recovery code stopped working. We
can use `jj debug operation` for this purpose now.
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
68b8069c5e demos: redirect setup commands to /dev/null
Previously, we needed to remove this manually from screenshots.
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
438a4564b0 demos: rename demo_helpers.sh and demo_resolve_conflict.sh
I think it's clearer if only the actual demos started with `demo_`,
so I renamed `demo_helpers.sh` to just `helpers.sh`.

`demo_resolve_conflict.sh` should match `resolve_conflicts.png` (with an s).
2023-10-03 23:52:28 -07:00
Ilya Grigoriev
2218143968 docs: create a basic homepage for the docs website
Before, https://martinvonz.github.io/jj/latest redirected to
https://martinvonz.github.io/jj/latest/install-and-setup.html.

Now, it will direct people to a basic page with a link to
the repo and a few other useful pages.

An additional motivation is the desire to have a homepage to
link to from
https://github.com/martinvonz/jj/pull/2273#discussion_r1331008117.

Better something very basic than nothing.
2023-10-03 19:58:22 -07:00
Yuya Nishihara
be3d588449 cli: inline export_head_to_git(), use the same wc_commit to update working copy 2023-10-04 01:43:34 +09:00
Yuya Nishihara
df716888c9 cli: reorder working-copy commit lookup bits in finish_transaction()
Just to make the next commit look slightly nicer. tx.mut_repo() is no longer
assigned to local variable to narrow scope of mutable borrow.
2023-10-04 01:43:34 +09:00
Yuya Nishihara
7ccbc0424c git: extract function that resets Git HEAD
I'll add a workaround for the root parent issue #1495 there. We can pass in
the wc parent id instead of the wc_commit object, but we might want to use
wc_commit.id() to generate a unique placeholder ref name.
2023-10-04 01:43:34 +09:00
dependabot[bot]
c0fbe6d238 github: bump the github-dependencies group with 1 update
Bumps the github-dependencies group with 1 update: [DeterminateSystems/magic-nix-cache-action](https://github.com/determinatesystems/magic-nix-cache-action).

- [Release notes](https://github.com/determinatesystems/magic-nix-cache-action/releases)
- [Commits](749fc5bbc9...a04e6275a6)

---
updated-dependencies:
- dependency-name: DeterminateSystems/magic-nix-cache-action
  dependency-type: direct:production
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-03 09:01:59 -07:00
Yuya Nishihara
7c96cead34 git_backend: rename git_repo_clone() as it isn't just cloning, propagate error
Since git2::Repository::open() will access to the filesystem, it can technically
fail.
2023-10-04 00:04:24 +09:00
Yuya Nishihara
837dc4f47c git_backend: rewrite remaining git_repo() callers, make it private
While debugging git issues, I often ended up creating a deadlock by adding
debug prints. It's also not obvious that git::export_refs() works even if the
git_repo() has already been locked, whereas git::import_refs() wouldn't. Let's
consolidate lock handling to the backend implementation.
2023-10-04 00:04:24 +09:00
Yuya Nishihara
0d63223dad git_backend: proxy git2::Repository methods to manage lock scope internally
Since git_repo() acquires Mutex, it's super easy to create a deadlock.
2023-10-04 00:04:24 +09:00
Ilya Grigoriev
b1b8f85005 mkdocs-offline.yml: fix a typo, forgot a word 2023-10-03 06:52:44 -07:00
Yuya Nishihara
902a43a341 cli: don't list commits abandoned by import/fetch, just print the number
Apparently, it gets too verbose if the remote history is actively rewritten.
Let's summarize the output for now. The plan is to show the list of moved refs
instead of the full list of abandoned commits.
2023-10-03 14:07:56 +09:00
Waleed Khan
d9597c55ec docs: use code block for ui.pager config example 2023-10-02 23:37:33 -05:00
Ilya Grigoriev
dbbed2d2a5 docs: restore directory structure of the website
The `offline` plugin added to the MkDocs config in commit 772e2b8 ended up
changing the directory structure of the website, see the resulting commit
56aec196.

**Before** that commit, the following URLs were valid:

<https://martinvonz.github.io/jj/v0.9.0/revsets>
<https://martinvonz.github.io/jj/v0.9.0/revsets/>

and <https://martinvonz.github.io/jj/v0.9.0/revsets.html> was invalid.

The situation described above should be restored by this commit.

**After** 772e2b8 and before this commit, the following URLs were valid:

<https://martinvonz.github.io/jj/v0.9.0/revsets>
<https://martinvonz.github.io/jj/v0.9.0/revsets.html> and
<https://martinvonz.github.io/jj/v0.9.0/revsets/> was invalid.

This commit is likely to break the version switcher between v0.9.0 and newer
versions. The breakage would be minimized if this is merged shortly before a
release (but with enough time to test it out). Alternatively, I could try to
fix up the docs for that version.

We could also consciously decide to leave things as they are now.

The problem was noticed by @hooper, who noticed URLs in their browser history
that were no longer valid.
2023-10-02 20:40:23 -07:00
dependabot[bot]
f4e6c90855 build(deps-dev): bump urllib3 from 2.0.4 to 2.0.6
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.4 to 2.0.6.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/2.0.4...2.0.6)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-03 02:02:56 +00:00
Martin von Zweigbergk
5947387a3d cli_utils: fix a typo in a comment
The codespell GitHub action fails because of the typo. I don't know
why it started failing now. The comment is 8 months old and the
codespell action hasn't been updated in 5 months.
2023-10-02 18:29:25 -07:00
Yuya Nishihara
0fe25575ba cli: ensure first new HEAD is detached
The problem is that the first non-working-copy commit moves the unborn current
branch to that commit, but jj doesn't "export" the moved branch. Therefore,
the next jj invocation notices the "external" ref change, which was actually
made by jj.

I'm not sure why we play nice by setting the "current" HEAD, but I *think* it's
okay to set the "new" HEAD and reset to the same commit to clear Git index.
2023-10-03 00:58:22 +09:00
dependabot[bot]
b91139a40a cargo: bump the cargo-dependencies group with 3 updates
Bumps the cargo-dependencies group with 3 updates: [indexmap](https://github.com/bluss/indexmap), [regex](https://github.com/rust-lang/regex) and [rustix](https://github.com/bytecodealliance/rustix).


Updates `indexmap` from 2.0.1 to 2.0.2
- [Changelog](https://github.com/bluss/indexmap/blob/master/RELEASES.md)
- [Commits](https://github.com/bluss/indexmap/compare/2.0.1...2.0.2)

Updates `regex` from 1.9.5 to 1.9.6
- [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.5...1.9.6)

Updates `rustix` from 0.38.14 to 0.38.15
- [Release notes](https://github.com/bytecodealliance/rustix/releases)
- [Commits](https://github.com/bytecodealliance/rustix/compare/v0.38.14...v0.38.15)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
- dependency-name: regex
  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
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-02 15:23:56 +00:00
Yuya Nishihara
480efc1503 cli: add context to checkout/abandon messages triggered by automated git import
Otherwise, it's unclear why "jj status" abandoned commits for example.
2023-10-02 17:31:05 +09:00
Yuya Nishihara
8579bc479f cli: print commits abandoned by git::import_refs() or fetch()
This will probably help to understand why you've got conflicts after fetching.
Maybe we can also report changed local refs.

I think the stats should be redirected to stderr, but we have many other similar
messages printed to stdout. I'll probably fix them all at once later.
2023-10-02 17:31:05 +09:00