Patchwork [21,of,22] strip: invalidate obsstore indexes

login
register
mail settings
Submitter Jun Wu
Date June 4, 2017, 11:59 p.m.
Message ID <cd962d45b21f4a2c20bf.1496620773@x1c>
Download mbox | patch
Permalink /patch/21196/
State Accepted
Headers show

Comments

Jun Wu - June 4, 2017, 11:59 p.m.
# HG changeset patch
# User Jun Wu <quark@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.

Patch

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):