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

391 commits

Author SHA1 Message Date
Martin von Zweigbergk
33b272f5fa working_copy: make some functions require mutable references
We use interior mutability for caching in `WorkingCopy`, but let's
still take mutable reference in the functions where the state change
is visible.
2021-11-17 10:15:33 -08:00
Martin von Zweigbergk
32018da423 cli: add a command for untracking already tracked paths
Especially when working on a new-to-you project, it's common to end up
with unwanted files automatically tracked before you realize that you
should have added them to the `.gitignore`. Even after adding them to
the `.gitignore`, it's not trivial to make them no longer tracked (you
need to move them away, run e.g. `jj st`, then move them back). This
patch adds `jj untrack` to simplify that (without actually moving the
files).

Closes #14.
2021-11-17 09:19:41 -08:00
Martin von Zweigbergk
ae3ff4e1be cli: add command aliases such as "commit" for "close"
Although "commit" isn't technically correct for what `close` does,
it's how new users think of it, so let's make it a bit easier for
them.
2021-11-10 11:11:09 -08:00
Martin von Zweigbergk
ced252f766 cleanup: replace some as_slice() by & 2021-11-10 10:55:58 -08:00
Martin von Zweigbergk
9375106a05 cli: use same color for timestamps in operation log as in commit log 2021-11-07 21:41:22 -08:00
Martin von Zweigbergk
0a43bc7088 cleanup: fix a formatting regression 2021-11-07 15:56:30 -08:00
Martin von Zweigbergk
c1bdba5403 cli: make jj st list paths with conflicts
Now that the working copy preserves conflicts, we can easily list
them.
2021-11-07 15:17:51 -08:00
Martin von Zweigbergk
99e5a28d17 cli: don't materialize conflicts when editing diffs
The diff-editing code shares the `TreeState` functionality with the
working-copy code. That means we can now let the user edit conflicts
without materializing them first. So now the user can do e.g. `jj edit
-r <some commit>` and resolve only some of the conflicts.
2021-11-07 15:17:51 -08:00
Martin von Zweigbergk
60ea81882f cli: use same template for jj log --no-graph as for jj log
It is weird how the template changes because you ask for now
graph. Also, I've never wanted the long format. Let's just remove it.
2021-10-27 21:28:04 -07:00
Martin von Zweigbergk
853b40cf18 cleanup: run rustfmt on formatter (missed in recent commit) 2021-10-27 21:26:22 -07:00
Martin von Zweigbergk
3981cd90f8 cli: use bright colors for head of operation log 2021-10-27 16:35:48 -07:00
Martin von Zweigbergk
922fea0c18 cli: use bright color for the current checkout's description too 2021-10-27 16:31:04 -07:00
Martin von Zweigbergk
18f450e530 cli: fix TODO about formatter label
Maybe something has changed since I added the TODO, but it seems the
problem it describes doesn't exist now.
2021-10-27 16:26:27 -07:00
Martin von Zweigbergk
6687f98d8a cli and docs: replace "id" by more correct "ID" 2021-10-27 15:06:10 -07:00
Martin von Zweigbergk
3587d4ec7e cli: use bright colors for the current checkout
As @arxanas noted, it's hard to tell which commit is currently checked
out. Hopefully bright colors will help. Maybe setting a background
color would be even clearer, but that's harder to do because the
formatter doesn't support background colors yet.
2021-10-27 14:16:13 -07:00
Martin von Zweigbergk
b3ad965a3b formatter: delete default colors for obsolete, evolution-related labels 2021-10-27 14:13:01 -07:00
Martin von Zweigbergk
452fecb7c4 cli: colorize diff summary and sort by path
The order used to be like Mercurial's and the (lack of) coloring used
to be like Git's. Let's try the opposite :)
2021-10-27 14:13:01 -07:00
Martin von Zweigbergk
7917bad5b2 cli: rename "left"/"right" formatter labels to "removed"/"added" 2021-10-27 13:39:59 -07:00
Martin von Zweigbergk
c13b5ae50e cli: make jj branch --delete/--forget error out if branch doesn't exist 2021-10-26 06:12:17 -07:00
Martin von Zweigbergk
9abee0096f conflicts: propagate errors from materialize_conflict()
All current callers pass in a buffer, so it should never fail, but the
function itself can't know that.
2021-10-24 23:02:00 -07:00
Martin von Zweigbergk
191c1ee166 cli: make "added {} files, modified {} files, ..." message start with uppercase
We pretty consistently start with uppercase so this message stood out
and bothered me.
2021-10-24 12:46:01 -07:00
Martin von Zweigbergk
50058d8a31 cli: show help when jj git remote is called without subcommand 2021-10-23 20:55:18 -07:00
Martin von Zweigbergk
5098270640 cli: remove "at" from "Modified file at README" etc.
This patch changes the preposition depending on the case and removes
it in most cases.
2021-10-22 12:47:22 -07:00
Martin von Zweigbergk
709b2e85c2 cli: use finish_transaction() for remaining two commands too
I don't think it matters here, but it might in the future, and this is
more consistent anyway.
2021-10-22 12:17:28 -07:00
Martin von Zweigbergk
a9aff0b7fe cli: abandon the initial checkout after cloning Git repo
The CLI code for cloning a Git repo didn't use the usual
`finish_transaction()` method, because we didn't have support for
doing that on a repo that was creating half-way through a
command. That led to a bug where it would leave the initial checkout
(the one on top of the root commit) after checking out the correct
head.
2021-10-22 12:08:47 -07:00
Martin von Zweigbergk
ffa727eb51 cli: add jj undo as shortcut for jj op undo
`jj undo` is probably what people would reach for first. It's also the
most commonly used `jj op` command, so it's nice to make it quick to
type.
2021-10-20 21:52:16 -07:00
Martin von Zweigbergk
ef616222a9 cli: rename ArgMatcher variables from *_matches to *_args
`args` seems to make it clear that these are command-line arguments
(this is not Python, so there's no `*args`). It also avoids the risk
of conflicts and confusion with other matches (e.g. file patterns or
regexes).
2021-10-20 21:46:08 -07:00
Martin von Zweigbergk
38607c1d29 cli: remove (another) mistakenly prefixed underscore from used variable 2021-10-20 21:41:34 -07:00
Martin von Zweigbergk
fa09f1531d cli: remove unused intermediate-level ArgMatches arguments 2021-10-20 17:00:07 -07:00
Martin von Zweigbergk
9a3127e659 cli: remove mistakenly prefixed underscore from used variable 2021-10-20 16:43:03 -07:00
Martin von Zweigbergk
e9f57332cc cli: rename jj git refresh to jj git import
I've been planning to add a command for exporting refs to the backing
Git repo, so `jj git import` and `jj git export` seem like obvious
names then.
2021-10-13 16:16:33 -07:00
Martin von Zweigbergk
7731b8d902 cli: make color-words diff handle all file types
Diffs between certain combinations of file types were not handled by
`jj diff` (for example, a diff between a conflict and another conflict
would not show a diff). This change fixes that, and also makes added
and removed files get printed with color and line numbers, which I've
often wanted.
2021-10-13 15:48:25 -07:00
Martin von Zweigbergk
efba256bc2 cli: rename color-words functions to include color_words 2021-10-13 14:01:23 -07:00
Martin von Zweigbergk
d914cc1dfd cli: add jj git remote remove command 2021-10-13 11:08:01 -07:00
Martin von Zweigbergk
e4f7795fd3 cli: add jj git remote add command
The user currently has to edit `.jj/git/config` (or run `git
--git-dir=.jj/git config`) to manage remotes in the underlying Git
repo. That's not very discoverable (and we may change the path some
day), so let's provide a command for it.
2021-10-13 10:59:29 -07:00
Martin von Zweigbergk
8bbfe9731e cleanup: let newer Clippy fix a few things it found 2021-10-13 08:27:44 -07:00
Martin von Zweigbergk
ebcd946732 cli: make default diff format configurable
This change adds a `diff.format` config option, which can be set to
"git", "color-words", or "summary".

Closes #33.
2021-10-10 09:37:07 -07:00
Martin von Zweigbergk
7add35999f cli: add support for Git's unified diff format
As #33 says, the default diff we have can be hard to read and it
cannot be used for use with other tools. This patch adds a `jj diff
--git` mode for showing Git's flavor of unified diffs.

We should add a config option to get these diffs by default. For
interchange with other tools, we also need a way of turnning off color
codes in output (it's currently always on, even when when not printing
to a TTY).
2021-10-10 00:10:19 -07:00
Martin von Zweigbergk
d92b29cca6 cli: extract a function for showing a word-level diff
I'm about to add support for Git's unified diff format next and
`cmd_diff()` was already really long.
2021-10-09 22:58:31 -07:00
Martin von Zweigbergk
fdb861b957 backend: remove unused Commit::is_pruned (#32) 2021-10-06 23:53:15 -07:00
Martin von Zweigbergk
4c4e436f38 evolution: delete it now that we don't use it anymore (#32)
It's been a lot of work, but now we're finally able to remove the
`Evolution` state! `jj obslog` still works as before (it just walks
the predecessor pointers).
2021-10-06 23:28:30 -07:00
Martin von Zweigbergk
82388c4d88 cli: remove redundant jj discard command
`jj abandon` now behaves very similar to how `jj discard` was supposed
to behave (it just hides heads), so let's remove `jj discard`.
2021-10-06 23:22:03 -07:00
Martin von Zweigbergk
09feb2e281 cli: reimplement divergent template keyword without evolution (#32)
This rewrites the `divergent` template keyword to be based on the
number of visible commits with a given change id. That's the same as
before; it's just that it's not based on the `Evolution` object's view
of which commits are visible anymore.

This is the last thing that depended on the evolution state!
2021-10-06 23:20:23 -07:00
Martin von Zweigbergk
a750be2b9b cli: remove most evolution-related template keywords (#32)
`obsolete`, `orphan`, and `abandoned` almost never appear in log
output these days, so let's remove them.
2021-10-06 23:20:23 -07:00
Martin von Zweigbergk
108c38d816 evolution: don't create pruned commits (#32)
Now that we rebase descendants and remove old heads as appropriate
(without using evolution), we don't need to create pruned commits
anymore.
2021-10-06 23:20:23 -07:00
Martin von Zweigbergk
e26d21dc18 revset: add .commit_ids() and .commits() to RevsetIterator
This makes it a little easier to iterate over commits or commit ids.
2021-10-06 14:18:11 -07:00
Martin von Zweigbergk
41779551fb revsets: remove heads arguments from builder API functions
Now that we no longer have to be careful whether we mean "all heads"
or "non-obsolete heads", there's no need to pass them as
arguments. It's still possible to get a DAG range to a hidden commit
by using `RevsetExpression::dag_range_to()`, as long as the hidden
commit is indexed.
2021-10-06 13:28:51 -07:00
Martin von Zweigbergk
9ec27645cf revsets: remove all_heads()
Now that we remove hidden heads whenever a transaction commits,
`non_obsolete_heads()` should always be the same as `all_heads()`,
except during a transaction. I don't think we depend on the difference
even during a transaction. Let's simplify a bit by removing the revset
function `all_heads()` and renaming `non_obsolete_heads()` to
`heads()`. This is part of issue #32.
2021-10-06 12:21:18 -07:00
Martin von Zweigbergk
09a33ec212 cli: fix updating of branches and working copy after jj rebase -r
Branches and the working copy are currently updated to the parents of
the old commit (if they pointed to the old commit to start
with). That's not what's supposed to happen; they're supposed to be
updated to point to the new commit. This patch fixes that by manually
rebasing the immediate children of the old commit, so that
`MutRepo::create_descendant_rebaser()` will do the right thing.
2021-10-06 10:20:17 -07:00
Martin von Zweigbergk
9a4de4a456 cli: remove rarely useful jj evolve command
This patch removes the `jj evolve` command, as part of removing the
evolution feature (#32). The command is very rarely useful since we
started evolving orphans after every transaction. I haven't used `jj
evolve` in many months.

After removing the command, the only good way of resolving divergence
will be `jj abandon` one side of the divergence. We will no longer
have a way of automatically merging the divergent commits. I plan to
add back that functionality, powered by the operation log instead of
the obsolescence log. That will probably take a long time, but it's
not a very high-priority feature anyway, so I think it's okay to lose
it for a while.
2021-10-03 22:38:49 -07:00
Martin von Zweigbergk
fcb79ef0a6 DescendantRebaser: also update checkout (#32)
This is similar to how a recent change taught `DescendantRebaser` to
update branches pointing to rewritten commits. Now we also update the
checkout if it pointed to a rewritten commit.
2021-10-03 22:38:49 -07:00
Martin von Zweigbergk
5be75d0e31 DescendantRebaser: also update branches
This patch moves the logic for updating branches from
`update_branches_after_rewrite()` into `DescendantRebaser`. The
branches are now updated along with each rebased commit rather than
all being updated at the end. The new code uses the information about
rewritten and abandoned commits that `DescendantRebaser` gets from
`MutableRepo`. That is different from the old code, which used the
evolution state. This patch thus moves us one step closer to removing
evolution (#32).
2021-10-03 10:07:09 -07:00
Martin von Zweigbergk
a78976cd29 DescendantRebaser: allow passing divergent changes as input
I'm going to teach `DescendantRebaser` to also update local branches
pointing to rewritten commits, taking over the responsibility from
`rewrite::update_branches_after_rewrite()`. For commits that have been
rewritten as multiple new commits (divergent, not split), that
function makes local branches pointing to the old commit point to all
the new commits. To replicate that behavior in `DescendantRebaser`, it
needs to know about divergent changes. This change addresses that.
2021-10-02 23:12:46 -07:00
Martin von Zweigbergk
1c55c02106 Transaction: remove hidden heads on commit
I recently made the CLI remove hidden heads when a transaction is
committed (38474a9). Let's move that to `Transaction::commit()`, so
the library crate becomes more similar to how the CLI behaves and more
similar to our evolution-less future (#32).
2021-10-02 23:12:46 -07:00
Martin von Zweigbergk
bbe20e0ea6 cli: make rebase and abandon commands rebase descendants using new helper
This makes `jj rebase` and `jj abandon` rebase descendants using
`MutableRepo::create_descendant_rebaser()`, except that `jj rebase -r`
needs to be special-case since it doesn't rebase descendants onto the
rewritten commit.
2021-10-02 10:30:09 -07:00
Martin von Zweigbergk
4883261c2a cli: rebase descendants without using evolution
This change makes it so we rebase descendants based on the rewrite
information recorded in `MutableRepo` instead of using evolution for
it. This is an important step towards removing evolution (#32).
2021-10-02 10:30:09 -07:00
Martin von Zweigbergk
0cb43c72d0 cli: make jj split manually rebase descendants
When we remove evolution (#32), I don't intend to replicate the hack
it had for rebasing descendants onto a split commit. Let's instead
have `jj split` manually rebase descendants of the original commit
onto the second part of the split. We use `DescendantRebaser` for
that. Branches and the working copy pointing to the split commit are
still updated using evolution in
`RepoCommandHelper::finish_transaction()`. I plan to have
`DescendantRebaser` update branches and working copies as well. That
should then also work as expected for `jj split`.
2021-10-02 10:30:09 -07:00
Martin von Zweigbergk
6949dab389 cli: make squash and unsquash commands record abandoned commits
This change makes `jj squash` and `jj unsquash` record the child or
parent (respectively) as abandoned if it becomes empty. We need to do
that because it won't get automatically recorded by
`CommitBuilder`. We could make `CommitBuilder` record abandoned
commits when `set_pruned()` was called, but that would be
short-sighted since we're about to delete that function as part of
removing support for evolution (#32).
2021-09-29 15:56:09 -07:00
Martin von Zweigbergk
3e938752d1 cli: also update descendant branches after rewriting working copy commit
After writing a new working copy commit, we update branches pointing
to it, and we rebase descendants on top. However, we should be doing
that in the opposite order, so the branch updates apply to rewritten
descendants as well.
2021-09-29 10:13:32 -07:00
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
76782b20dd cli: add debug command for generating command-line-completion scripts 2021-09-24 10:04:16 -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
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
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
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
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
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
2a23ee3f15 cli: guess destination for jj git clone if it's not provided 2021-09-11 10:25:46 -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
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
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
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
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
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
451451563b revset: work with Rc<RevsetExpression> everywhere
It's about break-even in this commit to `Rc` everywhere, but it will
allow big savings in the next commit.
2021-08-25 22:53:57 -07:00
Martin von Zweigbergk
52678237a7 cli: after cloning git repo, update to remote's HEAD 2021-08-25 21:42:32 -07:00
Martin von Zweigbergk
723ebb3809 cleanup: restructure escaped newlines to make new rustc happy 2021-08-18 10:06:15 -07:00
Martin von Zweigbergk
c310477765 cleanup: fix formatting of commands.rs 2021-08-18 09:58:17 -07:00
Martin von Zweigbergk
b4d0549146 cli: make jj status report conflicted branches
This change makes `jj status` include a section about conflicted local
branches and another section about conflicted remote branches. They
show up only if there are conflicts. They include hints about how to
resolve.
2021-08-15 19:40:55 -07:00
Martin von Zweigbergk
5493b44ba5 cli: update branches when working copy committed 2021-08-15 19:01:14 -07:00
Martin von Zweigbergk
e66d3120c5 cli: evolve descendants when working copy committed 2021-08-15 19:01:14 -07:00
Martin von Zweigbergk
2afed65132 working_copy: move logic for creating commit to caller
The auto-rebasing of descendants doesn't work if you have an open
commit checked out, which means that you may still end up with orphans
in that case (though that's usually a short-lived problem since they
get rebased when you close the commit). I'm also about to make
branches update to successors, but that also doesn't work when the
branch is on a working copy commit that gets rewritten. To fix this
problem, I've decided to let the caller of `WorkingCopy::commit()`
responsible for the transaction.

I expect that some of the code that this change moves from the lib
crate to the cli crate will later move back into the lib crate in some
form.
2021-08-15 18:55:09 -07:00
Martin von Zweigbergk
0d24e72260 cli: extract a helper for evolving descendants
I want to reuse this bit of code for evolving descendants of a
rewritten working copy commit.

I expect this to change again soon (I'll probably make it do a regular
rebase instead of evolve), but this will do for now.
2021-08-15 18:37:08 -07:00
Martin von Zweigbergk
3c1a9b4d10 cli: update branches after rewriting commits
This makes it so (local) branches get updated when the commit they
point to gets rewritten. If the branch was conflicted, we just print a
warning and don't update the branch (though one could imagine
rewriting the conflict). We also just print a warning if the new
target is unclear because the commit was rewritten into multiple new
commits (divergent).

The updating doesn't work when the working copy commit gets rewritten
because the working copy changed on disk. That's because that's done
in a separate transaction inside `working_copy.rs`. That's similar to
how orphans of the working copy commit don't get automatically
evolved. I'll fix both problems soon.
2021-08-15 18:35:24 -07:00
Martin von Zweigbergk
8fe4433c9c cli: make revision argument positional for jj describe
I missed this command in the previous change.
2021-08-15 18:29:02 -07:00
Martin von Zweigbergk
8ad60f8c99 cli: make revision argument position for some commands
For example, `jj open/close` doesn't seem to make sense with paths, so
let's save the user from typing "-r".
2021-08-15 17:20:26 -07:00
Martin von Zweigbergk
45f926c234 cli: don't require --allow-backwards when creating a branch
If a branch doesn't exist yet, it's clearly safe to move it "forward"
to any commit (it was simply a bug that we required
`--allow-backards`).
2021-08-11 11:15:14 -07:00
Martin von Zweigbergk
aba0d200e2 cleanup: fix bad formatting of commands.rs 2021-08-11 10:58:22 -07:00
Martin von Zweigbergk
42090c8078 cli: make jj branches also list remote branches if different from local 2021-08-11 09:19:20 -07:00
Martin von Zweigbergk
4878c94052 cli: color branch name and conflict marker in jj branches output 2021-08-11 09:15:08 -07:00
Martin von Zweigbergk
81ba65e3a5 git: force push when not known to be a fast-forward
With this change, we no longer fail if the user moves a branch
sideways or backwards and then push.

The push should ideally only succeed if the remote branch is where we
thought it was (like `git push --force-with-lease`), but that requires
rust-lang/git2-rs#733 to be fixed first.
2021-08-04 23:28:42 -07:00
Martin von Zweigbergk
8b8aff171e cli: delete branch from git remote when pushing locally deleted branch 2021-08-04 22:50:52 -07:00
Martin von Zweigbergk
7dc82c1580 cli: make jj git push push given branch
Now that we have native branches, we can make `jj git push` only be
about pushing a branch to a remote branch with the same name.

We may want to add back support for the more advanced case of pushing
an arbitrary commit to an arbitrary branch later, but let's get the
common case simplified first.
2021-08-04 22:14:43 -07:00
Martin von Zweigbergk
f85613cf66 cli: make branch command's --delete flag actually a flag, and require name arg
I had forgotten to make the `delete` argument a flag by giving it a
name, so instead it conflicted with `name` argument, as tests
discovered.

While at it, I also made `name` required. It wasn't before because I
originally had a single command for `jj branch` and `jj branches` and
then I didn't think to make it required when I split them up.
2021-08-04 14:26:50 -07:00
Martin von Zweigbergk
10b2e25c30 cli: add a command for listing branches 2021-08-04 14:07:19 -07:00
Martin von Zweigbergk
40a260a37f cli: add a command for updating branches 2021-08-04 14:04:06 -07:00
Martin von Zweigbergk
15132a1166 cli: replace git refs by branches and tags in log output
Now that our own branches and tags are updated when git refs are
updated and the user can use them to specify revisions, we can start
displaying them instead of the git refs. This commit adds new
`branches` and `tags` template keywords and updates the default
templates to use them instead of `git_refs`.
2021-08-04 11:53:37 -07:00
Martin von Zweigbergk
0aa738a518 view: add support for conflicting git refs in the model
This adds support for having conflicting git refs in the view, but we
never create conflicts yet. The `git_refs()` revset includes all "add"
sides of any conflicts. Similarly `origin/main` (for example) resolves
to all "adds" if it's conflicted (meaning that `jj co origin/main` and
many other commands will error out if `origin/main` is
conflicted). The `git_refs` template renders the reference for all
"adds" and adds a "?" as suffix for conflicted refs.

The reason I'm adding this now is not because it's high priority on
its own (it's likely extremely uncommon to run two concurrent `jj git
refresh` and *also* update refs in the underlying git repo at the same
time) but because it's a building block for the branch support I've
planned (issue #21).
2021-07-24 19:01:56 -07:00
Martin von Zweigbergk
c889baaabe cli: make jj describe not rewrite commit if description was unchanged 2021-07-24 10:33:40 -07:00
Martin von Zweigbergk
9448fe665a files: use diff::DiffHunk in DiffLine definition
The new `diff::DiffHunk` type is very similar but more generic. We
don't need the generality here. I just don't two very similar types
with the same name.
2021-06-26 23:49:58 -07:00
Martin von Zweigbergk
4c416dd864 cleanup: let Clippy fix a bunch of warnings 2021-06-14 00:27:31 -07:00
Martin von Zweigbergk
214a32faa8 cli: remove TODOs address by previous commit 2021-06-10 08:13:44 -07:00
Martin von Zweigbergk
755f4e7b6a cli: parse file names as relative and using platform separator 2021-06-09 22:56:02 -07:00
Martin von Zweigbergk
9de8b2a8f6 cli: support filtering jj diff by paths 2021-06-09 16:45:47 -07:00
Martin von Zweigbergk
1ac72b9807 cli: rewrite jj restore <path> to use a matcher created from arguments 2021-06-09 16:45:30 -07:00
Martin von Zweigbergk
dd4c47f373 tree: support filtering diff by matcher
This change teaches `Tree::diff()` to filter by a matcher. It only
filters the result so far; it does not restrict the tree walk to what
`Matcher::visit()` says is necessary yet. It also doesn't teach the
CLI to create a matcher and pass it in.
2021-06-09 16:26:58 -07:00
Martin von Zweigbergk
b593e552b8 cleanup: remove some Vec<_> annotations, mostly by using collect_vec() 2021-06-09 14:21:57 -07:00
Martin von Zweigbergk
fdeb499836 trees: merge into tree module 2021-06-05 14:20:07 -07:00
Martin von Zweigbergk
82b62e92f1 cli: respect color choice in graph logs too
This patch makes it so we use color in the graph iff we use it other
output. We currently always use color except for in the smoke tests,
so it has no effect in practice. It's easy to turn off color when
stdout is redirected (using the `atty` crate), but I haven't done that
because I occasionally pipe `jj log` output to `less` and I want color
then.
2021-06-05 08:38:28 -07:00
Martin von Zweigbergk
b50ef1410d styler: rename Styler to more standard Formatter 2021-06-05 08:38:28 -07:00
Martin von Zweigbergk
edef604c88 cli: use "@" in graph to indicate the current checkout and head operation
This both helps find the current checkout and head operation and
hopefully helps teach the user that "@" is the symbol for the working
copy. I removed the current "<--" indication from the graph (and
non-graph) log template. Hopefully the "@" is clear enough on its own,
but we may want to add back some further indication later. We'll see.
2021-05-31 10:54:00 -07:00
Martin von Zweigbergk
03ea8779df cli: make diff editor configurable
This patch adds a simple `ui.diff-editor` config, which defaults to
`meld`. This fixes issue #10.
2021-05-31 09:40:29 -07:00
Martin von Zweigbergk
38a3462d4e cli: clarify "Now at: <commit>" message as "Working copy now at: <commit>"
I considered even changing the message to "Checking out: <commit>" as
that's technically more correct (the message is printed when the
view's checkout is updated, i.e. before the working copy is
updated). However, I worried that users would find it confusing that
e.g. `jj close` would result in a "Checking out: " message, even
though that's what actually happens.
2021-05-31 09:01:59 -07:00
Martin von Zweigbergk
83c460449b cli: remove overly verbose "Leaving: <commit>" message
I remember adding that message a long time ago so the user has a trace
of working copy commit ids in the terminal output. They should be able
to get the same information from the operation log combined with
e.g. `jj st --at-op`.
2021-05-31 08:55:08 -07:00
Martin von Zweigbergk
4a3ba5b8e4 cli: allow using --at-op=@ to refer to head operation
We already support using "@" to refer to the head operation when doing
e.g. `jj op undo -o @`. This patch adds support for `--at-op=@`. It
also makes that the default.
2021-05-28 23:05:16 -07:00
Martin von Zweigbergk
082b34206e cli: abbreviate operation ids to 12 hex digits 2021-05-28 22:48:39 -07:00
Martin von Zweigbergk
b26d9817c0 cli: add support for looking up operation id by prefix
This fixes issue #16.
2021-05-28 22:34:02 -07:00
Martin von Zweigbergk
b0fe2564d4 cli: don't commit working copy when using --at-op
The working copy is related to the current repo state; it makes little
sense to commit the working copy when looking at an old repo state.
2021-05-28 11:08:24 -07:00
Martin von Zweigbergk
b48e06a94b cli: make jj status get the working copy commit from the view
This prepares `jj status` for working better on an old repo state
(with `--at-op`). When looking at an old repo state, the "working
copy" should reflect the state from that state, i.e. the view's
"checkout", not the current working copy.
2021-05-28 10:56:03 -07:00
Martin von Zweigbergk
11005ae9b8 cli: make condition for committing working copy slightly smarter
Before this patch, `jj log` would always commit the working copy and
most other commands would commit the working copy only if they were
passed a revset of exactly "@". This patch makes it so they all commit
the working copy unless they are passed just a symbol other than "@"
(typically a commit id). That means that we will not commit the
working copy if the user does `jj diff -r abc123`, but we will if they
do `jj diff -r :abc123`. It's clearly unnecessary in both those cases,
and we should fix, but this is probably good enough for now.
2021-05-28 10:31:17 -07:00
Martin von Zweigbergk
440a423b54 cli: allow pruning more than one revision 2021-05-28 10:14:37 -07:00
Martin von Zweigbergk
bbbdb11289 cli: consistently check that a commit can be rewritten before rewriting it
This patch adds checks in all (?) commands that rewrite commits to
make sure the commit they're about to rewrite is allowed to be
rewritten. The only check we do is that it's not a root commit. We
should at least add checks for public commits later.
2021-05-28 09:44:50 -07:00
Martin von Zweigbergk
69e3da46d8 cli: add a helper for parsing a revset and possibly committing working copy 2021-05-28 09:30:03 -07:00
Martin von Zweigbergk
749317f82d cli: replace "evolve" by "rebase" in a help text about jj prune
Now that we auto-evolve after most operations, the user may not know
what "evolve" means. Even before that, the way `jj evolve` resolved
orphans after pruning was by rebasing them.
2021-05-28 09:28:09 -07:00
Martin von Zweigbergk
e658cc0084 revsets: add a RevsetExpression::evaluate() method for convenience 2021-05-28 09:01:34 -07:00
Martin von Zweigbergk
080a9b37ff cli: make jj st show parent commit before working copy commit
Perhaps it makes more sense to display the working copy commit just
above the changes in the working copy commit, even though that means
that the order between the working copy commit and the parent becomes
the opposite of the order in `jj log`.
2021-05-23 22:09:02 -07:00
Martin von Zweigbergk
ba8ff31e32 cli: make the working copy changes in jj status clearer 2021-05-23 22:08:34 -07:00
Martin von Zweigbergk
dcfc888f50 cli: remove "Done" message at end of git clone
It's probably obvious that the cloning is done when the command
finishes.
2021-05-23 22:08:09 -07:00
Martin von Zweigbergk
54f6165ef1 repo_path: replace remaining uses of DirRepoPath by RepoPath 2021-05-19 15:11:04 -07:00