Mercurial > hg > mercurial-crew-with-dirclash
changeset 4168:bbfe5a3fc80c
Add a features list to branches.cache to detect caches of old hg versions.
The leading space in the written file makes sure that the feature list never
can match an existing version, even if the first feature can be read as hex.
Additionally old hg versions display the id with --debug, too.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 09 Mar 2007 19:12:03 +0100 |
parents | 4574a8cb080f |
children | 0182cb2e4aac |
files | mercurial/localrepo.py tests/test-mq-caches.out tests/test-newbranch.out |
diffstat | 3 files changed, 25 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -17,6 +17,7 @@ demandload(globals(), "os revlog time ut class localrepository(repo.repository): capabilities = ('lookup', 'changegroupsubset') supported = ('revlogv1', 'store') + branchcache_features = ('unnamed',) def __del__(self): self.transhandle = None @@ -376,6 +377,22 @@ class localrepository(repo.repository): f = self.opener("branches.cache") lines = f.read().split('\n') f.close() + features = lines.pop(0).strip() + if not features.startswith('features: '): + raise ValueError(_('branch cache: no features specified')) + features = features.split(' ', 1)[1].split() + missing_features = [] + for feature in self.branchcache_features: + try: + features.remove(feature) + except ValueError, inst: + missing_features.append(feature) + if missing_features: + raise ValueError(_('branch cache: missing features: %s') + % ', '.join(missing_features)) + if features: + raise ValueError(_('branch cache: unknown features: %s') + % ', '.join(features)) last, lrev = lines.pop(0).split(" ", 1) last, lrev = bin(last), int(lrev) if not (lrev < self.changelog.count() and @@ -397,6 +414,7 @@ class localrepository(repo.repository): def _writebranchcache(self, branches, tip, tiprev): try: f = self.opener("branches.cache", "w") + f.write(" features: %s\n" % ' '.join(self.branchcache_features)) f.write("%s %s\n" % (hex(tip), tiprev)) for label, node in branches.iteritems(): f.write("%s %s\n" % (hex(node), label))
--- a/tests/test-mq-caches.out +++ b/tests/test-mq-caches.out @@ -7,6 +7,7 @@ No .hg/branches.cache # some regular revisions Patch queue now empty tip: 1 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -15,10 +16,12 @@ 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff applying p1 Now at: p1 tip: 2 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo tip: 3 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -27,6 +30,7 @@ branch bar: 2 # removing the cache tip: 3 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -35,6 +39,7 @@ branch bar: 2 # importing rev 1 (the cache now ends in one of the patches) tip: 3 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -49,5 +54,6 @@ applying p1 applying p2 Now at: p2 tip: 3 + features: unnamed 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo