Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating new wc commit when @ becomes immutable #3600

Merged
merged 1 commit into from
May 14, 2024
Merged

creating new wc commit when @ becomes immutable #3600

merged 1 commit into from
May 14, 2024

Conversation

tdaron
Copy link
Contributor

@tdaron tdaron commented Apr 30, 2024

Hi !
I am currently trying to write a fix for #3201

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have added tests to cover my changes

@tdaron
Copy link
Contributor Author

tdaron commented Apr 30, 2024

I currently have this implementation but it starts an infinite loop creating commits again and again on top of the @ immutable, cause when i call tx.finish() to end-up my new wc commit creation, the maybe_new_wc_commit still points to @ and not on my newly created commit (which should have become @ but doesn't)

am i doing a huge blunder ?

cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
@tdaron
Copy link
Contributor Author

tdaron commented May 8, 2024

Is it any good ?

I tried to avoid copy-pasting check_rewritable so i tried organizing stuff in a clear way.

@tdaron tdaron changed the title WIP: creating new wc commit when @ becomes immuable WIP: creating new wc commit when @ becomes immutable May 8, 2024
@tdaron tdaron requested a review from martinvonz May 10, 2024 05:11
@martinvonz
Copy link
Member

This is still marked as a draft. Did you just forget to mark it ready?

@tdaron
Copy link
Contributor Author

tdaron commented May 10, 2024

Nope I didn't add any tests yet, but I wanted a feedback on my implementation to avoid writing any additional code that I should delete anyway

Sry if I shouldn't ask review for that I don't really know how things works, I am new to contributing haha

@martinvonz
Copy link
Member

Nope I didn't add any tests yet, but I wanted a feedback on my implementation to avoid writing any additional code that I should delete anyway

Sry if I shouldn't ask review for that I don't really know how things works, I am new to contributing haha

Ah, that makes sense. I think people typically mark it ready for review and leave a comment saying that they haven't added tests yet. I generally ignore PRs in draft state. I don't know if others do the same.

@martinvonz martinvonz marked this pull request as ready for review May 12, 2024 17:30
@martinvonz
Copy link
Member

Nope I didn't add any tests yet, but I wanted a feedback on my implementation to avoid writing any additional code that I should delete anyway

Actually, the tests would be end-to-end tests of the CLI, I think, so they should not have to depend on how exactly it's implemented. https://github.com/martinvonz/jj/blob/main/cli/tests/test_immutable_commits.rs is probably a good place to add them.

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.

Thanks for working on this! Sorry it took me a while to get to it.

cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
@tdaron
Copy link
Contributor Author

tdaron commented May 12, 2024

No problem haha, thank you to take time to review my PR :)

@tdaron tdaron changed the title WIP: creating new wc commit when @ becomes immutable creating new wc commit when @ becomes immutable May 12, 2024
@tdaron
Copy link
Contributor Author

tdaron commented May 12, 2024

I added a test, and i am now checking all workspaces to update them.

I also inlined what i could, but i didn't moved my check to maybe_snapshot because I didn't know what i had to look at as the transaction has not even been created at this point. But I might just misunderstood this part of the code.

Shall i add a test to check if it updates well every workspace ?

@tdaron tdaron requested a review from martinvonz May 12, 2024 21:07
cli/tests/test_immutable_commits.rs Show resolved Hide resolved
cli/tests/test_immutable_commits.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
@tdaron
Copy link
Contributor Author

tdaron commented May 13, 2024

I added more tests, i had two issues doing it:

  • tx.mut_repo().view().wc_commit_ids() item's order is not deterministic, so i had to sort them to be able to test the output. (otherwise the order of the warnings could change)
  • This one is a question, but am i supposed to create a different new wc commit per workspace (this is how it works now) or create one and check out all affected workspaces on the same newly created commit ?

@martinvonz
Copy link
Member

I added more tests, i had two issues doing it:

  • tx.mut_repo().view().wc_commit_ids() item's order is not deterministic, so i had to sort them to be able to test the output. (otherwise the order of the warnings could change)

Makes sense.

  • This one is a question, but am i supposed to create a different new wc commit per workspace (this is how it works now) or create one and check out all affected workspaces on the same newly created commit ?

It's rare that multiple workspaces point to the same commit, so I don't think we need to worry about that. I.e., what you have right now is good enough IMO.

@tdaron
Copy link
Contributor Author

tdaron commented May 13, 2024

In that case i think we have an usable version of the PR :)

Is there anything more i can do about it ?

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.

Looks good. Thanks!

cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
cli/src/cli_util.rs Outdated Show resolved Hide resolved
@tdaron tdaron linked an issue May 14, 2024 that may be closed by this pull request
@tdaron tdaron merged commit 823041c into jj-vcs:main May 14, 2024
16 checks passed
tdaron added a commit that referenced this pull request May 14, 2024
tdaron added a commit that referenced this pull request May 14, 2024
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.

If @ turns immutable, it can still be mutated
4 participants