Commit graph

6274 commits

Author SHA1 Message Date
Danny Hooper
3050685ff3 cli: implement enough of jj fix to run a single tool on all files 2024-06-04 14:28:21 -05:00
Danny Hooper
bbd9ba31df lib: move command variable interpolation from merge tools to generic location 2024-06-04 14:28:21 -05:00
Danny Hooper
1ece76d128 cli: add a fake code formatter tool for testing 2024-06-04 14:28:21 -05:00
Martin von Zweigbergk
650eeb8935 cli: add jj fix proof of concept 2024-06-04 14:28:21 -05:00
Yuya Nishihara
fcc0b86f0a docs: fix another missing shell quoting around root()
We've turned the "root" symbol into a function before. That's probably why.
2024-06-04 21:19:16 +09:00
Matthew Davidson
88cb56d3dd docs: Fix zsh-breaking logging example 2024-06-04 20:44:11 +09:00
Yuya Nishihara
3a4258916c revset: inline parse_function_call_args()
The separate function looked rather verbose.
2024-06-04 09:56:21 +09:00
Yuya Nishihara
8a4abee87d revset: insert named "function" rules
This patch copies function rule processing from templater and fileset. Since
function and identifier rules are quite different, it's better to not rely on
the subtle difference between identifier and function_name tokens.
2024-06-04 09:56:21 +09:00
Yuya Nishihara
127e4d3455 revset: flatten symbol rule
This makes it clear that the identifier node is special. For the other
constructs, we don't distinguish between bare symbol and quoted string.
2024-06-04 09:56:21 +09:00
Yuya Nishihara
674d897352 revset: inline trivial parsing functions to eliminate obvious assertions 2024-06-04 09:56:21 +09:00
Ilya Grigoriev
441175f2f9 jj help git: Include "Git remotes" in the title
Previously, it sounded like `jj git` might only include highly-technical
commands, while IMO the most important commands in here are `jj git
fetch` and `jj git push`.
2024-06-03 09:36:06 -07:00
dependabot[bot]
0f12582818 cargo: bump proc-macro2 in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [proc-macro2](https://github.com/dtolnay/proc-macro2).


Updates `proc-macro2` from 1.0.84 to 1.0.85
- [Release notes](https://github.com/dtolnay/proc-macro2/releases)
- [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.84...1.0.85)

---
updated-dependencies:
- dependency-name: proc-macro2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 11:27:12 -05:00
Ilya Grigoriev
b1e5ca5348 cli git push: clearer user-facing messages
"Move forward" instead of "Move", "Move sideways" or "Move backward"
instead of (now misleading) "Force...".
2024-06-01 18:42:12 -07:00
Ilya Grigoriev
21b9453d59 jj help: note that move, checkout, and merge as deprecated 2024-06-01 18:38:23 -07:00
Ilya Grigoriev
ab195339b4 docs and jj help: hide deprecated jj move
Fixes #3807
2024-06-01 18:38:23 -07:00
Yuya Nishihara
2c9132adfc revset: remove RevsetExpression::StringPattern hack
It's no longer needed since we have proper AST tree now.
2024-06-02 10:28:54 +09:00
Yuya Nishihara
89ac3a1851 revset: split AST-level parsing and expression lowering stages
This will allows us to parse "file(..)" arguments as fileset expression by
transforming AST for example. I'm not sure if that's good or bad, but we'll
probably want to embed fileset expressions without quoting.

parse_expression_rule() is split to the first str->ExpressionNode stage and
the second ExpressionNode->RevsetExpression stage. The latter is called
"resolve_*()" in fileset, but we have another "symbol" resolution stage in
revset. So I choose "lower_*()" instead.
2024-06-02 10:28:54 +09:00
Yuya Nishihara
444e88e3b8 revset: backport AST types and helpers from templater and fileset
These types and helper functions will be enabled by the next patch.
2024-06-02 10:28:54 +09:00
Yuya Nishihara
2ea173185d revset: add expect_exact_arguments() helper, replace expect_one_argument()
Prepares for migration to dsl_util::FunctionCallNode.
2024-06-02 10:28:54 +09:00
Ilya Grigoriev
a30df323bd jj git push docs: document safety checks
As discussed in
https://discord.com/channels/968932220549103686/1226363798483636265/1226415448615288864
2024-06-01 11:19:48 -07:00
Yuya Nishihara
5e7cb3435e git: unset unborn HEAD ref on export
Otherwise, newly created default branch would be re-imported as a new Git HEAD.
This could be addressed by cmd_git_init(), but the same situation can be
crafted by using "git checkout -b".
2024-06-01 11:01:16 +09:00
Yuya Nishihara
00ae8603db tests: use get_log_output() helper in test_git_init.rs
It's copied from test_git_colocated.rs, and switched to commit_id.short()
because full-length commit_id looked too verbose. "all()" history isn't needed,
but it's easier to follow.
2024-06-01 11:01:16 +09:00
dependabot[bot]
4c57a8868f github: bump github/codeql-action in the github-dependencies group
Bumps the github-dependencies group with 1 update: [github/codeql-action](https://github.com/github/codeql-action).


Updates `github/codeql-action` from 3.25.6 to 3.25.7
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](9fdb3e4972...f079b84933)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-31 10:45:52 -05:00
dependabot[bot]
0fd616960f cargo: bump tokio from 1.37.0 to 1.38.0 in the cargo-dependencies group
Bumps the cargo-dependencies group with 1 update: [tokio](https://github.com/tokio-rs/tokio).


Updates `tokio` from 1.37.0 to 1.38.0
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.37.0...tokio-1.38.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: cargo-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-31 10:45:36 -05:00
mlcui
458580cee2 working_copy: Add is_file_states_sorted to tree state proto
See #2651 and a935a4f70c for more
background.

This speeds up `jj log` in a large repo with watchman enabled by around
9%:

```
$ hyperfine --sort command --warmup 3 --runs 20 -L bin \
jj-before,jj-after "target/release/{bin} -R ~/chromiumjj/src log"
Benchmark 1: target/release/jj-before -R ~/chromiumjj/src log
  Time (mean ± σ):     788.3 ms ±   3.4 ms    [User: 618.6 ms, System: 168.8 ms]
  Range (min … max):   783.1 ms … 793.3 ms    20 runs

Benchmark 2: target/release/jj-after -R ~/chromiumjj/src log
  Time (mean ± σ):     713.4 ms ±   5.2 ms    [User: 536.1 ms, System: 176.2 ms]
  Range (min … max):   706.6 ms … 724.7 ms    20 runs

Relative speed comparison
        1.11 ±  0.01  target/release/jj-before -R ~/chromiumjj/src log
        1.00          target/release/jj-after -R ~/chromiumjj/src log
```
2024-05-31 22:28:35 +10:00
Martin von Zweigbergk
404f31cbc1 backend: add error variant for access denied, handle when diffing
Some backends, like the one we have at Google, can restrict access to
certain files. For such files, if they return a regular
`BackendError::ReadObject`, then that will terminate iteration in many
cases (e.g. when diffing or listing files). This patch adds a new
error variant for them to return instead, plus handling of such errors
in diff output and in the working copy.

In order to test the feature, I added a new commit backend that
returns the new `ReadAccessDenied` error when the caller tries to read
certain objects.
2024-05-30 18:27:38 -07:00
Martin von Zweigbergk
fccba76e8b cat: slightly change warning message about non-file paths
I'm going to add a similar message for access denied. That will want
an error message printed at the end. For consistency, let's do the
same for non-file paths.
2024-05-30 18:27:38 -07:00
Benjamin Tan
e0e123873b revset_graph: rename to graph and make generic over graph node type 2024-05-31 02:39:34 +08:00
Gregory Anders
f4bedf56f6 cli: clear line after writing
Clear the rest of the cursor line (from the cursor to the end of the
row) after drawing the progress bar rather than clearing the entire line
before drawing. This reduces flickering on terminal emulators which are
able to redraw rapidly.
2024-05-30 12:27:11 -05:00
Martin von Zweigbergk
ec5914c830 cli: move to_toml_value() to src/config.rs
Google would like to use `to_toml_value()` for writing TOML-formatted
configs from our internal bug report command.
2024-05-29 23:41:30 -07:00
Glen Choo
8a4087d07b docs: document code.cmd editor on Windows
On Windows `code` works in the shell, but not when specified to jj, because the
executable is actually named `code.cmd`! This is a feature of Windows, where
certain file extensions (defined by the PATHEXT environment variable) are
automatically treated as executable and can have their extensions omitted.

Presumably, jj doesn't support this feature on Windows, though perhaps it
should. For now, avoid adding an explanation of PATHEXT so as to not clutter
things too much, and just suggest `code.cmd` on Windows. Most readers should be
able to put two and two together from there.
2024-05-30 10:21:20 +08:00
Martin von Zweigbergk
3090adfd5c repo: consider empty and undescribed merge commits as discardable 2024-05-29 06:54:30 -07:00
Martin von Zweigbergk
5d2c0347a2 MutableRepo: add test of updating away from empty merge commit
Merge commits are very similar to non-merge commits in jj. An empty
merge commit with no description is not really different from an empty
non-merge commit with no description. As we discussed on
https://github.com/martinvonz/jj/issues/2859, we should not treat
merge commits differently when updating away from them. This patch
adds test for the current behavior (which is to leave the merge commit
in place).
2024-05-29 06:54:30 -07:00
Martin von Zweigbergk
28050e9da1 repo: update some stale mentions of MutableRepo::check_out() 2024-05-29 06:54:30 -07:00
Martin von Zweigbergk
e02622b143 repo: when abandoning a working copy that a merge, recreate it
I recently needed to test something on top of a two branches at the
same time, so I created a new commit on top of both of them (i.e. a
merge commit). I then ran tests and made some adjustments to the
code. These adjustments belonged in one of the parent branches, so I
used `jj squash --into` to squash it in there. Unfortunately, that
meant that my working copy became a single-parent commit based on one
of the branches only. We already had #2859 for tracking this issue.

This patch changes the behavior so we create a new working-copy commit
with all of the previous parents.
2024-05-29 06:54:30 -07:00
Yuya Nishihara
b0845d1df2 dsl_util: add keyword arguments and parsing helper to FunctionCallNode
This will replace revset_parser::expect_named_arguments(). More tests will be
added by migrating revset parsing.
2024-05-29 22:36:15 +09:00
Yuya Nishihara
da2ef7fe4e dsl_util: use .ok() to drop unprintable error
I used .map_err(|_: Vec<_>|) to clarify that the original data is returned as
an error (so it can't be .unwrap()-ed.) However, it can be said that the error
detail isn't important and .map_err() is too verbose.
2024-05-29 22:36:15 +09:00
Yuya Nishihara
db16a5968b dsl_util: forward upper-bounded expect_*_arguments() to common function
I'm going to add keyword arguments handling, and I want to deduplicate check
for unsupported arguments.
2024-05-29 22:36:15 +09:00
Yuya Nishihara
b55c62beb5 dsl_util: add helper function that formats arguments count error message 2024-05-29 22:36:15 +09:00
Yuya Nishihara
89270a37fb fileset: insert missed blank line 2024-05-29 22:36:15 +09:00
mlcui
4c03506fb5 git: Avoid resetting Git index when trees are identical
This accounts for commit message-only changes which do not change the
tree ID, as well as checkouts between commits with identical tree
contents.

See #3748 for previous work on avoiding resetting HEAD when the
*commits* are identical.
2024-05-29 18:11:26 +10:00
Ilya Grigoriev
77ad668b19 test_git_push: test unexpectedly deleted branch 2024-05-29 00:57:50 -07:00
mlcui
e4cfbc10e5 git: Refactor reset_head to share set_git_head_target call
This shares some common code to both the root and the non-root case, and
provides easier access to `mut_repo` in the function - as
`set_git_head_target` mutably borrows `mut_repo`.

This will be used for a cleaner implementation of #3767.
2024-05-29 15:44:47 +10:00
Ilya Grigoriev
e3bb825a21 jj git push: remove the NotFastForward error
Now that we always force push, it should not occur in practice.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
12081166f6 test_git.rs: delete now-useless test 2024-05-28 21:38:26 -07:00
Ilya Grigoriev
777da99533 jj git push: always force-push, all safety logic now in push_negotiation
This should be a no-op, though that is not necessarily obvious in corner
cases.

Note that libgit2 already performs the push negotiation even when
pushing without force (without `+` in the refspec).
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
8d3dd17b51 jj git push: safety checks in push negotiation, "force-with-lease"
As explained in the commit, our logic is a bit more complicated than
that of `git push --force-with-lease`. This is to match the behavior of
`jj git fetch` and branch conflict resolution rules.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
b0306eb742 jj git push: no-op push negotiation, plumb data to it
Hopefully, splitting the no-op portion will make the following commits
easier to review.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
b54d962d58 test_git.rs: add two more commits to PushSetup, rename them
The new names are a bit clearer. Soem tests already use a
`sideways_commit`, `parent_of_main_commit` will be needed in
an upcoming test.
2024-05-28 21:38:26 -07:00
Ilya Grigoriev
1e1507d5cb test_git_push: add a test for creating unexpectedly existing branch
This tests `git push` attempting to create a branch when the branch
already unexpectedly exists on the remote. This should (and does)
fail.

Also changes another test to use `jj_cmd_failure`.
2024-05-28 21:38:26 -07:00