Mercurial > hg-stable
changeset 27048:86290f6f6599
mergestate._resolve: handle change/delete conflicts
We will represent a deleted file as 'nullhex' in the in-memory and on-disk
merge states. We need to be able to create absentfilectxes in that case, and
delete the file from disk rather than try to write it out.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 20 Nov 2015 01:14:15 -0800 |
parents | e1458049dca5 |
children | 0d61f7ec7f76 |
files | mercurial/merge.py |
diffstat | 1 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Sat Nov 14 00:00:46 2015 -0800 +++ b/mercurial/merge.py Fri Nov 20 01:14:15 2015 -0800 @@ -414,8 +414,9 @@ stateentry = self._state[dfile] state, hash, lfile, afile, anode, ofile, onode, flags = stateentry octx = self._repo[self._other] - fcd = wctx[dfile] - fco = octx[ofile] + fcd = self._filectxorabsent(hash, wctx, dfile) + fco = self._filectxorabsent(onode, octx, ofile) + # TODO: move this to filectxorabsent fca = self._repo.filectx(afile, fileid=anode) # "premerge" x flags flo = fco.flags() @@ -429,9 +430,12 @@ flags = flo if preresolve: # restore local - f = self._repo.vfs('merge/' + hash) - self._repo.wwrite(dfile, f.read(), flags) - f.close() + if hash != nullhex: + f = self._repo.vfs('merge/' + hash) + self._repo.wwrite(dfile, f.read(), flags) + f.close() + else: + self._repo.wvfs.unlinkpath(dfile, ignoremissing=True) complete, r, deleted = filemerge.premerge(self._repo, self._local, lfile, fcd, fco, fca, labels=labels) @@ -462,6 +466,12 @@ return complete, r, action + def _filectxorabsent(self, hexnode, ctx, f): + if hexnode == nullhex: + return filemerge.absentfilectx(ctx, f) + else: + return ctx[f] + def preresolve(self, dfile, wctx, labels=None): """run premerge process for dfile