[PATCH 21 of 22] strip: invalidate obsstore indexes

Jun Wu quark at fb.com
Sun Jun 4 19:59:33 EDT 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1496615926 25200
#      Sun Jun 04 15:38:46 2017 -0700
# Node ID cd962d45b21f4a2c20bf60726b4b3e6c6e136aca
# Parent  edae716e97c441aff52688f3be4750b34b199901
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r cd962d45b21f
strip: invalidate obsstore indexes

The indexes assume an append-only obsstore and need rebuild if obsstore is
not append-only.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -835,4 +835,9 @@ class obsstore(object):
                 index.update()
 
+    def invalidateindexes(self):
+        """call this when obsstore is not append-only. remove index files"""
+        for name in ('successors', 'precursors', 'children'):
+            self.svfs.tryunlink('cache/obsindex-%s' % name)
+
     def relevantmarkers(self, nodes):
         """return a set of all obsolescence markers relevant to a set of nodes.
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -369,4 +369,6 @@ def deleteobsmarkers(obsstore, indices):
         left.append(m)
 
+    obsstore.invalidateindexes()
+
     newobsstorefile = obsstore.svfs('obsstore', 'w', atomictemp=True)
     for bytes in obsolete.encodemarkers(left, True, obsstore._version):


More information about the Mercurial-devel mailing list