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.
hg-reviewers |
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.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
for f, entry in self._state.items(): | for f, entry in self._state.items(): | ||||
if entry[0] == MERGE_RECORD_DRIVER_RESOLVED: | if entry[0] == MERGE_RECORD_DRIVER_RESOLVED: | ||||
yield f | yield f | ||||
def extras(self, filename): | def extras(self, filename): | ||||
return self._stateextras.setdefault(filename, {}) | return self._stateextras.setdefault(filename, {}) | ||||
def _resolve(self, preresolve, dfile, wctx): | 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): | if self[dfile] in (MERGE_RECORD_RESOLVED, MERGE_RECORD_DRIVER_RESOLVED): | ||||
return True, 0 | return True, 0 | ||||
if self._state[dfile][0] == MERGE_RECORD_MERGED_OTHER: | if self._state[dfile][0] == MERGE_RECORD_MERGED_OTHER: | ||||
return True, 0 | return True, 0 | ||||
stateentry = self._state[dfile] | stateentry = self._state[dfile] | ||||
state, localkey, lfile, afile, anode, ofile, onode, flags = stateentry | state, localkey, lfile, afile, anode, ofile, onode, flags = stateentry | ||||
octx = self._repo[self._other] | octx = self._repo[self._other] | ||||
extras = self.extras(dfile) | extras = self.extras(dfile) | ||||
if preresolve: | if preresolve: | ||||
# restore local | # restore local | ||||
if localkey != nullhex: | if localkey != nullhex: | ||||
f = self._repo.vfs(b'merge/' + localkey) | f = self._repo.vfs(b'merge/' + localkey) | ||||
wctx[dfile].write(f.read(), flags) | wctx[dfile].write(f.read(), flags) | ||||
f.close() | f.close() | ||||
else: | else: | ||||
wctx[dfile].remove(ignoremissing=True) | wctx[dfile].remove(ignoremissing=True) | ||||
complete, r, deleted = filemerge.premerge( | complete, merge_ret, deleted = filemerge.premerge( | ||||
self._repo, | self._repo, | ||||
wctx, | wctx, | ||||
self._local, | self._local, | ||||
lfile, | lfile, | ||||
fcd, | fcd, | ||||
fco, | fco, | ||||
fca, | fca, | ||||
labels=self._labels, | labels=self._labels, | ||||
) | ) | ||||
else: | else: | ||||
complete, r, deleted = filemerge.filemerge( | complete, merge_ret, deleted = filemerge.filemerge( | ||||
self._repo, | self._repo, | ||||
wctx, | wctx, | ||||
self._local, | self._local, | ||||
lfile, | lfile, | ||||
fcd, | fcd, | ||||
fco, | fco, | ||||
fca, | fca, | ||||
labels=self._labels, | labels=self._labels, | ||||
) | ) | ||||
if r is None: | if merge_ret is None: | ||||
# no real conflict | # If return value of merge is None, then there are no real conflict | ||||
del self._state[dfile] | del self._state[dfile] | ||||
self._stateextras.pop(dfile, None) | self._stateextras.pop(dfile, None) | ||||
self._dirty = True | self._dirty = True | ||||
elif not r: | elif not merge_ret: | ||||
self.mark(dfile, MERGE_RECORD_RESOLVED) | self.mark(dfile, MERGE_RECORD_RESOLVED) | ||||
if complete: | if complete: | ||||
action = None | action = None | ||||
if deleted: | if deleted: | ||||
if fcd.isabsent(): | if fcd.isabsent(): | ||||
# dc: local picked. Need to drop if present, which may | # dc: local picked. Need to drop if present, which may | ||||
# happen on re-resolves. | # happen on re-resolves. | ||||
action = ACTION_FORGET | action = ACTION_FORGET | ||||
else: | else: | ||||
# cd: remote picked (or otherwise deleted) | # cd: remote picked (or otherwise deleted) | ||||
action = ACTION_REMOVE | action = ACTION_REMOVE | ||||
else: | else: | ||||
if fcd.isabsent(): # dc: remote picked | if fcd.isabsent(): # dc: remote picked | ||||
action = ACTION_GET | action = ACTION_GET | ||||
elif fco.isabsent(): # cd: local picked | elif fco.isabsent(): # cd: local picked | ||||
if dfile in self.localctx: | if dfile in self.localctx: | ||||
action = ACTION_ADD_MODIFIED | action = ACTION_ADD_MODIFIED | ||||
else: | else: | ||||
action = ACTION_ADD | action = ACTION_ADD | ||||
# else: regular merges (no action necessary) | # 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): | def preresolve(self, dfile, wctx): | ||||
"""run premerge process for dfile | """run premerge process for dfile | ||||
Returns whether the merge is complete, and the exit code.""" | Returns whether the merge is complete, and the exit code.""" | ||||
return self._resolve(True, dfile, wctx) | return self._resolve(True, dfile, wctx) | ||||
def resolve(self, dfile, wctx): | def resolve(self, dfile, wctx): |