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

1307 commits

Author SHA1 Message Date
Yuya Nishihara
3792f4a019 templater: use .map_or() to silence clippy without sacrificing readability 2024-06-30 10:25:18 +09:00
Yuya Nishihara
0ca8502c5a diff: inline hunk processing in get_diff_stat()
This is simpler and more efficient. If we add word-diff to unified_diff_hunks(),
it will do more expensive work that isn't needed here.
2024-06-30 10:17:41 +09:00
Ilya Grigoriev
6d3d7c61f2 nightly clippy fixes
Includes a false-positive, https://github.com/rust-lang/rust-clippy/issues/13018.
2024-06-29 11:22:01 -07:00
Ilya Grigoriev
c563ea8b29 clippy: remove warning when not using watchman feature
I keep seeing the one in lib/ when running tests in VS Code, but I also
fixed the warnings in watchman.rs for good measure.
2024-06-29 11:22:01 -07:00
Scott Taylor
1eebbe57c0 commit_builder: reset author timestamp on discardable commits
It's common to create empty working-copy commits while using jj, and
currently the author timestamp for a commit is only set when it is first
created. If you create an empty commit, then don't work on a repo for a
few days, and then start working on a new feature without abandoning the
working-copy commit, the author timestamp will remain as the time the
commit was created rather than being updated to the time that work began
or finished.

This commit changes the behavior so that discardable commits (empty
commits with no description) by the current user have their author
timestamps reset when they are rewritten, meaning that the author
timestamp will become finalized whenever a commit is given a description
or becomes non-empty.
2024-06-29 08:35:53 -05:00
Ilya Grigoriev
e21e5e69d2 cli chore: standardize subcommand function and argument type names
Now, the command for `jj git remote add` is `cmd_git_remote_add` and its
argument type is `GitRemoteAddArgs`. This should make it easier to find
the CLI docs and the implementation for commands.

This is how `jj branch` commands were already set up in this way. The
`jj op` commands were also already set up in this way, except the
functions are called e.g. `cmd_op_undo`, I kept this for simplicity.

I was mainly motivated by the `jj file` commands. Most other commands
had functions already named in the above pattern, but used to have
shorter argument type names.
2024-06-28 13:38:04 -07:00
Martin von Zweigbergk
eba9ac0b1b cli: add a debug command for generic working copy info
We have two other kinds of working copies at Google and it's sometimes
useful to get the basic information about operation id and tree id for
them, for exampel for debugging stale workspaces. This patch adds a
command for that.

We could instead have made the old `jj debug working-copy` command
work for all kinds of working copies (like the new command) and only
have extra information for the standard local-disk implementation. I
don't feel strongly either way and could do it other other way instead
if people prefer that.
2024-06-28 21:31:44 +09:00
Martin von Zweigbergk
8f9f46f18f cli: rename jj debug working-copy to jj debug local-working-copy
I'd like to add a more generic `jj debug working-copy` command that
prints the information that's shared across implementations.
2024-06-28 21:31:44 +09:00
Yuya Nishihara
af986a58ed cli: branch: assume deleted tracking branch name is still allocated
While explaining branch tracking behavior, I find it's bad UX that a deleted
branch can be re-"create"d with tracking state preserved. It's rather a "set"
operation. Since deleted tracking branch is still listed, I think it's better
to assume that the local branch name is reserved.

https://github.com/martinvonz/jj/discussions/3871

Renaming to deleted tracking branch is still allowed (with warning) because the
"rename" command can't handle tracked remotes very well. If it were banned, bad
rename couldn't be reverted by using "jj branch rename". It would be confusing
if "rename a b" succeeded with warning, but the following "rename b a" failed.
2024-06-28 19:36:09 +09:00
Yuya Nishihara
06813d9462 cli: branch: slightly update warning message about rename with tracked remotes
We use "tracked remote branches" in the doc, and hints are usually capitalized.
2024-06-28 19:36:09 +09:00
Yuya Nishihara
ce2e016e57 cli: branch: extract helper that checks if tracked remote branch exists 2024-06-28 19:36:09 +09:00
Yuya Nishihara
76ff35eba4 cli: branch: inline view.remove_branch() in cmd_branch_forget()
This API no longer makes sense, and we'll probably add some flags to forget
only tracked remotes for example.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
e7ea0d579a cli: branch: let find_*_branches() return (name, target) pairs
This will help inline view.remove_branch() in cmd_branch_forget(). I don't
care much about owned (String, _) vs (&str, _), but we can't simplify the
lifetime issue in find_forgettable_branches() anyway. So I made all callers
pass cloned Arc<ReadonlyRepo> and borrow (name, target) pairs from there.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
19904e9e00 cli: branch: inline make_branch_term(), use singular form
It's used only in transaction descriptions, and I think singular form works
at adjective position.
2024-06-28 10:29:06 +09:00
Yuya Nishihara
9613ec4f82 revset: drop Eq/PartialEq from RevsetExpression and related types
It was convenient that expression nodes can be compared in tests, but no
equivalence property is needed at runtime. Let's remove Eq/PartialEq to
simplify the extension support.
2024-06-28 10:28:51 +09:00
Yuya Nishihara
5abc87fdb6 tests: add word-level hunks and capture some colorized diff outputs 2024-06-27 12:00:08 +09:00
Ilya Grigoriev
e6c2108d4d cli: rename jj file print (formerly jj cat) to jj file show
We now have two `cmd_show` in the repo. I think this one should become
`cmd_file_show`, but this should be done uniformly over all the commands
for consistency.

I did *not* keep `print` as an alias (I couldn't find a compelling
reason to do it), but let me know if anyone feels like keeping it.
2024-06-26 17:11:16 -07:00
Martin von Zweigbergk
848bb610cc cli: underline added/removed lines only in color-words diffs
We don't want e.g. `jj diff --git` to have underlined text because
it's redundant there. This patch fixes that by adding a new `token`
label used only in the color-words diff (for now - it may be used in
git diffs in the future).

This means we could remove the `line_number` label but I left it
because there's little harm in having it and it seems like it can
still be useful.

Thanks to @yuja for noticing and suggesting the fix.
2024-06-27 06:47:18 +09:00
Jonathan Tan
9e18a61550 diff: underline added/removed parts by default
This helps better visualize changes that contain leading and/or trailing
whitespace.
2024-06-25 13:08:47 -07:00
Ilya Grigoriev
40bb207747 docs: replace jj chmod -> jj file chmod
`jj chmod` is now deprecated
2024-06-24 21:01:55 -07:00
Ilya Grigoriev
46b37aca2f docs: replace jj files -> jj file list
`jj files` is now deprecated
2024-06-24 21:01:55 -07:00
Martin von Zweigbergk
5ba6078354 cli: add label for line numbers in --color-words diff
If you want to set a background color on added/removed lines, you
currently get the same style on the line numbers. This patch lets you
specify a different style by overriding it on the line numbers.
2024-06-25 11:57:31 +09:00
mlcui
6ae4f45838 cli: Ignore immutable() in jj git push conflict/desc/user checks
Fixes #3029.
2024-06-24 10:45:29 +10:00
Yuya Nishihara
297a0ebb68 cli: stop using shared id prefix context to compute immutable heads
It's unlikely that the immutable set is defined by short hashes, and more
importantly, the cache must not be initialized by using tx.repo().
2024-06-24 09:16:15 +09:00
James Sully
f8e106a194 cli: git: add jj git remote set-url command 2024-06-23 12:31:43 +10:00
Yuya Nishihara
3c80e3453d cli: branch: make "set" do upsert as before
Since "set <thing>" often adds a <thing> if not exists, it make some sense
that "branch set" does upsert. The current "branch set" use case is now covered
by "branch move", so it's okay to change the "set" behavior.

If new branch is created by "branch set", status message and hint will be
printed to help migration. The user should be able to undo creation if it was
a mistake.

Closes #3584
2024-06-23 09:44:38 +09:00
Yuya Nishihara
9dd8477f73 cli: sort operation subcommands 2024-06-23 09:43:30 +09:00
Yuya Nishihara
ebe97e3a9b cli: remove unneeded "pub" from "op undo" mode type and constant
Maybe we don't care, but let's make them private as all users and helper
functions are private.
2024-06-23 09:43:30 +09:00
Yuya Nishihara
b72f2827d0 cli: move cmd_operation() dispatcher fn next to type definition 2024-06-23 09:43:30 +09:00
Martin von Zweigbergk
15e0d62380 cli: split up commands/operation.rs into one file per command 2024-06-22 08:49:02 +09:00
Martin von Zweigbergk
3db183b4c5 prev: make revset code more similar to next 2024-06-22 04:48:29 +09:00
Martin von Zweigbergk
49b76cbd8c next/prev: fix a few bugs in --conflict 2024-06-22 04:48:29 +09:00
Martin von Zweigbergk
d8cd38a3a8 next: make test cases test what they were supposed to 2024-06-22 04:48:29 +09:00
Martin von Zweigbergk
741fa8dfe2 next: add a test for jj next --edit on a head 2024-06-22 04:48:29 +09:00
Martin von Zweigbergk
8aeb9a8ea8 next/prev: include graph in --conflict tests, highlighting bugs
There are several bugs in both the tests and in the implementation
that are made more clear by showing the log output before and after
running the command.
2024-06-22 04:48:29 +09:00
Yuya Nishihara
ddeb10b3f3 cli: branch: drop support for deprecated --glob option
It's been 8 months since the option got deprecated by 8dbe12da2a.
2024-06-21 09:43:23 +09:00
Yuya Nishihara
adcd78a0b7 cli: sort config/sparse subcommands in lexicographical order 2024-06-21 09:43:14 +09:00
Yuya Nishihara
78dba90ac8 cli: sort match arms in run_command() 2024-06-21 09:43:14 +09:00
Yuya Nishihara
ef9633135e cli: rename derived_subcommands to subcommand, remove redundant type annotation
I don't think "derived" here makes much sense.
2024-06-21 09:43:14 +09:00
Yuya Nishihara
20f1ba5a08 cli: rename "sub_args" variables to "args"
Just for consistency.
2024-06-21 09:43:14 +09:00
Yuya Nishihara
026d83b61f cli: rename SparseArgs to SparseCommand 2024-06-21 09:43:14 +09:00
Philip Metzger
de022aeaa7 next/prev: Implement next/prev --conflict
This allows users to jump to the next conflict in the ancestors or children of 
the start commit.

Continues work on #2126

Co-Authored-By: Noah Mayr <dev@noahmayr.com>
2024-06-20 23:29:41 +02:00
Philip Metzger
0d9000271e lib: Add RevsetExpression::filtered().
This allows users to easily filter a commit range by conflicts, which will be needed for `next/prev`
further down in the next commit. Users which benefit from it were also migrated.
2024-06-20 23:29:41 +02:00
Matt Kulukundis
c9b3d64ce5 Add background snapshotting info to debug watchman status. 2024-06-20 16:09:06 -04:00
Austin Seipp
397e96f9ae cli: let jj git push --change handle large revsets
In a repo of mine I wanted to do something like the following to push all of my
leaves to the remote as backup:

    jj git push -c 'all:heads(base::) & mine() ~ empty()'

But couldn't, because `jj git push` doesn't handle large revsets, even though
it does handle multiple `-c` arguments, so I had to work out some pipe-to-xargs
command instead.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-20 11:40:55 -05:00
Austin Seipp
aab82cd641 cli: print out short change ids with jj git push --change
The follow up diff will make `-c` accept large revsets, so it won't make any
sense to print out the original expression when multiple branches will be
created from it.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-06-20 11:40:55 -05:00
Yuya Nishihara
5988a00ae4 cli: branch: reject empty branch name consistently by "set"
Though "branch set" can't create new branch, this should provide a better error
message.
2024-06-20 17:00:34 +09:00
Yuya Nishihara
d4e64c46b4 cli: branch: remove trailing period from command/arg summary lines
That's the convention of clap.
2024-06-20 17:00:34 +09:00
Yuya Nishihara
844e6684bd cli: branch: remove inconsistent "pub"s from Args fields 2024-06-20 17:00:34 +09:00
Yuya Nishihara
d640645d7b cli: branch: sort cmd_branch() match arms 2024-06-20 17:00:34 +09:00