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

Better handling of add/add conflicts #728

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

novalis
Copy link
Contributor

@novalis novalis commented Sep 7, 2019

Well, I didn't get everything I wanted done, but at least I got this.

It would be nice to do something about them, but at least we can
test that we're not totally doomed.
const our = conflict.our.id;
const their = conflict.their.id;
errorMessage += `
To choose your version of the ${name}, use the following magic:
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this the only/recommended way to resolve add-add conflict? Should we trust our user to resolve the conflict manually? I am afraid people may blinded run them and override upstream changes.

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 third way is more complicated: we could see if the two sets share a merge-base and if so rebase inside the submodule. That's a TODO -- it's one reason why I did the half-open. But I would guess that this same merge-base thing only happens in some small number of cases; mostly add/adds are e.g. different people importing the same ext codebase.

People might do something stupid, and if so it'll show up in code review. So hopefully someone will notice.

@@ -281,3 +281,7 @@ exports.makeBareCopy = co.wrap(function *(repo, path) {
yield NodeGit.Remote.delete(bare, "origin");
return bare;
});

exports.quotemeta = function(str) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you explain briefly why we suddenly need this helper now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we're now doing regex matching.

yield fetcher.fetchSha(subRepo, name, stage.id);
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a useful and orthogonal piece of code, could we make it a util function, something like "fetch sha for half opend subrepo if needed"

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 question is: what sha? Here, we loop over the stages, which is what's needed in this case. But is that really generally useful?

@novalis novalis force-pushed the more-rebase branch 2 times, most recently from 01ecd75 to 98d4a54 Compare September 12, 2019 00:34
@novalis
Copy link
Contributor Author

novalis commented Sep 12, 2019

(just removed a few console.logs)

try {
// We just want to see if it's configured
const url = yield fetcher.getSubmoduleUrl(name);
configured = url !== null;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's nothing in the contract of getSubmoduleUrl that says it might return a null; what's the check for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it definitely happens in the tests...

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see how it could return a null after a (quick) look at the implementation, but if it can the contract should be updated to explain when; as it is the contract is to throw a UserError on failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if this.d_urls[name] actually contains null, that would happen. I think this may only happen in tests. I could change the code to instead detect that case and throw UserError (then catch it here instead of checking for null) -- what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd want to understand how this.d_urls comes to have null values first, and what it means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, wait a second -- I think I just checked the wrong thing. In fact it's not null. I could just set configured to true here.

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.

3 participants