diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1425,6 +1425,18 @@ class localrepository(object): cache.update(self, ctxgen) cache.write(self) + # When one tries to: + # 1) destroy nodes thus calling this method (e.g. strip) + # 2) use phasecache somewhere (e.g. commit) + # + # then 2) will fail because the phasecache contains nodes that were + # removed. We can either remove phasecache from the filecache, + # causing it to reload next time it is accessed, or simply filter + # the removed nodes now and write the updated cache. + if '_phasecache' in self._filecache: + self._phasecache.filterunknown(self) + self._phasecache.write() + # Ensure the persistent tag cache is updated. Doing it now # means that the tag cache only has to worry about destroyed # heads immediately after a strip/rollback. That in turn diff --git a/tests/test-keyword.t b/tests/test-keyword.t --- a/tests/test-keyword.t +++ b/tests/test-keyword.t @@ -578,7 +578,6 @@ Commit and show expansion in original an $ hg --debug commit -ma2c -d '1 0' -u 'User Name ' c c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292 - removing unknown node 40a904bbbe4c from 1-phase boundary overwriting c expanding keywords committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d $ cat a c @@ -749,7 +748,6 @@ Commit with multi-line message and custo $ hg --debug commit -l log -d '2 0' -u 'User Name ' a - removing unknown node 40a904bbbe4c from 1-phase boundary overwriting a expanding keywords committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83 $ rm log