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

606 commits

Author SHA1 Message Date
Martin von Zweigbergk
38474a9fb9 cli: remove non-visible heads after every operation
This makes it so that almost every command will remove non-visible
heads. That shouldn't have much visible effect, except that the
`all_heads()` revset will become the same as
`non_obsolete_heads()`.

It will help us remove support for evolution by cleaning up existing
repos. Existing repos (like mine) will lose the unwanted heads (~8.5k
heads in my case), so they don't clutter the repo once evolution is
gone.

This is part of issue #32.
2021-09-29 10:13:32 -07:00
Martin von Zweigbergk
ff71af1e11 MutableRepo: accept just CommitId instead of whole Commit where possible 2021-09-29 10:13:32 -07:00
Martin von Zweigbergk
e1fd69cfa8 evolution: don't crash when commit is no longer in view's set of heads
If you rewrite a change twice, from A to A' to A'', then undo the
operation that created A', you'll end up with a repo where A'' refers
to commit (A') that's not reachable from any head in the view. We
currently crash when that happens. This change fixes the
crash. Undoing the A' operation now instead produces a state where A
and A'' are divergent. That at least makes some sense.

This may not seem important since I'm working on removing support for
evolution (#32), but I wanted to get it fixed in order to help with
the transition off of evolution. Specifically, I want to be able to
start removing old heads more freely.

This closes #28.
2021-09-29 10:13:32 -07:00
Martin von Zweigbergk
de5bf90675 cleanup: fix issues found by latest rustc and clippy 2021-09-29 10:12:38 -07:00
Martin von Zweigbergk
eb00981aca git: also test imported refs and branches after fetch 2021-09-24 22:42:37 -07:00
Martin von Zweigbergk
76782b20dd cli: add debug command for generating command-line-completion scripts 2021-09-24 10:04:16 -07:00
Martin von Zweigbergk
edf7ec0a72 git: don't fetch tags we're not fetching commits for
In the recent switch away from `git2::Remote::fetch()`, I passed
`git2::AutotagOption::All`, which caused cloning of e.g. the `clap`
repo to fail like this:

```
Error: Fetch failed: Error { code: -1, klass: 4, message: "target OID for the reference doesn't exist on the repository" }
```

This commit changes from `All` to `Unspecified`, which respects the
remote's configuration.
2021-09-24 07:46:54 -07:00
Martin von Zweigbergk
d121cd7f75 cli: add a jj branch --forget for forgetting everything about a branch 2021-09-22 21:29:46 -07:00
Martin von Zweigbergk
0711757324
Merge pull request #31 from arxanas/test-default-branch
git: properly detect default branch
2021-09-22 20:54:18 -07:00
Waleed Khan
bfb5e55cfd git: properly detect default branch
The default branch relies on checking the value of `HEAD`. The `empty_git_commit` function updates the ref `refs/heads/main`, but since `HEAD` was never updated to point to that ref, the default branch can't be determined. The fix is to explicitly set `HEAD`.

Personally, this test failed reliably for me on macOS. I don't know why this behavior would be non-deterministic on other platforms.
2021-09-22 16:45:04 -07:00
Martin von Zweigbergk
a69096a4d4 git: remove test of default branch because of issue #30 2021-09-22 15:22:53 -07:00
Martin von Zweigbergk
eed715dc51 git: try to fix flaky (?) fetch tests by keeping connection open longer
It seems it wasn't Windows that behaved differently when it comes
getting the remote's default branch; the test failed on Ubuntu
too.

The documentation for `Remote::default_branch()` says that it can be
called even after the connection has been closed, but let's see if
calling it while the connection is open helps anyway. To do that, we
have to replicate what `Remote::fetch()` does.
2021-09-22 11:48:42 -07:00
Martin von Zweigbergk
2086d1a84d git: make fetch-test pass on Windows by expecting no default branch 2021-09-22 10:56:53 -07:00
Martin von Zweigbergk
f56262ce85 git: add test for default branch after fetch
This adds tests I should have added in 48f237e33e.
2021-09-22 10:28:28 -07:00
Martin von Zweigbergk
880d469b5f readme: fix typoed "tutorial" 2021-09-20 09:02:40 -07:00
Martin von Zweigbergk
4b9282ed40 cli: make jj abandon explicitly rebase descendant commits
This change makes it so `jj abandon` uses `DescendantRebaser` for
rebasing descendants of the abandoned commits. That makes it not
depend on evolution for it.
2021-09-19 22:57:09 -07:00
Martin von Zweigbergk
d4004fcb6f rewrite: teach DescendantRebaser to handle abandoned commits specially
Descendants of abandoned commits should be rebased onto their parents,
or the rewritten parents if they had been rewritten. This patch
teaches `DescendantRebaser` to do that. It updates `jj rebase -r` to
use the functionality. I plan to also use it in `jj abandon`
(naturally, given the name), and for rebasing descendants of deleted
refs imported from `jj git refresh/fetch/push`.
2021-09-19 22:51:12 -07:00
Martin von Zweigbergk
439fe1cfd3 rewrite: don't report skipped commits when rebasing descendants
The fact that `DescendantRebaser` visits some commits that don't need
to be rebased is mostly an implementation detail. I can't think of a
reason that callers would care about these commits.
2021-09-19 22:51:12 -07:00
Martin von Zweigbergk
ae7f00e7b1 cli: rename jj prune to jj abandon
The command's help text says "Abandon a revision", which I think is a
good indication that the command's name should be `abandon`. This
patch renames the command and other user-facing occurrences of the
word. The remaining occurrences should be removed when I remove
support for evolution.
2021-09-19 22:51:12 -07:00
Martin von Zweigbergk
84081a5727 cli: use new helper for updating branches after committing working copy
This makes conflicted branches pointing to the working copy get
updated when the working copy changes, just like they are when it
changes for other reason (such as `jj describe`).
2021-09-18 10:04:55 -07:00
Martin von Zweigbergk
ef4cb663ae cli: move logic for updating branches after rewrite to lib crate
This patch moves the function for updating branches after rewrite from
`commands.rs` into `rewrite.rs`.

It also changes the function to update branches even if they were
conflicted or become conflicted. I think that seems better than
leaving branches on old commits. For example, let's say you have start
with this:

```
C main
|
B origin@main
|
A
```

You now pull from origin, which has updated the main branch from B to
B'. We apply that change to both the remote branch and the local
branch, which results in a conflict in the local branch:

```
C main?
|
B B' main? origin@main
|/
A
```

If you now rewrite C to C', the conflicted main branch will still
point to C, which is just weird. This patch changes that so the
conflicted side of main gets repointed to C'.

I also refactored the code to reuse our existing
`MutableRepo::merge_single_ref()`, which improves the behavior in
several cases, such as the conflict-resolution case in the last test
case.
2021-09-18 10:03:26 -07:00
Martin von Zweigbergk
0c1ce664ea store: remove (weak) self-reference and take &Arc<Self> arguments instead
The `weak_self` stuff was from before I knew that `self` could be of
type `&Arc<Self>`.
2021-09-16 23:30:30 -07:00
Martin von Zweigbergk
e76dc5a425 cli: don't crash when . is given as file pattern 2021-09-15 22:46:27 -07:00
Martin von Zweigbergk
a02b5af1e8 cli: use RepoCommandHelper::finish_transaction() for git commands as well
I don't know why I hadn't already updated these. Maybe I thought it
wasn't necessary. That's probably true right now, but I want to make
`jj git fetch` and `jj git refresh` automatically rebase commits when
branches were updated on a remote or in the underlying Git repo. We
want to make sure that the working copy also gets updated then.
2021-09-15 22:33:21 -07:00
Martin von Zweigbergk
ca114d6d7e rewrite: add support for rebasing descendants of multiple rewritten commits
I plan to use this for rebasing descendants of rewritten remote
branches (on fetch).
2021-09-15 22:13:40 -07:00
Martin von Zweigbergk
30bcf6508e rewrite: when rebasing forward, also rebase "side branches"
As the updates test case shows, when rebasing forward, we missed
commits that fork off from the section between the source and the
destination.

As part of the fix, I also restructured the code a bit to prepare for
support for rebasing descendants of multiple rewritten commits.
2021-09-15 22:08:32 -07:00
Martin von Zweigbergk
e4bc8f5b4c tests: extract helpers to reduce repetition in test_rewrite 2021-09-15 22:02:58 -07:00
Martin von Zweigbergk
d9ddd6ed09 cli: fix an obsolete variable name
I forgot to remove the `fetch_head` from a variable name when I
recently realized that Git's `FETCH_HEAD` is not what we want to check
out after fetching.
2021-09-15 09:37:10 -07:00
Martin von Zweigbergk
48f237e33e cli: correctly update to remote's default branch after clone
It turns out that `FETCH_HEAD` is not the remote's `HEAD` (it's
actually not even a normal symbolic ref; it contains many lines of
commits and names). We're supposed to ask the remote for its default
branch instead. That's what this patch does.
2021-09-13 22:28:13 -07:00
Martin von Zweigbergk
ce5e95fa80 store: rename Store to Backend and StoreWrapper to Store
For what's currently called `Store` in the code, I have been using
"backend" in plain text. That probably means that `Backend` is a good
name for it.
2021-09-12 12:02:10 -07:00
Martin von Zweigbergk
1f2ce49e89 docs: remove unnecessary git steps in git-comparison doc
The table describes the simplified Git workflow of always using `git
commit -a`. With that workflow, you don't need to `git add` or `git
rm` to stage changes.
2021-09-12 12:01:28 -07:00
Martin von Zweigbergk
802bd227e0 docs: update git-comparison doc with help about push/pull 2021-09-12 11:49:52 -07:00
Martin von Zweigbergk
39693dcaff docs: update git-comparison doc with help about working with branches 2021-09-12 00:36:07 -07:00
Martin von Zweigbergk
cea3c1537a cli: make jj git push push all branches by default
It's annoying to have to add `--branch main` every time I push to
GitHub.

Maybe we should make it push only the current branch by default, but
we don't even have a concept of a current branch yet...
2021-09-11 23:51:53 -07:00
Martin von Zweigbergk
0bc42c0066 cli: extract function for figuring out how to update branches on a remote 2021-09-11 23:41:53 -07:00
Martin von Zweigbergk
344435e90f git: add support for pushing multiple ref updates at once 2021-09-11 22:54:29 -07:00
Martin von Zweigbergk
11c0130303 index: squash an index segment into its parent more aggressively
Before this change, you could end up with an index segment with 10
commits, then a child segment with 9 commits, then another child with
8 commits, and so on. That's not what I had intended. This changes
makes it so we squash if a segment has more than half as many commits
as its parent instead.
2021-09-11 22:51:13 -07:00
Martin von Zweigbergk
2a23ee3f15 cli: guess destination for jj git clone if it's not provided 2021-09-11 10:25:46 -07:00
Martin von Zweigbergk
20e9d29c4b CommitBuilder: remove write_to_new_transaction(), which was only used in tests 2021-09-11 10:11:15 -07:00
Martin von Zweigbergk
be64e5118d cli: teach jj discard to discard a public head
I'm not sure what the interface should be, but until public heads are
automatically removed when they disappear from a remote, this will at
least be useful as a workaround.
2021-09-10 21:57:43 -07:00
Martin von Zweigbergk
15858b7630 cli: make jj branches say how much remote branches are ahead/behind
For example:
```
main: 4f2efc5bb873 cli: make `jj branches` say how much remote branches are ahead/behind
  @origin (behind by 2 commits): 5023d8d360 Merge pull request #26 from martinvonz/git-comparison
```
2021-09-10 18:33:28 -07:00
Martin von Zweigbergk
8b2db95897 cli: make jj branches indent remote branches and not repeat the branch name
Before:
```
git-comparison: de5aa1ac6c docs: add a table of git/jj command equivalences
git-comparison@origin: 15bbd1083b0e cli: add a table of git/jj command equivalences
main: 4aa1fd7cbb docs: move tutorial from README.md to docs/tutorial.md
```

After:
```
git-comparison: de5aa1ac6c docs: add a table of git/jj command equivalences
  @origin: 15bbd1083b0e cli: add a table of git/jj command equivalences
main: 4aa1fd7cbb docs: move tutorial from README.md to docs/tutorial.md
```
2021-09-10 18:19:42 -07:00
Martin von Zweigbergk
5023d8d360
Merge pull request #26 from martinvonz/git-comparison
cli: add a table of git/jj command equivalences
2021-09-10 17:54:51 -07:00
Martin von Zweigbergk
de5aa1ac6c docs: add a table of git/jj command equivalences 2021-09-10 13:52:07 -07:00
Martin von Zweigbergk
4aa1fd7cbb docs: move tutorial from README.md to docs/tutorial.md 2021-09-09 11:10:40 -07:00
Martin von Zweigbergk
014cf6e297 cli: make short description for jj describe fit on one line 2021-09-09 10:55:56 -07:00
Martin von Zweigbergk
77662c0674 readme: add "Status" section and stop saying it's not ready for use
I have been using the tool myself for 7-8 months now, and the UX has
improved substantially, so I think it's ready for use.
2021-09-08 10:40:13 -07:00
Martin von Zweigbergk
118d0cc31d cli: clarify that --help provides more help than -h
It turns out that `--help` provides a longer version of the help text
than `-h` does. I only discovered that because I was wondering what
the difference between `clap::App::about()` and
`clap::App::long_about()` was. There's clap-rs/clap#1015 for tracking
it in clap, but let's clarify it ourselves for now by changing the
help text for `-h/--help`.
2021-09-08 10:01:57 -07:00
Martin von Zweigbergk
826e69a10c cli: add help texts for all CLI arguments 2021-09-08 09:51:50 -07:00
Martin von Zweigbergk
ad96820642 cli: add concepts guide about the operation log 2021-09-06 22:24:55 -07:00