Sheriffing/How To/Merge Conflicts: Difference between revisions
Jump to navigation
Jump to search
(First final version of example) |
No edit summary |
||
| Line 42: | Line 42: | ||
<code>hg commit</code></li> | <code>hg commit</code></li> | ||
<li>Push the backout and the merge to central:<br> | <li>Push the backout and the merge to central:<br> | ||
<code>hg push tip central</code></li> | <code>hg push -r tip central</code></li> | ||
<li>Update the bug about the backout.</li> | <li>Update the bug about the backout.</li> | ||
<li>Merge back from central as usual.</li> | <li>Merge back from central as usual.</li> | ||
Revision as of 22:20, 30 November 2017
During merges, sheriffs might run into merge conflicts if code in the same line or near each other has changed in the same file both on the repository to which the merge is done and from which the changesets got pulled.
Resolving merge conflicts without the domain knowledge of the original patch author is prone to error. Sheriffs should not to resolve merge conflicts except for trivial cases or they possess the required domain knowledge. In almost all cases, it is safer to simply backout the changeset causing the merge conflict.
Example
- mozilla-central was on revision c2fe4b3b1b93
- Then autoland got "merged" up to revision 597025d8888f to central. Technically it got updated because there were no changes on central since the last merge, so autoland already contained all the changes from central.
- The attempted merge of the revisions up to a84fff04d938 from inbound to central failed:
~/mozilla/mozilla-unified$ hg merge -r a84fff04d938 merging dom/base/nsRange.cpp merging mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java merging mobile/android/base/java/org/mozilla/gecko/webapps/WebAppActivity.java merging mobile/android/base/moz.build merging taskcluster/scripts/misc/build-sccache.sh merging toolkit/library/gtest/rust/Cargo.lock merging toolkit/library/rust/Cargo.lock merging widget/android/GeneratedJNINatives.h merging widget/android/GeneratedJNIWrappers.cpp merging widget/android/GeneratedJNIWrappers.h warning: conflicts while merging mobile/android/base/moz.build! (edit, then use 'hg resolve --mark') warning: conflicts while merging widget/android/GeneratedJNINatives.h! (edit, then use 'hg resolve --mark') warning: conflicts while merging widget/android/GeneratedJNIWrappers.cpp! (edit, then use 'hg resolve --mark') warning: conflicts while merging widget/android/GeneratedJNIWrappers.h! (edit, then use 'hg resolve --mark') 282 files updated, 6 files merged, 0 files removed, 4 files unresolved use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
These files with the conflicts got changed on both inbound and central (which got the change from the previous merge from autoland. - Let's abandon the merge and back out the conflicting changes to these files from the integration repository (inbound!). Update the working repository to the inbound revision which shall be merged:
hg update -C a84fff04d938 - Now the bugs with the changesets which cause the merge conflicts have to be identified. On hg.mozilla.org, open the repository to which shall be merged (in this case: mozilla-central).
- Click on 'Files' in the header and navigate to the folder which contains the file with the merge conflict. This is mobile/android/base/ in this case.
- Click on the revisions link next to the file name, in this case moz.build.
- Now you can see the recent changes to the file. The latest changes got
pushed 2017-11-07 10:28 +0000and are from bug 1413698. The bug contains information what changesets belong to that push. You only need that information if you want to fix the merge conflict by manually merging the code. - Do the same thing for mozilla-inbound, this time it's mandatory. Copying the url of the tab with the revision history, opening a new tab and pasting the url while replacing "/mozilla-central/" with "/integration/mozilla-inbound/" and the revision (here "597025d8888fa91b9418231f33e65424d384d83f") with "tip" is often a useful shortcut (but will even show changes which landed after the merge candidate you picked; if you don't want that, use the revision of the merge candidate). This got this changelog.
- There is one recent change
pushed 2017-11-07 01:43 +0000from bug 1413362. - Find the changesets which got pushed for that bug in comment 38.
- Do a backout for these changesets:
hg oops -esr 653c66220a5f::8b15dfaeecaa - The working directory is now in a state which allows merging with central. Run:
hg merge central - Then:
hg commit - Push the backout and the merge to central:
hg push -r tip central - Update the bug about the backout.
- Merge back from central as usual.
- Get rid of the files left over from the merge conflicts with the original state of the files. They are in the same folder like the files for which the merge failed, but got an additional
.origfile extension. To achieve this, run:
hg purge
If you the Mercurial purge extension hasn't been enabled yet, open the.hgrcfile in your home directory and add the following line below[extensions]:
purge =