[Updated] D9038: mergestate: extract overridable methods for making/restoring file backups
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Sep 18 02:37:26 UTC 2020
Closed by commit rHGe833ff4dd0ea: mergestate: extract overridable methods for making/restoring file backups (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9038?vs=22686&id=22705
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9038/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9038
AFFECTED FILES
mercurial/mergestate.py
CHANGE DETAILS
diff --git a/mercurial/mergestate.py b/mercurial/mergestate.py
--- a/mercurial/mergestate.py
+++ b/mercurial/mergestate.py
@@ -545,6 +545,13 @@
return hex(hashutil.sha1(path).digest())
+ def _make_backup(self, fctx, localkey):
+ self._repo.vfs.write(b'merge/' + localkey, fctx.data())
+
+ def _restore_backup(self, fctx, localkey, flags):
+ with self._repo.vfs(b'merge/' + localkey) as f:
+ fctx.write(f.read(), flags)
+
def add(self, fcl, fco, fca, fd):
"""add a new (potentially?) conflicting file the merge state
fcl: file context for local,
@@ -558,7 +565,7 @@
localkey = nullhex
else:
localkey = mergestate.getlocalkey(fcl.path())
- self._repo.vfs.write(b'merge/' + localkey, fcl.data())
+ self._make_backup(fcl, localkey)
self._state[fd] = [
MERGE_RECORD_UNRESOLVED,
localkey,
@@ -664,9 +671,7 @@
if preresolve:
# restore local
if localkey != nullhex:
- f = self._repo.vfs(b'merge/' + localkey)
- wctx[dfile].write(f.read(), flags)
- f.close()
+ self._restore_backup(wctx[dfile], localkey, flags)
else:
wctx[dfile].remove(ignoremissing=True)
complete, merge_ret, deleted = filemerge.premerge(
To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200918/89d6389a/attachment-0002.html>
More information about the Mercurial-patches
mailing list