--- a/mercurial/revlogutils/nodemap.py Fri Feb 28 03:05:52 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py Fri Feb 28 03:18:57 2020 +0100
@@ -102,6 +102,9 @@
def add(self, *args, **kwargs):
pass
+ def addabort(self, *args, **kwargs):
+ pass
+
def update_persistent_nodemap(revlog):
"""update the persistent nodemap right now
@@ -171,7 +174,17 @@
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)
+
+ tryunlink = revlog.opener.tryunlink
+
+ def abortck(tr):
+ tryunlink(datafile)
+
+ callback_id = b"delete-%s" % datafile
+
+ # some flavor of the transaction abort does not cleanup new file, it
+ # simply empty them.
+ tr.addabort(callback_id, abortck)
with revlog.opener(datafile, b'w+') as fd:
fd.write(data)
if feed_data:
@@ -198,9 +211,6 @@
if feed_data:
revlog.index.update_nodemap_data(target_docket, new_data)
- # EXP-TODO: if the transaction abort, we should remove the new data and
- # reinstall the old one.
-
# search for old index file in all cases, some older process might have
# left one behind.
olds = _other_rawdata_filepath(revlog, target_docket)