543 """hash the path of a local file context for storage in the .hg/merge |
543 """hash the path of a local file context for storage in the .hg/merge |
544 directory.""" |
544 directory.""" |
545 |
545 |
546 return hex(hashutil.sha1(path).digest()) |
546 return hex(hashutil.sha1(path).digest()) |
547 |
547 |
|
548 def _make_backup(self, fctx, localkey): |
|
549 self._repo.vfs.write(b'merge/' + localkey, fctx.data()) |
|
550 |
|
551 def _restore_backup(self, fctx, localkey, flags): |
|
552 with self._repo.vfs(b'merge/' + localkey) as f: |
|
553 fctx.write(f.read(), flags) |
|
554 |
548 def add(self, fcl, fco, fca, fd): |
555 def add(self, fcl, fco, fca, fd): |
549 """add a new (potentially?) conflicting file the merge state |
556 """add a new (potentially?) conflicting file the merge state |
550 fcl: file context for local, |
557 fcl: file context for local, |
551 fco: file context for remote, |
558 fco: file context for remote, |
552 fca: file context for ancestors, |
559 fca: file context for ancestors, |
662 elif flags == fla: |
669 elif flags == fla: |
663 flags = flo |
670 flags = flo |
664 if preresolve: |
671 if preresolve: |
665 # restore local |
672 # restore local |
666 if localkey != nullhex: |
673 if localkey != nullhex: |
667 f = self._repo.vfs(b'merge/' + localkey) |
674 self._restore_backup(wctx[dfile], localkey, flags) |
668 wctx[dfile].write(f.read(), flags) |
|
669 f.close() |
|
670 else: |
675 else: |
671 wctx[dfile].remove(ignoremissing=True) |
676 wctx[dfile].remove(ignoremissing=True) |
672 complete, merge_ret, deleted = filemerge.premerge( |
677 complete, merge_ret, deleted = filemerge.premerge( |
673 self._repo, |
678 self._repo, |
674 wctx, |
679 wctx, |