[PATCH 2 of 3 STABLE] strip: access bookmark before getting a reference to changelog

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Aug 1 13:55:39 EDT 2019

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at octobus.net>
# Date 1564669367 -7200
#      Thu Aug 01 16:22:47 2019 +0200
# Branch stable
# Node ID df77a77a8b1744d93de9823fb8ac2d5c5d8c07d8
# Parent  309dee8dfbce8fb1b3e96535e167da107727c178
# EXP-Topic debug-book
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r df77a77a8b17
strip: access bookmark before getting a reference to changelog

Bookmark access might invalidate the current changelog (to make sure both are in
a reasonable synchronisation state). So we should grab the reference to
changelog after we access bookmark. Otherwise we risk using a dead object for
the whole strip process.

(note: this dead object business probably requires a new layers of checking)

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -109,6 +109,9 @@ def strip(ui, repo, nodelist, backup=Tru
     repo = repo.unfiltered()
     vfs = repo.vfs
+    # load bookmark before changelog to avoid side effect from outdated
+    # changelog (see repo._refreshchangelog)
+    repo._bookmarks
     cl = repo.changelog
     # TODO handle undo of merge sets

More information about the Mercurial-devel mailing list