comparison mercurial/hg.py @ 477:520540fd6b64

Handle errors in .hgtags or hgrc [tags] section more gracefully. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Handle errors in .hgtags or hgrc [tags] section more gracefully. manifest hash: 85c62e1bf3ad78b243ee60f43c3c577700a8c96d -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCvp6jW7P1GVgWeRoRAo23AKCZRU22IweynNtf9k3q4pEyqEaozACeMIRV 6tNOkr3h6jTiMZ2bJgPeabg= =+U5s -----END PGP SIGNATURE-----
author Thomas Arendsen Hein <thomas@intevation.de>
date Sun, 26 Jun 2005 13:25:07 +0100
parents 4c7f687e4313
children 934279f3ca53
comparison
equal deleted inserted replaced
476:0a338d506268 477:520540fd6b64
371 if pat.search(f): return True 371 if pat.search(f): return True
372 return False 372 return False
373 373
374 def tags(self): 374 def tags(self):
375 '''return a mapping of tag to node''' 375 '''return a mapping of tag to node'''
376 if not self.tagscache: 376 if not self.tagscache:
377 self.tagscache = {} 377 self.tagscache = {}
378 try: 378 try:
379 # read each head of the tags file, ending with the tip 379 # read each head of the tags file, ending with the tip
380 # and add each tag found to the map, with "newer" ones 380 # and add each tag found to the map, with "newer" ones
381 # taking precedence 381 # taking precedence
384 h.reverse() 384 h.reverse()
385 for r in h: 385 for r in h:
386 for l in fl.revision(r).splitlines(): 386 for l in fl.revision(r).splitlines():
387 if l: 387 if l:
388 n, k = l.split(" ", 1) 388 n, k = l.split(" ", 1)
389 self.tagscache[k.strip()] = bin(n) 389 try:
390 except KeyError: pass 390 bin_n = bin(n)
391 except TypeError:
392 bin_n = ''
393 self.tagscache[k.strip()] = bin_n
394 except KeyError:
395 pass
391 for k, n in self.ui.configitems("tags"): 396 for k, n in self.ui.configitems("tags"):
392 self.tagscache[k] = bin(n) 397 try:
393 398 bin_n = bin(n)
399 except TypeError:
400 bin_n = ''
401 self.tagscache[k] = bin_n
402
394 self.tagscache['tip'] = self.changelog.tip() 403 self.tagscache['tip'] = self.changelog.tip()
395 404
396 return self.tagscache 405 return self.tagscache
397 406
398 def tagslist(self): 407 def tagslist(self):
399 '''return a list of tags ordered by revision''' 408 '''return a list of tags ordered by revision'''
400 l = [] 409 l = []
401 for t,n in self.tags().items(): 410 for t, n in self.tags().items():
402 try: 411 try:
403 r = self.changelog.rev(n) 412 r = self.changelog.rev(n)
404 except: 413 except:
405 r = -2 # sort to the beginning of the list if unknown 414 r = -2 # sort to the beginning of the list if unknown
406 l.append((r,t,n)) 415 l.append((r,t,n))