diff -r 47f00b0de337 -r 6d6d0248530b mercurial/localrepo.py --- a/mercurial/localrepo.py Wed Jan 02 01:36:57 2013 +0100 +++ b/mercurial/localrepo.py Fri Jan 04 19:05:20 2013 +0100 @@ -1413,16 +1413,6 @@ code to update the branchheads cache, rather than having future code decide it's invalid and regenerating it from scratch. ''' - # If we have info, newheadnodes, on how to update the branch cache, do - # it, Otherwise, since nodes were destroyed, the cache is stale and this - # will be caught the next time it is read. - if newheadnodes: - ctxgen = (self[node] for node in newheadnodes - if self.changelog.hasnode(node)) - cache = self._branchcaches[None] - 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) @@ -1435,6 +1425,16 @@ self._phasecache.filterunknown(self) self._phasecache.write() + # If we have info, newheadnodes, on how to update the branch cache, do + # it, Otherwise, since nodes were destroyed, the cache is stale and this + # will be caught the next time it is read. + if newheadnodes: + ctxgen = (self[node] for node in newheadnodes + if self.changelog.hasnode(node)) + cache = self._branchcaches[None] + cache.update(self, ctxgen) + cache.write(self) + # 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