# HG changeset patch # User Alexis S. L. Carvalho # Date 1165037935 7200 # Node ID 9433bdcaa9ae30fed3cee257cdca1661067fba5c # Parent aeafd80c1e78d2d7f6a2841b53d41b96cfd24f62 Ignore all errors while parsing the branch cache. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -327,16 +327,20 @@ class localrepository(repo.repository): f.close() last, lrev = lines.pop(0).rstrip().split(" ", 1) last, lrev = bin(last), int(lrev) - if (lrev < self.changelog.count() and - self.changelog.node(lrev) == last): # sanity check - for l in lines: - if not l: continue - node, label = l.rstrip().split(" ", 1) - partial[label] = bin(node) - else: # invalidate the cache - last, lrev = nullid, nullrev - except IOError: - last, lrev = nullid, nullrev + if not (lrev < self.changelog.count() and + self.changelog.node(lrev) == last): # sanity check + # invalidate the cache + 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) + except (KeyboardInterrupt, util.SignalInterrupt): + raise + except Exception, inst: + if self.ui.debugflag: + self.ui.warn(str(inst), '\n') + partial, last, lrev = {}, nullid, nullrev return partial, last, lrev def _writebranchcache(self, branches, tip, tiprev): diff --git a/tests/test-newbranch b/tests/test-newbranch --- a/tests/test-newbranch +++ b/tests/test-newbranch @@ -30,4 +30,11 @@ hg branches -q echo % test for invalid branch cache hg rollback +cp .hg/branches.cache .hg/bc-invalid hg log -r foo +cp .hg/bc-invalid .hg/branches.cache +hg --debug log -r foo +rm .hg/branches.cache +echo corrupted > .hg/branches.cache +hg log -qr foo +cat .hg/branches.cache diff --git a/tests/test-newbranch.out b/tests/test-newbranch.out --- a/tests/test-newbranch.out +++ b/tests/test-newbranch.out @@ -56,3 +56,22 @@ user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: modify a branch +Invalid branch cache: unknown tip +changeset: 4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f +branch: foo +tag: tip +parent: 1:b699b1cec9c2966b3700de4fef0dc123cd754c31 +parent: -1:0000000000000000000000000000000000000000 +manifest: 4:d01b250baaa05909152f7ae07d7a649deea0df9a +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +files: a +extra: branch=foo +description: +modify a branch + + +4:4909a3732169 +4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4 +4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo +67ec16bde7f1575d523313b9bca000f6a6f12dca bar