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

1590 commits

Author SHA1 Message Date
Yuya Nishihara
92ba6d336d cli: op diff: be more strict about multiple diff sources/destinations
As the doc comment states, this function only supports change of "a single
added and removed commit", "only a single added", or "single removed commit."
It doesn't make sense to show diffs from the parent commit ignoring multiple
removed commits for example.
2024-08-07 10:51:23 +09:00
Ilya Grigoriev
b42e94906d jj run: describe it as a stub in the help text 2024-08-06 17:51:01 -07:00
Ilya Grigoriev
132dfd30e2 describe: warn user of limitations when describing multiple commits
I think it might be nice to have this in the upcoming release, but I'd
like to warn people that their changes will be lost if they aren't
careful, and to not rely on the syntax being fixed just yet.
2024-08-06 11:28:21 -07:00
Ilya Grigoriev
6d1cc7f803 describe multiple commits: instruct user where to put commit descriptions
This seems especially helpful if the descriptions start out empty.
2024-08-06 11:28:21 -07:00
Yuya Nishihara
0b1a6cd9e0 cli: allow any number of trailing dashes in "JJ: describe" line
Because a line without " -------" is allowed, it makes sense to strip other
variants like " --".
2024-08-06 10:15:32 +09:00
Yuya Nishihara
fb3e120092 cli: minor style cleanup in parse_bulk_edit_message() 2024-08-06 10:15:32 +09:00
Yuya Nishihara
f7b8a22c66 cli: remove redundant string concatenation from parse_bulk_edit_message() 2024-08-06 10:15:32 +09:00
Yuya Nishihara
f4dd856f9f ui: do not write() to channel if builtin pager has terminated 2024-08-05 10:34:33 +09:00
Yuya Nishihara
ce2bc8d6b6 ui: include error sources in pager warning
An error in builtin pager can be nested.
2024-08-05 10:21:23 +09:00
Benjamin Tan
35b04f45dc describe: allow updating the description of multiple commits
If multiple commits are provided, the description of each commit
will be combined into a single file for editing.
2024-08-05 02:06:40 +08:00
Ilya Grigoriev
37ccfd5acc built-in pager: write a message to the user if pager failed to start
The message is printed at the end, any text sent to the pager before
then is lost. See
https://github.com/martinvonz/jj/pull/4197#discussion_r1701799135
for a discussion about why that seems OK.
2024-08-03 17:45:18 -07:00
Yuya Nishihara
9ec617534c cli: merge op heads and snapshot working copy by "op log" by default
This partially reverts 543036c753 "cli: run 'op log' without loading repo or
merging concurrent ops." User can now get around the issue by --at-op=@
--ignore-working-copy.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
5bfb3742e8 cli: migrate trivial uses of op_walk::resolve_op_for_load()
Now heads merging can be turned off by --at-op=@.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
2008991749 cli: do not attempt to merge op heads if --at-op=@ is specified
The idea is that --at-op specifies a certain operation, so --at-op=@ can be
interpreted as the option to select _the_ known head operation. This helps
eliminate special cases from "op log" which doesn't snapshot nor merge
concurrent ops.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
b290af8e29 op_walk: include operation ids in multiple match error 2024-08-03 09:22:26 +09:00
Yuya Nishihara
e9d744db32 tests: add crash recovery test from bad GC
The current "op abandon" and "op log" have workarounds to recover from this
situation. Let's make sure they work as expected.
2024-08-03 09:22:26 +09:00
Yuya Nishihara
cf053b7e09 ui: print :builtin pager suggestion as a hint 2024-08-03 09:14:29 +09:00
Yuya Nishihara
b503ecb071 ui: rewrite request_pager() to return early and use stdout instance 2024-08-03 09:14:29 +09:00
Yuya Nishihara
47a4406f4d ui: extract finalize_pager() as UiOutput method 2024-08-03 09:14:29 +09:00
Stephen Jennings
6c41b1bef8 revset: add author_date and committer_date revset functions
Author dates and committer dates can be filtered like so:

    committer_date(before:"1 hour ago") # more than 1 hour ago
    committer_date(after:"1 hour ago")  # 1 hour ago or less

A date range can be created by combining revsets. For example, to see any
revisions committed yesterday:

    committer_date(after:"yesterday") & committer_date(before:"today")
2024-08-01 09:04:07 -07:00
Essien Ita Essien
7c4185cd41 Change conflict hint depending on state of working commit.
To avoid always printing the rebase instructions to fix a conflict
even when a child commit to fix the conflict already exists, implement
the following:

* If working commit has conflicts:
  * Continue printing the same message we print today.

* If working commit has no conflicts:
  * If any parent has conflicts, we print: "Conflict in parent is resolved in working copy".
    Also explicitly not printing the "conflicting parent" here, since a merge commit
    could have conflict in multiple parents.
  * If no parent has any conflicts: exit quietly.
* Update unittests for conflict hinting update.
* Update CHANGELOG
2024-08-01 16:21:24 +01:00
Yuya Nishihara
d0f6f429e1 diff: add "diff" label globally by outer show_diff/patch() functions
It's not so important, but this removes duplicated "diff" labels from template
output. Perhaps, this also fixes "diff access-denied" label in file-by-file
external diffs.

The inner show_*() functions no longer add "diff" labels, but that's okay
because all CLI callers (except for the templater) use DiffRenderer.
2024-08-01 22:56:36 +09:00
Yuya Nishihara
07b0b0676d tests: rerun commit.diff() template test with --color=debug
The added test shows the "diff" label is repeated because of auto-labeling of
templater. The original "--color=always" test is also kept to ensure that color
sequences are unchanged even if we remove one of the "diff" labels.
2024-08-01 22:56:36 +09:00
Yuya Nishihara
052f022479 formatter: make error type of with_label() callback generic
This will help eliminate push/pop_label() calls from show_diff_*().
2024-08-01 22:56:36 +09:00
Yuya Nishihara
f57a7e5eba cli: move cmd_config_list() entry point next to Args struct 2024-08-01 09:54:12 +09:00
Yuya Nishihara
9168500341 cli: split commands/config.rs into sub modules 2024-08-01 09:54:12 +09:00
Yuya Nishihara
dc2b5500ff diff: specify available terminal width by caller, subtract graph width
The width parameter is mandatory so it wouldn't fall back to ui.term_width() by
mistake. The API is getting messy and we might want to extract some parameters
to separate struct.

Fixes #4158
2024-08-01 02:03:03 +09:00
Yuya Nishihara
1977748642 ui: fill in default term width globally and return as usize
I'm going to add more ui.term_width() callers, and it's unlikely we'll have to
set different defaults or error out.
2024-08-01 02:03:03 +09:00
Yuya Nishihara
b2b86825cb cli: move cmd_workspace_update_stale() entry point next to Args struct 2024-07-31 10:21:34 +09:00
Yuya Nishihara
21e1ce4f50 cli: split commands/workspace.rs into sub modules 2024-07-31 10:21:34 +09:00
Yuya Nishihara
a39dd0f176 cli: duplicate cmd_workspace_root() to cmd_root()
Suppose cmd_root() will gain options to print other kind of root paths, it's
probably simpler to inline path handling there instead of turning cmd_root()
into a dispatcher function. If cmd_root() remains with the current form, maybe
we can add aliases.root = ["workspace", "root"] instead.
2024-07-31 10:21:34 +09:00
Danny Hooper
51e11ff7e3 cli: fix: replace obsolete todo with a new one 2024-07-29 14:23:26 -05:00
Scott Taylor
304f6dfc3f workspace: warn if destination doesn't contain path separator
Users may try to run `jj workspace add <name>` without specifying a
path, which results in the workspace being created in the current
directory. This can be confusing, since the workspace contents will also
be snapshotted in the original workspace if it is not sparse. Adding a
warning should reduce confusion in this case.
2024-07-26 18:37:11 -05:00
Scott Taylor
4d8eee3416 test: update workspace path in test case
This test case was creating "workspace1" as a sub-directory of the
default workspace, which seems like a mistake.
2024-07-26 18:37:11 -05:00
Danny Hooper
89f5d16dc0 cli jj fix: add ability to configure multiple tools for different filesets
The high level changes include:
 - Reworking `fix_file_ids()` to loop over multiple candidate tools per file,
   piping file content between them. Only the final file content is written to
   the store, and content is no longer read for changed files that don't match
   any of the configured patterns.
 - New struct `ToolsConfig` to represent the parsed/validated configuration.
 - New function `get_tools_config()` to create a `ToolsConfig` from a `Config`.
 - New tests; the only old behavior that has changed is that we don't require
   `fix.tool-command` if `fix.tools` defines one or more tools. The general
   approach to validating the config is to fail early if anything is weird.

Co-Authored-By: Josh Steadmon <steadmon@google.com>
2024-07-25 13:40:18 -05:00
Danny Hooper
8fe2274584 fake-formatter: add --uppercase and --append formatting behaviors
This allows tests to easily distinguish the effects of multiple formatters that
could be applied during a single `jj fix` command, which is helpful for testing
the feature for configuring multiple formatters on potentially overlapping
filesets.

Uppercase is a counterpart to lowercase. Append exposes the number of changes
and their order of execution in the file content, which provides a terse way of
writing test expectations.
2024-07-25 13:40:18 -05:00
Yuya Nishihara
d6e97883df cli: port description template to templater
This implements a building block of "signed-off-by line" #1399 and "commit
--verbose" #1946. We'll probably need an easy way to customize the diff part,
but I'm not sure if it can be as simple as a template alias function. User
might want to embed diffs without "JJ: " prefixes?

Perhaps, we can deprecate "ui.default-description", but it's not addressed in
this patch. It could be replaced with "default_description" template alias,
but we might want to configure default per command. Suppose we add a default
"backout_description" template, it would have to be rendered against the
source commit, not the newly-created backout commit.

The template key is named as "draft_commit_description" because it is the
template to generate an editor template. "templates.commit_description_template"
sounds a bit odd.

There's one minor behavior change: the default description is now terminated
by "\n".

Closes #1354
2024-07-25 22:39:00 +09:00
Yuya Nishihara
5a19eb6331 cli: merge description_template_for_*() functions 2024-07-25 22:39:00 +09:00
Yuya Nishihara
45d16f4b34 cli: commit, split: set default description to intermediate commit object
description_template_for_*() functions will be merged soon.

We don't need to set the default description to the second commit of the split
because its description should be kept empty if it was.
2024-07-25 22:39:00 +09:00
Yuya Nishihara
6395d32358 cli: commit, split: pass temporary commit object to description helper 2024-07-25 22:39:00 +09:00
Yuya Nishihara
b9cc61b535 cli: describe: set default description to temporary commit object
This could be handled by description_template_for_describe(), but I think it's
better to do mutation by caller. I also think commands like "backout" or "new"
can do a similar thing to generate a default commit description from the source
or merge parent commits.
2024-07-25 22:39:00 +09:00
Philip Metzger
fa7f4e68c5 run: Treat jj run -j0 <command> as use all available cores
Waleed noticed this in #4021.
2024-07-24 22:13:28 +02:00
Yuya Nishihara
7d50ebc23e cli: commit: set up rewritten commit early
For the same reason as the previous commit.
2024-07-25 00:09:39 +09:00
Yuya Nishihara
453e4f3fcc cli: split: set up rewritten commits early
For the same reason as the cmd_describe() change. A temporary commit object
will be constructed in order to render it as a description template.
2024-07-25 00:09:39 +09:00
Yuya Nishihara
0208e60358 cli: split: make local variable names shorter 2024-07-25 00:09:39 +09:00
Yuya Nishihara
4e234c1a18 cli: split: narrow scope of temporary variables of first/second commits 2024-07-25 00:09:39 +09:00
Yuya Nishihara
d637216c16 cli: describe: start transaction and set up rewritten commit early
This will help consolidate description_template_for_*() functions and port them
to templater. This change also means the committer (and operation start)
timestamp is set earlier. I think that's good.
2024-07-25 00:09:39 +09:00
Yuya Nishihara
69bb57d1d1 cli: describe: don't unwrap read error of stdin 2024-07-25 00:09:39 +09:00
Yuya Nishihara
d328adca7b tests: use insta::assert_snapshot!() to capture description templates 2024-07-25 00:09:39 +09:00
Martin von Zweigbergk
d740f1801b conflicts: use non-legacy MergedTreeId for root commit
This is part of migrating away from legacy trees (with path-level
conflicts). I can't think of any practical impact (we already compare
the tree ids equal).
2024-07-24 14:33:05 +02:00
Yuya Nishihara
bafb357209 git: on abandoning unreachable commits, don't count HEAD ref
This basically reverts 20eb9ecec1 "git: don't abandon HEAD commit when it
loses a branch." I think the new behavior is more consistent because the Git
HEAD is equivalent to @- in jj, so it shouldn't be considered a named ref.

Note that we've made old HEAD branch not considered at 92cfffd843 "git: on
external HEAD move, do not abandon old branch."

#4108
2024-07-24 21:22:26 +09:00
Yuya Nishihara
eb332b1d08 cli: make for_loaded_repo() callers specify whether repo/workspace are synced
It's wrong to deduce loaded_at_head from command-line arguments if the repo was
loaded at an arbitrary operation. Instead, the caller should specify whether
the working copy state is synchronized with the repo view.

I think .for_loaded_repo(ui, workspace, repo, true) would be bad for
readability, so I added separate functions. I'm not happy with the name
.for_temporary_repo(), but it seems okay for the current call sites.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
d7c1b97418 cli: fix "workspace add --at-op" to set up new working copy properly
Because new workspace is created for the new operation forked from the --at-op
operation, the new working copy should be writable.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
b76947c1d6 cli: error out on "init --at-op/--ignore-working-copy" or "clone --at-op"
--at-op should be invalid on repo initialization. "init --ignore-working-copy"
could be supported by using working_copy.reset(), but I don't think it's
worth the effort. If the working directory is empty, --ignore-working-copy
is meaningless, and if the directory is not empty, the user would probably
want to do snapshot at some point.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
c705afa299 cli: exit with CLI error status on "op abandon --at-op"
The command option --at-op isn't supported by "op abandon", so it's rather a
CLI error.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
b9e82f6e06 tests: run workspace-creation commands with --at-op or --ignore-working-copy
I'm going to fix misuse of CommandHelper::for_loaded_repo(), which expects
that the given repo respects the --at-operation option.

I don't think all of the added tests are useful, but "clone
--ignore-working-copy" might be legit as a replacement for bare repos.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
3f05d065b5 cli: uncapitalize op description of "workspace add" and custom command example
That's our convention.
2024-07-24 18:06:09 +09:00
Yuya Nishihara
8fec7500c3 cli: enable fileset by default
I've tested it for months and found no problems.
2024-07-24 10:49:46 +09:00
Stephen Jennings
2a9fdbac52 git: add --allow-private option to push command 2024-07-23 08:45:51 -07:00
Stephen Jennings
03b6d380f5 git: add git.private-commits setting for preventing commits from being pushed
The user can define the setting `git.private-commits` as they desire. For
example:

    git.private-commits = 'description(glob:"wip:*")'

If any commits are in this revset, then the push is aborted.

If a commit would be private but already exists on the remote, then it does
not block pushes, nor do its descendents block pushes unless they are also
contained in `git.private-commits`.

Closes #3376
2024-07-23 08:45:51 -07:00
Benjamin Tan
dade156859 cli: add jj operation show command 2024-07-22 19:16:42 +08:00
Benjamin Tan
a6d82cc344 cli: add jj operation diff command 2024-07-22 19:16:42 +08:00
Yuya Nishihara
ddc601fbf9 str_util: add regex pattern
This patch adds minimal support for the regex pattern. We might have to add
"regex-i:" for completeness, but it can be achieved by "regex:'(?i)..'".
2024-07-22 12:00:52 +09:00
Scott Taylor
14d3bb85bc workspace: use cwd for printing relative path
The user probably would expect the path to be relative to their current
directory rather than the workspace root. For instance, if the user is
in a child directory and runs `jj workspace add ../../name`, then they
might be surprised if we printed "../name" instead of "../../name".
2024-07-21 14:26:18 -05:00
Yuya Nishihara
8df7857706 cli_util: add tx.commit_summary_template() and related helper functions
These functions mirror the ones in WorkspaceCommandHelper. I'm not sure if all
of them will have to be public, but parse_commit_template() might be useful in
order to implement description template.
2024-07-20 09:08:59 +09:00
Yuya Nishihara
b762dd55cd cli_util: cache IdPrefixContext by transaction wrapper
This addresses lifetime issue in the next patch, in which the context has to
be borrowed from a known location.
2024-07-20 09:08:59 +09:00
Scott Taylor
d5c526f496 branch: ignore git tracking branches for rename warning
Prevents a warning from being printed when renaming branches in a
colocated repo, since git tracking branches were being considered as
remote tracking branches.
2024-07-18 17:27:19 -05:00
Yuya Nishihara
5649ee4f45 fileset: parse glob characters as identifier
It's inconvenient that we have to quote glob patterns as 'glob:"*.rs"'. Suppose
filesets are usually specified in shell, it's better to allow unquoted strings
if possible. This change also means we'll probably abandon #2101 "make the
parsing of string arguments stricter."

Note that we can no longer introduce ? operator or [] subscript syntax in
filesets.

Closes #4053
2024-07-18 13:49:10 +09:00
Ilya Grigoriev
ff0188d63a cli branch create/set: add --to aliases for -r
Now that `jj move` does not accept `-r` (since it has `--from` and `--to`), `jj set --to` seems more useful
than `jj set -r`. `create --to` is also added for ease of switching
between `branch create` and `branch move`.
2024-07-17 21:21:40 -07:00
Yuya Nishihara
1a387489d9 files: relax requirement of merge() inputs
Most callers have Merge<ContentHunk> or Merge<Vec<u8>>.
2024-07-18 11:34:43 +09:00
Yuya Nishihara
a9af8d21f8 diff: move materialized_diff_stream() to jj_lib::conflicts module
New diff_contains() revset function will use this helper.
2024-07-18 01:01:16 +09:00
Martin von Zweigbergk
f2bfb90c8c cli: remove unused dependency on gix-filter
This dependency was added in 067d37aa but it seems it ended up being
used only from the jj-lib crate.
2024-07-17 11:53:51 +02:00
Yuya Nishihara
d1912bf016 templater: add commit.diff().<format>() methods
This patch adds TreeDiff template type to host formatting options. The main
reason of this API design is that diff formats have various incompatible
parameters, so a single .diff(files, format[, options..]) method would become
messy pretty quickly. Another reason is that we can probably add custom
summary templating support as diff.files().map(|file| file.path()..).

RepoPathUiConverter is passed to templater explicitly because the one stored
in RevsetParseContext is behind Option<_>.
2024-07-17 18:52:49 +09:00
Yuya Nishihara
4a63a1f660 diff: pass repo.store() to inner show_*_diff() functions, reorder arguments
This will help remove lifetimed &dyn Repo from diff object in templater.

Function arguments are reordered in a way that all show_*() functions have
common parameters in the same order.
2024-07-17 18:52:49 +09:00
Yuya Nishihara
18d60ad0d3 cli: use lossy string conversion to accept non-UTF-8 template outputs
I'm going to add diff() method which provides no guarantee about content
encoding.
2024-07-17 18:52:49 +09:00
Vincent Ging Ho Yim
79b326d56b cli_util: add missing word in conflict resolution instructions 2024-07-17 08:10:25 +02:00
Anton Älgmyr
c7eac90200 Enable the new graph nodes by default.
It's been tested in various places now, so this is probably mature
enough to be the default.
2024-07-16 12:54:24 +02:00
Yuya Nishihara
a757fddcf1 revset: parse file() argument as fileset expression
Since fileset and revset languages are syntactically close, we can reparse
revset expression as a fileset. This might sound a bit scary, but helps
eliminate nested quoting like file("~glob:'*.rs'"). One oddity exists in alias
substitution, though. Another possible problem is that we'll need to add fake
operator parsing rules if we introduce incompatibility in fileset, or want to
embed revset expressions in a fileset.

Since "file(x, y)" is equivalent to "file(x|y)", the former will be deprecated.
I'll probably add a mechanism to collect warnings during parsing.
2024-07-16 10:18:57 +09:00
Scott Taylor
91504cae02 obslog: reverse order of predecessors in topo traversal
Currently, when there is a commit with two predecessors, the graph
splits into two branches, and all of the predecessors on the first
branch are printed before all of the predecessors on the second branch.
This causes the graph to grow wider with each squashed commit, since the
second branch must always get indented one level farther each time a
commit is squashed. I have some commits where the graph is indented more
than 10 levels due to squashing more than 10 times, making it very
difficult to read.

Reversing the order and printing the second branch before the first
branch prevents this unnecessary indentation and makes the graph easier
to read. This does not change the order of the edges in the graph (i.e.
the first predecessor is still the first edge and the second predecessor
is still the second edge in the graph).
2024-07-15 20:10:31 -05:00
Scott Taylor
fcf1ca95f2 obslog: update test to show multiple squashes 2024-07-15 20:10:31 -05:00
Yuya Nishihara
ea3a574e36 cli: include untracked remote branches in default immutable_heads()
I used to use "remote_branches() & ~mine()" to exclude "their" branches from
the default log, and I don't think that's uncommon requirement. Suppose
untracked branches are usually read-only, it's probably okay to make them
immutable by default.
2024-07-15 23:41:07 +09:00
Yuya Nishihara
692c9960c0 diff: do not emit unified diff for binary files 2024-07-15 14:45:59 +09:00
Yuya Nishihara
e3055e5aaf diff: do not emit unified diff header on absent/empty transitions
---/+++ lines are part of unified diff hunks, not Git diff header.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
53f7acbc42 diff: refactor show_git_diff() to construct GitDiffPart for absent side
This will simplify binary content handling.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
7bdc4a9681 diff: clarify that mode flag of GitDiffPart is hard-coded
We can also change it to enum, but let's keep it str for now.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
07a6a8016c diff: fix typo in Git diff "index old..new" header
Spotted while consolidating "index" line generation. Git appears to use ".." to
separate hashes.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
0912c74ecf diff: add tests for mode changes and absent/empty transitions
This captures a bug of "diff --git" which emits unified diff header without
hunks.
2024-07-15 14:45:59 +09:00
Yuya Nishihara
59daef2351 diff: accept diff inputs by generic iterator
This helps migrate internal [u8] variables to BStr.

b"" literals in tests are changed to &str to get around potential type
incompatibility between &[u8; N].
2024-07-14 23:26:29 +09:00
Scott Taylor
2dd75b5c53 revset: add tracked/untracked_remote_branches()
Adds support for revset functions `tracked_remote_branches()` and
`untracked_remote_branches()`. I think this would be especially useful
for configuring `immutable_heads()` because rewriting untracked remote
branches usually wouldn't be desirable (since it wouldn't update the
remote branch). It also makes it easy to hide branches that you don't
care about from the log, since you could hide untracked branches and
then only track branches that you care about.
2024-07-13 10:43:21 -05:00
Yuya Nishihara
8ee5b783b3 formatter: minor cleanup in --color=debug handling 2024-07-13 11:08:01 +09:00
Jonathan Tan
de2940f9b7 --color=debug: combine segments with same labels
This not only makes the output easier to read, but also protects against
implementation detail changes in `write!` when used with a format
string (especially, how many times and with what strings it calls the
underlying writer).
2024-07-11 10:39:05 -07:00
Jonathan Tan
579ba8031b --color=debug: print unlabeled text without markup
This makes the debug output cleaner and makes the subsequent commit
easier to write.
2024-07-11 10:39:05 -07:00
Emily
93d76e5d8f str_util: support case‐insensitive string patterns
Partially resolve a 1.5‐year‐old TODO comment.

Add opt‐in syntax for case‐insensitive matching, suffixing the
pattern kind with `-i`. Not every context supports case‐insensitive
patterns (e.g. Git branch fetch settings). It may make sense to make
this the default in at least some contexts (e.g. the commit signature
and description revsets), but it would require some thought to avoid
more confusing context‐sensitivity.

Make `mine()` match case‐insensitively unconditionally, since email
addresses are conventionally case‐insensitive and it doesn’t take
a pattern anyway.

This currently only handles ASCII case folding, due to the complexities
of case‐insensitive Unicode comparison and the `glob` crate’s lack
of support for it. This is unlikely to matter for email addresses,
which very rarely contain non‐ASCII characters, but is unfortunate
for names and descriptions. However, the current matching behaviour is
already seriously deficient for non‐ASCII text due to the lack of any
normalization, so this hopefully shouldn’t be a blocker to adding the
interface. An expository comment has been left in the code for anyone
who wants to try and address this (perhaps a future version of myself).
2024-07-10 05:58:34 +01:00
Scott Taylor
b27ff28956 cli: skip formatting instructions if not required
`tx.format_commit_summary()` can be expensive because it needs to build
an IdPrefixContext now, so it's best to avoid formatting instruction
messages unless they are actually required.
2024-07-09 20:24:14 -05:00
Yuya Nishihara
8856e6d328 diff: fix typo in get_diff_stat() comment 2024-07-10 10:05:31 +09:00
Yuya Nishihara
6a1d9262a0 diff: add short for Diff::for_tokenizer(_, find_line_ranges)
Line-by-line diff is common. Let's add a helper method for convenience.
2024-07-10 10:05:31 +09:00
Martin von Zweigbergk
fefe07b3c3 diff: consider uncommon words to match only if they have the same count
Patience diff starts by lining up unique elements (e.g. lines) to find
matching segments of the inputs. After that, it refines the
non-matching segments by repeating the process. Histogram expands on
that by not just considering unique elements but by continuing with
elements of count 2, then 3, etc.

Before this commit, when diffing "a b a b b" against "a b a b a b", we
would match the two "a"s in the first input against the first two "a"s
in the second input. After this patch, we ignore the "a"s because
their counts differ, so we try to align the "b"s instead.

I have had this commit lying around since I wrote the histogram diff
implementation in 1e657c5331. I vaguely remember thinking that the
way I had implemented it (without this commit) was a bit weird, but I
wasn't sure if this commit would be an improvement or not. The bug
report from @chooglen today of a case where we behave differently from
Git is enough to make me think that we make this change after all.

#761
2024-07-09 20:35:36 +09:00
Scott Taylor
a983abb594 cli_util: short-prefixes for commit summary in transaction
I've run into change ID prefixes being 4-5 characters instead of the
usual 1-2 characters in commands like `jj duplicate` and `jj split`
fairly often, and it seems like this should resolve that.
2024-07-08 08:23:39 -05:00
Scott Taylor
ddfce6d2c9 cli_util: extract new_id_prefix_context method 2024-07-08 08:23:39 -05:00
Vladimir Petrzhikovskii
802d2f5327 cli: recursively create clone destination path 2024-07-07 23:02:41 +02:00
Benjamin Tan
cd41bc3584 backout: accept multiple revisions to back out
Closes #3339.
2024-07-07 17:58:10 +08:00
Yuya Nishihara
5c649e734d cli: show commit summary at end of "branch set"
For the same reason as the previous commit.

Created and moved stats are printed separately because it's unusual to do both
within one "branch set" invocation.
2024-07-06 10:12:43 +09:00
Yuya Nishihara
a5095c1da6 cli: show commit summary at end of "branch create"
For the same reason as cdc0cc3601. This will help notice problems like wrong
target revision.

The warning for multiple branches is reorganized as a hint for "-r" option,
which I think is the main purpose of this warning. Unlike "squash", we don't
check if an argument can be parsed as a revset because branch name is usually
a valid symbol expression.
2024-07-06 10:12:43 +09:00
Yuya Nishihara
e02c576282 cli: print branch update stats within transaction
It's weird that export failure was emitted before the branch changes. Spotted
while adding "Created N branches" stats.
2024-07-06 10:12:43 +09:00
Benjamin Tan
d2eb4d9b56 backout: include backed out commit's subject in new commit 2024-07-05 17:11:37 +08:00
Benjamin Tan
82bab36c0e backout: inline rewrite::back_out_commit 2024-07-05 17:11:37 +08:00
Benjamin Tan
456356aacb backout: add initial tests 2024-07-05 17:11:37 +08:00
Yuya Nishihara
44a39017f0 diff: highlight word-level changes in git diffs
The output looks somewhat similar to color-words diffs. Unified diffs are
verbose, but are easier to follow if adjacent lines are added/removed + modified
for example.

Word-level diffing is forcibly enabled. We can also add a config knob (or
!color condition) to turn it off to save CPU time.

I originally considered disabling highlights in block insertion/deletion, but
that wasn't always great. This can be addressed separately as it also applies
to color-words diffs. #3958
2024-07-05 16:07:12 +09:00
Yuya Nishihara
9e8a739e4d diff: deduplicate write() calls in show_unified_diff_hunks()
I'm going to add word-level highlighting there.
2024-07-05 16:07:12 +09:00
Scott Taylor
54877e1f79 workspace: abandon discardable working copy on forget
Forgetting a workspace removes its working-copy commit, so it makes
sense for it to be abandoned if it is discardable just like editing a
new commit will cause the old commit to be abandoned if it is
discardable.
2024-07-04 19:37:56 -05:00
Scott Taylor
fa398ab405 cli: fix typo in jj workspace help 2024-07-04 19:37:56 -05:00
Yuya Nishihara
1cae93ce27 cli: rephrase hint for updating just one branch by "branch move"
Suggested by Ilya.
2024-07-05 07:58:18 +09:00
Yuya Nishihara
cdc0cc3601 cli: show commit summary at end of "branch move"
It's nice to see the result of "branch move", "create", etc., and this is more
important in "branch move" because the source branches can be specified in an
abstracted way. I originally considered printing a list of affected branches,
but it looked rather verbose. Since the destination revision is unique, we can
use commit_summary template instead.

This patch also removes a warning about multiple branches because the branch
names are included in the commit summary. I think the hint message is good
enough to signal possible mistake.
2024-07-05 07:58:18 +09:00
Benjamin Tan
0c0e001262 git init: add revset alias for trunk() when intializing with existing git repository 2024-07-04 23:04:19 +08:00
Benjamin Tan
d8899e1ae7 git clone: add revset alias for trunk() 2024-07-04 23:04:19 +08:00
Matt Stark
31ac0d7e1f feat(rebase): Rename --skip-empty to --skip-emptied.
This is based on @martinvonz's comment in #3830 about the inconsistency between squash --keep-emptied and rebase --skip-empty.
2024-07-04 12:13:02 +10:00
Yuya Nishihara
034859b52f cli: branch: print stats even if just one branch is updated
We usually print stats at the end of mutable operation, and I think these
messages are useful even if N = 1. I understand that "Deleted N" (N > 1) is
unusual and the original intent of these messages was to signal possible
mistakes. However, I don't think printing N=1 stats would nullify the original
purpose.

No emptiness check is needed for delete/forget, but names can be empty in
track/untrack because of noop changes.
2024-07-04 10:58:50 +09:00
mlcui
c256ad8a0a windows: avoid UNC paths in run_ui_editor
See #3986 for more details. This is a no-op for non-Windows.
2024-07-04 11:30:20 +10:00
Matt Kulukundis
2917dea0a1 copy-tracking: add a command line driver with a simple test 2024-07-03 20:26:30 -04:00
Matt Kulukundis
dab8a29683 copy-tracking: stub get_copy_records
- add the method and types for all backends
2024-07-03 20:26:30 -04:00
Matt Kulukundis
067d37aa3c copy-tracking: cargo add gix-format and gix diff-blob feature 2024-07-03 20:26:30 -04:00
Matt Kulukundis
aaa99e6dc7 diff: add a file-by-file variant for external diff tools 2024-07-03 20:09:17 -04:00
Yuya Nishihara
455daa4d67 cli: remove deprecated --allow-large-revsets flag at all
It's been deprecated since v0.9.0 (2023-09-06). This patch doesn't add
changelog entry because the use of --allow-large-revsets was hard error.
2024-07-03 23:06:26 +09:00
Matt Stark
ca4eb60426 feat(squash): Add --keep-emptied flag
Fixes #3815
2024-07-03 12:03:26 +10:00
Matt Stark
7682a038a1 chore: Make squash tests log empty commits. 2024-07-03 12:03:26 +10:00
Scott Taylor
e54ecefbd4 commit: add --reset-author option 2024-07-02 18:21:21 -05:00
Yuya Nishihara
f9a15ba542 diff: do not add excessive number of context lines to last unified-diff hunk
The last hunk could be truncated instead, but the .peekable() version is easier
to follow. If we truncated lines, we would have to adjust line ranges
accordingly.
2024-07-02 18:49:52 +09:00
Yuya Nishihara
ec709e7f8b diff: rely on emptiness of unified hunk lines whether to append "after" context
show_context_after was set once when DiffHunk::Different received, and was
never turned off. This means DiffHunk::Matching is not supposed to repeat.
Under this condition, we can assume that removed/added lines exist if lines
isn't empty.
2024-07-02 18:49:52 +09:00
Yuya Nishihara
318f594291 diff: simplify context line extraction by using DoubleEndedIterator 2024-07-02 18:49:52 +09:00
Yuya Nishihara
3d458c3e58 diff: extract helpers that push unified-diff hunk lines 2024-07-02 18:49:52 +09:00
Yuya Nishihara
a4f5462d07 tests: add test for leading/trailing diff context lines 2024-07-02 18:49:52 +09:00
mlcui
3bca159b1a fake-editor: replace expectpath with dump-path
This allows us to assert the expected path in the test itself, rather
than in the fake editor.
2024-07-02 11:15:44 +10:00
Jonathan Tan
1eef1a4f55 workspace add: add filename context to FS error
At work, a user encountered a panic upon attempting to create a dir at
the line in the diff below, but it turned out to be difficult to debug
because I didn't know what the path was. There already is a mechanism to
add path context in the lib crate; make it available in the cli crate as
well, and use the mechanism to add path context to "workspace add".
2024-07-01 16:05:29 -07:00
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
Yuya Nishihara
d2d0041333 cli: branch: rename local sub_args to args
There are no other "args" in this context.
2024-06-20 17:00:34 +09:00
Yuya Nishihara
b9c2daa408 cli: branch: move command fn next to Command/Args type 2024-06-20 17:00:34 +09:00
Yuya Nishihara
9e35b9b218 cli: branch: split to per-command module files
This is another big subcommand module. Let's split it up.

I'm not a big fan of r#move syntax, but we already have one in src/commands,
so there's no point to avoid it.
2024-06-20 17:00:34 +09:00
Martin von Zweigbergk
494de23ea5 revset: clarify error about missing working-copy commit for workspace
The error message that says something like 'Workspace "default"
doesn't have a working copy' confused me when I saw it. The problem
it's describing is that the repo view doesn't have a working-copy
commit for the given workspace id. Saying "working-copy commit"
instead of "working copy" hopefully clarifies it a bit.
2024-06-20 16:21:58 +09:00
Yuya Nishihara
68b8b1a6a6 cli: rename "debug workingcopy" to "debug working-copy"
I think "working-copy" is more readable. It's a debug command, so we can freely
rename it.
2024-06-20 09:55:18 +09:00
Yuya Nishihara
567f0db734 cli: move cmd_git() dispatcher function next to GitCommand enum 2024-06-20 09:55:18 +09:00
Yuya Nishihara
e5a3d6a2ba cli: sort debug/git subcommands lexicographically 2024-06-20 09:55:18 +09:00
Matt Kulukundis
33ab8d4371 cli: Add an option to diff to output only paths. 2024-06-19 20:27:51 -04:00
Yuya Nishihara
5f2f13a876 diff: simply pass tokenizer Fn by value 2024-06-20 08:46:26 +09:00
Matt Kulukundis
3e7ad4d23c Add jj debug snapshot command and use it in trigger
The command only takes a snapshot and avoids other overhead, so it can
be used as a target for the watchman trigger that gets installed.
2024-06-19 11:30:27 -04:00
Matt Kulukundis
bbe71626ee Split jj debug command into multiple files 2024-06-18 21:23:18 -04:00
Matt Kulukundis
2364cf2c21 Split all git commands into separate files
Moved commands are `git clone`, `git export`, `git fetch`, `git import`,
`git init`, `git push`, `git remote`, and `git submodule`.
2024-06-18 19:16:24 -04:00
Yuya Nishihara
b8e921eeae cli: branch: add "move" command that can update branches by revset or name
This basically supersedes the current "branch set" command. The plan is to turn
"branch set" into an "upsert" command, and deprecate "branch create". (#3584)
Maybe we can also add "branch set --new" flag to only allow creation of new
branches. One reason behind this proposed change is that "set" usually allows
both "creation" and "update". However, we also need a typo-safe version of
"set" to not create new branches by accident.

"jj branch move" is useful when advancing ancestor branches. Let's say you've
added a couple of commits on top of an existing PR branch, you can advance the
branch by "jj branch move --from 'heads(::@- & branches())' --to @-". If this
pattern is super common, maybe we can add --advance flag for short.

One drawback of this change is that "git branch --move" is equivalent to
"jj branch rename". I personally don't find this is confusing, but it's true
that "move" sometimes means "rename".
2024-06-18 12:48:32 +09:00
Yuya Nishihara
b52b0646c2 cli: branch: restore is_fast_forward() function
This basically backs out 8706fadca1 "cli: inline check for
non-fast-forwardable branch move." I'm going to add another subcommand that
moves existing branches.
2024-06-18 12:48:32 +09:00
Yuya Nishihara
4ab1fc9bfe cli: file: sort subcommands chronologically
Otherwise they wouldn't be sorted in help. I also reordered the match statement.
Since subcommands are split to per-file modules, there's no point to keep some
logical ordering.
2024-06-18 10:45:06 +09:00
Yuya Nishihara
8e5671975c ui: remove Option<_> wrapping from ui.hint_() helpers
It's cumbersome to unwrap the Option just to print a short hint message. Let's
send the message to null output instead.
2024-06-18 09:37:23 +09:00
Yuya Nishihara
a162e4f1a4 cli: don't reuse ui.hint_default() instance to print multiple hints
ui.hint_*() calls will be inlined by the next commit.
2024-06-18 09:37:23 +09:00