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

1618 commits

Author SHA1 Message Date
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
Yuya Nishihara
09cedd83a7 cli: add specialized function for pre-validated templates
I'll make parse_<language>_template() require &Ui, but these cached templates
should be re-constructible without access to a Ui.

Maybe we can split a parsed template object into RevsetExpression-like
evaluation tree and interpreter environment, but that'll be a big challenge.
2024-09-20 23:01:12 +09:00
Yuya Nishihara
3c04507097 cli: remove unneeded &mut from edit_multiple_descriptions() 2024-09-20 23:01:12 +09:00
Yuya Nishihara
dd9213a954 cli: leverage parse_operation_template() in cmd_op_show() 2024-09-20 23:01:12 +09:00
Yuya Nishihara
7e04af1729 cli: cache immutable heads revset expression
This will help simplify warning handling in future patches. I'm going to add
deprecation warnings to revset, so Ui will be required in order to parse a user
revset expression.

revset_util::parse_immutable_expression() is inlined as it's a thin wrapper
around parse_immutable_heads_expression().
2024-09-20 06:56:03 +09:00
Yuya Nishihara
1d86e325c6 cli: move check_repo_rewritable() to WorkspaceCommandEnvironment
This ensures that the repo argument is used instead of self.repo(). store() is
now obtained from the repo argument (which shouldn't matter, though.)
2024-09-20 06:56:03 +09:00
Yuya Nishihara
0c9bc37f10 diff: buffer color-words context lines
I'm testing simple conflicts diffs locally, and we'll probably need to handle
consecutive context hunks when we add some form of unmaterialized conflicts
diffs. Let's buffer context hunks (up to 1 right now.) The new code looks
simpler.
2024-09-19 20:01:51 +09:00
Yuya Nishihara
9f5ce934d2 diff: extract function that prints color-words diff lines
This block is relatively big, and will become even bigger if we add support
for unmaterialized conflicts diffs.
2024-09-19 20:01:51 +09:00
Yuya Nishihara
79e76c5dad diff: extract line number handling from show_color_words_diff_line()
This seems more consistent with !can_inline case, and we can remove extra
vec![] allocation from context line processing.
2024-09-19 20:01:51 +09:00
Samuel Tardieu
726cbbd66c diffedit: separate extra help information in its own paragraph 2024-09-18 09:11:07 +02:00
Vamsi Avula
a2e67bdd9b templates: add .normal_hex() for {Commit,Change}Id
This doesn't do much for CommitId but outputs the "forward" hex for
ChangeId, which can be useful to use as Gerrit Change-Id.
2024-09-17 21:11:00 -05:00
Samuel Tardieu
05c6d62c68 bookmark: add "b" alias
`jj bookmark` is a frequently used command. Its subcommands already have
one letter aliases. Defining `jj b` as an alias for `jj bookmarks` make
bookmarks really easy to use.
2024-09-17 18:24:26 +02:00
Essien Ita Essien
e25ec536ed next/prev: Fetch descendants with more correctness.
See context in [this discussion](https://github.com/martinvonz/jj/pull/3935#discussion_r1649520967)

Fixes #3947
2024-09-17 16:39:29 +01:00
Samuel Tardieu
6d0a092410 cli: remove unused dependency on hex 2024-09-17 12:34:31 +02:00
Samuel Tardieu
c1a032fad6 squash doc: --keep-emptied let the description unchanged 2024-09-17 11:49:48 +02:00
Kevin Liao
412ef36259 cli: Support renaming workspaces
fixes #4342
2024-09-16 19:35:36 -07:00
Samuel Tardieu
a7f32d3652 squash: accept -k as a shorthand for --keep-emptied
This eases the workflow in which a commit in the middle of the tree is
repeatedly squashed into its parent.
2024-09-15 18:31:47 +02:00
Lukas Wirth
7ff12ec8b0 op-diff: Use op_summary template 2024-09-15 14:11:33 +02:00
Lukas Wirth
8e727de2ab undo: Report what operation has been undone in jj op undo 2024-09-15 14:11:33 +02:00
Yuya Nishihara
cb07e5ab67 cli: borrow RepoLoader from Workspace
It should be slightly cheaper than constructing new RepoLoader.
2024-09-15 20:40:46 +09:00
Yuya Nishihara
9dc2cf802c cli: add helper to set up op template environment for the current repo state
We'll add a few more callers.
2024-09-15 20:40:46 +09:00
Yuya Nishihara
0c0e1b61e3 git-push: just say "Changes to push to <REMOTE>"
"Bookmark changes" sounds like changes will be bookmarked, and "Bookmark" here
is redundant. If we add support for pushing tags, this message will have to be
generalized anyway.
2024-09-15 07:06:56 +09:00
Yuya Nishihara
a48ecf3e62 git-push: remove redundant hash map lookup from print-changes loop 2024-09-15 07:06:56 +09:00
Yuya Nishihara
2f78c25d35 git-push: skip print-changes loop if --quiet 2024-09-15 07:06:56 +09:00
Yuya Nishihara
42f7908b8d git-push: extract function that prints bookmark changes to be pushed 2024-09-15 07:06:56 +09:00
Samuel Tardieu
6e72b1cfb0 git: add --remote option to clone command
This makes it easier to work with multiple remotes at once while
tracking the default branch of the remote used to create the local
repository:

```shell
$ jj git clone --remote upstream https://github.com/upstream-org/repo
$ cd repo
$ jj git remote add origin git@github.com:your-org/repo
$ jj config set --repo git.fetch upstream
```

In the example above, `upstream` is the repository containing the
reference source code that you might want to patch, while `origin` is
your fork where pull-request will be pushed. The branch `main@upstream`
will be tracked.
2024-09-13 18:14:57 +02:00
Yuya Nishihara
41ef9a76de cli: actually test if format_short_change_id() can be parsed
It's usually included in the commit_summary template, but not guaranteed.
2024-09-13 21:59:35 +09:00
Lukas Wirth
1410f2bee7 docs: Remove trailing whitespace in markdown files 2024-09-13 13:06:28 +02:00
Lukas Wirth
bccd8214df conflicts: Highlight change ids in rebase advice 2024-09-13 12:57:56 +02:00
Martin von Zweigbergk
63e616c801 git: restore support for git.push-branch-prefix config but deprecate it 2024-09-12 23:28:30 -07:00
Martin von Zweigbergk
c2220ca4d5 config-schema: update stale push-branch-prefix config
We missed this when we renamed `push-branch-prefix` to
`push-bookmark-prefix`. I changed the description slightly to try to
clarify that it's about the local bookmark that's created before
pushing it to the remote as a branch.
2024-09-12 23:00:20 -07:00
Martin von Zweigbergk
1aa2aec141 bookmarks: update some leftover uses of the word "branch" 2024-09-11 19:19:31 -07:00
Yuya Nishihara
d97a7ba86f cli: fix missed working-copy "bookmark" colors
Quoting style changed because of insta v1.40.0.
2024-09-12 09:02:16 +09:00
Yuya Nishihara
78edc6aba5 op log: add --op-diff option to embed operation diffs
This is basically "log -p" for "op log". The flag name has "op" because --diff
and --patch mean a similar thing in this context. Since -p implies --op-diff,
user can just do "op log -p" if he's okay with verbose op + content diffs.
Note that --no-graph affects both "op log" and "op diff" parts.

We might want to do some style changes later, such as inserting/deleting blank
lines, highlighting headers, etc.
2024-09-12 06:51:45 +09:00
Yuya Nishihara
050cde94ef op diff: apply word wrapping to non-graph template outputs
These contents may be embedded in "op log", and it's probably good to enable
word wrapping consistently.
2024-09-12 06:51:45 +09:00
Yuya Nishihara
babdf6b9c1 cli: relax error type of LogContentFormat::write() 2024-09-12 06:51:45 +09:00
Yuya Nishihara
6154827129 cli: make log word-wrapping helper calculate width eagerly
Multiple graphs will be nested in "op log" output, and things would be messy if
we had to calculate graph widths lazily. Let's simply make LogContentFormat
track the current available width no matter if ui.log-word-wrap is off.
2024-09-12 06:51:45 +09:00
Philip Metzger
d9c68e08b1 everything: Rename branches to bookmarks
Jujutsu's branches do not behave like Git branches, which is a major
hurdle for people adopting it from Git. They rather behave like
Mercurial's (hg) bookmarks. 

We've had multiple discussions about it in the last ~1.5 years about this rename in the Discord, 
where multiple people agreed that this _false_ familiarity does not help anyone. Initially we were 
reluctant to do it but overtime, more and more users agreed that `bookmark` was a better for name 
the current mechanism. This may be hard break for current `jj branch` users, but it will immensly 
help Jujutsu's future, by defining it as our first own term. The `[experimental-moving-branches]` 
config option is currently left alone, to force not another large config update for
users, since the last time this happened was when `jj log -T show` was removed, which immediately 
resulted in breaking users and introduced soft deprecations.

This name change will also make it easier to introduce Topics (#3402) as _topological branches_ 
with a easier model. 

This was mostly done via LSP, ripgrep and sed and a whole bunch of manual changes either from
me being lazy or thankfully pointed out by reviewers.
2024-09-11 18:54:45 +02:00
Yuya Nishihara
d04ff1213f op diff: set up diff/template context without using WorkspaceCommandHelper
I'll use a similar setup in "op log", but for each log entry. We might want to
extract some parts to helper function, but I don't have a good idea right now.

CommandHelper::operation_template_extensions() is removed because it's unlikely
to parse operation template without loading a workspace.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
1e17078eb5 op log: leverage WorkspaceCommandEnvironment to parse template
I'll add an option to include diffs in "op log", and workspace_env will be used
in order to set up diff/template contexts per operation.

cmd_op_log() is split because of owned/borrowed type differences.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
e0da3ec010 cli: move some template helpers to WorkspaceCommandEnvironment
These functions will be used by "op log"/"diff"/"show".

This patch also changed the error type as it's obvious that there are no other
errors to be returned.
2024-09-10 07:06:43 +09:00
Yuya Nishihara
1da9ebcec1 cli: cache parsed revsets.short-prefixes expression
It doesn't make sense to reparse revset expression. Let's reuse the parse
result. This also simplifies error handling bits.

OnceCell is switched to the std one as we no longer need get_or_try_init().
2024-09-10 07:06:43 +09:00