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

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 1, 2019, 5:55 p.m.
Message ID <df77a77a8b1744d93de9.1564682139@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41108/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 1, 2019, 5:55 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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)

Patch

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()
     repo.destroying()
     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