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

202 commits

Author SHA1 Message Date
Martin von Zweigbergk
5eba305844 git: when exporting, skip conflicted branches 2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
759ddd1e60 git: on initial export, export all branches
As I said in the previous patch, I don't know why I made the initial
export to Git a no-op. Exporting everything makes more sense to
(current-)me. It will make it slightly easier to skip exporting
conflicted branches (#463). It also lets us remove a `jj export` call
from `test_templater.rs`.
2022-11-13 15:06:10 -08:00
Martin von Zweigbergk
f40c8d86a1 tests: add more tests of working copy colocated with Git
We had very little testing of the colocated case, so let's add a bit
more before I start working on this code in coming patches. This
includes a test for #463.
2022-11-13 15:06:10 -08:00
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
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
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
Martin von Zweigbergk
3c7c4e9f5c tests: move testutils module into separate crate
The `testutils` module should ideally not be part of the library
dependencies. Since they're used by the integration tests (and the CLI
tests), we need to move them to a separate crate to achieve that.
2022-11-08 07:29:35 -08: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
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
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
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
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
Martin von Zweigbergk
efce1e54e6 tests: extract setup of libgit2 config to lib crate
We have some problems with non-hermetic tests in the lib crate, so
we'll want to reuse the setup code there.
2022-10-23 11:08:22 -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
Benjamin Saunders
037eaaf36c repo: forbid checking out the root commit
Prevents `jj edit root` from succeeding, which would otherwise place
the repo in a state where every operation panics.
2022-10-21 10:10:07 -07:00
Benjamin Saunders
305cb3a7ee cli: search @- for branches to push when @ has none 2022-10-20 22:18:48 -07:00
Benjamin Saunders
b009019d8d cli: add git remote rename subcommand 2022-10-20 11:04:16 -07:00
Benjamin Saunders
646fc338ab Include @ in the default revset
Yields a less confusing behavior of `jj log` after pushing a commit.
2022-10-19 13:30:16 -07:00
Martin von Zweigbergk
94501131ac cli: when merging concurrent operations, snapshot afterwards
It seems simpler to do the snapshotting after merging any concurrent
operations instead of snapshotting on top of one of the operations,
especially since the attempt to snapshot may end up noticing that the
working copy is stale.

More importantly, snapshotting before resolving operations resulted in
a crash if the working copy was modified. That happened because we
held a lock on the operation heads (`locked_op_heads`) while we tried
to record the operation committing the working copy. I noticed this
only after adding the test.
2022-10-12 06:22:38 -07:00
Martin von Zweigbergk
5fa21b612c cli: remind the user to configure their name and email
This commit adds a reminder in `finish_transaction()` if the user
hasn't configured their name and email. That means they'll get a
reminder after most mutating commits, except for commands that only
snapshot the working copy, and a few more cases.

Closes #530.
2022-10-09 21:24:05 -07:00
Martin von Zweigbergk
af4d183c7e cleanup: automated fixes by new Clippy version 2022-10-09 12:20:15 -07:00
Martin von Zweigbergk
043d118f1f cli: disallow initializing repo with native backend by default
The native backend is just a proof of concept and there's no real
reason to use it other than for testing, so let's reduce the risk of
accidentally creating repos using it.
2022-10-09 01:00:03 -07:00
Tal Pressman
621caa4dcb add default log revset configuration setting 2022-10-02 16:56:18 +09:00
Martin von Zweigbergk
b561a05d25 cargo: upgrade to clap 4.0.4
I changed the "GLOGAL OPTIONS" help heading to use title case, to
match clap's new help style.

I also removed our override of the help text for `-h, --help` because
the default text now includes "(use `-h` for a summary)" (and it's
harder override now).

Perhaps the most obvious difference to users will be the changed help
output
(https://epage.github.io/blog/2022/09/clap4/#polishing-help-output). It
no longer has color, and long lines are not wrapped. I suppose we
should wrap the text ourselves instead..
2022-09-29 17:53:36 -07:00
Martin von Zweigbergk
d1565fb6eb cli: on push, indicate which branches we're going to force-push 2022-09-27 02:23:05 -07:00
Martin von Zweigbergk
2d2ed53a34 tests: use different commit per branch in jj git push tests
I think I meant for this test to use different commits but because
they have the same content and metadata, they ended up with the same
hash.
2022-09-27 02:23:05 -07:00
Yuya Nishihara
16f2b82feb conflicts: change diff line marker to %%%%%%%
I feel the original -------/+++++++ pair is slightly confusing because
each half can be a separator by itself. I don't know what character other
than '-'/'+' is preferred, but let's pick '%' (for "mod") per @martinvonz
suggestion.
2022-09-20 15:26:29 +09:00
Martin von Zweigbergk
6812bd9584 cleanup: rename checkout to wc_commit
`wc_commit` seems clearer than `checkout` and not too much longer. I
considered `working_copy` but it was less clear (could be the path to
the working copy, or an instance of `WorkingCopy`). I also considered
`working_copy_commit`, but that seems a bit too long.
2022-09-18 16:19:58 -07:00
Yuya Nishihara
c9c3735faf cli: add basic support for 'jj log PATH'
In the current implementation, tree is diffed twice if both PATH and -p
are specified. If this adds significant cost, we'll need to reimplement
it without using a revset abstraction (or maybe adjust revset/graph API.)
2022-09-16 13:02:58 +09:00
Ilya Grigoriev
3244398e89 Fix rebase -r of a parent of a merge commit
Previously, using `rebase -r` on the parent of a merge commit
turned it into a non-merge commit. In other words, starting
with

```
    o   d
    |\
    o | c
    o | b
    | o a
    |/  
    o 
```

and doing `rebase -r c -d a` resulted in

```
    o d
    o b
    | o c
    | o a
    |/  
    o 
```

where `d` is no longer a merge commit.

For reference, here's a complete test that passed before this commit (but should NOT pass; see the diff for a test that should pass):

```
#[test]
fn test_rebase_single_revision_merge_parent() {
    let test_env = TestEnvironment::default();
    test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
    let repo_path = test_env.env_root().join("repo");

    create_commit(&test_env, &repo_path, "a", &[]);
    create_commit(&test_env, &repo_path, "b", &[]);
    create_commit(&test_env, &repo_path, "c", &["b"]);
    create_commit(&test_env, &repo_path, "d", &["a", "c"]);
    // Test the setup
    insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
    @
    o   d
    |\
    o | c
    o | b
    | o a
    |/
    o
    "###);

    let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-r", "c", "-d", "a"]);
    insta::assert_snapshot!(stdout, @r###"
    Also rebased 2 descendant commits onto parent of rebased commit
    Working copy now at: 3e176b54d680 (no description set)
    Added 0 files, modified 0 files, removed 2 files
    "###);
    insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
    @
    o d
    | o c
    o | b
    | o a
    |/
    o
    "###);
}
```
2022-09-12 12:23:21 -07:00
Yuya Nishihara
b21a123bc8 cli: ensure rebase destinations are unique and not form a merge with root 2022-09-12 23:46:15 +09:00
Josh Soref
fd3f8afe1a spelling: nonexistent
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-09 11:58:37 -07:00
Yuya Nishihara
872081c867 tests: use testutils::new_temp_dir() thoroughly 2022-09-07 23:49:46 +09:00
Glen Choo
468418f1ce cli: add interdiff command
Add the `jj interdiff` command for comparing only the diffs of commits.
Its args are identical to that of `jj diff`, minus `--revision` (because
interdiff always requires two commits).

Like `jj obslog -p`, Changes introduced by intervening commits are
ignored by rebasing `--from` onto `--to` 's parents.
2022-09-02 02:59:37 +08:00
Yuya Nishihara
c5aab9fe29 cli: fix crash on "jj merge whatever root" 2022-09-01 13:36:17 +09:00