Commit 33aebf45 authored by Pulkit Goyal's avatar Pulkit Goyal
Browse files

mergestate: use dirstate.update_file API in recordupdates() [WIP]

Also introduces another function so should be split.
parent fc8ff572816c
Pipeline #24109 failed with stages
in 31 minutes and 30 seconds
......@@ -488,35 +488,44 @@ class dirstate(object):
def update_file(
self,
filename,
p1_tracked=False,
wc_tracked,
p1_tracked,
p2_tracked=False,
wc_tracked=False,
merged=False,
clean_p1=False,
clean_p2=False,
possibly_dirty=False,
):
assert self._parentwriters > 0
# assert self._parentwriters > 0
assert not (merged and (clean_p1 or clean_p1))
if not (p1_tracked or p2_tracked or wc_tracked):
self.drop(filename)
elif merged:
assert self.wc_tracked
self._addpath(filename, merged=True)
assert wc_tracked
self._addpath(filename, merged=True, possibly_dirty=possibly_dirty)
self._map.copymap.pop(filename, None)
elif not (p1_tracked or p2_tracked) and wc_tracked:
self._addpath(filename, added=True)
self._addpath(filename, added=True, possibly_dirty=possibly_dirty)
self._map.copymap.pop(filename, None)
elif (p1_tracked or p2_tracked) and not wc_tracked:
self._remove(filename)
elif clean_p2 and wc_tracked:
assert p2_tracked
self.otherparent(filename)
elif not p1_tracked and p2_tracked and wc_tracked:
self._addpath(filename, from_p2=True)
self._addpath(filename, from_p2=True, possibly_dirty=possibly_dirty)
self._map.copymap.pop(filename, None)
elif possibly_dirty:
self._addpath(filename, possibly_dirty=possibly_dirty)
elif wc_tracked:
self.normal(filename)
# XXX We need something for file that are dirty after an update
else:
assert False, 'unreachable'
def update_parent_file_data(self, f, filedata):
self.normal(f, parentfiledata=filedata)
def _addpath(
self,
f,
......
......@@ -765,34 +765,44 @@ def recordupdates(repo, actions, branchmerge, getfiledata):
# remove (must come first)
for f, args, msg in actions.get(ACTION_REMOVE, []):
if branchmerge:
repo.dirstate.remove(f)
repo.dirstate.update_file(
f, p1_tracked=True, wc_tracked=False
)
else:
repo.dirstate.drop(f)
repo.dirstate.update_file(
f, p1_tracked=False, wc_tracked=False
)
# forget (must come first)
for f, args, msg in actions.get(ACTION_FORGET, []):
repo.dirstate.drop(f)
repo.dirstate.update_file(f, p1_tracked=False, wc_tracked=False)
# resolve path conflicts
for f, args, msg in actions.get(ACTION_PATH_CONFLICT_RESOLVE, []):
(f0, origf0) = args
repo.dirstate.add(f)
repo.dirstate.update_file(f, p1_tracked=False, wc_tracked=True)
repo.dirstate.copy(origf0, f)
if f0 == origf0:
repo.dirstate.remove(f0)
repo.dirstate.update_file(
f0, p1_tracked=True, wc_tracked=False
)
else:
repo.dirstate.drop(f0)
repo.dirstate.update_file(
f0, p1_tracked=False, wc_tracked=False
)
# re-add
for f, args, msg in actions.get(ACTION_ADD, []):
repo.dirstate.add(f)
repo.dirstate.update_file(f, p1_tracked=False, wc_tracked=True)
# re-add/mark as modified
for f, args, msg in actions.get(ACTION_ADD_MODIFIED, []):
if branchmerge:
repo.dirstate.normallookup(f)
else:
repo.dirstate.add(f)
repo.dirstate.update_file(
f, p1_tracked=False, wc_tracked=True
)
# exec change
for f, args, msg in actions.get(ACTION_EXEC, []):
......@@ -813,10 +823,11 @@ def recordupdates(repo, actions, branchmerge, getfiledata):
# get
for f, args, msg in actions.get(ACTION_GET, []):
if branchmerge:
repo.dirstate.otherparent(f)
# tracked in p1 can be True also but update_file should not care
repo.dirstate.update_file(f, p1_tracked=False, p2_tracked=True, wc_tracked=True, clean_p2=True)
else:
parentfiledata = getfiledata[f] if getfiledata else None
repo.dirstate.normal(f, parentfiledata=parentfiledata)
repo.dirstate.update_parent_file_data(f, parentfiledata)
# merge
for f, args, msg in actions.get(ACTION_MERGE, []):
......@@ -824,10 +835,10 @@ def recordupdates(repo, actions, branchmerge, getfiledata):
if branchmerge:
# We've done a branch merge, mark this file as merged
# so that we properly record the merger later
repo.dirstate.merge(f)
repo.dirstate.update_file(f, p1_tracked=True, wc_tracked=True, merged=True)
if f1 != f2: # copy/rename
if move:
repo.dirstate.remove(f1)
repo.dirstate.update_file(f1, p1_tracked=True, wc_tracked=False)
if f1 != f:
repo.dirstate.copy(f1, f)
else:
......@@ -839,26 +850,26 @@ def recordupdates(repo, actions, branchmerge, getfiledata):
# merge will appear as a normal local file
# modification.
if f2 == f: # file not locally copied/moved
repo.dirstate.normallookup(f)
repo.dirstate.update_file(f, p1_tracked=True, wc_tracked=True, possibly_dirty=True)
if move:
repo.dirstate.drop(f1)
repo.dirstate.update_file(f1, p1_tracked=False, wc_tracked=False)
# directory rename, move local
for f, args, msg in actions.get(ACTION_DIR_RENAME_MOVE_LOCAL, []):
f0, flag = args
if branchmerge:
repo.dirstate.add(f)
repo.dirstate.remove(f0)
repo.dirstate.update_file(f, p1_tracked=False, wc_tracked=True)
repo.dirstate.update_file(f0, p1_tracked=True, wc_tracked=False)
repo.dirstate.copy(f0, f)
else:
repo.dirstate.normal(f)
repo.dirstate.drop(f0)
repo.dirstate.update_file(f, p1_tracked=True, wc_tracked=True)
repo.dirstate.update_file(f0, p1_tracked=False, wc_tracked=False)
# directory rename, get
for f, args, msg in actions.get(ACTION_LOCAL_DIR_RENAME_GET, []):
f0, flag = args
if branchmerge:
repo.dirstate.add(f)
repo.dirstate.update_file(f, p1_tracked=False, wc_tracked=True)
repo.dirstate.copy(f0, f)
else:
repo.dirstate.normal(f)
repo.dirstate.update_file(f, p1_tracked=True, wc_tracked=True)
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