Sheriffing/How To/Merge Conflicts: Difference between revisions

Jump to navigation Jump to search
added: Example: code added and modified, conflict fixed
No edit summary
(added: Example: code added and modified, conflict fixed)
Line 49: Line 49:
If you the Mercurial purge extension hasn't been enabled yet, open the <code>.hgrc</code> file in your home directory and add the following line below <code>[extensions]</code>:<br>
If you the Mercurial purge extension hasn't been enabled yet, open the <code>.hgrc</code> file in your home directory and add the following line below <code>[extensions]</code>:<br>
<code>purge =</code></li>
<code>purge =</code></li>
</ol>
== Example: code added and modified, conflict fixed ==
<ol>
<li>mozilla-inbound revision [https://hg.mozilla.org/integration/mozilla-inbound/rev/f60ce40b73c519a0d3b0b2a490de9b2475f84ed7 f60ce40b73c519a0d3b0b2a490de9b2475f84ed7] should be merge to mozilla-central revision [https://hg.mozilla.org/mozilla-central/rev/46a5fc19bd7aed9fc92946215ee7f83eea279f8d 46a5fc19bd7aed9fc92946215ee7f83eea279f8d].</li>
<li>This failed:
<pre>~/mozilla/mozilla-unified$ hg merge -r f60ce40b73c519a0d3b0b2a490de9b2475f84ed7
merging devtools/client/preferences/devtools.js
merging devtools/client/shared/components/splitter/SplitBox.js
merging dom/html/HTMLMediaElement.cpp
merging dom/media/tests/mochitest/head.js
merging dom/media/tests/mochitest/mochitest.ini
warning: conflicts while merging devtools/client/shared/components/splitter/SplitBox.js! (edit, then use 'hg resolve --mark')
289 files updated, 4 files merged, 4 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon</pre></li>
<li>Changelogs for those revisions: [https://hg.mozilla.org/mozilla-central/filelog/46a5fc19bd7aed9fc92946215ee7f83eea279f8d/devtools/client/shared/components/splitter/SplitBox.js mozilla-central], [https://hg.mozilla.org/integration/mozilla-inbound/filelog/f60ce40b73c519a0d3b0b2a490de9b2475f84ed7/devtools/client/shared/components/splitter/SplitBox.js mozilla-inbound]</li>
<li>There is only one recent changeset for that file on each tree, the other ones are much older: [https://hg.mozilla.org/mozilla-central/rev/b401fc737a4f mozilla-central], [https://hg.mozilla.org/integration/mozilla-inbound/rev/8b549261f40d mozilla-inbound]</li>
<li>The merge conflict in the file is shown like this:
<pre>  onMove(x, y) {
    const node = ReactDOM.findDOMNode(this);
    let size;
    let { endPanelControl, vert } = this.state;
<<<<<<< working copy
    if (this.state.vert) {
      // Use the document owning the SplitBox to detect rtl. The global document might be
      // the one bound to the toolbox shared BrowserRequire, which is irrelevant here.
      const doc = node.ownerDocument;
=======
    if (vert) {
>>>>>>> merge rev
      // Switch the control flag in case of RTL. Note that RTL
      // has impact on vertical splitter only.
      if (doc.dir === "rtl") {
        endPanelControl = !endPanelControl;
      }</pre></li>
<li>The changes on mozilla-central are these:
<pre>  onMove(x, y) {
    const node = ReactDOM.findDOMNode(this);
    let size;
    let { endPanelControl } = this.props;
    if (this.state.vert) {
+      // Use the document owning the SplitBox to detect rtl. The global document might be
+      // the one bound to the toolbox shared BrowserRequire, which is irrelevant here.
+      const doc = node.ownerDocument;
+
      // Switch the control flag in case of RTL. Note that RTL
      // has impact on vertical splitter only.
-      if (document.dir === "rtl") {
+      if (doc.dir === "rtl") {
        endPanelControl = !endPanelControl;
      }</pre></li>
<li>The changes on mozilla-inbound at the conflicting position are those:
<pre>    * Adjust size of the controlled panel. Depending on the current
    * orientation we either remember the width or height of
    * the splitter box.
    */
  onMove(x, y) {
    const node = ReactDOM.findDOMNode(this);
    let size;
-    let { endPanelControl } = this.props;
+    let { endPanelControl, vert } = this.state;
-    if (this.state.vert) {
+    if (vert) {
      // Switch the control flag in case of RTL. Note that RTL
      // has impact on vertical splitter only.
      if (document.dir === "rtl") {
        endPanelControl = !endPanelControl;
      }
      size = endPanelControl ?
        (node.offsetLeft + node.offsetWidth) - x :</pre></li>
<li>Observations:
<ul>
<li>The mozilla-inbound code changes affect the code before the one changed on mozilla-central.</li>
<li>On mozilla-inbound, lines got only modified, while on mozilla-central also new lines got added. This is the reason for the different number of lines between the conflict markers ("<<<<<<<" and ">>>>>>>") and the separator for the conflicting code ("=======").</li>
<li>The element used in the new code added on mozilla-central <code>node.ownerDocument</code> didn't get modified by the mozilla-inbound patch.</li>
<li>The patches don't share a modified line.</li>
<li>The conflict can be resolved: The new states have to be taken into account. This means, the lines which got added remain and for the line starting with <code>if</code>, the modified line gets used.</li>
</ul></li>
<li>The end result is this:
<pre>    if (vert) {
      // Use the document owning the SplitBox to detect rtl. The global document might be
      // the one bound to the toolbox shared BrowserRequire, which is irrelevant here.
      const doc = node.ownerDocument;
</pre>
With surrounding code:
<pre>  onMove(x, y) {
    const node = ReactDOM.findDOMNode(this);
    let size;
    let { endPanelControl, vert } = this.state;
    if (vert) {
      // Use the document owning the SplitBox to detect rtl. The global document might be
      // the one bound to the toolbox shared BrowserRequire, which is irrelevant here.
      const doc = node.ownerDocument;
      // Switch the control flag in case of RTL. Note that RTL
      // has impact on vertical splitter only.
      if (doc.dir === "rtl") {
        endPanelControl = !endPanelControl;
      }</pre></li>
</ol>
</ol>
Confirmed users
611

edits

Navigation menu