##// END OF EJS Templates
Handle errors in .hgtags or hgrc [tags] section more gracefully....
Thomas Arendsen Hein -
r477:520540fd default
parent child Browse files
Show More
@@ -662,15 +662,15 b' def tag(ui, repo, name, rev = None, **op'
662
662
663 def tags(ui, repo):
663 def tags(ui, repo):
664 """list repository tags"""
664 """list repository tags"""
665
665
666 l = repo.tagslist()
666 l = repo.tagslist()
667 l.reverse()
667 l.reverse()
668 for t,n in l:
668 for t, n in l:
669 try:
669 try:
670 r = repo.changelog.rev(n)
670 r = "%5d:%s" % (repo.changelog.rev(n), hg.hex(n))
671 except KeyError:
671 except KeyError:
672 r = "?"
672 r = " ?:?"
673 print "%-30s %5d:%s" % (t, repo.changelog.rev(n), hg.hex(n))
673 ui.write("%-30s %s\n" % (t, r))
674
674
675 def tip(ui, repo):
675 def tip(ui, repo):
676 """show the tip revision"""
676 """show the tip revision"""
@@ -373,7 +373,7 b' class localrepository:'
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
@@ -386,11 +386,20 b' class localrepository:'
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
@@ -398,7 +407,7 b' class localrepository:'
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:
General Comments 0
You need to be logged in to leave comments. Login now