Mercurial > hg-stable
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 Fri Mar 09 18:09:02 2007 +0100 +++ b/mercurial/localrepo.py Fri Mar 09 19:12:03 2007 +0100 @@ -17,6 +17,7 @@ class localrepository(repo.repository): capabilities = ('lookup', 'changegroupsubset') supported = ('revlogv1', 'store') + branchcache_features = ('unnamed',) def __del__(self): self.transhandle = None @@ -376,6 +377,22 @@ 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 @@ 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 Fri Mar 09 18:09:02 2007 +0100 +++ b/tests/test-mq-caches.out Fri Mar 09 19:12:03 2007 +0100 @@ -7,6 +7,7 @@ # some regular revisions Patch queue now empty tip: 1 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -15,10 +16,12 @@ 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 @@ # removing the cache tip: 3 + features: unnamed 3f910abad313ff802d3a23a7529433872df9b3ae 1 3f910abad313ff802d3a23a7529433872df9b3ae bar 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo @@ -35,6 +39,7 @@ # 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 p2 Now at: p2 tip: 3 + features: unnamed 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
--- a/tests/test-newbranch.out Fri Mar 09 18:09:02 2007 +0100 +++ b/tests/test-newbranch.out Fri Mar 09 19:12:03 2007 +0100 @@ -74,6 +74,7 @@ 4:4909a3732169 + features: unnamed 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4 bf1bc2f45e834c75404d0ddab57d53beab56e2f8 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo