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.
--- a/mercurial/localrepo.py Fri Sep 25 13:30:49 2015 -0700
+++ b/mercurial/localrepo.py Tue Sep 29 21:57:08 2015 +0900
@@ -429,7 +429,10 @@
heads.append(n)
return heads
- @storecache('phaseroots')
+ # _phaserevs and _phasesets depend on changelog. what we 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)
--- a/tests/test-commandserver.t Fri Sep 25 13:30:49 2015 -0700
+++ b/tests/test-commandserver.t Tue Sep 29 21:57:08 2015 +0900
@@ -367,6 +367,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