Commit Graph

4327 Commits

Author SHA1 Message Date
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
Yuya Nishihara
fb08e16238 cli: return early if git::import_some_refs() is noop
I'll make it a bit more verbose if mut_repo().has_changes().
2023-10-02 17:31:05 +09:00
Yuya Nishihara
65ecac10e9 git: exclude hidden commits from list of commits to be abandoned
This wasn't a problem before, but we wouldn't want to report previously-hidden
commits as abandoned.
2023-10-02 17:31:05 +09:00
Yuya Nishihara
16d3bcd4c5 git: make import_refs() return abandoned commits to caller
It'll be reported to user.
2023-10-02 17:31:05 +09:00
Martin von Zweigbergk
58de7c292b cli: redefine default log revset using immutable_heads()
I think most users who change the set of immutable heads away from
`trunk() | tags()` are going to also want to change the default log
revset to include the newly mutable commit and to exclude the newly
immutable commits. So let's update the default log revset to use
`immutable_heads()` instead.

`test_templater` changed because we have overridden the set of
immutable commits there so `jj log` now includes the remote branch.
2023-10-01 11:15:30 -07:00
Martin von Zweigbergk
8ec402fc90 cli: report error on bad short-prefixes revset 2023-10-01 11:15:30 -07:00
Waleed Khan
d58664d40c command: add --interactive flag to jj commit 2023-09-30 22:03:51 -05:00
Waleed Khan
946a6e0bf7 commands: support path arguments to jj commit 2023-09-30 21:45:06 -05:00
Waleed Khan
d91dcc0c78 commands: add --interactive flag to jj split
`jj split` with no arguments operates interactively, but I am nonetheless constantly running `jj split -i` because I expect an `--interactive` flag to exist for consistency.

However, `jj split <paths>` before this commit always operates non-interactively, so this commit has the nice practical effect that you can restrict your interactive splitting to a certain set of paths.
2023-09-30 21:45:06 -05:00
Yuya Nishihara
f0f1d72cf3 view: add method that iterates remote branches only
There aren't many callers, but let's add it for consistency.
2023-09-30 12:02:35 +09:00
Yuya Nishihara
c5474ff505 view: extract method that iterates local branches only
I'll probably reorganize the local/remote branches structure, so let's
minimize call sites which rely on the BranchTarget struct.
2023-09-30 12:02:35 +09:00
Yuya Nishihara
520f692a46 git: on import_refs(), don't preserve old branches referenced by remote refs
If we made @git branches real .remote_targets["git"], remotely-rewritten
commits could also be pinned by the @git branches, and therefore wouldn't be
abandoned. We could exclude the "git" remote, but I don't think local commits
should be pinned by remote refs in general. If we squashed a fetched commit,
remote ref would point to a hidden commit anyway.
2023-09-30 12:02:35 +09:00
dependabot[bot]
5f63400f2f 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.5 to 4.4.6
- [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.5...v4.4.6)

Updates `clap_complete` from 4.4.2 to 4.4.3
- [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.2...clap_complete-v4.4.3)

---
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>
2023-09-29 08:41:36 -07:00
dependabot[bot]
db538bd0f4 cargo: bump the cargo-dependencies group with 2 updates
Bumps the cargo-dependencies group with 2 updates: [indexmap](https://github.com/bluss/indexmap) and [insta](https://github.com/mitsuhiko/insta).


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

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

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-28 15:55:13 +00:00
Yuya Nishihara
ce0821f06d docs: adjust tracking branches design to deal with "fetch/push && undo"
The original idea was to completely replace git_refs with remotes["git"] by
introducing "forgotten" state, but it turned out to break "fetch && undo"
scenario. There are other ways around, but they also have problems:

* Sets tombstone on forgotten/deleted remote refs, exports remote refs without
  comparing to the known refs.
  * `jj undo` would need to insert tombstone by diffing old/new views.
  * `jj branch forget` would need to preserve the @git branch whereas the other
    remote branches would be forgotten.
* Always overwrites remote refs on export.
  * `jj git export` without importing would discard remote refs.

So, I decided to not remove git_refs. Apparently, it also improves the undo
behavior. In the new model, `jj git fetch && jj undo && jj git fetch` works
even if git_refs isn't rolled back. So we can unify the default of
`jj undo --what`.
2023-09-28 18:00:25 +09:00
Martin von Zweigbergk
7fda80fc22 tree: simplify conflict before resolving at hunk level
I ran into a bug the other day where `jj status` said there was a
conflict in a file but there were no conflict markers in the working
copy. The commit was created when I squashed a conflict resolution
into the commit's parent. The rebased child commit then ended up in
this state. I.e., it looked something like this before squashing:

```
C (no conflict)
|
| B conflict
|/
A conflict
```

The conflict in B was different from the conflict in A. When I
squashed in C, jj would try to resolve the conflicts by first creating
a 7-way conflict (3 from A, 3 from B, 1 from C). Because of the exact
content-level changes, the 7-way conflict couldn't be automatically
resolved by `files::merge()` (the way it currently works
anyway). However, after simplifying the conflict, it could be
resolved. Because `MergedTree::merge()` does another round of conflict
simplification of the result at the end of the function, it was the
simplifed version that actually got stored in the commit. So when
inspecting the conflict later (e.g. in the working copy, as I did), it
could be automatically resolved.

I think there are at least two ways to solve this. One is to call
`merge_trees()` again after calling `tree.simplify()` in
`MergedTree::merge()`. However, I think it would only matter in the
case of content-level conflicts. Therefore, it seems better to make
the content-level resolution solve this case to start with. I've done
that by simplifying the conflict before passing it into
`files::merge()`. We could even do the fix in `files::merge()`, but
doing it before calling it has the advantage that we can avoid reading
some unchanged content from the backend.
2023-09-27 22:14:39 -07:00
Martin von Zweigbergk
af80e4e407 files: take Merge argument to merge()
All non-test callers already have a `Merge` object, so let's pass that
instead. We thereby simplify the callers a little, and we enforce the
"adds.len() == removes.len() + 1" constraint in the type.
2023-09-27 22:14:39 -07:00
Philip Metzger
e158423cb0 Docs: Make github.md a bit clearer
This adresses #1989
2023-09-28 01:11:47 +02:00
Emily Fox
35f11e2cdc docs: add missing word to config.md 2023-09-27 12:26:08 -05:00
dependabot[bot]
58ef82b1c0 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).

- [Release notes](https://github.com/embarkstudios/cargo-deny-action/releases)
- [Commits](a50c7d5f86...1e59595bed)

---
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>
2023-09-27 16:12:17 +00:00
dependabot[bot]
06d728e7c0 cargo: bump the cargo-dependencies group with 1 update
Bumps the cargo-dependencies group with 1 update: [thiserror](https://github.com/dtolnay/thiserror).

- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](https://github.com/dtolnay/thiserror/compare/1.0.48...1.0.49)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-27 10:30:30 -05:00
Martin von Zweigbergk
e50f6acab1 templater: fast-path empty and conflict to not read trees
When there's a single parent, we can determine if a commit is empty by
just comparing the tree ids. Also, when using tree-level conflicts, we
don't need to read the trees to determine if there's a conflict. This
patch adds both of those fast paths, speeding up `jj log -r ::main`
from 317 ms to 227 ms (-28.4%). It has much larger impact with our
cloud-based backend at Google (~5x faster).

I made the same fix in the revset engine and the Git push code (thanks
to Yuya for the suggestion).
2023-09-26 18:18:52 -07:00
Hong Shin
e5ad32e29e docs: update basic workflow to use autogenned branch name 2023-09-26 13:16:44 -07:00
Hong Shin
0c0b924e7a docs: add revset clarification to github.md 2023-09-26 10:59:38 -07:00
dependabot[bot]
9938051d99 cargo: bump the cargo-dependencies group with 4 updates
Bumps the cargo-dependencies group with 4 updates: [clap](https://github.com/clap-rs/clap), [clap_complete](https://github.com/clap-rs/clap), [pest](https://github.com/pest-parser/pest) and [pest_derive](https://github.com/pest-parser/pest).


Updates `clap` from 4.4.4 to 4.4.5
- [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.4...v4.4.5)

Updates `clap_complete` from 4.4.1 to 4.4.2
- [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.1...clap_complete-v4.4.2)

Updates `pest` from 2.7.3 to 2.7.4
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.3...v2.7.4)

Updates `pest_derive` from 2.7.3 to 2.7.4
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.3...v2.7.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-26 15:28:16 +00:00
Martin von Zweigbergk
a6ef3f0b6c cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).

This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.

Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.

For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-25 15:41:45 -07:00