[Request] [+- ] D8920: mergestate: use _stateextras instead of merge records for commit related info

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Mon Aug 10 11:18:57 UTC 2020


pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  There is a set of information related to a merge which is needed on commit. We
  want to store such information in the mergestate so that we can read it while
  committing.
  
  For this purpose, we are using merge records and introduced a merge
  entry state for that. However this won't scale and is not clean way to implement
  this.
  
  This patch reworks the existing logic related to this to use _stateextras and
  read from it.
  
  Right now the information stored is not very descriptive but it will be in next
  patch.
  
  Using _stateextras also makes MERGE_RECORD_MERGED_OTHER useless and only to be
  kept for BC.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8920

AFFECTED FILES
  mercurial/commands.py
  mercurial/commit.py
  mercurial/mergestate.py

CHANGE DETAILS

diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -81,6 +81,8 @@
 MERGE_RECORD_DRIVER_RESOLVED = b'd'
 # represents that the file was automatically merged in favor
 # of other version. This info is used on commit.
+# This is now deprecated and commit related information is now
+# stored in RECORD_FILE_VALUES
 MERGE_RECORD_MERGED_OTHER = b'o'
 
 #####
@@ -257,7 +259,13 @@
                 LEGACY_RECORD_RESOLVED_OTHER,
             ):
                 bits = record.split(b'\0')
-                self._state[bits[0]] = bits[1:]
+                # merge entry type MERGE_RECORD_MERGED_OTHER is deprecated
+                # and we now store related information in _stateextras, so
+                # lets write to _stateextras directly
+                if bits[1] == MERGE_RECORD_MERGED_OTHER:
+                    self._stateextras[bits[0]][b'filenode'] = b'other'
+                else:
+                    self._state[bits[0]] = bits[1:]
             elif rtype == RECORD_FILE_VALUES:
                 filename, rawextras = record.split(b'\0', 1)
                 extraparts = rawextras.split(b'\0')
@@ -486,8 +494,6 @@
                 records.append(
                     (RECORD_PATH_CONFLICT, b'\0'.join([filename] + v))
                 )
-            elif v[0] == MERGE_RECORD_MERGED_OTHER:
-                records.append((RECORD_MERGED, b'\0'.join([filename] + v)))
             elif v[1] == nullhex or v[6] == nullhex:
                 # Change/Delete or Delete/Change conflicts. These are stored in
                 # 'C' records. v[1] is the local file, and is nullhex when the
@@ -587,7 +593,7 @@
         self._dirty = True
 
     def addmergedother(self, path):
-        self._state[path] = [MERGE_RECORD_MERGED_OTHER, nullhex, nullhex]
+        self._stateextras[path] = {b'filenode': b'other'}
         self._dirty = True
 
     def __contains__(self, dfile):
@@ -636,8 +642,6 @@
         """
         if self[dfile] in (MERGE_RECORD_RESOLVED, MERGE_RECORD_DRIVER_RESOLVED):
             return True, 0
-        if self._state[dfile][0] == MERGE_RECORD_MERGED_OTHER:
-            return True, 0
         stateentry = self._state[dfile]
         state, localkey, lfile, afile, anode, ofile, onode, flags = stateentry
         octx = self._repo[self._other]
diff --git a/mercurial/commit.py b/mercurial/commit.py
--- a/mercurial/commit.py
+++ b/mercurial/commit.py
@@ -325,10 +325,7 @@
         elif not fparentancestors:
             # TODO: this whole if-else might be simplified much more
             ms = mergestate.mergestate.read(repo)
-            if (
-                fname in ms
-                and ms[fname] == mergestate.MERGE_RECORD_MERGED_OTHER
-            ):
+            if ms.extras(fname).get(b'filenode') == b'other':
                 fparent1, fparent2 = fparent2, nullid
 
     # is the file changed?
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5969,8 +5969,6 @@
             if not m(f):
                 continue
 
-            if ms[f] == mergestatemod.MERGE_RECORD_MERGED_OTHER:
-                continue
             label, key = mergestateinfo[ms[f]]
             fm.startitem()
             fm.context(ctx=wctx)
@@ -6018,9 +6016,6 @@
 
             didwork = True
 
-            if ms[f] == mergestatemod.MERGE_RECORD_MERGED_OTHER:
-                continue
-
             # don't let driver-resolved files be marked, and run the conclude
             # step if asked to resolve
             if ms[f] == mergestatemod.MERGE_RECORD_DRIVER_RESOLVED:



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200810/3e2d5729/attachment-0001.html>


More information about the Mercurial-patches mailing list