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

1213 commits

Author SHA1 Message Date
dploch
539edad216 diff_util: don't panic for file hashes < 10 hex chars 2024-06-06 11:50:59 -04:00
Michael Gattozzi
3bc361a8b9 cli: add --allow-empty-description flag to push
This commit adds an optional flag to be able to push commits with an
empty description to a remote git repo. While the default behavior is
ideal we might need to interact with a repo that has an empty commit
description in it. I ran into this issue a few weeks ago pushing commits
from an open source repo to an empty repo and had to go back to using
git for that push as I would not want to rewrite the history which was
many many years long just for that.

This flag allows users an escape hatch for pushing empty descriptions
for commits and they're sure that they want that behavior.

This commit adds the flag to the `git push` command and updates the docs
for the command. It also updates the original test to make sure that the
flag works as intended to reject the commit when not set and to allow
the commit when the flag is set.

Closes #2633
2024-06-05 14:58:36 -04:00
Benjamin Tan
a3c6a9b1b7 new: allow --insert-before and --insert-after simultaneously 2024-06-05 19:29:27 +08:00
Benjamin Tan
bbadc6f14f new: extract out ensure_no_commit_loop function 2024-06-05 19:29:27 +08:00
Benjamin Tan
256a51f835 new: convert --insert-before and --insert-after into proper options 2024-06-05 19:29:27 +08:00
Benjamin Tan
f74618f41d new: refactor creation of new commit into common code path 2024-06-05 19:29:27 +08:00
Benjamin Tan
a45a505b66 new: avoid manual unwrap() call 2024-06-05 19:29:27 +08:00
Yuya Nishihara
9f33d13dfd revset: replace ParseState with &RevsetParseContext
There's no longer a mutable state to be tracked.
2024-06-05 10:39:32 +09:00
Yuya Nishihara
14421ac126 revset: omit function name from type error messages
This simplifies the interface of helper functions. While revset doesn't have
top-level string pattern or integer literal, these parsing helpers could be
used to parse array subscript or n-th parent operator if any.
2024-06-05 10:39:32 +09:00
Yuya Nishihara
e9db051b84 cli: git: split loop that collects push directions and new targets
Just a minor code cleanup.
2024-06-05 10:39:17 +09:00
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
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
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
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
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
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
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
Ilya Grigoriev
77ad668b19 test_git_push: test unexpectedly deleted branch 2024-05-29 00:57:50 -07: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
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
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
Ilya Grigoriev
221cd44904 test_git_push: demo behavior we'd like to be safer
Adds two tests where pushing should fail, but currently succeeds.
2024-05-28 21:38:26 -07:00
Martin von Zweigbergk
35c7606350 diff_util: replace DiffWorkspaceContext by RepoPathUiConverter 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
1e3b49abf5 revset: use FsRepoPathUiConverter in RevsetWorkspaceContext 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
058461ebb1 fileset: replace FilesetParseContext by RepoPathUiConverter 2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
3b702250a6 repo_path: add type for formatting and parsing RepoPath, use in CLI
We want to move UI-independent logic that's currently in `jj-cli` into
`jj-lib`. `WorkspaceCommandHelper` is perhaps the most important part
to start moving. As I was looking into what to move from
`WorkspaceCommandHelper`, the first thing I saw there was the
`cwd`. It might seem like a good candidate to start moving. However,
when running a server, you might be running operations on repos stored
in database, so `cwd` and the workspace root don't make sense then
(because the repo is not stored at a particular path).

So, instead, this patch starts abstracting out our uses of those two
paths by adding an enum for converting between `RepoPath` and paths as
they are presented in the UI. I added a variant for repos stored in a
file system, and made `WorkspaceCommandHelper` use that to show that
it works. We'll probably add a server variant later.

I put the new type in `repo_path.rs` because at least the
file-system-based implementation is closely related to
`RepoPath::parse_fs_path()`.
2024-05-28 21:36:40 -07:00
Martin von Zweigbergk
7e6a968415 conflicts: consider the empty tree a non-legacy tree
Since we no longer depend on legacy trees being preserved when we
build new trees or merge trees, we can consider the root tree a
non-legacy tree.
2024-05-27 06:25:27 -07:00
Martin von Zweigbergk
8e6e04b929 conflicts: always use tree-level format for merged trees
It's been about six months since we started using tree-level conflicts
by default. I can't imagine we would switch back. So let's continue
the migration by always using tree-level conflicts when merging trees,
even if all inputs were legacy trees.
2024-05-27 06:25:27 -07:00
Yuya Nishihara
b31f75bc94 dsl_util: introduce visitor-based generic alias substitution
The original expand_node() body is migrated as follows:
- Identifier -> fold_identifier()
- FunctionCall -> fold_function_call()

expand_defn() now manages states stack by itself, which simplifies lifetime
parameters.
2024-05-26 11:21:45 +09:00
Yuya Nishihara
0efd2aa316 dsl_util: add trait for alias body parsing
This could be a closure argument passed to expand_aliases(), but it's nice
that the parsing function is constrained by the aliases map type.
2024-05-26 11:21:45 +09:00
Yuya Nishihara
7be4a0a560 dsl_util: add visitor-like API primarily designed for alias substitution
The templater implementation of FoldableExpression is a stripped-down version
of expand_node(). It's visitor-like because I'm going to write generic alias
substitution rules over abstract expression types (template, revset, fileset.)

Naming comes from rustc.
https://rust-unofficial.github.io/patterns/patterns/creational/fold.html
2024-05-26 11:21:45 +09:00
Yuya Nishihara
5061d4b831 dsl_util: add trait for alias substitution errors
This is basically the same as the previous patch, but for error types. Some
of these functions could be encoded as "E: From<AliasExpandError<'i>>", but
alias substitution logic is recursive, so it would have to convert E back and
force.
2024-05-26 11:21:45 +09:00
Yuya Nishihara
cf6357459d dsl_util: add trait that constructs ExpressionKind of basic AST node types
This isn't fancy, but we'll need some generic way to return either original
or substituted expression node. I think this is the simplest abstraction.
2024-05-26 11:21:45 +09:00
Martin von Zweigbergk
5dea2a9b9b cli: add space around = in jj config list output
I think this makes it more readable. It seems to be how most people
write TOML.
2024-05-24 19:35:45 -07:00
Yuya Nishihara
4478055e1d cli: don't abandon non-discardable old wc commit by import_git_head()
Perhaps, the original intent was to abandon non-empty working-copy commit
assuming it was rewritten by git (therefore it should be superseded by the
current working-copy content.) However, there are other reasons that could
make the HEAD out of sync (including concurrent jj operations), and abandoning
non-empty commit can be a disaster. This patch turns it to safer side, and let
user abandon non-empty commit manually.

Fixes #3747
2024-05-25 10:29:30 +09:00
Yuya Nishihara
02eb164dae config: migrate "config get"/"set" to TOML-based name argument parsing 2024-05-23 12:22:12 +09:00
Yuya Nishihara
97023b8da6 fileset, templater: extract basic AST node types
I'm going to extract generic alias substitution functions, and these AST types
will be accessed there. Revset parsing will also be migrated to the generic
functions.
2024-05-23 10:18:36 +09:00