# HG changeset patch # User Yuya Nishihara # Date 1443531428 -32400 # Node ID 2b31d8636f25ad32fb6aa787c6068d1b3a1b383e # Parent 72bccc1f26b1a2e88243c8964781c2e0aaf0a978 localrepo: recreate phasecache if changelog was modified (issue4855) Because _phaserevs and _phasesets cache revision numbers, they must be invalidated if there are new commits or stripped revisions. We could do that by calling _phasecache.invalidate(), but it wasn't simple to be integrated with the filecache mechanism. So for now, phasecache will be recreated after repo.invalidate() if 00changelog.i was modified before. diff -r 72bccc1f26b1 -r 2b31d8636f25 mercurial/localrepo.py --- a/mercurial/localrepo.py Sat Sep 26 00:10:48 2015 -0400 +++ b/mercurial/localrepo.py Tue Sep 29 21:57:08 2015 +0900 @@ -434,7 +434,10 @@ heads.append(n) return heads - @storecache('phaseroots') + # _phaserevs and _phasesets depend on changelog. what wee need is to + # call _phasecache.invalidate() if '00changelog.i' was changed, but it + # can't be easily expressed in filecache mechanism. + @storecache('phaseroots', '00changelog.i') def _phasecache(self): return phases.phasecache(self, self._phasedefaults) diff -r 72bccc1f26b1 -r 2b31d8636f25 tests/test-commandserver.t --- a/tests/test-commandserver.t Sat Sep 26 00:10:48 2015 -0400 +++ b/tests/test-commandserver.t Tue Sep 29 21:57:08 2015 +0900 @@ -366,6 +366,49 @@ *** runcommand status -i -u I ignored-file +cache of non-public revisions should be invalidated on repository change +(issue4855): + + >>> import os + >>> from hgclient import readchannel, runcommand, check + >>> @check + ... def phasesetscacheaftercommit(server): + ... readchannel(server) + ... # load _phasecache._phaserevs and _phasesets + ... runcommand(server, ['log', '-qr', 'draft()']) + ... # create draft commits by another process + ... for i in xrange(5, 7): + ... os.system('echo a >> a') + ... os.system('hg commit -Aqm%d' % i) + ... # new commits should be listed as draft revisions + ... runcommand(server, ['log', '-qr', 'draft()']) + *** runcommand log -qr draft() + 4:7966c8e3734d + *** runcommand log -qr draft() + 4:7966c8e3734d + 5:41f6602d1c4f + 6:10501e202c35 + + >>> import os + >>> from hgclient import readchannel, runcommand, check + >>> @check + ... def phasesetscacheafterstrip(server): + ... readchannel(server) + ... # load _phasecache._phaserevs and _phasesets + ... runcommand(server, ['log', '-qr', 'draft()']) + ... # strip cached revisions by another process + ... os.system('hg --config extensions.strip= strip -q 5') + ... # shouldn't abort by "unknown revision '6'" + ... runcommand(server, ['log', '-qr', 'draft()']) + *** runcommand log -qr draft() + 4:7966c8e3734d + 5:41f6602d1c4f + 6:10501e202c35 + *** runcommand log -qr draft() + 4:7966c8e3734d + +cache of phase roots should be invalidated on strip (issue3827): + >>> import os >>> from hgclient import readchannel, sep, runcommand, check >>> @check