Skip to content

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Sep 2, 2025

Might be better to merge after the release.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

@yuja yuja requested a review from a team as a code owner September 2, 2025 02:27
Comment on lines +42 to +46
* `jj` now records content hash of materialized conflict files in addition to
file modification time, and relies on them to detect changes. Unchanged
conflicts checked out by old `jj` may be snapshotted by new `jj`. Run `jj new
<REVISION-WITHOUT-CONFLICTS> && jj undo` to check out fresh conflict files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a user, I don't think it's clear under what circumstances I need to run those commands and what happens if I don't. It sounds like the purpose of the hash is to handle some corner case (do we have a bug report?), but is that case common enough that we even need to tell users how to work around it? Or did I misunderstand the purpose of the hash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to remove re-materialization when parsing conflicts.

https://github.com/jj-vcs/jj/pull/7399/files#diff-15b48dd183d7f89959f15b80cee2dcae0bb7099e1e934497f74c73384315fa6bL962

Since existing checkout doesn't have a content hash, touch conflict_file && jj stat may snapshot unchanged conflict as different set of added/removed files. I don't feel strongly whether we should suggest a workaround command (because the situation would be rare), but I think formatting changes should be documented.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file's timestamp has already been updated, will jj new <REVISION-WITHOUT-CONFLICTS> && jj undo still be able to restore it to an unmodified state? Since the jj new there does snapshotting, I would think it would not help. So do you actually need jj new <REVISION-WITHOUT-CONFLICTS> && <upgrade jj> && jj undo? IIUC, the confusing thing is that we might snapshot some file and make it look modified but with an empty diff (just a ... line). jj restore <path> can be used for fixing that, right? Should we suggest that instead?

@yuja yuja force-pushed the push-smwzwnwzwpuq branch from 6792815 to 01d5bbf Compare September 3, 2025 05:26
yuja added 2 commits September 3, 2025 20:00
This test would fail if we removed comparison of materialized contents from
conflicts::update_from_content().
I'm going to add content hash field to remove re-materialization of conflicts
from update_from_content(). This patch also removes Copy because content hash
will be stored as Vec<u8>.
@yuja yuja force-pushed the push-smwzwnwzwpuq branch from 01d5bbf to df43517 Compare September 3, 2025 11:06
yuja added 2 commits September 3, 2025 20:18
This will help detect unchanged conflict files.
…licts

It seemed odd that we had to pass ConflictMarkerStyle to snapshot functions.
Since we just need to check if the on-disk data has changed, we can instead
store and compare content hashes. Conflict files checked out by old jj might be
updated on mtime change, which seems okay. It's less likely to leave conflict
files in the working copy for long and touch them.

updated_from_content() is called by merge tools, and unchanged conflicts may be
updated there. I think that's okay since "jj resolve" is an explicit operation.

test_materialize_parse_roundtrip_different_markers() is simplified as there
should no longer be "pair" of marker styles.
@yuja yuja force-pushed the push-smwzwnwzwpuq branch from df43517 to 0938a26 Compare September 3, 2025 11:19
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, it seems like we should make update_from_content() better at preserving the original merge. If the user modified only the conflict hunk, then it seems like we should not update the other parts of the merge. This is also related to #4152.

Comment on lines +42 to +46
* `jj` now records content hash of materialized conflict files in addition to
file modification time, and relies on them to detect changes. Unchanged
conflicts checked out by old `jj` may be snapshotted by new `jj`. Run `jj new
<REVISION-WITHOUT-CONFLICTS> && jj undo` to check out fresh conflict files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file's timestamp has already been updated, will jj new <REVISION-WITHOUT-CONFLICTS> && jj undo still be able to restore it to an unmodified state? Since the jj new there does snapshotting, I would think it would not help. So do you actually need jj new <REVISION-WITHOUT-CONFLICTS> && <upgrade jj> && jj undo? IIUC, the confusing thing is that we might snapshot some file and make it look modified but with an empty diff (just a ... line). jj restore <path> can be used for fixing that, right? Should we suggest that instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants