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

893 commits

Author SHA1 Message Date
Evan Mesterhazy
3d267de53e Use CommitIteratorExt to replace .map(|c| c.id().clone())
This replaces `.map(|c| c.id().clone())` with `.ids().cloned()` to use nicer
syntax for getting `CommitId`s from an iterator of commits using the
`CommitIteratorExt` trait.

In one case we can actually call `.parent_ids()` directly. I also pluralized a
variable to make it clearer that it's a vec of IDs and not a single ID.
2024-04-19 08:16:42 -04:00
Martin von Zweigbergk
449fc423b8 parallelize: drop redundant "Nothing changed." case
The rewritten code is already a no-op when there's a single input. I
don't think the case is common enough to warrant having a special case
for performance reasons either. Also, by not having the special case,
`jj parallelize <immutable commit>` fails consistently with the
non-singleton case.
2024-04-18 21:06:52 -07:00
Martin von Zweigbergk
89356aebc6 parallelize: make the command pass in more cases
The checks are not needed by the new implementation, so just drop
them.
2024-04-18 21:06:52 -07:00
Martin von Zweigbergk
e0a32d4809 parallelize: don't rewrite commits that keep their parents
The new API makes it easy to leave commits in place if their parents
didn't change, so let's do that.
2024-04-18 21:06:52 -07:00
Martin von Zweigbergk
d6b41c18c9 parallelize: rewrite using transform_descendants()
`jj parallelize` was a good example of a command that can be
simplified by the new API, so I decided to rewrite it as an example.

The rewritten version is more flexible and doesn't actually need the
restrictions from the old version (such as checking that the commits
are connected). I still left the check for now to keep this patch
somewhat small. A subsequent commit will remove the restrictions.
2024-04-18 21:06:52 -07:00
Yuya Nishihara
18f94bbb8b cli: suggest root:"<path>" if cwd-relative path is not in workspace
Closes #3216
2024-04-19 09:35:47 +09:00
Martin von Zweigbergk
2859277941 rewrite: pass CommitRewriter into rebase_commit_with_options()
`CommitRewriter` wraps 3 of the arguments, so I think it makes sense
to pass it instead. More importantly, I hope to continue refactoring
so many of the callers already have a `CommitRewriter`.
2024-04-18 08:08:51 -07:00
Yuya Nishihara
7fded98e40 cli: remove redundant elided node expression from builtin node templates 2024-04-18 11:14:28 +09:00
Yuya Nishihara
1b3bcedd53 cli: label log/obslog template as "log"
It was removed at 522025e091 "log: remove unused and inconsistent `log`
label", but obslog had the same inconsistency. Since it's now easy to label
the template output, let's re-add the "log" label.

The change in test_templater_upper_lower() is noop. Formatter no longer
emits reset sequence in the middle because the template is still labeled.
2024-04-18 11:14:28 +09:00
Yuya Nishihara
6da9167585 cli: set "node" template labels globally
These labels could be renamed to "log_node"/"op_log_node" for consistency, but
I'm not sure if that's a good idea. A single "node" namespace is practically
more convenient.
2024-04-18 11:14:28 +09:00
Yuya Nishihara
2cf40adf02 templater: add template.labeled() for convenience
It's not uncommon to label the whole template output with command or template
name. If the output doesn't have to be captured, we can simply push the label
to the formatter. cmd_config_list() is an example of such cases, but it's also
migrated for consistency.
2024-04-18 11:14:28 +09:00
Yuya Nishihara
610e310112 templater: extract formatting function from LabelTemplate 2024-04-18 11:14:28 +09:00
Yuya Nishihara
4474577ceb fileset: parse cwd/root-glob patterns
Mercurial appears to resolve cwd-relative path first, so "glob:*.c" could be
parsed as "**/*.c" if cwd was literally "**". It wouldn't practically matter,
but isn't correct. Instead, jj's parser first splits glob into literal part
and pattern. That's mainly because we want to parse the user input texts into
type-safe objects, and (RepoPathBuf, glob::Pattern) pairs are the simplest
ones. The current parser can't handle patterns like "foo/*/.." (= "foo" ?),
and errors out. I believe this restriction is acceptable.

Unlike literal paths, the 'glob:' pattern anchors to the whole file path. I
don't think "prefix"-matching glob is useful, and making it the default would
be rather confusing.
2024-04-18 11:09:54 +09:00
Martin von Zweigbergk
93baff0b8a rewrite: pass just IDs of new parents into rewrite::rebase*()
It's cheap to look up commits again from the cache in `Store` but it
can be expensive to look up commits we didn't end up needing. This
will make it easier to refactor further and be able to cheaply set
preliminary parents for a rewritten commits and then let the caller
update them.
2024-04-17 06:13:54 -07:00
Martin von Zweigbergk
057b7c8d0b rewrite: take commit and new parents by value in rebase_commit()
I'm going to add a helper struct to help with rewriting commits. I
want to make that struct own the old commit and the new parents to
simplify lifetimes. This patch prepares for that by passing the
commits by value to `rebase_commit()`.
2024-04-17 06:13:54 -07:00
Evan Mesterhazy
fc49d35daa Fix empty files can't be selected in the builtin diff editor
This fixes several issues that made working with empty files difficult using
the builtin diff editor.

1. The scm-record library used for the editor expects each file to have at
least one section. For new empty files this should be a file mode section. jj
wasn't rendering this mode section, which prevented empty files from being
selected at all.

2. The scm-record library returns `SelectedContents::Absent` if the file has no
contents after the diff editor is invoked. This can be because of several
reasons: 1) the file is new and empty; 2) the file was empty before and is
still empty; 3) the file has been deleted. Perhaps this is a bug in scm-record
and it should return `SelectedContents::Unchanged` or
`SelectedContents::Present` if the file hasn't been deleted. Until this is
patched upstream, we can work around it by disambiguating these cases.

See https://github.com/arxanas/scm-record/issues/26 for the upstream bug.


Fixes #3016
2024-04-15 23:28:06 -04:00
Yuya Nishihara
c147125ce9 cli: migrate "cat" to matcher API, warn unmatched paths
This is the last non-debug command that doesn't support file patterns. It
wouldn't make much sense to "cat" multiple files (despite the command name),
but doing that should be harmless.
2024-04-16 10:12:31 +09:00
Yuya Nishihara
ac794e560f cli: extract function that prints multiple file contents
Prepares for migrating to the matcher API. "Path exists but is not a file"
error is turned into a warning because the loop shouldn't terminate there.

"No such path" error message is also updated for consistency.
2024-04-16 10:12:31 +09:00
Anton Älgmyr
af185725a1 Move to inline labeling and building a single label in log node template. 2024-04-15 22:21:31 +02:00
Anton Älgmyr
2af590eb54 Add template aliases with node symbol configs. 2024-04-15 22:21:31 +02:00
Evan Mesterhazy
0ef25bb4b6 Add a --use-destination-message option to jj squash
if `--use-destination-message/-u` is passed to `jj squash`, the resulting
revision will use the description of the destination revision and the
description(s) of the source revision(s) will be discarded.
2024-04-14 16:58:30 -04:00
Ilya Grigoriev
82c85ba754 docs: stop mentioning meld as the default diff editor
The default is now `:builtin`.
2024-04-12 21:47:17 -07:00
dploch
57a5d7dd64 cli_util: support multiple extensions consistently
If we ever implement some sort of ABI for dynamic extension loading, we'll need these underlying APIs to support multiple extensions, so we might as well do that first.
2024-04-12 14:07:33 -04:00
Yuya Nishihara
30984dae4a cli: if enabled, parse path arguments as fileset expressions
If this doesn't work out, maybe we can try one of these:
 a. fall back to bare file name if expression doesn't contain any operator-like
    characters (e.g. "f(x" is an error, but "f x" can be parsed as bare string)
 b. introduce command-line flag to opt in (e.g. -e FILESET)
 c. introduce pattern prefix to opt in (e.g. set:FILESET)

Closes #3239, #2915, #2286
2024-04-12 11:36:40 +09:00
Yuya Nishihara
a9694cba27 cli: add ui.allow-filesets to experiment with fileset/pattern syntax
The pattern syntax could be enabled unconditionally, but I want to fully
replace the ad-hoc pattern parsing function.
2024-04-12 11:36:40 +09:00
Ilya Grigoriev
8fa256ebac New jj debug watchman status command
This command checks not only whether Watchman works, but also whether
it's enabled in the config. Also, the output is easier to understand
than that of the other `jj debug watchman` commands.

It would be nice if `jj debug watchman` called `jj debug watchman
status`, but it's not trivial in `clap` to have a default subcommand.
2024-04-11 10:55:59 -07:00
Ilya Grigoriev
383711fcd8 config docs: document valid fsmonitor values
I was wondering how to disable the watchman in a repo if it's enabled in
the user config.
2024-04-11 10:55:59 -07:00
Evan Mesterhazy
37be542ebf Fix a bug when the target of jj split has merge commit children
Ilya reported this in https://github.com/martinvonz/jj/issues/3483.

The bug was introduced in 976320726d.

Before this fix, `jj split` dropped any parents what weren't involved in the
split when it rebased the children of the commit being split. This meant that
any children which were merge commits lost their other parents unintentionally.

Fixes #3483
2024-04-11 13:26:07 -04:00
Yuya Nishihara
1bfacea2f9 cli: migrate "chmod" to matcher API, warn unmatched paths 2024-04-11 00:51:19 +09:00
Yuya Nishihara
ae70db843e cli: warn explicit paths not exist in either of diff trees
Maybe we can optimize it to check paths during diffing, but I think it's okay
to add extra lookup cost at the end. The size of the path arguments is usually
small.

Closes #505
2024-04-11 00:51:19 +09:00
Jeremy O'Brien
580a90b694 cli: fix typo in 'jj untrack --help' 2024-04-09 09:18:40 -07:00
Yuya Nishihara
05b0fb50f1 cli: add fileset utility functions and debug command
Path parsing will be migrated to parse_union_filesets(), but I haven't decided
how we'll go forward:
 a. migrate everything to fileset
 b. require flag like "-e FILESET" (note -p conflicts with log -p)
 c. require flag like "-e FILESET" and deprecate positional PATHs #2554
 d. require prefix like "set:FILESET" (not consistent with -r REVSET)

I'm currently dogfooding (a). It works for me, but I don't use exotic file
names that would require quoting in zsh.

#3239
2024-04-09 20:42:09 +09:00
Yuya Nishihara
521bcd81ab dsl_util: deduplicate collect_similar() from revset and templater
For convenience, sort and dedup are done by collect_similar().
2024-04-09 20:42:09 +09:00
Evan Mesterhazy
13592ce49e Make jj next work when the working copy is a merge commit 2024-04-08 14:52:11 -04:00
Evan Mesterhazy
d90a0ec246 Make jj prev work when the working copy is a merge commit
Before this commit `jj prev` fails if the current working copy commit is a
merge commit. After this commit it will prompt the user to choose the ancestor
they want to select.

#2126
2024-04-08 14:52:11 -04:00
Anton Bulakh
feaaa48ed0 templates: Change builtin_log_root to be consistent with other hooks 2024-04-07 19:46:52 +03:00
Anton Bulakh
0f2573abae templates: Split oplog template into hookable functions
This is to allow modifying default templates without completely overriding
them, for example to change the oplog snapshots but keep other defaults
2024-04-07 19:46:52 +03:00
Anton Bulakh
29729e844d templater: Add operation.snapshot() boolean
Expose the information we now record, to allow changing the default "snapshot
working copy" message or to make snapshots more compact/less distracting in
the log
2024-04-07 19:46:52 +03:00
Evan Mesterhazy
f4fb8f18a7 Update the documentation for jj next
This is to match the recent changes made to the docs for `jj prev`.
2024-04-07 12:21:35 -04:00
Evan Mesterhazy
506392703b Make a minor formatting change to the help page for jj parallelize
Per discussion on another PR, we're going to avoid ALL CAPS for argument names
in the documentation even though Clap uses that style for the `--help` output.

- https://github.com/martinvonz/jj/pull/3453#discussion_r1554169975
2024-04-07 12:20:19 -04:00
Evan Mesterhazy
c1920d765f Improve the documentation of jj prev
This will hopefully make it clear that `jj prev` does not
move by [OFFSET] relative to `@`, which is a misconception
that I had and I think others may also have.

I am suggesting this change as a result of the vigorous discussion in
these two issues:

- https://github.com/martinvonz/jj/issues/3426
- https://github.com/martinvonz/jj/pull/3445

We should make similar changes to `jj next` as well since
it follows similar rules.
2024-04-07 12:19:54 -04:00
Yuya Nishihara
274183fa66 dsl_util: extract helper that parses string literal with \-escapes
The top-level assertion is removed since it's now obvious that the pair
represents a Rule::string_literal.
2024-04-08 00:37:25 +09:00
Yuya Nishihara
46b4c68325 templater: mark string literal as compound atomic, and integer as atomic
They aren't important because we don't use implicit whitespace rule, but let's
clarify they are atomic rules.

https://pest.rs/book/grammars/syntax.html#atomic
2024-04-08 00:37:25 +09:00
Yuya Nishihara
6039e9889c templater: rename string literal rules
This patch adds "string_" prefix to the related rules to discriminate them from
integer_literal. I also renamed "raw_literal" because it sounds like a raw
string literal that preserves backslash characters.
2024-04-08 00:37:25 +09:00
Yuya Nishihara
9b1eb03c73 cli: inline matcher_from_values() in favor of parse_file_patterns() 2024-04-07 19:43:29 +09:00
Yuya Nishihara
07d027193b cli: add support for file kind:pattern syntax
This is basically the same as string kind:pattern syntax in CLI. This will
hopefully be superseded by filesets, but I'm not sure if that will work out.
A file name is more likely to contain whitespaces, which will have to be
quoted as '"Documents and Settings"'.
2024-04-07 19:43:29 +09:00
Yuya Nishihara
47150d2bb4 revset: migrate file() predicate to be based on FilesetExpression 2024-04-06 23:59:54 +09:00
Scott Olson
e22370c485 cli: support filtering by paths in status 2024-04-05 20:41:44 +01:00
Evan Mesterhazy
64e242ab3a Implement jj parallelize
Parallelize revisions by making them siblings

Running `jj parallelize 1::2` will transform the history like this:
```text
3
|             3
2            / \
|    ->     1   2
1            \ /
|             0
0
```

Each of the target revisions is rebased onto the parents of the root(s) of
the target revset (not to be confused with the repo root). The children of
the head(s) of the target revset are rebased onto the target revisions.

The target revset is the union of the REVISIONS arguments.

The target revset being parallelized must satisfy several conditions,
otherwise the command will fail.

1. The heads of the target revset must not have different children.
2. The roots of the target revset must not have different parents.
3. The parents of all target revisions except the roots must also be
   parallelized. This means that the target revisions must be connected.
2024-04-05 12:43:10 -04:00
Austin Seipp
4b45dde8c6 clippy: disable bogus lints for nightly clippy
The nightly compiler has several clippy fix-its that, if applied, break the
build. There are various bugs about this, but there isn't enough space in the
margins to detail it all.

Just ignore these on a per-function basis; about 70% of them are just multiple
instances happening inside a single function.

This makes `cargo clippy --workspace --all-targets` run clean, even with the
nightly compiler.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ic26a025d3c62b12fbf096171308b56e38f7d1bb9
2024-04-05 11:39:29 -05:00