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

447 commits

Author SHA1 Message Date
Yuya Nishihara
a63dbcc329 templater: include actual type name in error messages 2024-04-26 00:57:26 +09:00
Rowan Walsh
f185a838d7 Fixes typo in 'jj git init' args 2024-04-24 09:12:37 -07:00
Martin von Zweigbergk
9d7ed54f8e git_backend: add a README to conflicted commits
When you use e.g. `git switch` to check out a conflicted commit,
you're going to end up with the `.jjconflicts-*` directories in your
working copy. It's probably not obvious what those mean. This patch
adds a README file to the root tree to try to explain to users what's
going on and how to recover.

The authoritative information about conflicts is stored in the
`jj:trees` commit header. The contents of conflicted commits is only
used for preventing GC. We can therefore add contents to the tree
without much consequence.
2024-04-22 06:22:54 -07:00
Benjamin Tan
e14ee8b563 rebase: do not simplify ancestor merges 2024-04-22 21:05:49 +08:00
Benjamin Tan
3ee35e70e9 rebase: modify tests to avoid a future ancestor merge with root commit
I will be updating `rebase -r` to avoid simplifying ancestor merges in a
subsequent commit, which will cause existing tests to fail for the Git
backend due to ancestor merges with the root commit.
2024-04-22 21:05:49 +08:00
Benjamin Tan
fb7c91ffa8 rebase: rewrite rebase_revision to use transform_descendants 2024-04-22 21:05:49 +08:00
Evan Mesterhazy
a2c49abbbe Add short a -e alias for --edit to prev and next
I'm not sure if this was an intentional omission, but I think it would be
useful to have `-e` as a short flag for `--edit`. I don't usually edit commits,
but I do use `prev` and `next` with edit to navigate to a commit that I want to
squash. Often this is easier than typing `--from` and `--into` plus the change
IDs.

If people want to edit commits we shouldn't stand in their way.
2024-04-21 13:58:38 -04:00
Evan Mesterhazy
e0c53bcfc0 Rewrite rebasing in jj split using transform_descendants()
This is following on the rewrite for `parallelize`.

- https://github.com/martinvonz/jj/pull/3521

Since rebase_descendants from rebase.rs is no longer used outside of that file,
it can be made private again.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
6d2884317a Add checks for stderr and stdout to jj split tests
This would have caught a bug in https://github.com/martinvonz/jj/pull/3550
that otherwise might have slipped through.
2024-04-21 12:21:39 -04:00
Evan Mesterhazy
0fb582ed8f Implement advance-branches for jj new 2024-04-20 10:26:04 -04:00
Evan Mesterhazy
3f0e4de64a Allow advance_branches tests to be parameterized
In a future commit these tests will run with both `jj commit` and `jj new` since
both will have the same semantics for advancing the branch pointer.

Parameterizing the tests allows us to run both variants without duplicating the
test bodies. Since the commit IDs are different when `jj describe` + `jj new`
is used instead of `jj commit`, this commit also drops the commit IDs from the
test snapshots. This is fine because the commit IDs are not important for these
tests.
2024-04-20 10:26:04 -04:00
Evan Mesterhazy
bbd9c7c7cb Implement advance-branches for jj commit
## Feature Description

If enabled in the user or repository settings, the local branches pointing to the
parents of the revision targeted by `jj commit` will be advanced to the newly
created commit. Support for `jj new` will be added in a future change.

This behavior can be enabled by default for all branches by setting
the following in the config.toml:

```
[experimental-advance-branches]
enabled-branches = ["glob:*"]
```

Specific branches can also be disabled:
```
[experimental-advance-branches]
enabled-branches = ["glob:*"]
disabled-branches = ["main"]
```

Branches that match a disabled pattern will not be advanced, even if they also
match an enabled pattern.

This implements feature request #2338.
2024-04-20 10:26:04 -04:00
Austin Seipp
f58e69f6ca cli: add another test for snapshot.max-new-file-size
This one just tests with a larger value and a human-readable string (10KB).

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: If9e5d62146b369d3a1b7efe4e56a1b6b4338c720
2024-04-19 13:03:24 -05:00
Austin Seipp
1d99ff6aef cli: improve snapshot.max-new-file-size error message
For new users this results in a significantly better error output, that
actually shows them how to solve the problem, and why it happened.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ide0c86fdfb40d66f970ceaef7b60a71392d2cd4b
2024-04-19 13:03:24 -05:00
Austin Seipp
ddfdf5e357 cli: allow snapshot.max-new-file-size to be a raw u64
Previously, this command would work:

    jj --config-toml='snapshot.max-new-file-size="1"' st

And is equivalent to this:

    jj --config-toml='snapshot.max-new-file-size="1B"' st

But this would not work, despite looking like it should:

    jj --config-toml='snapshot.max-new-file-size=1' st

This is extremely confusing for users.

This config value is deserialized via serde; and while the `HumanByteSize`
struct allegedly implemented Serde's `visit_u64` method, it was not called by
the deserialize visitor. Strangely, adding an `visit_i64` method *did* work, but
then requires handling of overflow, etc. This is likely because TOML integers
are naturally specified in `i64`.

Instead, just don't bother with any of that; implement a `TryFrom<String>`
instance for `HumanByteSize` that uses `u64::from_str` to try parsing the string
immediately; *then* fall back to `parse_human_byte_size` if that doesn't work.
This not only fixes the behavior but, IMO, is much simpler to reason about; we
get our `Deserialize` instance for free from the `TryFrom` instance.

Finally, this adjusts the test for `max-new-file-size` to now use a raw integer
literal, to ensure it doesn't regress. (There are already in-crate tests for
parsing the human readable strings.)

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I8dafa2358d039ad1c07e9a512c1d10fed5845738
2024-04-19 13:03:24 -05: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
860b39b80f parallelize: include parents in template for all tests
Should make it easier to understand the graph shape when there are
lots of crossing lines.
2024-04-18 21:06:52 -07:00
Martin von Zweigbergk
fe57602b03 tests: avoid a future ancestor merge with root commit
I'm going to make some `jj parallelize` cases that currently error out
instead be successful. Some of the will result in ancestor merges with
the root commit. This patch updates those tests to avoid that.
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
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
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
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
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
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
Evan Mesterhazy
65a525cfd9 Add a test for splitting the parent of a merge commit without --siblings
This is the same as the `test_split_siblings_with_merge_child` added in
https://github.com/martinvonz/jj/pull/3485, but without the siblings flag. I
forgot to add the non-siblings version in that PR.

#3485
2024-04-11 14:58:55 -04: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
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
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
Evan Mesterhazy
cc6d290679 Fix a few minor issues with the jj prev tests
This commit adds commit graphs to most of the tests for `jj prev` to make it
clearer where `@` points before and after `prev` is run.

In addition, there were a couple of tests where the comments suggested the test
meant to have `@` pointing to a specific commit, but it actually pointed to an
empty child of that commit.

This sort of issue also exists in `test_prev_editing`. The test is supposed to
check that `--edit` is implied if you run `jj prev` on an interior commit, but
it actually caused a new empty commit to be created since `@` was sitting on a
tip commit.
2024-04-08 09:12:19 -04: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
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
8b32a8a916 revset: add support for file(kind:pattern) syntax
There are no more callers of parse_function_argument_to_string(), so it's
removed. This function was a thin wrapper of literal parser, and can be
easily reintroduced if needed.
2024-04-07 19:43:29 +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
db14f33170 cli: add ui.always-allow-large-revsets option
This lets users use "large" revsets in commands such as `jj rebase`, without
needing the `all:` modifier.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Ica80927324f3d634413d3cc79fbc73057ccefd8a
2024-04-04 18:38:48 -05:00
Noah Mayr
2cf1c34f58 template: add method mine() to commit type 2024-04-04 22:47:34 +02:00
Evan Mesterhazy
b07fb3ea58 Rename the "AMOUNT" argument for jj prev and jj next to OFFSET
Offset is a more descriptive noun for this argument. This commit also tweaks
the help message for the argument.

This isn't an option/flag, so this change should be transparent to users.
2024-04-04 09:32:29 -04:00
Benjamin Tan
7e46cc13dc cli: print conflicted paths whenever the working copy is changed
This is disabled when the global `--quiet` flag is used.
2024-04-04 11:24:09 +08:00
Yuya Nishihara
eaa15f804d squash: accept multiple --from arguments
Since multiple revisions can be specified, there's no reason to reject multiple
--from arguments.
2024-04-04 12:08:42 +09:00