Patchwork [02,of,10,v2] localrepo: introduce destroying function

login
register
mail settings
Submitter Idan Kamara
Date Jan. 10, 2013, 10:10 p.m.
Message ID <10c413247f0d3f179f8d.1357855849@idan>
Download mbox | patch
Permalink /patch/527/
State Accepted
Commit 4499ba5ac35caacc6445ab960af451c66fea9c1c
Delegated to: Kevin Bullock
Headers show

Comments

Idan Kamara - Jan. 10, 2013, 10:10 p.m.
# HG changeset patch
# User Idan Kamara <idankk86@gmail.com>
# Date 1355594893 -7200
# Node ID 10c413247f0d3f179f8daa2404dc18195f181565
# Parent  65504f14b760ed55e9869eba44e0556b43ed8454
localrepo: introduce destroying function

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -895,6 +895,7 @@ 
             return 0
 
         parents = self.dirstate.parents()
+        self.destroying()
         transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
         if os.path.exists(self.join('undo.bookmarks')):
             util.rename(self.join('undo.bookmarks'),
@@ -1379,6 +1380,20 @@ 
             lock.release()
 
     @unfilteredmethod
+    def destroying(self):
+        '''Inform the repository that nodes are about to be destroyed.
+        Intended for use by strip and rollback, so there's a common
+        place for anything that has to be done before destroying history.
+
+        This is mostly useful for saving state that is in memory and waiting
+        to be flushed when the current lock is released. Because a call to
+        destroyed is imminent, the repo will be invalidated causing those
+        changes to stay in memory (waiting for the next unlock), or vanish
+        completely.
+        '''
+        pass
+
+    @unfilteredmethod
     def destroyed(self, newheadnodes=None):
         '''Inform the repository that nodes have been destroyed.
         Intended for use by strip and rollback, so there's a common
diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -61,6 +61,7 @@ 
     # have to consider the effect of the stripped revisions and not revisions
     # missing because the cache is out-of-date.
     branchmap.updatecache(repo)
+    repo.destroying()
 
     cl = repo.changelog
     # TODO handle undo of merge sets