Mercurial > hg-stable
diff mercurial/revlog.py @ 8073:e8a28556a0a8
strip: make repair.strip transactional to avoid repository corruption
Uses a transaction instance from the local repository to journal the
truncation of revlog files, such that if a strip only partially completes,
hg recover will be able to finish the truncate of all the files.
The potential unbundling of changes that have been backed up to be restored
later will, in case of an error, have to be unbundled manually. The
difference is that it will be possible to recover the repository state so
the unbundle can actually succeed.
author | Henrik Stuart <henrik.stuart@edlund.dk> |
---|---|
date | Thu, 16 Apr 2009 15:34:03 +0200 |
parents | 685ce2f7ee35 |
children | bbc24c0753a0 |
line wrap: on
line diff
--- a/mercurial/revlog.py Wed Apr 15 19:54:22 2009 +0200 +++ b/mercurial/revlog.py Thu Apr 16 15:34:03 2009 +0200 @@ -1285,7 +1285,7 @@ return node - def strip(self, minlink): + def strip(self, minlink, transaction): """truncate the revlog on the first revision with a linkrev >= minlink This function is called when we're stripping revision minlink and @@ -1314,14 +1314,12 @@ # first truncate the files on disk end = self.start(rev) if not self._inline: - df = self.opener(self.datafile, "a") - df.truncate(end) + transaction.add(self.datafile, end) end = rev * self._io.size else: end += rev * self._io.size - indexf = self.opener(self.indexfile, "a") - indexf.truncate(end) + transaction.add(self.indexfile, end) # then reset internal state in memory to forget those revisions self._cache = None