Commit graph

1769 commits

Author SHA1 Message Date
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
a6dd84dc5c tests: avoid about-to-be-deleted open template keyword 2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
5a4c463dc0 tests: avoid about-to-be-deleted close command 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
ea576a8327 test_git_colocated: remove an unnecessary git import
The whole file is about the colocated case, where we automatically
import and export on every command, so there should be no reason to
call `git import` here.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
1bab9db28e test_rebase_command: avoid unnecessary close command
Closing the working-copy commit doesn't seem to add anything to the
tests.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
4399ef54c1 test_rebase_command: avoid an unnecessary special case
`jj new` can be used with 1 or more arguments to create non-merge
commits or merge commits.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
d09a8f50df tests: delete obsolete smoke test
The smoke test was useful a year ago, when our CLI test environment
was still annoying enough to use that there were very few tests. We
now have enough tests that the smoke test is not needed.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
c8c4497ea0 docs: describe the conflict-resolution workflow without open commits 2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
6dd91cf1c1 test_mut_repo: also run tests with Git backend
I haven't tried to figure out when it happened, but these tests seem
to consistently pass now.
2022-11-05 06:14:37 -07:00
Martin von Zweigbergk
6f2359c36d lib: remove ineffective enabling of map_first_last
If I'm reading this attribute correctly, it says that if the
`map_first_last` feature is enabled, then we should enable the
`map_first_last` feature, which seems like it would not have any
effect. We started getting warnings from the nightly compiler about
this line because it tries to enable a feature that's stable in that
version.
2022-11-05 06:07:27 -07:00
Yuya Nishihara
f62aafa79f repo: comment about safety implication of view/view_dirty 2022-11-05 00:13:26 +09:00
Yuya Nishihara
f26c5c1a05 repo: turn off view_dirty flag by enforce_view_invariants()
Otherwise enforce_view_invariants() could mutate view while its reference
is alive.
2022-11-05 00:13:26 +09:00
Ilya Grigoriev
2b8dabaae4 Fixes suggested by new version of Clippy 2022-11-03 21:38:16 -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
650853401d tests: replace test env path in output by $TEST_ENV
Mercurial's test runner does something like this.

I considered replacing `\` by `/` everywhere, but we use `\` in
graph-log output quite frequently, so it doesn't seem worth it.
2022-11-03 19:27:17 -07:00
Yuya Nishihara
1c4888f769 revset: report bad number of arguments with span 2022-11-03 09:41:04 +09:00
Yuya Nishihara
b938b5e907 revset: report invalid string argument with span
Also dropped "found: {}" from the error summary as it's obvious.
2022-11-03 09:41:04 +09:00
Yuya Nishihara
aeee0acd08 revset: report unknown function with span 2022-11-03 09:41:04 +09:00
Yuya Nishihara
fdbd44571d revset: report unparsable file path with span 2022-11-03 09:41:04 +09:00
Yuya Nishihara
65c903869c revset: wrap RevsetParseError to optionally have code span
The idea is to (ab)use pest::error::Error type to pretty-print error
message with code span. pest::error::Error will be constructed upfront
to erase lifetime from Span<'i>/Position<'i>.
2022-11-03 09:41:04 +09:00
Yuya Nishihara
f4cb91c7dd revset: remove pre-calculation of arguments count 2022-11-03 09:41:04 +09:00
Yuya Nishihara
1d4b5fd8a7 revset: add helper functions that extracts function arguments
These functions doesn't return inner Pairs but Pair so that the Span of
the matching tokens can be easily obtained.
2022-11-03 09:41:04 +09:00
dependabot[bot]
e4e4fe4461 github: bump github/codeql-action from 2.1.29 to 2.1.30
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.29 to 2.1.30.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](ec3cf9c605...18fe527fa8)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-02 09:33:52 -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
Benjamin Saunders
de1dc4ca13 tesutils: replace lazy_static with std::sync::Once 2022-11-01 12:23:07 -07:00
Yuya Nishihara
62511f7cad revset: extend file() predicate to accept more than one paths
'file(a, b)' could be expressed as 'file(a) | file(b)', but the former is
easier to type and can be evaluated efficiently without optimization step.
2022-11-02 01:02:37 +09:00
Yuya Nishihara
fba6741c23 revset: resolve file path at parse() stage
Baby step towards embedding matcher in RevsetExpression. If we had a fileset
language or regex pattern, we would probably want to parse it at this stage
so the syntax error can be reported without evaluation.
2022-11-02 01:02:37 +09: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
dependabot[bot]
38ee349cc2 cargo: bump once_cell from 1.15.0 to 1.16.0
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-31 09:13:00 -07:00
dependabot[bot]
43cfe5488c cargo: bump clap_mangen from 0.2.3 to 0.2.4
Bumps [clap_mangen](https://github.com/clap-rs/clap) from 0.2.3 to 0.2.4.
- [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_mangen-v0.2.3...clap_mangen-v0.2.4)

---
updated-dependencies:
- dependency-name: clap_mangen
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-31 09:10:42 -07: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
Martin von Zweigbergk
416a36a59c git: don't abandon root commit when all refs are gone
If you remove all refs from the backing Git repo and then run `jj git
import`, we would see that all commits disappeared from the Git repo,
so we would remove them from the jj repo too. However, we do that by
doing a history walk from old heads to the new heads, which includes
the root commit when the new heads is an empty set. That means that we
mark the root commit as abandoned, which led to a crash in
`rewrite.rs` (when we try pick the root commit's first parent to use
as parent for rebased commits).
2022-10-29 03:02:26 -07:00
Martin von Zweigbergk
20eb9ecec1 git: don't abandon HEAD commit when it loses a branch
I was trying to create a reproduction script for #412, but the script
ran into another bug first. The script removed all the local and
remote branches from the backing Git repo. I noticed that we would
then try to abandon all commits. We should still count Git HEAD's
target as visible and not try to abandon it. This patch fixes that.
2022-10-29 03:02:26 -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
3d1ac8b933 repo: propagate I/O errors gracefully from ReadonlyRepo::init 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