IDEA-92994 Integrate project with mercurial shows local changes as 'Changes from server' in conflict ui. Update fix for IDEA-81214.

*Change merge provider: first parent - local revison, second - server
*When you perform pull, update and merge -  do not update head to new revision (server revision)
* Note: merges in Mercurial are not symmetrical!  If I hg update to 17 and then hg merge with 23, Mercurial records 17 as the first parent of the merge, and 23 as the second. etc...This may produce misunderstatnding.
This commit is contained in:
Nadya.Zabrodina
2013-01-28 16:38:14 +04:00
parent 3b5c4371a0
commit a67bea8ec2
2 changed files with 10 additions and 15 deletions
@@ -62,18 +62,16 @@ public class HgMergeProvider implements MergeProvider {
if (wasFileCheckedIn(repo, file)) {
// 1. We checked in.
// We have a merge in progress, which means we have 2 heads (parents).
// the revision with greater revision number is "their" revision pulled from the parent repo,
// the revision with lesser revision number is the local change. see http://hgbook.red-bean.com/read/a-tour-of-mercurial-merging-work.html
// to retrieve the base version we get the parent of the local change, i.e. the [only] parent of appropriate parent - grandparent.
// the second one is "their" revision pulled from the parent repo,
// first parent is the local change.
// to retrieve the base version we get the parent of the local change, i.e. the [only] parent of the first parent.
//Whick one is local revision depends on which one is merged with,
// i.e if you update to 17 revision and then merge it woth 23, so 17 is your local and 17->parent is your base revision.
// This may produce misunderstanding when you update your project with merging (your update firstly to next revisions and then
// merge with previous). see http://hgbook.red-bean.com/read/managing-releases-and-branchy-development.html
final Pair<HgRevisionNumber, HgRevisionNumber> parents = command.parents(repo, file);
if (parents.first.getRevision().compareTo(parents.second.getRevision()) > 0) {
serverRevisionNumber = parents.first;
localRevisionNumber = parents.second;
}
else {
serverRevisionNumber = parents.second;
localRevisionNumber = parents.first;
}
serverRevisionNumber = parents.second;
localRevisionNumber = parents.first;
final HgContentRevision local = new HgContentRevision(myProject, hgFile, localRevisionNumber);
mergeData.CURRENT = local.getContentAsBytes();
// we are sure that we have a grandparent, because otherwise we'll get "repository is unrelated" error while pulling,
@@ -113,10 +113,7 @@ public class HgRegularUpdater implements HgUpdater {
abortOnMultiplePulledHeads(pulledBranchHeads);
abortOnMultipleLocalHeads(remainingOriginalBranchHeads);
//update to the pulled in head, because we consider that head as the 'authoritative' head
updateToPulledHead(repository, updatedFiles, pulledBranchHeads.get(0), indicator);
HgCommandResult mergeResult = doMerge(updatedFiles, indicator, warnings, remainingOriginalBranchHeads.get(0));
HgCommandResult mergeResult = doMerge(updatedFiles, indicator, warnings, pulledBranchHeads.get(0));
if (shouldCommitAfterMerge()) {
commitOrWarnAboutConflicts(warnings, mergeResult);