Mercurial > hg
diff mercurial/revlogutils/nodemap.py @ 44635:99ea74cbed74
nodemap: display percentage of unused in `hg debugnodemap`
This is useful to assess the density of the cache.
Differential Revision: https://phab.mercurial-scm.org/D8192
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 28 Feb 2020 03:18:57 +0100 |
parents | 01b0805534bb |
children | c70bcaf7927b |
line wrap: on
line diff
--- 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)