Commit graph

726 commits

Author SHA1 Message Date
Martin von Zweigbergk
92f6571b31 cli: use "hint" style for hint about using --git-repo=. 2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
7ce8138794 cli: use separate hint for errors from jj branch 2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
698bba387f cli: separate out hint in untrack message 2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
6a15cc02bf cli: print hints using "hint" style, not "error" style
Several lines of red text can be overwhelming, and makes it harder to
tell the hint from the error. Let's separate the hint from the error
instead. This matches what hg does. Having the hints separated out
also means that we could have a single config to turn them off.
2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
2a17bb76e9 cli: add factory function for CommandError::UserError
I want to add a separate field for a hint, so that can be printed in a
different color (than red). Having a factory function is useful then,
since most call sites don't want to pass a hint. Also, by using a
factory function instead of using the constructor directly means that
we can accept `&str` arguments instead of forcing the caller to
convert a string literal to `String`.
2022-11-12 17:58:22 -08:00
Martin von Zweigbergk
6c600e98cf templater: indicate if branch needs to be pushed to a remote
It's useful to know when you've modified a branch that exists on a
remote. A typical case is when you have pushed a branch to a remote
and then rewritten it. This commit adds an indication in the
`branches` template keyword. A branch that needs to be pushed to a
remote now has a `*` at the end (similar to how conflicted branches
have a `?` at the end). Note that the indication only considers
remotes where the branch currently exists, so there won't be an
indication that the branch has not been pushed to a remote.

Closes #254
2022-11-09 22:44:55 -08:00
Benjamin Saunders
46fe0791e8 cli: fix rebase error 2022-11-06 18:50:58 -08:00
Benjamin Saunders
210b54afd7 cli: hide cursor during progress display 2022-11-06 18:15:22 -08:00
Benjamin Saunders
472b6926e5 cli: define drop+signal guard helper 2022-11-06 18:15:22 -08:00
Benjamin Saunders
135e4d64dd cli: clean up progress error handling 2022-11-06 17:31:29 -08:00
Benjamin Saunders
d69eb808df git: prompt for credentials when needed 2022-11-06 17:31:29 -08:00
Benjamin Saunders
fd0a065801 cli: remove lifetime from Progress 2022-11-06 17:31:29 -08:00
Benjamin Saunders
a23cc8eb5a cli: factor out RemoteCallbacks setup 2022-11-06 17:31:29 -08:00
Benjamin Saunders
88a4f83cf8 git: factor ssh key lookup out of lib 2022-11-06 17:31:29 -08:00
Benjamin Saunders
b55c4ae0a3 git: move progress callback into a struct 2022-11-06 17:31:29 -08:00
Martin von Zweigbergk
a27da7d8d5 repo: remove last mutating method from ReadonlyRepo
`ReadonlyRepo::reindex()` is only used in `jj debug reindex`, and it
can be implemented by creating a new instance instead of mutating
`ReadonlyRepo`.
2022-11-06 16:43:54 -08:00
Ilya Grigoriev
cf3b6ee2c9 Include file list when editing split commit description
Example:

        JJ: Enter commit description for the first part (parent).
        Better split commit message

        JJ: This part contains the following changes:
        JJ:   M src/formatter.rs
        JJ:
        JJ: Lines starting with "JJ: " (like this one) will be removed.
2022-11-06 13:51:28 -08:00
Martin von Zweigbergk
a86de96bd4 cli: replace "current checkout" by "working-copy commit" 2022-11-05 22:56:14 -07:00
Martin von Zweigbergk
1d97f39da1 cleanup: avoid an unnecessary Box for argument to formatter
I think this cleanup was enabled by a recent refactoring that replaced
a trait object by a type parameter (3392e83486).
2022-11-05 22:49:54 -07:00
Ilya Grigoriev
93b7b34871 Add --config-toml command-line argument for additional TOML config
Unfortunately, TOML requires quotes around the argument. So, the
usage is `jj --config-toml ui.color=\"always\"` in bash. The plan is
to eventually have a `--config` option with simpler syntax for
simple cases.

As discussed in https://github.com/martinvonz/jj/discussions/688.
2022-11-05 21:21:33 -07:00
Yuya Nishihara
5d42c9ebca cli: handle init destination error gracefully 2022-11-05 22:50:29 +09:00
Martin von Zweigbergk
61468ed126 commit_builder: remove redundant for_open_commit()
The function is now the same as `for_new_commit()`, except that it
accepts only one parent.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
6703810c6e backend: remove Commit::is_open field from data model 2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
91ee32b183 templater: drop support for open template keyword 2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
6320f24360 cli: remove open/close commands 2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
21cda3431c cli: drop support for ui.enable-open-commits config 2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
f02d92a3fe cli: add commit as its own command (not an alias for close)
It seems very likely that we're going to remove support for open
commits, but it's still useful to have a `commit` command that lets
the user enter a description and starts a new change. Calling it
`commit` seems good to make the transition from other VCSs simpler.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
0870c47559 cli: on init, don't crash when Git repo doesn't exist 2022-11-03 19:27:17 -07:00
Martin von Zweigbergk
66838cd532 cli_util: avoid exit() in handle_command_result()
We try to keep the calls to `exit()` in one place. I seem to just have
missed this case in an earlier cleanup.
2022-11-01 17:46:00 -07:00
Yuya Nishihara
78c0cf81bf revset: pass workspace context around parse() functions
The next commit will move file path resolution to parse().
2022-11-02 01:02:37 +09:00
Yuya Nishihara
2193d7768d cli: add stub function to parse revset with workspace context
parse() will take a workspace context to resolve file paths.
2022-11-02 01:02:37 +09:00
Glen Choo
4ebeb95203 cli: print clap errors through Ui
Use clap::Command::try_get_matches_from() to parse args, and handle the
resulting error as a CommandError. The exit code 2 matches the exit code that
clap would output (this is tested by test_alias).

With this new abstraction, teach the clap output to respect "ui.color"
(--color doesn't seem to be understood). We'll also make use of it when
we route output through the pager.

The "errors" returned by try_get_matches_from() can be found at
https://docs.rs/clap/latest/clap/error/enum.ErrorKind.html. I've tested:

- no args
- --help
- help subcommand
- --version
- subcommand with --help
- subcommand with bad args
2022-11-01 07:35:25 +08:00
Glen Choo
470c9f3a5f ui: add write_stderr()
This lets us write to stderr, but unlike write_error(), this won't write
with formatting. This will be used for preformatted strings, e.g. those
coming from clap.
2022-11-01 07:35:25 +08:00
Glen Choo
a52c32adef ui: add color field
This gives us a convenient way to read the color setting when handling
errors from clap.
2022-11-01 07:35:25 +08:00
Yuya Nishihara
55184237e1 cli: suggest 'jj init --git-repo' if .git directory already exists
I made new empty repository by mistake, and didn't notice it until I ran
'jj status'.
2022-10-31 01:00:40 +09:00
Martin von Zweigbergk
7947ba16f1 cleanup: use imported UserError variant instead of qualifying
We already have the variant imported and we use it so much that it
seems reasonable to use it instead of qualifying it by the
`CommandError` type.
2022-10-29 17:56:14 -07:00
Benjamin Saunders
cf5b86b9b7 cli: style tweak 2022-10-28 11:51:53 -07:00
Benjamin Saunders
01bb1e67da workspace: fail gracefully on non-Unicode paths 2022-10-28 11:51:53 -07:00
Benjamin Saunders
cfa46c50e2 workspace: propagate I/O errors gracefully 2022-10-28 11:51:53 -07:00
Martin von Zweigbergk
8e2dd4b406 cli: include tags as upstream commits to exclude in default log revset
Sometimes a tagged commit is not in any branch on the remote, but we
should still consider them upstream and not include them in the
default log template.

This was reported by @colemickens but now that I think about it, I
remember seeing such commits in the Git core repo (v1.4.4.5 and a few
commits before it were never merged into main).

We don't have a good way of testing this because we don't have a
command for creating tags.

Closes #681
2022-10-27 20:56:41 -07:00
Martin von Zweigbergk
95638d453c progress: use clamp() for readability
This was actually what I meant in my code-review comment but I used
the wrong word ("clip") :) I wasn't going to bother changing it, but
Clippy nightly just started warning about it.
2022-10-27 17:47:12 -07:00
Yuya Nishihara
f48675ad90 revset: evaluate optimized expression 2022-10-27 21:33:35 +09:00
Benjamin Saunders
78f2de20f0 cli: erase progress feedback on completion 2022-10-24 12:52:41 -07:00
Benjamin Saunders
e773709e31 cli: draw bar in progress report 2022-10-24 12:52:41 -07:00
Benjamin Saunders
3dd2cbf799 cli: limit progress report update rate 2022-10-24 12:52:41 -07:00
Benjamin Saunders
f11b3d2476 cli: factor progress reporting out into its own module 2022-10-24 12:52:41 -07:00
Benjamin Saunders
9381765739 cli: fix cursor flicker during progress reports 2022-10-24 12:52:41 -07:00
Benjamin Saunders
c03c746f8d cli: report fetch progress continuously 2022-10-23 12:13:25 -07:00
Yuya Nishihara
cb2fcde560 revset: implement file(pattern[, candidates]) predicate
The name "file()" is just copied from hg. I'm not sure if it's good in
jj's context, but I couldn't find a better name.
2022-10-24 01:48:00 +09:00
Yuya Nishihara
5c52b4e819 revset: introduce wrapper struct to pass around workspace information
More workspace-derived parameters will be added, and I don't think wrapping
with Option for each makes sense because all parameters should be available
if workspace exists.
2022-10-24 01:48:00 +09:00