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

92 commits

Author SHA1 Message Date
Martin von Zweigbergk
0058236a43 cli: make jj restore --to <rev> restore from the working copy 2022-04-25 17:29:48 -07:00
Martin von Zweigbergk
9f9af78c45 cli: provide better error message for no-arg jj move 2022-04-25 17:29:48 -07:00
Martin von Zweigbergk
04f11c0dc3 rebase: update bookkeeping for branches as we rebase descendants
The `DescendantRebaser` keeps a map of branches from the source
commit, so it gets efficient lookup of branches to update when a
commit has been rebased. This map was not kept up to date as we
rebased. That could lead to branches getting left on hidden
intermediate commits. Specifically, if a commit with a branch was
rewritten by some command, and an ancestor of it was also rewritten,
then we'd only update the branch only the first step and not update it
again when rebasing onto the rewritten ancestor.
2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
cc7e20859c tests: add tests of jj move to ancestor, showing lost branch
I noticed earlier today that branches get lost (stuck on a hidden
commit) when you move part of a change to an ancestor. This patch adds
tests for both of those cases, showing the bug. There's no special
logic for this case in the CLI crate, so we should be able to test it
in the library crate instead, but since I have already written the
tests, maybe we can keep them.
2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
9d440ca835 tests: remove a duplicate log output in jj move test 2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
cf7bef88fe tests: extract a function for getting log output in jj move test 2022-04-25 14:05:27 -07:00
Martin von Zweigbergk
2e0d80919d cli: some fixes and touch-ups for jj workspace, plus tests 2022-04-22 15:45:35 -07:00
Martin von Zweigbergk
90edd670d9 tests: move tests of Ui from tests/ into ui module
The tests only test the `Ui` type and don't need anything from
`testutils`, so it seems they should be treated as unit tests.
2022-04-22 15:45:35 -07:00
Martin von Zweigbergk
8745ee7030 cli: use . in output for current directory instead of empty string 2022-04-20 13:52:25 -07:00
Martin von Zweigbergk
bd035004b9 tests: use jj_cmd_success() in one more place 2022-04-14 23:46:28 -07:00
Martin von Zweigbergk
3c71ae3c76 cli: make jj rebase default to -b @ (#168)
Closes #168.
2022-04-14 23:46:28 -07:00
Martin von Zweigbergk
30f5471fc3 cli: add mode for rebasing branch onto destination (#168) 2022-04-14 23:46:28 -07:00
Martin von Zweigbergk
7ec93ddb32 tests: also check output from jj rebase
I'd like to have tests showing the number of commits rebased. I just
missed it when adding the tests.
2022-04-14 23:46:28 -07:00
Martin von Zweigbergk
7aac95ac80 test: add tests for jj rebase 2022-04-13 21:27:30 -07:00
Martin von Zweigbergk
109a9422f0 cli: teach jj split to include all specified paths in first commit 2022-04-10 09:13:51 -07:00
Martin von Zweigbergk
d6d2b8b5bc cli: allow overriding ui.editor config by $JJ_EDITOR variable 2022-04-10 09:13:51 -07:00
Martin von Zweigbergk
96d559a4b4 cli: allow overriding $EDITOR variable by ui.editor config 2022-04-10 09:13:51 -07:00
Martin von Zweigbergk
2958f5791c cli: don't crash if $EDITOR fails 2022-04-10 09:13:51 -07:00
Martin von Zweigbergk
f8724ee5a9 tests: add tests for jj describe 2022-04-10 09:13:51 -07:00
Martin von Zweigbergk
486f49435b cli: if $JJ_CONFIG points to a directory, read all files in it
It's annoying especially for tests to not be able to append to a
config file without knowing the contents (as you have to do with
TOML). Let's read all files in a directory if `$JJ_CONFIG` points to a
directory. Mercurial does that for its `$HGRCPATH` variable.
2022-04-10 09:13:51 -07:00
Martin von Zweigbergk
4be0da3607 cli: teach jj squash to move only changes to specified paths 2022-04-09 16:13:01 -07:00
Martin von Zweigbergk
082ec5ae3b cli: teach jj move to move only changes to specified paths
I quite often want to move the changes to a particular file from one
commit to another. We already support that using `jj move -i`, but
that can be annoying to run because we don't have a TUI for it
(#48). Let's make it possible to do `jj move --from X --to Y <path>`.
2022-04-09 16:13:01 -07:00
Martin von Zweigbergk
9a15e32351 cli: require at least one path for jj untrack
It seems very unlikely that the user would want to untrack all paths
(that's still possible with `jj untrack .`, if they really want to,
and have added all their current paths to the `.gitignore`).
2022-04-09 16:13:01 -07:00
Martin von Zweigbergk
88e34d703e cli: let clap error out for us on jj restore -i <file> 2022-04-09 16:13:01 -07:00
Martin von Zweigbergk
bc3c2db828 cli: print errors to stderr 2022-04-09 16:13:01 -07:00
Martin von Zweigbergk
a4449cd7bc tests: add tests for jj squash -i 2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
3aa153fb59 tests: add tests for jj squash 2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
3d8d0bea71 tests: add tests for jj move -i 2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
dc41c4bfe4 tests: add tests of jj move 2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
696a583e4e tests: add tests for jj edit on merge commit 2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
066f74a1b4 tests: check set of files passed to diff-editor in jj edit 2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
3907677c51 tests: add tests for jj edit
These tests are very similar to the `jj restore -i` tests because `jj
edit -r $REV` is a specialized version of `jj restore -i --from $REV-
--to $REV` on non-merge commits.
2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
7a013a59ae cli: add a command for printing the contents of a file in a revision
I'm adding this mostly because it's useful for testing. That's also
the reason it supports displaying conflicts. I didn't call it `cat`
like `hg cat` because I haven't found `hg cat` on multiple files
useful.
2022-04-06 23:31:28 -07:00
Martin von Zweigbergk
28916ceb19 cli: in help output, list global options under separate heading
I've found it hard to read the `jj help` output because command
options are mixed with global options. This patch fixes that by
putting global options under a separate heading.
2022-04-02 14:57:48 -07:00
Martin von Zweigbergk
f21a069a47 tests: add tests for jj restore -i 2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
d37cb530ec tests: add tests for jj restore 2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
9b44822dc1 tests: add helper for failing tests as well 2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
6344faa3fe tests: allow setting env var for all commands in TestEnvironment
Sometimes it's useful to have an environment variable set for all
commands in a test. This patch lets you do that by adding environment
variables to the `TestEnvironment` itself. These will then be set on
all subsequent commands.
2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
257b85a1b5 test: add helper for writing config file to TestEnvironment 2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
e7648b6342 tests: add tests for jj diff 2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
710d51c45b tests: move testutils from src/ to tests/ 2022-04-02 14:22:58 -07:00
Martin von Zweigbergk
034fbb47e3 cli: fix crash when initializing workspace colocated with Git repo
When initializing a workspace that shares its working copy with a Git
repo (i.e. `jj init --git-repo=.`), we import refs and HEAD when
creating the `WorkspaceCommandHelper` (as we do for all commands when
the working copy is shared). That makes the explicit import we do in
`cmd_init()` unnecessary. It also makes the checkout of HEAD I added
for the fix of #102 unnecessary. More importantly, as @yuja reported
in #177, it makes the command crash (at least if the repo is small
enough that the two checkouts happen within a second). I think the
problem is that the second checkout tries to create the same commit
except that the Change ID is different (the problem is not the
predecessors as I speculated in the issue tracker). The fix is to
simply avoid doing the redundant work. We still need a proper fix for
#27 eventually.

Closes #177.
2022-03-30 22:09:55 -07:00
Martin von Zweigbergk
197f669976 cli: fix git-colocated working copy on Windows
This patch adds a very simple e2e test of having a working copy shared
with Git. The test initially failed on Windows. The symptom was that
the "master" branch did not get updated when we create a commit using
`jj`. That suggested that we didn't correctly detect that the working
copy was shared. After a lot of troubleshooting, I think I mostly
understand what we going on here (thanks to @arxanas for suggesting
https://github.com/mxschmitt/action-tmate). The path we get from
`git2::Repository::workdir()` seems to not be canonicalized in the
same way as `std::fs::canonicalize()` canonicalizes. Specifically, it
does not have the "\\?\" prefix we get from that function. I suppose
that's because libgit2 is a C library and canonicalizes the path using
some other system call.
2022-03-30 22:09:55 -07:00
Yuya Nishihara
a7e3269ed8 log: add -p/--patch option to show diff along with commit meta data
"log -p | less" is the option I often use with hg/git to find interesting
bits from the changelog, and I think it's also valid with jj. Unlike
"hg log -p --stat", "jj log -p --summary" does not show both diff summary
and patch to reflect the internal structure. This behavoir is arguable and
may be changed later.

The logic of show_patch() is extracted from cmd_show().
2022-03-30 16:24:34 -07:00
Martin von Zweigbergk
2ac62203d5 tests: add test for invalid config (#55) 2022-03-27 21:11:55 -07:00
Martin von Zweigbergk
12bce70bed cli: display how many commits were rebased when merging operations (#111)
This involved copying `UnresolvedHeadRepo::resolve()` into the CLI
crate (and modifying it a bit to print number of rebased commit),
which is unfortunate.
2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
04ad9a3628 repo: when merging in removed head, rebase descendants (#111) 2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
749ea62c08 cli: let the user know if there's been a concurrent modification (#111) 2022-03-26 22:31:49 -07:00
Martin von Zweigbergk
a663a5d89c repo: don't abandon empty commit if it has descendants
It's unusual for the current commit to have descendants, but it can
happen. In particular, it can easily happen when you run `jj new`. You
probably don't want to abandon it in those cases.
2022-03-26 21:11:42 -07:00
Martin von Zweigbergk
0ceb4f0dce cli: teach jj new to set initial description with -m
I rarely use `jj new`, so this feature is mostly for use in tests.
2022-03-26 21:11:42 -07:00