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

172 commits

Author SHA1 Message Date
Martin von Zweigbergk
0d1c23bf02 changelog: asking for a combined description is a feature, not a bug fix
I suppose it could be seen as a bug fix that we no longer discard a
description without asking, but it was intentionally done the way it
was before.

While at it, I also clarified that the source commit gets abandoned if
it becomes empty.
2022-08-31 01:03:01 -07:00
Martin von Zweigbergk
b5378caa81 cli: make jj move/squash/unsquash ask for combined description
In 8ae9540f2c, I made `jj move/squash/unsquash` not abandon the
working copy if it became empty because that would lose any
description associated with it. It turned out that the new behavior
was also confusing because it made it unclear if the working-copy
commit was actually abandoned. Let's roll back that change and instead
ask the user for a combined description when both the source and
destination commits have non-empty descriptions. Not discarding a
non-empty description seems like a good improvement regardless of the
behavior related to working-copy commits. It's also how `hg fold`
behaves (though hg doesn't allow the description to be empty).
2022-08-30 21:41:26 -07:00
Ilya Grigoriev
7dbb8e0fa2 Have jj merge print id of the created commit
I was using a custom `jj log` command and had some trouble finding
 the commit `jj merge` created. The default `jj log` command shows it
 by default, but my custom one didn't.
2022-08-30 20:43:11 -07:00
Martin von Zweigbergk
0d1bf7cb3b cli: disable open commits by default 2022-08-26 23:34:52 -07:00
Martin von Zweigbergk
cd458ec96b cli: teach jj checkout a -m flag, to match jj new
The two commands are very similar and we should probably make one an
alias of the other (or just delete one), but for now let's at least
make them more similar by supporting `-m` for both.

I currently think `jj new` is more natural when starting a new change
on top of the current one and `jj checkout` is more natural when
starting a new change on top of another one, as well as when you just
want to look around or run tests. `jj checkout` doesn't currently
default to the working copy like `jj new` does. Perhaps we should make
it do that. Will people eventually feel that it's natural to run `jj
checkout` to create a new change on top of the working copy, or will
they feel that it's natural to run `jj new` on an unrelated commit
even to just look around, or will we want them as synonyms forever?
2022-08-26 23:34:52 -07:00
Martin von Zweigbergk
3e79eacaf7 cli: snapshot working copy even on e.g. jj diff -r <some hash>
I was initially worried about the cost of always snapshotting the
working copy, so that's why e.g. `jj diff -r <some hash>` doesn't do
it. However, there's been a few caused by missing snapshotting, and
there are still a few (I just noticed it in `jj undo` while writing
this patch). Let's always do the snapshotting and if the user really
doesn't want it, they can pass `--no-commit-working-copy` (which we
should probably rename to `--no-snapshot-working-copy` or maybe just
`--no-snapshot`). That should reduce bugs and make the CLI more
predictable.

Two test cases were affected becasue `jj merge` also didn't snapshot
the working copy.

Before this patch, e.g. `jj co --no-commit-working-copy` would error
out, but now it will succeed (without touching the working copy,
leaving the working copy stale). That may be confusing, but it should
be easy to recover from (e.g. by `jj undo`). We can consider adding a
check for it later if it seems too confusing (it's probably rarely
something the user wanted).
2022-07-29 22:06:53 +02:00
Martin von Zweigbergk
8bc4574ee5 cli: push only branches pointing to @ by default
Since we now allow pushing open commits, we can implement support for
pushing the "current" branch by defining a "current" branch as any
branch pointing to `@`. That definition of a current/active seems to
have been the consensus in discussion #411.

Closes #246.
2022-07-13 16:23:13 -07:00
Martin von Zweigbergk
42b2937d5e cli: add jj edit for editing a commit in the wokring copy 2022-07-01 08:58:08 +08:00
Martin von Zweigbergk
6952b4f91e rewrite: create new checkout on top iff commit abandoned
When rebasing commits after rewrites, we also update all workspaces'
checkouts. If the new commit is closed, we create a new commit on
top. Since we're hoping to remove the open/closed concept, we need a
new condition. I considered creating a new commit on top if the change
ID was different from before the rewrite. However, that would make at
least `jj split` more complicated because it makes the first commit
keep the change ID but it wants the second commit to be checked
out. This patch instead creates the new commit on top only when the
original commit was abandoned.
2022-07-01 08:58:08 +08:00
Martin von Zweigbergk
9c55d98842 cli: rename jj edit to jj touchup 2022-07-01 08:58:08 +08:00
Martin von Zweigbergk
fc4b109e5b cli: allow pushing open commits
Since we're thinking of removing the concept of open and closed
commits, we can't use that open/closed distinction to decide to not
push some commits.
2022-07-01 08:58:08 +08:00
Martin von Zweigbergk
051c01491c cli: teach obslog an option to show diff
This patch adds `jj obslog -p` for including the diff compared to the
predecessor (the first predecessor if there are several). If the
predecessor's parents are different, then we create a temporary tree
by rebasing the predecessor to have the same parents and we use the
result as base for the diff. That way, we avoid polluting the diff
with the changes caused by the rebase. (I don't think we currently
have any commands that can change both parents and content, so the
diff should always be empty for rewrites caused by a rebase.)

Working on this also reminded me that it'll be really nice when we
replace `jj obslog` by something based on the operation log - I really
miss seeing information about the operation in the output (like `hg
obslog` gets from its obsmarkers).
2022-06-14 04:39:49 -07:00
Yuya Nishihara
4dea1f9e16 cli: parse --color option and reconfigure ui
I often redirect the jj output to pager, so I set ui.color = "always" in
config file. This patch allows me to remove such config, and instead specify
--color=always only when needed.
2022-06-10 12:47:06 +09:00
Yuya Nishihara
3d41db1659 config: move NO_COLOR handling from ui, don't override user setting
According to the NO_COLOR FAQ, "user-level configuration files [...] should
override $NO_COLOR." https://no-color.org/

Unfortunately this makes it harder to test the $NO_COLOR behavior since the
test environment isn't attached to a tty. We could allocate a pty or
LD_PRELOAD shim to intercept isatty(), but I feel it would be too much to do.

https://github.com/assert-rs/assert_cmd/issues/138
2022-06-10 12:47:06 +09:00
Martin von Zweigbergk
6667b3efec cli: prevent pushing commits without description, author, or committer
This patch prevents perhaps pushing commits with an empty description
or the placeholder "(no user/email configured)" values for
author/committer.

Closes #322.
2022-06-06 17:31:01 -07:00
Martin von Zweigbergk
bcf94bd70e CommitBuilder: when rewriting commit, replace placeholder user/email
If a commit's author field has the placeholder user/email values
(i.e. "(no name configured)" and "(no email configured)"), and they
have now configured their email and username, they probably want us to
update the author field with the new information, so that's what this
patch does. Thanks to durin42@ for the suggestion on #322.
2022-06-06 17:31:01 -07:00
Waleed Khan
de1c8f0f37 cli: make jj branch take subcommands, not flags
As per https://github.com/martinvonz/jj/issues/330.
2022-06-06 09:02:56 -07:00
Martin von Zweigbergk
8ae9540f2c cli: make move/squash/unsquash keep empty working-copy commit
If the source commit becomes empty as a result of
`move/squash/unsquash`, we abandon it. However, perhaps we shouldn't
do that if the source commit is a working-copy commit because
working-copy commits are often work-in-progress commits.

The background for this change is that @arxanas had just started a new
change and had set a description on it, and then decided to make some
changes in the working copy that should be in the parent
commit. Running `jj squash` then abandoned the working-copy commit,
resuling in the description getting lost.
2022-05-30 07:52:24 -07:00
Tal Pressman
9831b82a98 Add configuration option to override branch name prefix. 2022-05-26 00:41:52 +09:00
Martin von Zweigbergk
6c6e6cb423 checkout: don't abandon old commit if it has non-empty description
If the user entered a description, we shouldn't abandon it even if it
has no changes to the content.
2022-05-21 22:12:15 -07:00
Martin von Zweigbergk
eedc315821 cli: make jj new always check out the new commit
Before this change, `jj new` would check out the new commit only if it
was created on top of the current commit. I never liked that
special-casing, and after thinking more about how the open/closed
should work (see discussion #321), I think we want `jj new` to behave
similar to how `git/hg checkout` works, so it can effectively replace
the current `jj checkout` command for the use case of starting new
work on top of an existing commit.
2022-05-21 22:12:15 -07:00
Martin von Zweigbergk
6c83eb6ae3 cli: teach log flag to show commits in reverse order
This adds a `--reversed` flag to `jj log` to show commits with later
commits further down. It works both with and without the graph.

Since the graph-drawing code is already independent of the
relationship between commits, it doesn't need any updating.
2022-05-15 05:17:54 -07:00
Martin von Zweigbergk
71c789f50b cli: make log show only local commits by default
The default log output of showing all commits is not very useful when
contributing to an existing repo. Let's have it default to showing
commits not on any remote branch instead. I think that's the best we
can do since we don't have a configurable main branch yet, and we
don't even have per-repo configuration..

Closes #250.
2022-05-14 11:50:05 -07:00
Martin von Zweigbergk
788831fed3 cli: allow alias after global args, and recursive aliases
Our support for aliases is very naively implemented; it assumes the
alias is the first argument in argv. It therefore fails to resolve
aliases after global arguments such as `--at-op`.

This patch fixes that by modifying the command defintion to have an
"external subcommand" in the list of available commands. That makes
`clap` give us the remainder of the arguments when it runs into an
unknown command. The first in the list will then be an alias or simply
an unknown command. Thanks to @epage for the suggestion on in
clap-rs/clap#3672.

With the new structure, it was easy to handle recursive alias
definitions, so I added support for that too.

Closes #292.
2022-05-12 06:30:27 -07:00
Martin von Zweigbergk
6483aeefea cli: respect $VISUAL, overriding $EDITOR
With this patch, the order is this:

`$JJ_EDITOR` environement variable
`ui.editor` config
`$VISUAL` environement variable
`$EDITOR` environement variable
`pico`

That matches git, except that git falls back to an editor determined
at compile time (usually `vi`) instead of using `pico`.
2022-05-10 10:39:59 -07:00
Martin von Zweigbergk
0f5e360d96 cli: allow config in ~/.jjconfig.toml
As I said in 095fb9fef4, removing support for `~/.jjconfig` was an
experiment. I've heard from a few people (including in #233) that they
would prefer to have configs in the home directory. This patch
therefore restores that functionality, except I added a `.toml`
extension to the file to clarify the expected format to users and
editors.

After this patch, we still allow configs in `$XDG_CONFIG_HOME` (and
the other paths used by `dirs::config_dir()`), but we error out there
are config files in both that location and `~/.jjconfig.toml`.
2022-05-10 10:21:22 -07:00
Martin von Zweigbergk
f5f363f079 cli: make invalid alias definition an error 2022-05-10 04:02:24 -07:00
Waleed Khan
7a551e584f cli: jj branch can accept any number of branches 2022-05-02 21:33:58 -07:00
Yuya Nishihara
f6acee41df diff_edit: load command arguments from merge-tools.<name> config
Apparently, I need to pass `--merge` option to use kdiff3 as a diff editor.

We could add `diff-editor-args` or extend `diff-editor` to a list of command
arguments, but we'll eventually add stock merge tools and the configuration
would look like:

    [merge-tools.<name>]
    program = ...
    diff-args = [...]
    edit-args = [...]
    merge-args = [...]
2022-05-03 12:24:05 +09:00
Martin von Zweigbergk
81a8cfefcb cli: add a mode of pushing with branch taken from change ID
This adds `jj git push --change <revision>` which creates a branch
with a name based on the revision's change ID, and then pushes that
like with `--branch`. That can be useful so you don't have to manually
add the branch (and come up with a name for it). The created branch
behaves like any other branch, so it's possible to make it point to a
commit with a different change ID.
2022-04-29 15:55:03 -07:00
Martin von Zweigbergk
0719dae975 cli: add a command for listing git remotes and their URLs
As requested by @talpr. I added this is a separate new command `jj git
remote list`. One could also imagine showing the listing when there is
no sub-command specified to `jj git remote`, but we don't have other
commands that behave that way yet.

Closes #243
2022-04-29 14:08:24 -07:00
Martin von Zweigbergk
57ba9a9409 git: when importing refs, abandon commits that were abandoned in git
Now that I'm using GitHub PRs instead of pushing directly to the main
branch, it's quite annoying to have to abandon the old commits after
GitHub rebases them. This patch makes it so we compare the remote's
previous heads to the new heads and abandons any commits that were
removed on the remote. As usual, that means that descendants get
rebased onto the closest remaining commit.

This is half of #241. The other half is to detect rewritten branches
and rebase on top.
2022-04-28 11:28:09 -07:00
Martin von Zweigbergk
0789a8a4c0 revsets: allow single internal - and + characters in symbols (#46) 2022-04-28 08:14:15 -07:00
Martin von Zweigbergk
885c780642 cli: add commands for working with sparse patterns (#52)
This adds a `jj sparse` command with options to list and manage the
set of paths to include in the working copy. It only supports includes
(postive matches) for now.

I'm not sure "sparse" is the best name for the feature. Perhaps it
would make sense as a subcommand under `jj workspace` - maybe `jj
workspace track`? However, there's also `jj untrack` for removing a
file from the working copy and leaving it in the working copy. I'm
happy to hear suggestions, or we can get back to the naming later.
2022-04-26 14:52:17 -07:00
Tal Pressman
ad79d89e4b Remove out-of-date parenthetical in tutorial.md 2022-04-26 08:10:28 -07:00
Martin von Zweigbergk
8744015f33 cli: make operation to undo or restore to a positional argument
I originally made the operation argument a named argument
(`--operation`) to allow for a change ID to be passed as a positional
argument, matching e.g. `hg revert -r <rev> <path>`. However, even if
we add support for undoing changes only to certain change IDs, it's
going to be done much less frequently than full undo/restore. We can
therefore make that a named argument if we ever add it.
2022-04-25 17:29:48 -07:00
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
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
2e0d80919d cli: some fixes and touch-ups for jj workspace, plus 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
762c8984c6 trees: when merging trees and one is missing, treat it as empty
When a directory is missing in one merge input (base or one side), we
would consider that a merge conflict. This patch changes that so we
instead merge trees by treating the missing tree as empty.
2022-04-20 13:47:03 -07:00
Martin von Zweigbergk
53911b076b working_copy: fix crash when updating and only executable bit changed 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
7e79f25508 revset: add a roots() function 2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
9ff21d8924 revset: add a connected() function
This introduces a `connected(x)` function, which is simply the same as
`x:x`. It's occasionally useful if `x` is a long expression. It's also
useful as a building block for `root(x)` (coming soon).
2022-04-13 23:24:51 -07:00
Martin von Zweigbergk
677dea1682 cli: require at least one destination for rebase
Rebasing onto no commits (i.e. onto the root commit) is almost
definitely not what you meant to do if you run `jj rebase` (without
any arguments).
2022-04-11 15:35:21 -07:00
Martin von Zweigbergk
97a1a3e20b merge: fix modify/delete conflict to not resolve 2022-04-10 18:32:36 -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
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
bc3c2db828 cli: print errors to stderr 2022-04-09 16:13:01 -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
6efa47814a release: release version 0.4.0
This release is mostly about the fix for #177, which looks pretty bad
even though I think it is actually harmless. It also has `jj log -p`
contributed by @yuja!
2022-04-02 23:35:15 -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
04ad9a3628 repo: when merging in removed head, rebase descendants (#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
Martin von Zweigbergk
2f59e8b68a cli: respect $NO_COLOR environment variable 2022-03-23 09:57:42 -07:00
Martin von Zweigbergk
7ba1c6bdb6 config: add support for a $JJ_CONFIG environment variable
It's useful for tests, scripts, and debugging to be able to use
specific config instead of the user's config. That's especially true
for our automated tests because they didn't have a place to read
config from on Windows before this patch (they read their config from
`{FOLDERID_RoamingAppData}`, which I don't think we can override in
tests).
2022-03-23 09:57:42 -07:00
Martin von Zweigbergk
095fb9fef4 config: drop support for ~/.jjconfig
I'm a little hesitant to do this because most tools I'm familiar with
have the config file directly in `~/`. It's also easier to describe
where to put the file if it doesn't vary across platforms. But we're
still early in the project, so let's try it and see if we get any
complaints.
2022-03-23 09:57:42 -07:00
Martin von Zweigbergk
cc13a2ec84 release: include the two recent no-op releases in the changelog
I keep forgetting to update things while doing a release...
2022-03-17 06:03:10 -07:00
Martin von Zweigbergk
a46bda3d49 release: update release notes for 0.3.1
I forgot to do this when I bumped the version number.
2022-03-13 21:54:45 -07:00
Martin von Zweigbergk
c14e138698 cli: expand ~ in core.excludesFile, don't crash when missing
I thought that `std::fs::canonicalize()` expanded "~", but it doesn't
seem to do that, which caused #131. Git seems to do the expansion
itself, so we probably also should. More importantly
`std::fs::canonicalize()` crashes when the file doesn't exist. The
manual expansion we do now does not.

Closes #131.
2022-03-13 12:40:37 -07:00
Martin von Zweigbergk
1777d85550 release: add a changelog 2022-03-12 23:03:01 -08:00