diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -15,6 +15,7 @@ import os, revlog, time, util class localrepository(repo.repository): capabilities = ('lookup', 'changegroupsubset') supported = ('revlogv1', 'store') + branchcache_features = ('unnamed',) def __del__(self): self.transhandle = None @@ -397,7 +398,23 @@ class localrepository(repo.repository): f = self.opener("branches.cache") lines = f.read().split('\n') f.close() - last, lrev = lines.pop(0).rstrip().split(" ", 1) + 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 self.changelog.node(lrev) == last): # sanity check @@ -405,8 +422,8 @@ class localrepository(repo.repository): raise ValueError('Invalid branch cache: unknown tip') for l in lines: if not l: continue - node, label = l.rstrip().split(" ", 1) - partial[label] = bin(node) + node, label = l.split(" ", 1) + partial[label.strip()] = bin(node) except (KeyboardInterrupt, util.SignalInterrupt): raise except Exception, inst: @@ -418,6 +435,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)) @@ -428,8 +446,7 @@ class localrepository(repo.repository): for r in xrange(start, end): c = self.changectx(r) b = c.branch() - if b: - partial[b] = c.node() + partial[b] = c.node() def lookup(self, key): if key == '.':