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

643 commits

Author SHA1 Message Date
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
Martin von Zweigbergk
b3a93b903f cli: add concept guide about the working copy 2021-09-04 11:46:00 -07:00
Martin von Zweigbergk
49e1462fe5 working_copy: delete two obsolete TODOs about ignores
We have had support for ignores via `.gitignore` files since
3b326a942c, and we haven't had the problem with the temporary
`.git/` directory created by libgit2 since 88f7f4732b.
2021-09-03 23:10:45 -07:00
Martin von Zweigbergk
fa73b17c66 cli: add jj concepts subcommand for concept help, starting with "branches"
With this commit, you can run `jj concepts branches` to get help about
the "branches" concept. We don't have much help for other commands and
their arguments yet, but I'm starting with concept guides so we can
point to them as we add help for commands and their arguments.

I initially tried to make the command to get help be `jj help
--concept branches`. That would require replacing clap's
implementation of the help command with our own. clap-rs/clap#1350
prevented me from doing that. But I'm pretty happy with having it
under `jj concepts` anyway. It's probably more discoverable that way.

I tried to mimic clap's styling with yellow headings.
2021-09-02 23:06:46 -07:00
Martin von Zweigbergk
fddcaaada1 cli: set custom, imperative messages for --help and --version
Clap uses present tense by default (e.g. "Prints help information"). I
considered switching our message to that style, but I found it harder
to describe some flags that way.
2021-09-02 11:01:02 -07:00
Martin von Zweigbergk
d7cc09e918 cli: disable --version on subcommands
`jj st --version` and `jj op log --version` don't make any sense.
2021-09-02 11:01:02 -07:00
Martin von Zweigbergk
4e9be8d2a4 rustfmt: format string literals 2021-09-02 11:01:02 -07:00
Martin von Zweigbergk
88fef10eac cleanup: use literal newlines in string literals
I'm about to enable `rustfmt`'s formatting of string literals, and
that makes these string literals with escaped newlines harder to read.
2021-09-02 11:01:02 -07:00
Martin von Zweigbergk
ccdd651953 working_copy: ignore .git directory/file when writing tree to store
Git doesn't want `.git` entries in its trees, so at least when using
the Git backend, we need to ignore such paths. Let's just ignore
`.git` paths regardless of backend to keep it simple.

Closes #24.
2021-09-01 08:40:28 -07:00
Martin von Zweigbergk
538bec22ff tutorial: clarify that rustup install nightly doesn't change the default 2021-09-01 08:08:18 -07:00
Martin von Zweigbergk
ecbbac23be cli: require argument for jj open
The current checkout is always open, so it doesn't make sense to have
that as default.
2021-08-30 00:07:55 -07:00
Martin von Zweigbergk
f27ca16a16 rewrite: when rebasing descendants, actually rebase them
When I added the function for rebasing descendants, I forgot to call
the existing `rebase()` function and instead simply created a new
commit with the new parents but the old contents.
2021-08-29 09:42:37 -07:00
Martin von Zweigbergk
f13f15e057 cli: add jj rebase -s and make jj rebase -r rebase descendants onto parents
I think it makes sense to have a version of rebase that rebases the
descendants of the rebased commit onto the parents of the rebased
commit. Let's make `jj rebase -r` do just that. Let's also add `jj
rebase -s` (matching Mercurial's `hg rebase -s`) for rebasing a commit
and its descendants onto another commit.

Since both flavors of the command now explicitly rebase the
descendants (just to different destinations), I also made the command
not evolve orphans afterwards. That would have made sense regardless
of this commit.
2021-08-28 10:01:00 -07:00
Martin von Zweigbergk
4e0a89b3dd rewrite: add a function for rebasing descendant commits
This should be useful in lots of places. For example, `jj rebase -r`
currently rebases all descendants, because that's what the auto-evolve
feature does. I think it would be nice to instead copy from
Mercurial's `-s` flag for also rebasing descendants. Then `jj rebase
-r` can be made to pull a commit out of a stack, rebasing descendants
onto the rebased commit's parents. I also intend to use this
functionality for rebasing descendants when remote branches have been
rewritten.
2021-08-28 10:01:00 -07:00