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

1659 commits

Author SHA1 Message Date
Yuya Nishihara
ae62b5b946 repo: teach OpStore about the root commit id
This removes an invalid View state from the root operation.

Note that the root index will have to be reindexed in order to resolve "root()"
in the root operation. I don't think this would practically matter, so this
patch doesn't bump the index version to invalidate the existing indexes.

See also 48a9f9ef56 "repo: use Transaction for creating repo-init operation."
2024-10-08 13:21:03 +09:00
Yuya Nishihara
33f0472fcf repo: add convenient methods to load operation object
It's hosted by RepoLoader for now. I'm not sure if we'll need a higher-level
abstraction like Store.
2024-10-08 13:21:03 +09:00
dploch
eb09a3e965 bookmarks-list: fix typo 2024-10-07 20:37:14 -04:00
dploch
95344f9e05 simplify-parents: add a command to remove redundant parents 2024-10-07 20:15:33 -04:00
dploch
0c7357ec5f ui: write prompt messages to stderr
This enables more scripting use cases where the caller may wish to parse stdout for programmatic purposes.
2024-10-07 19:47:18 -04:00
dploch
7b8df5d8fd ui: simplify stripping logic and get rid of warning 2024-10-07 19:47:18 -04:00
Matt Stark
a524f1f996 refactor: Allow the aliases map to map to arbitrary types.
For #3673, we will have aliases such as:
```toml
'upload(revision)' = [
  ["fix", "-r", "$revision"],
  ["lint", "-r", "$revision"],
  ["git", "push", "-r", "$revision"],
]
```

Template aliases:
1) Start as Config::Value
2) Are converted to String
3) Are placed in the alias map
4) Expand to a TemplateExpression type via expand_defn.

However, command aliases:
1) Start as Config::Value
2) Are converted to Vec<Vec<String>>
3) Are placed in an alias map
4) Do not expand

Thus, AliasesMap will need to support non-string values.
2024-10-08 10:19:14 +11:00
Martin von Zweigbergk
b90d60ca1f git: allow both --branch/--bookmark for git fetch/push
`jj git push` has a `--bookmark` argument, which takes a list of
bookmarks to push to the Git remote. They'll become branches on the
Git remote. `jj git fetch` has a `--branch` argument, which takes a
list of Git branches to fetch. They'll become bookmarks once
fetched. So the naming is consistent, but the reasoning is quite
subtle. Let's provide the other name as a hidden alias to help users
who get it wrong.
2024-10-07 10:08:43 -07:00
Yuya Nishihara
68f48605e9 cli: in color-words diffs, highlight word-level hunks in context lines
Since context lines are styled in the same way as diff lines, it makes sense
to highlight words within context lines.
2024-10-06 09:45:27 +09:00
Yuya Nishihara
1eeeb1462a cli: extract helpers from show_color_words_context_lines()
This should make the next patch a bit easier to read.
2024-10-06 09:45:27 +09:00
Yuya Nishihara
6877ec4316 cli: add diff --ignore-all-space/--ignore-space-change flags
These flags only apply to line-based diffs. This is easy, and seems still useful
to highlight whitespace changes (that could be ignored by line diffing.)

I've added short options only to "diff"-like commands. It seemed unclear if
they were added to deeply-nested commands such as "op log".

Closes #3781
2024-10-06 09:45:27 +09:00
Yuya Nishihara
dc954517b9 cli: extract UnifiedDiff/DiffStatOptions structs
UnifiedDiffOptions could be wrapped by GitDiffOptions, but there are no Git-diff
specific options right now.
2024-10-06 09:45:27 +09:00
Yuya Nishihara
df40a09a5d cli: rename ColorWordsOptions to ColorWordsDiffOptions
I'm going to add an options struct for git diff, but GitOptions, UnifiedOptions,
StatOptions, etc. sound odd.
2024-10-06 09:45:27 +09:00
Yuya Nishihara
383cca4c4d diff: return matching hunk contents from all inputs
We're likely to use the right (or new) context lines in rendered diffs, but
it's odd that the hunks iterator choose which context hunk to return. We'll
also need both contents to calculate left/right line numbers.

Since the hunk content types are the same, I also split enum DiffHunk into
{ kind, contents } pair.
2024-10-06 09:45:27 +09:00
Samuel Tardieu
6368544f4f style: use explicit loop instead of .for_each() in simple cases 2024-10-04 22:29:13 +02:00
Samuel Tardieu
12f4d6d17b style: avoid using .to_owned()/.to_vec() on owned objects
`.clone()` is more explicit when we already have an object
of the right type.
2024-10-04 22:29:13 +02:00
Samuel Tardieu
3f2ef2ee04 style: add semicolon at the end of expressions used as statements 2024-10-04 22:29:13 +02:00
Samuel Tardieu
46e2723464 style: inline variables into format strings 2024-10-04 22:29:13 +02:00
Samuel Tardieu
62f582e6ab style: remove useless uses of .iter()
Most collection references implement `.into_iter()` or its mutable version,
so it is possible to iterate over the elements without using an explicit
method to do so.
2024-10-04 22:29:13 +02:00
Samuel Tardieu
3f0703ca2c cargo: inherit lints configuration from workspace 2024-10-04 22:29:13 +02:00
Samuel Tardieu
794db9dae0 style: do not return a Result when this is not needed 2024-10-04 22:29:13 +02:00
Samuel Tardieu
fb12e48fc9 cli: add short method summary to its documentation 2024-10-04 17:09:54 +02:00
Samuel Tardieu
e2408078bf cli: add pointer to the documentation in case of fileset syntax error 2024-10-04 17:09:43 +02:00
Yuya Nishihara
af556aa01c tests: rename test_file_print_command.rs to_file_show_command.rs 2024-10-04 20:52:59 +09:00
Lukas Wirth
72c5bbb4e6 Be more specific when warning the user about missing identity configs
Check if only the email or the name are missing in the config and specifically name the missing one, instead of always defaulting to potentially both missing.
2024-10-02 18:10:46 +02:00
Yuya Nishihara
0a8d8dad67 cli: make default log revset work without working-copy commit
Spotted while adding an error propagation path from IdPrefixContext.
2024-10-01 20:04:06 +09:00
Yuya Nishihara
1f5835c267 cli: simplify help about default "log -r"
Since we've moved the default log revset to config/*.toml at 3dab92d2, we don't
have to repeat the default value. It can be queried by "jj config list". I also
split the help paragraphs.
2024-10-01 20:04:06 +09:00
Tyler Goffinet
9f8d936189 cli: color author and commiter names yellow
When `format_short_signature(signature)` is set to `signature.name()` the author names are not yellow like other signature types (eg email and username). When the commit signatures have no colors, they blend in making it hard to distinguish between signatures and commit messages.

If just `name` were set to `yellow`, just like email and username, it affects the colorization of branch names making them also yellow despite them being designated as magenta. Setting `author` and `committer` to `yellow` is specific enough to allow branches to keep their colors while still coloring signature names. This is known to affect signatures in both 'log' and 'show'.
2024-09-28 23:34:26 -07:00
Samuel Tardieu
f38c59f734 split: do not prevent all changes from going into the first commit
Let the user select all changes interactively and put them into
the first commit, and create a second commit with the possibility
of preserving the current commit message. This was previously only
possible in non-interactive mode by specifying matching paths, e.g.
".".  In both cases, a warning will be issued indicating that the second
commit is empty.
2024-09-27 13:33:05 +02:00
Samuel Tardieu
98c16c4e19 split: do not reference file paths in warning
jj split warning was potentially wrong in both interactive and
non-interactive modes when everything is put into the child commit:

- Non-interactive mode: "The given paths does not match any file:
  PATHS". The message is misleading, as the PATHS given on the command-line
  may match files but not match files containing changes.
- Interactive mode: "The given paths does not match any file: " while
  if possible that no paths were given on the command line.
2024-09-27 13:33:05 +02:00
Samuel Tardieu
baf25ba482 unsquash: deprecate in favor of squash and diffedit
Everything that could be done with `jj unsquash` can be done with
`jj squash` or `jj diffedit --preserve-descendants`.
2024-09-26 16:34:48 +02:00
Yuya Nishihara
9551794f19 cli: print operation summary on "op restore" as we do for "undo" 2024-09-25 16:30:22 +09:00
Yuya Nishihara
b30ce36c55 cli: print operation summary before committing transaction
It seemed a bit odd that working-copy update was printed before the "undo"
operation we made earlier.
2024-09-25 16:30:22 +09:00
Essien Ita Essien
895d53f395 Rename conflict and file revsets to conflicts and files.
See discussion thread in linked issue.

With this PR, all revset functions in [BUILTIN_FUNCTION_MAP](8d166c7642/lib/src/revset.rs (L570))
that return multiple values are either named in plural or the naming is hard to misunderstand (e.g. `reachable`)

Fixes: #4122
2024-09-24 20:02:49 +01:00
Samuel Tardieu
cf7847d784 restore: add --restore-descendants flag 2024-09-24 14:26:54 +02:00
Samuel Tardieu
e8deb08f78 abandon: add --restore-descendants flag 2024-09-24 10:52:06 +02:00
Samuel Tardieu
f76ee1872f diffedit: add --restore-descendants flag 2024-09-24 09:30:28 +02:00
Yuya Nishihara
05b90390ae cli: get author timestamp of description template in consistent way
There's a subtle difference. If the original commit was discardable, its author
timestamp is updated by CommitBuilder.
2024-09-24 07:17:33 +09:00
Yuya Nishihara
49e5585130 tests: snapshot some editor contents in test_describe_author() 2024-09-24 07:17:33 +09:00
Samuel Tardieu
69d1600d82 Inline variables in format string 2024-09-23 22:34:55 +02:00
Yuya Nishihara
49e45cc245 revset, templater: add deprecation warnings 2024-09-23 07:07:07 +09:00
Yuya Nishihara
11286b3072 templater: pass diagnostics receiver around 2024-09-23 07:07:07 +09:00
Yuya Nishihara
8b1760ca5d revset: pass diagnostics receiver around
Stacking at AliasExpanded node looks wonky. If we migrate error handling to
Diagnostics API, it might make sense to remove AliasExpanded node and add
node.aliases: vec![(id, span), ..] field instead.

Some closure arguments are inlined in order to help type inference.
2024-09-23 07:07:07 +09:00
Yuya Nishihara
4b477fa59e fileset: pass diagnostics receiver around, add printing function
CLI tests will be added later.
2024-09-23 07:07:07 +09:00
Yuya Nishihara
df8967970e revset, templater: make context message of nested errors less specific
So that these error variants can be reused as warning contexts.
2024-09-23 07:07:07 +09:00
Mateusz Mikuła
8dd3003bec refactor: mark Timestamp struct as Copy 2024-09-22 16:23:53 +02:00
Essien Ita Essien
76f40e5990 cli: reorder updating and reporting for consistency.
* See #4239 for details.
* For now, update working copy before reporting repo changes, so that
  potential errors in reporting changes don't leave the repo in a stale
  state.

Fixes: #4239
2024-09-22 15:02:21 +01:00
Mateusz Mikuła
2e9049b188 cli: add --author argument for commit and describe 2024-09-22 12:40:46 +02:00
Essien Ita Essien
0f5c5530df cli: Warn if specified remote branch not found for jj git fetch
* First fetch from remote.
* Then check tx.{base_repo(),repo}.view().remote_bookmarks_matching(<branch>, <remote>).
  This has to happen after the fetch has been done so the tx.repo() is updated.
* Warn if a branch is not found in any of the remotes used in the fetch. Note that the remotes
  used in the fetch can be a subset of the remotes configured for the repo, so the language
  of the warning tries to point that out.

Fixes: #4293
2024-09-21 14:09:24 +01:00
Yuya Nishihara
4533e81957 cli: pass &Ui to parse fileset/revset/template functions
Deprecation warnings will be printed there. auto_tracking_matcher(ui) could
be cached, but there aren't many callers right now, so it should be okay to
parse and emit warnings for each invocation. Other than that, the changes are
straightforward.
2024-09-20 23:01:12 +09:00