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

cli: hint for conflicted branches and change ids #2244

Merged
merged 3 commits into from
Sep 22, 2023
Merged

Conversation

wmrmrx
Copy link
Collaborator

@wmrmrx wmrmrx commented Sep 10, 2023

Resolves issue #2192

The output of the changed hint is:

$ jj checkout letters
Error: Revset "letters" resolved to more than one revision
Hint: The revset "letters" resolved to these revisions:
rmyxvrmv f54150b7 letters?? | (conflict) E ammended
pysvtnpy f9e2e044 letters?? | (conflict) E
This error is due to a conflicted branch. To resolve this, try setting to which revision the branch points to with "jj branch set letters --revision <REVISION>"

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 tests to cover my changes

@google-cla
Copy link

google-cla bot commented Sep 10, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@wmrmrx
Copy link
Collaborator Author

wmrmrx commented Sep 10, 2023

Hi! I've done the above but I'm still not too sure about when jj abandon is applicable
(I just signed the CLA too)

@PhilipMetzger
Copy link
Collaborator

Thanks for your contribution, the CLA will be valid after the next push.
At the moment your change is still missing a test to verify the new behavior.

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
@wmrmrx wmrmrx marked this pull request as draft September 10, 2023 22:58
@wmrmrx wmrmrx force-pushed the issue-2192 branch 6 times, most recently from 3bfeb7f to 310e72a Compare September 10, 2023 23:50
@wmrmrx wmrmrx marked this pull request as ready for review September 10, 2023 23:51
@wmrmrx
Copy link
Collaborator Author

wmrmrx commented Sep 10, 2023

I tried to address the comments and also added another separate hint for when there's commits with the same change id. Not too sure about tests yet since I don't know how to easily reproduce these situations.

Also thanks for the review!

@ilyagr
Copy link
Collaborator

ilyagr commented Sep 11, 2023

Re PR description: it might be more accurate to say that this resolves a portion of #2192. There are also the other kinds of conflicts.

Update: I missed where you said that you added something about change ids. You should split that into a separate commit.

@ilyagr
Copy link
Collaborator

ilyagr commented Sep 11, 2023

For the tests, you could base a test on one of the fetch tests:

https://github.com/martinvonz/jj/blob/8bfb6c10fd8781b8a8729719fe0826637b22c86d/cli/tests/test_git_fetch.rs#L295

Alternatively, you can also try adding a test there that does the equivalent of:

let pre_creation_id = test_env.current_operation_id(&repo_path);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "a", "-r=one_commit"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "a", "-r=another_commit",
                                      "--at-op", pre_creation_id]);

This could go into https://github.com/martinvonz/jj/blob/main/cli/tests/test_branch_command.rs. There aren't many tests with conflicted branches there at the moment, but they might be nice to have.

By the way, the tests should go either into the same commit where you make the change or in a commit before that, so that the commit where you make the change also changes the test.

@wmrmrx wmrmrx marked this pull request as draft September 11, 2023 01:45
@wmrmrx wmrmrx force-pushed the issue-2192 branch 3 times, most recently from 7b02752 to 41b9190 Compare September 20, 2023 03:02
@wmrmrx wmrmrx changed the title cli: hint for conflicted branches cli: hint for conflicted branches and change ids Sep 20, 2023
@wmrmrx wmrmrx marked this pull request as ready for review September 21, 2023 02:43
@wmrmrx
Copy link
Collaborator Author

wmrmrx commented Sep 21, 2023

Hi! I've added the tests in test_checkout.rs!

(The snippet didn't create a branch conflict for me when testing locally)

let pre_creation_id = test_env.current_operation_id(&repo_path);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "a", "-r=one_commit"]);
test_env.jj_cmd_success(&repo_path, &["branch", "create", "a", "-r=another_commit",
                                      "--at-op", pre_creation_id]);

@wmrmrx wmrmrx marked this pull request as draft September 21, 2023 17:10
@wmrmrx wmrmrx force-pushed the issue-2192 branch 2 times, most recently from b7aa67c to eb27a38 Compare September 21, 2023 21:59
@wmrmrx wmrmrx marked this pull request as ready for review September 21, 2023 21:59
@wmrmrx wmrmrx marked this pull request as draft September 21, 2023 22:02
@wmrmrx wmrmrx marked this pull request as ready for review September 21, 2023 22:03
@wmrmrx
Copy link
Collaborator Author

wmrmrx commented Sep 21, 2023

Hi, I believe I addressed all the requested changes! (Not sure if this is sufficient for the issue)

@martinvonz
Copy link
Member

Hi, I believe I addressed all the requested changes! (Not sure if this is sufficient for the issue)

Thanks! I had started another round of reviewing and then got distracted. I'll finish that now

cli/tests/test_checkout.rs Outdated Show resolved Hide resolved
cli/tests/test_checkout.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 Show resolved Hide resolved
cli/tests/test_checkout.rs Outdated Show resolved Hide resolved
cli/tests/test_checkout.rs Show resolved Hide resolved
@wmrmrx wmrmrx marked this pull request as draft September 21, 2023 23:45
@wmrmrx wmrmrx marked this pull request as ready for review September 22, 2023 00:46
@wmrmrx
Copy link
Collaborator Author

wmrmrx commented Sep 22, 2023

Hi, I just made the changes. Thanks for the feedback on the tests, it ended up being way simpler!

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.

Nice! Extracting that commits_summary variable was a bigger improvement that I had expected.

cli/src/cli_util.rs Outdated Show resolved Hide resolved
@wmrmrx wmrmrx force-pushed the issue-2192 branch 2 times, most recently from e217e15 to b2ccc89 Compare September 22, 2023 01:23
@wmrmrx wmrmrx merged commit 4894636 into jj-vcs:main Sep 22, 2023
15 checks passed
@wmrmrx wmrmrx deleted the issue-2192 branch September 22, 2023 01:53
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.

4 participants