Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revlogutils/nodemap.py @ 44638:01b0805534bb
nodemap: make sure on disk change get rolled back with the transaction
In case of errors, we need to rollback the change made to the persistent
nodemap.
Differential Revision: https://phab.mercurial-scm.org/D8191
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 28 Feb 2020 03:05:52 +0100 |
parents | 448d700e0d27 |
children | 99ea74cbed74 |
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py Fri Feb 28 02:23:38 2020 +0100 +++ b/mercurial/revlogutils/nodemap.py Fri Feb 28 03:05:52 2020 +0100 @@ -93,6 +93,15 @@ def addpostclose(self, callback_id, callback_func): self._postclose[callback_id] = callback_func + def registertmp(self, *args, **kwargs): + pass + + def addbackup(self, *args, **kwargs): + pass + + def add(self, *args, **kwargs): + pass + def update_persistent_nodemap(revlog): """update the persistent nodemap right now @@ -138,6 +147,7 @@ # EXP-TODO: if this is a cache, this should use a cache vfs, not a # store vfs new_length = target_docket.data_length + len(data) + tr.add(datafile, target_docket.data_length) with revlog.opener(datafile, b'r+') as fd: fd.seek(target_docket.data_length) fd.write(data) @@ -161,6 +171,7 @@ data = persistent_data(revlog.index) # EXP-TODO: if this is a cache, this should use a cache vfs, not a # store vfs + tr.add(datafile, 0) with revlog.opener(datafile, b'w+') as fd: fd.write(data) if feed_data: @@ -177,6 +188,10 @@ file_path = revlog.nodemap_file if pending: file_path += b'.a' + tr.registertmp(file_path) + else: + tr.addbackup(file_path) + with revlog.opener(file_path, b'w', atomictemp=True) as fp: fp.write(target_docket.serialize()) revlog._nodemap_docket = target_docket