--- a/mercurial/localrepo.py Sun Aug 06 17:47:41 2017 -0700
+++ b/mercurial/localrepo.py Wed Jul 19 13:34:06 2017 -0700
@@ -1461,6 +1461,13 @@
# dirstate is invalidated separately in invalidatedirstate()
if k == 'dirstate':
continue
+ if (k == 'changelog' and
+ self.currenttransaction() and
+ self.changelog._delayed):
+ # The changelog object may store unwritten revisions. We don't
+ # want to lose them.
+ # TODO: Solve the problem instead of working around it.
+ continue
if clearfilecache:
del self._filecache[k]