Commit graph

127 commits

Author SHA1 Message Date
Martin von Zweigbergk
1674a421ec commit_builder: take MergedTreeId for root id argument 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
b19afb6d45 cli: migrate jj untrack to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
6d89f0c0a0 cli: migrate jj restore to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
a0291e99d7 cli: migrate cat, files & git submodule print to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
d753c85e01 cli: migrate most diff-editing functions to MergedTree API 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
732e448458 diff_util: use MergedTree throughout
This switches the whole `diff_util` module to working with
`MergedTree`, `Merge<Option<TreeValue>>` etc., so it can support
tree-level conflicts.

Since we want to avoid using `ConflictId`s, I switched the hash we use
for conflicts in `--git` style diffs to use an all-'0' id instead of
using the conflict id.
2023-08-27 07:50:28 -07:00
Martin von Zweigbergk
5309335405 diff_util: make diff_content() return empty for missing path
I'm not sure this is a win on its own, but it simplifies coming
patches.
2023-08-27 07:50:28 -07:00
Martin von Zweigbergk
5ef925deb8 diff_util: unify handling of unexpected cases
This moves the error cases last in each `match` block, switches to
using format strings, and includes the full value in the message.
2023-08-27 07:50:28 -07:00
Martin von Zweigbergk
6df7db3dc0 merge_tools: pass MergedTree to run_mergetool() 2023-08-27 07:35:01 -07:00
Martin von Zweigbergk
17fe5e39c5 merge_tools: pass MergedTrees to edit_diff() 2023-08-27 07:35:01 -07:00
Martin von Zweigbergk
54b9ecce68 merge_tools: pass MergeTree to run_mergetool_external() 2023-08-27 07:35:01 -07:00
Martin von Zweigbergk
1895a55157 working_copy: make old_checkout argument be MergedTreeId
I think this was the last piece for making the working copy handle
tree-level conflicts.
2023-08-27 06:49:45 -07:00
Martin von Zweigbergk
abf3853717 working_copy: return MergedTreeId on snapshot 2023-08-27 06:49:45 -07:00
Martin von Zweigbergk
88e9933462 working_copy: enable storing multiple tree ids in state file 2023-08-27 06:49:45 -07:00
Yuya Nishihara
a0ae09f461 templates: reword signature placeholders to match description 2023-08-27 09:38:36 +09:00
Yuya Nishihara
f422f1300c templater: move empty signature placeholder to user template
This patch also extracts format_detailed_signature() function to deduplicate
the "show" template bits.

The added placeholder templates aren't labeled as "empty". If needed, I think
the whole template can be labeled as "empty" (or "empty_commit") just like
"working_copy".

Closes #2112
2023-08-27 09:38:36 +09:00
Yuya Nishihara
b45da80c12 tests: add more tests for empty signature
As I'm going to change the Signature type to not fill out a placeholder
message, we need to test the builtin templates as well.
2023-08-27 09:38:36 +09:00
Yuya Nishihara
88b509f857 tests: do not use "author" template keyword to test string functions
I'm going to change the default formatting of empty Signature type, and
these tests should use a non-empty keyword.
2023-08-27 09:38:36 +09:00
Martin von Zweigbergk
a186b5ffce cli: use MergedTree in jj chmod 2023-08-26 08:16:57 -07:00
Martin von Zweigbergk
d0fb154e7e cli: use MergedTreeBuilder in jj chmod 2023-08-26 08:16:57 -07:00
Martin von Zweigbergk
f877610792 merge: add Merge::num_sides()
An alternative name for it would be `arity()`, but `num_sides()`
probably more clearly says that it's not about the number of removes
or the total number of terms.
2023-08-25 08:54:49 -07:00
Martin von Zweigbergk
85bdba5bea working_copy: use MergedTree for diffing in reset() 2023-08-25 07:06:20 -07:00
Yuya Nishihara
3f7d884d00 templater: fix offset of negative substr() index to be char-based 2023-08-25 22:59:31 +09:00
Yuya Nishihara
3bf92a0914 templater: make .short(negative_len) return 0-length string
I think this is less surprising than falling back to the default length.
i64-to-usize conversion can also overflow on 32 bit environment, but I'm not
bothered to handle overflow scenario.
2023-08-25 22:59:20 +09:00
Martin von Zweigbergk
23509e939e working_copy: get diff from MergedTrees
To support tree-level conflicts, we're going to need to update the
working copy from one `MergedTree` to another. We're going need to
store multiple tree ids in the `tree_state` file. This patch gets us
closer to that by getting the diff from `MergedTree`s`, even though we
assume that they are legacy trees for now, so we can write to the
single-tree `tree_state` file.
2023-08-25 06:40:36 -07:00
Vamsi Avula
89b7b0bfe8 templates: colorize description_placeholder
Also, see https://github.com/martinvonz/jj/pull/2100.
2023-08-25 10:03:30 +05:30
Zachary Dremann
ac448202da templates: Add more string methods
Add starts_with/ends_with/remove_prefix/remove_suffix/substr methods to string when templating.
2023-08-24 11:24:07 -04:00
Zachary Dremann
9702a425e5 Allow negative numbers in the template grammar
This allows negative numbers, which also means functions which took numbers can now take negative numbers

Luckily, they all already handled this exactly as expected.
2023-08-24 11:24:07 -04:00
Martin von Zweigbergk
6b5544f335 tree_builder: add a set_or_remove() and simplify callers
Many of the `TreeBuilder` users have an `Option<TreeValue>` and call
either `set()` or `remove()` or the builder depending on whether the
value is present. Let's centralize this logic in a new
`TreeBuilder::set_or_remove()`.
2023-08-24 06:08:25 -07:00
Vladimir Petrzhikovskii
386f002f5a git: add --all-remotes to git fetch 2023-08-24 12:52:41 +02:00
Martin von Zweigbergk
0dcd2fa265 cli: make jj git push default to -r 'remote_branches()..@'
The way `jj git push` without arguments chooses branches pointing to
either `@` or `@-` is unusual and difficult to explain. Now that we
have `-r`, we could instead default it to `-r '@-::@'`. However, I
think it seems likely that users will want to push all local branches
leading up to `@` from the closest remote branch. That's typically
what I want. This patch changes the default to do that.
2023-08-23 15:00:03 -07:00
Martin von Zweigbergk
14d35b0198 cli: make jj git push -r just warn if no branches targeted
If there are branches in the revset that don't need to be pushed
because they already match the destination, we currently just print
`Nothing changed.` It seems consistent with that to also treat it as
success if there are no branches in the specified set to start
with. This patch makes the command print a warning in that case
instead.
2023-08-23 15:00:03 -07:00
Martin von Zweigbergk
d9bd578662 cli: reduce scope of a variable in jj git push 2023-08-23 15:00:03 -07:00
Oscar Bonilla
31f71f29bf Enable wrapping help in clap 2023-08-22 22:24:03 -07:00
Piotr Kufel
2109a7b488 Fix .gitignore handling of ignored directories
- Ignore .gitignore files from untracked directories
 - Do not allow un-ignoring files within ignored directories
2023-08-22 22:08:32 -07:00
Waleed Khan
1633eccdca Use { workspace = true } to appease VS Code's Cargo.toml parser
The VS Code "Better TOML" plugin (which I think most of our VS Code developers use?) doesn't support the `x.y = z` syntax at the top level, even though it's valid TOML. 

This is also useful if we ever want to add additional properties in different sub-crates (although unlikely for the near future).
2023-08-22 21:38:53 -07:00
Oscar Bonilla
30c2a21a14 Fix docs for diff --stat 2023-08-22 20:38:15 -07:00
Yuya Nishihara
c5b6e9705d git: extract add_remote() function, and map git2::Error there
I'm going to add check for remote named "git" there.
2023-08-23 10:02:52 +09:00
Yuya Nishihara
61172b1c1e git: on rename_remote(), check conflicts of new remote name 2023-08-23 10:02:52 +09:00
Yuya Nishihara
46dd6dd9c6 git: handle remote not found error by remove/rename_remote() 2023-08-23 10:02:52 +09:00
Ilya Grigoriev
872a0932cd cli tests: Move current_operation_id to test_utils 2023-08-22 17:39:56 -07:00
Zachary Dremann
1221e306a1 Make find_all_variables lazy, and not allocate
There's no need for it to allocate the variable names, and the only place it's
currently used can benefit from returning early if `$output` is found
2023-08-22 13:15:56 -04:00
Zachary Dremann
562b9d42bf No need for Lazy in LIVE_GUARDS
Mutex::new and Slab::new are both const, so we can use a static mutex directly
2023-08-22 02:12:05 -04:00
Ilya Grigoriev
038867fd3f merge_tools: Allow 3-pane diff editing
As discussed in https://github.com/martinvonz/jj/discussions/1905#discussioncomment-6589673
2023-08-21 20:19:15 -07:00
Ilya Grigoriev
ccd4f8e159 merge_tools: function to extract all variables from tool arguments
To be used in the next commit
2023-08-21 20:19:15 -07:00
Ilya Grigoriev
e743ba78b0 fake_diff_editor: Allow specifying extra arguments to be ignored 2023-08-21 20:19:15 -07:00
Ilya Grigoriev
54d4c9c475 cli_utils: reduce duplication in select_diff 2023-08-21 20:19:15 -07:00
Ilya Grigoriev
fdf1a56178 test_diffedit_command: Show that diffedit ignores unknown files
To me, this behavior seems a bit unexpected. We may want to fix it later
2023-08-21 19:02:19 -07:00
Martin von Zweigbergk
c43a3067eb revset: pass all context arguments to parse() via an object
`revset::parse()` already has a `RevsetWorkspaceContext` argument, so
I think it makes sense to put that and the other context arguments
into a larger `RevsetParseContext` object.
2023-08-20 21:30:06 -07:00
Martin von Zweigbergk
5f3df4aaea revset: resolve "@" symbol's workspace id earlier (while parsing)
We resolve file paths into repo-relative paths while parsing the
revset expression, so I think it's consistent to also resolve which
workspace "@" refers to while parsing it. That means we won't need the
workspace context both while parsing and while resolving symbols.

In order to break things like `author("martinvonz@")` (thanks to @yuja
for catching this), I also changed the parsing of working-copy
expressions so they are not allowed to be
quoted. `author(martinvonz@)` will therefore be an error now. That
seems like a small improvement anyway, since we have recently talked
about making `root` and `[workspace]@` not parsed as other symbols.
2023-08-20 17:57:18 -07:00