-
Notifications
You must be signed in to change notification settings - Fork 349
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
resolve: try to resolve all conflicted files in fileset #5111
base: main
Are you sure you want to change the base?
Conversation
I recently learned that some commands support filesets. Is |
We actually already support filsets in this command. It's just that the command would always stop after the first conflict before this PR (so even |
Yes, it already does support filesets, and the default is Edit: nevermind, looks like @martinvonz already responded! |
Is this because existing merge editor work on a single file at a time, so we have no choice but to resolve conflicts individually? (Is there a warning in the case that subsequent conflicts are ignored?) For uniformity, should we have an
|
If we want the default behavior of picking a single file to be expressable with filesets, then we'd probably want a TBH, I'm not sure I've ever actually wanted the default behavior of only resolving a single, seemingly-random file though. Usually, I want to resolve every conflict, or I want to resolve a conflict in a specific file I specify. So maybe we could just change |
29cfe83
to
11fc840
Compare
Makes sense to me, although implementing that is its whole own matter.
In both your workflow and my workflow, it sounds like resolving a single arbitrary file is probably not desirable:
|
I think in practice, this shouldn't be an issue because we treat an unmodified or blank output file as an error, so it would stop launching more editors if someone closes the editor without making any changes. That being said, it does feel a bit strange to launch the editor multiple times without the user requesting it explicitly, so it might be nice to not launch multiple editors by default anyway. At some point, I'm thinking that we probably will want to support merge tools which can merge whole directories at once instead of being invoked with each file individually. |
I'm also for that. |
Oh, @ilyagr might also have thoughts. He wrote most of the current implementation. |
11fc840
to
69c8240
Compare
--all
optiondbbe3df
to
ecf54fa
Compare
cli/src/merge_tools/external.rs
Outdated
"Stopping due to error after resolving {i} conflicts" | ||
)?; | ||
print_error_sources(ui, Some(&err))?; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should still return the error here to make it more predictable for scripts? Otherwise the exit code is a bit hard to interpret. Alternatively, we could make it not an error even after no conflicts were resolved. What do you think? It might be unlikely that scripts call jj resolve
(without --list
), so maybe I'm worrying about nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was considering that as well. I mainly chose to make it a warning instead of an error because I didn't want any previous successful resolutions to be discarded (so returning an error immediately isn't an option), and I thought it looked strange having the error message be at the end of the command after the transaction commits successfully instead of being before the transaction commits. Maybe I could make it so that it prints the error immediately, but doesn't actually exit with the error code until after the transaction commits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I could make it so that it prints the error immediately, but doesn't actually exit with the error code until after the transaction commits?
SGTM, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm it ended up being more difficult to print the error immediately than I thought. It seems necessary to return a CommandError
from the command, because calling std::process::exit
would skip finalizing the pager, but all the current CommandError
variants print a message at the end of the command. I'm not sure that printing the error immediately would be worth the complexity, so I currently changed it to just return the error like normal, but just wait until after committing the transaction.
I think it might be clear enough that some conflicts were successfully resolved, since I added an error message saying Stopped due to error after resolving <count> conflicts
. What do you think?
cli/src/merge_tools/mod.rs
Outdated
pub fn edit_file( | ||
&self, | ||
ui: &Ui, | ||
path_converter: &RepoPathUiConverter, | ||
tree: &MergedTree, | ||
repo_path: &RepoPath, | ||
repo_paths: &[&RepoPath], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment. Perhaps, this will be edit(ui, tree, matcher)
at some point, but more refactoring will be needed.
0b8147c
to
fdb52c6
Compare
I'm going to change the merge tools to accept multiple files, and this will make it easier to pass all the required data about each file.
If many files are conflicted, it would be nice to be able to resolve all conflicts at once without having to run `jj resolve` multiple times. This is especially nice for merge tools which try to automatically resolve conflicts without user input, but it is also good for regular merge editors like VS Code. This change makes the behavior of `jj resolve` more consistent with other commands which accept filesets since it will use the entire fileset instead of picking an arbitrary file from the fileset. Since we don't support passing directories to merge tools yet, the current implementation just calls the merge tool repeatedly in a loop until every file is resolved, or until an error occurs. If an error occurs after successfully resolving at least one file, it is downgraded to a warning instead. This means the user can just close the editor at any point to cancel resolution on all remaining files.
fdb52c6
to
7c4f747
Compare
If many files are conflicted, it would be nice to be able to resolve all conflicts at once without having to run
jj resolve
multiple times. This is especially nice for merge tools which try to automatically resolve conflicts without user input, but it can also be used for regular merge editors like VS Code.Checklist
If applicable:
CHANGELOG.md