Patchwork [07,of,13] mergestate: rename a helpless variable name to bit helpful one

login
register
mail settings
Submitter Pulkit Goyal
Date July 17, 2020, 8:59 a.m.
Message ID <7265d8b575ff4f3adfc3.1594976368@workspace>
Download mbox | patch
Permalink /patch/46782/
State Accepted
Headers show

Comments

Pulkit Goyal - July 17, 2020, 8:59 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1594300089 -19800
#      Thu Jul 09 18:38:09 2020 +0530
# Node ID 7265d8b575ff4f3adfc392247f868344eadd43c2
# Parent  8dd9eeb56cd015f1e323fedad6c8d58de2d81bb1
# EXP-Topic mergestate-refactor
mergestate: rename a helpless variable name to bit helpful one

The old variable name `r` makes it ~impossible to understand what does it mean.
One can only understand that after going to callers and hoping that its
documented there.

I also documented return value of the function involved while I was there.

Differential Revision: https://phab.mercurial-scm.org/D8738

Patch

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -619,7 +619,10 @@  class mergestate(object):
         return self._stateextras.setdefault(filename, {})
 
     def _resolve(self, preresolve, dfile, wctx):
-        """rerun merge process for file path `dfile`"""
+        """rerun merge process for file path `dfile`.
+        Returns whether the merge was completed and the return value of merge
+        obtained from filemerge._filemerge().
+        """
         if self[dfile] in (MERGE_RECORD_RESOLVED, MERGE_RECORD_DRIVER_RESOLVED):
             return True, 0
         if self._state[dfile][0] == MERGE_RECORD_MERGED_OTHER:
@@ -660,7 +663,7 @@  class mergestate(object):
                 f.close()
             else:
                 wctx[dfile].remove(ignoremissing=True)
-            complete, r, deleted = filemerge.premerge(
+            complete, merge_ret, deleted = filemerge.premerge(
                 self._repo,
                 wctx,
                 self._local,
@@ -671,7 +674,7 @@  class mergestate(object):
                 labels=self._labels,
             )
         else:
-            complete, r, deleted = filemerge.filemerge(
+            complete, merge_ret, deleted = filemerge.filemerge(
                 self._repo,
                 wctx,
                 self._local,
@@ -681,12 +684,12 @@  class mergestate(object):
                 fca,
                 labels=self._labels,
             )
-        if r is None:
-            # no real conflict
+        if merge_ret is None:
+            # If return value of merge is None, then there are no real conflict
             del self._state[dfile]
             self._stateextras.pop(dfile, None)
             self._dirty = True
-        elif not r:
+        elif not merge_ret:
             self.mark(dfile, MERGE_RECORD_RESOLVED)
 
         if complete:
@@ -708,9 +711,9 @@  class mergestate(object):
                     else:
                         action = ACTION_ADD
                 # else: regular merges (no action necessary)
-            self._results[dfile] = r, action
+            self._results[dfile] = merge_ret, action
 
-        return complete, r
+        return complete, merge_ret
 
     def preresolve(self, dfile, wctx):
         """run premerge process for dfile