comparison mercurial/branchmap.py @ 18166:3a2e810dd3d8

branchmap: improve invalid cache message when reading This factors out the generation of the message. This helps future error reporting when reading cache for filtered repository.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Fri, 28 Dec 2012 00:13:32 +0100
parents db25bf1dc828
children 59ac9a551bf4
comparison
equal deleted inserted replaced
18165:0f5a0a2073a8 18166:3a2e810dd3d8
20 last, lrev = lines.pop(0).split(" ", 1) 20 last, lrev = lines.pop(0).split(" ", 1)
21 last, lrev = bin(last), int(lrev) 21 last, lrev = bin(last), int(lrev)
22 partial = branchcache(tipnode=last, tiprev=lrev) 22 partial = branchcache(tipnode=last, tiprev=lrev)
23 if not partial.validfor(repo): 23 if not partial.validfor(repo):
24 # invalidate the cache 24 # invalidate the cache
25 raise ValueError('invalidating branch cache (tip differs)') 25 raise ValueError('tip differs')
26 for l in lines: 26 for l in lines:
27 if not l: 27 if not l:
28 continue 28 continue
29 node, label = l.split(" ", 1) 29 node, label = l.split(" ", 1)
30 label = encoding.tolocal(label.strip()) 30 label = encoding.tolocal(label.strip())
31 if not node in repo: 31 if not node in repo:
32 raise ValueError('invalidating branch cache because node '+ 32 raise ValueError('node %s does not exist' % node)
33 '%s does not exist' % node)
34 partial.setdefault(label, []).append(bin(node)) 33 partial.setdefault(label, []).append(bin(node))
35 except KeyboardInterrupt: 34 except KeyboardInterrupt:
36 raise 35 raise
37 except Exception, inst: 36 except Exception, inst:
38 if repo.ui.debugflag: 37 if repo.ui.debugflag:
39 repo.ui.warn(str(inst), '\n') 38 repo.ui.warn(('invalid branchheads cache: %s\n') % inst)
40 partial = branchcache() 39 partial = branchcache()
41 return partial 40 return partial
42 41
43 42
44 43