Sheriffing/How To/Merge Conflicts: Difference between revisions
Jump to navigation
Jump to search
ChrisCooper (talk | contribs) m (ChrisCooper moved page Sheriffing/How:To:Merge Conflicts to Sheriffing/How To/Merge Conflicts: More intuitive naming scheme) |
(explain how to resolve merge conflicts, work in progress (save to not lose progress by accident)) |
||
| Line 1: | Line 1: | ||
{{Sheriffing How To|Merge conflicts}} | {{Sheriffing How To|Merge conflicts}} | ||
During [[Sheriffing/How:To:Merges|merges]], sheriffs might run into merge conflicts. | During [[Sheriffing/How:To:Merges|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 [[Sheriffing/How:To:Backouts|backout]] the changeset causing the merge conflict. | 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 [[Sheriffing/How:To:Backouts|backout]] the changeset causing the merge conflict. | ||
== Example == | |||
<ol> | |||
<li>mozilla-central was on revision [https://hg.mozilla.org/mozilla-central/rev/c2fe4b3b1b930b3e7fdb84eae44cec165394f322 c2fe4b3b1b93]</li> | |||
<li>Then autoland got "merged" up to revision [https://hg.mozilla.org/integration/autoland/rev/597025d8888fa91b9418231f33e65424d384d83f 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.</li> | |||
<li>The attempted merge of the revisions up to [https://hg.mozilla.org/integration/mozilla-inbound/rev/a84fff04d9384160bec16b22dbb7063c62149b2e a84fff04d938] from inbound to central failed:<br> | |||
<pre>~/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</pre> | |||
These files with the conflicts got changed on both inbound and central (which got the change from the previous merge from autoland.</li> | |||
<li>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: <code>hg update -C a84fff04d938</code></li> | |||
<li>Now the bug with the changesets which cause the merge conflicts have to be identified. On [https://hg.mozilla.org hg.mozilla.org], open the repository to which shall be merged (in this case: mozilla-central).</li> | |||
<li>Click on 'Files' in the header and navigate to the folder which contains the file with the merge conflict. This is [https://hg.mozilla.org/mozilla-central/file/597025d8888fa91b9418231f33e65424d384d83f/mobile/android/base mobile/android/base/] in this case.</li> | |||
<li>Click on the [https://hg.mozilla.org/mozilla-central/log/597025d8888fa91b9418231f33e65424d384d83f/mobile/android/base/moz.build revisions] name next to the file name, in this case moz.build.</li> | |||
<li>Now you can see the recent changes to the file. The latest changes got <code>pushed 2017-11-07 10:28 +0000</code> and are from [https://bugzilla.mozilla.org/show_bug.cgi?id=1413698 bug 1413698]. | |||
Revision as of 18:18, 7 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 bug 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 name 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.