Commit graph

142 commits

Author SHA1 Message Date
Martin von Zweigbergk
8e47d2d66f merged_tree: add config option to write trees using new format
We're finally ready to start writing trees using the new format where
we represent conflicts by having multiple trees in the commit instead
of having a single tree with multiple entries at a path. This patch
adds a config option for that. It's not ready to be used yet, so I
haven't updated the release notes or other documentation.

I added only a simple CLI test for testing what happens when the
config is enabled in an existing repo. 108 tests currently fail if we
flip the default.
2023-08-30 06:17:21 -07:00
Waleed Khan
56c61fd047 merge_tools: create builtin diff editor 2023-08-30 05:38:10 -04:00
Waleed Khan
ccd67e8156 merge_tools: rename MergeTool::Internal -> MergeTool::Builtin
The name we will expose to the user is `builtin`, so this changes the internal messaging to match that.
2023-08-30 04:10:39 -04:00
Vamsi Avula
32377a13f4 templates: default placeholders to red
With the idea that less severe placeholders (like description) could
(and should) explicitly "opt out".

(Both email and name placeholders will be red with this change.)
2023-08-30 12:54:15 +08:00
Vamsi Avula
dbf13a5250 tests: add test for log builtin templates with colors 2023-08-30 12:54:15 +08:00
Martin von Zweigbergk
145b0b24d8 commit: drop merged_ prefix from tree() and tree_id()
The old `tree()` and `tree_id()` functions are now gone, so we can use
those names for the new functions.
2023-08-29 08:32:04 -07:00
Martin von Zweigbergk
67832a3940 merged_tree: take store argument to write_tree() instead of new()
The store isn't needed until we write the trees, so I think it makes
more sense to pass it there.
2023-08-29 08:32:04 -07:00
Yuya Nishihara
55c6e90555 git: remove handling of real remote named "git", always override
#1690
2023-08-29 22:50:46 +09:00
Yuya Nishihara
ce3d28e234 git: do not import refs from remote named "git"
I made it simply fail on explicit fetch/import, and ignored on implicit import.
Since the error mode is predictable and less likely to occur. I don't think it
makes sense to implement warning propagation just for this.

Closes #1690.
2023-08-29 22:50:46 +09:00
Yuya Nishihara
35a596ff66 git: prohibit creation of remote named "git"
#1690
2023-08-29 22:50:46 +09:00
Yuya Nishihara
0e26ef7733 git: add constant for pseudo remote name "git" 2023-08-29 22:50:46 +09:00
Martin von Zweigbergk
dc06bbc7d1 commit: migrate remaining uses of Commit::tree_id() and delete it 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
90e78a1424 rewrite: return MergedTree from merge_commit_trees() 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
494026a9bf cli: merge trees via MergedTree in rebase_to_dest_parent() 2023-08-28 15:58:34 -07:00
Martin von Zweigbergk
bd6098e09e cli: merge trees via MergedTree in jj move 2023-08-28 15:58:34 -07:00
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