Skip to content
Snippets Groups Projects
Commit 851825214aa3 authored by Phil Cohen's avatar Phil Cohen
Browse files

filemerge: convert a couple of wvfs calls in internal mergetools to contexts

One hitch is that sometimes fcd is actually an absentfilectx which does not
expose any mutator functions. In order to still use the context functions,
we look up the underlying workingfilectx to perform the write there.

One alternate way would be to put the write functions on the absentfilectx and
have them pass-through. While this makes the callsites cleaner, we would need
to decide what its getter functions would return after this point, since
returning None for `data` (and True for `isabsent()`) might no longer be
correct after a write. I discussed with Sidd about just having the getters
raise RuntimeErrors after a mutator has been called, but we actually call
isabsent() in merge.py after running the internal merge tools.
parent 77e666f943a6
No related branches found
No related tags found
No related merge requests found
......@@ -298,6 +298,6 @@
"""Uses the other `p2()` version of files as the merged version."""
if fco.isabsent():
# local changed, remote deleted -- 'deleted' picked
repo.wvfs.unlinkpath(fcd.path())
_underlyingfctxifabsent(fcd).remove()
deleted = True
else:
......@@ -302,6 +302,6 @@
deleted = True
else:
repo.wwrite(fcd.path(), fco.data(), fco.flags())
_underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
deleted = False
return 0, deleted
......@@ -313,6 +313,6 @@
used to resolve these conflicts."""
# for change/delete conflicts write out the changed version, then fail
if fcd.isabsent():
repo.wwrite(fcd.path(), fco.data(), fco.flags())
_underlyingfctxifabsent(fcd).write(fco.data(), fco.flags())
return 1, False
......@@ -317,5 +317,15 @@
return 1, False
def _underlyingfctxifabsent(filectx):
"""Sometimes when resolving, our fcd is actually an absentfilectx, but
we want to write to it (to do the resolve). This helper returns the
underyling workingfilectx in that case.
"""
if filectx.isabsent():
return filectx.changectx()[filectx.path()]
else:
return filectx
def _premerge(repo, fcd, fco, fca, toolconf, files, labels=None):
tool, toolpath, binary, symlink = toolconf
if symlink or fcd.isabsent() or fco.isabsent():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment