Commit 5495fff7 authored by Pulkit Goyal's avatar Pulkit Goyal
Browse files

mergestate: use _stateextras instead of merge records for commit related info

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.

Differential Revision: https://phab.mercurial-scm.org/D8920
parent ede4c121239e
......@@ -5969,8 +5969,6 @@ def resolve(ui, repo, *pats, **opts):
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 @@ def resolve(ui, repo, *pats, **opts):
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:
......
......@@ -325,10 +325,7 @@ def _filecommit(
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-source') == b'other':
fparent1, fparent2 = fparent2, nullid
# is the file changed?
......
......@@ -81,6 +81,8 @@ MERGE_RECORD_RESOLVED_PATH = b'pr'
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 @@ class mergestate(object):
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-source'] = 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 @@ class mergestate(object):
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 @@ class mergestate(object):
self._dirty = True
def addmergedother(self, path):
self._state[path] = [MERGE_RECORD_MERGED_OTHER, nullhex, nullhex]
self._stateextras[path] = {b'filenode-source': b'other'}
self._dirty = True
def __contains__(self, dfile):
......@@ -636,8 +642,6 @@ class mergestate(object):
"""
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]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment