Mercurial > hg-stable
changeset 1988:18a3e6369600
merge with crew.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Tue, 21 Mar 2006 23:31:04 -0800 |
parents | 04c17fc39c84 (current diff) 719cf07b076d (diff) |
children | 0541768fa558 |
files | |
diffstat | 3 files changed, 56 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Mar 21 23:29:21 2006 -0800 +++ b/mercurial/localrepo.py Tue Mar 21 23:31:04 2006 -0800 @@ -78,33 +78,43 @@ '''return a mapping of tag to node''' if not self.tagscache: self.tagscache = {} - def addtag(self, k, n): - try: - bin_n = bin(n) - except TypeError: - bin_n = '' - self.tagscache[k.strip()] = bin_n - try: - # read each head of the tags file, ending with the tip - # and add each tag found to the map, with "newer" ones - # taking precedence - fl = self.file(".hgtags") - h = fl.heads() - h.reverse() - for r in h: - for l in fl.read(r).splitlines(): - if l: - n, k = l.split(" ", 1) - addtag(self, k, n) - except KeyError: - pass + def parsetag(line, context): + if not line: + return + s = l.split(" ", 1) + if len(s) != 2: + self.ui.warn(_("%s: ignoring invalid tag\n") % context) + return + node, key = s + try: + bin_n = bin(node) + except TypeError: + self.ui.warn(_("%s: ignoring invalid tag\n") % context) + return + if bin_n not in self.changelog.nodemap: + self.ui.warn(_("%s: ignoring invalid tag\n") % context) + return + self.tagscache[key.strip()] = bin_n + + # read each head of the tags file, ending with the tip + # and add each tag found to the map, with "newer" ones + # taking precedence + fl = self.file(".hgtags") + h = fl.heads() + h.reverse() + for r in h: + count = 0 + for l in fl.read(r).splitlines(): + count += 1 + parsetag(l, ".hgtags:%d" % count) try: f = self.opener("localtags") + count = 0 for l in f: - n, k = l.split(" ", 1) - addtag(self, k, n) + count += 1 + parsetag(l, "localtags:%d" % count) except IOError: pass
--- a/tests/test-tags Tue Mar 21 23:29:21 2006 -0800 +++ b/tests/test-tags Tue Mar 21 23:31:04 2006 -0800 @@ -31,3 +31,13 @@ hg id hg status +hg commit -m "merge" -d "1000000 0" +# invalid tags +echo "spam" >> .hgtags +echo >> .hgtags +echo "foo bar" >> .hgtags +echo "$T invalid" | sed "s/..../a5a5/" >> .hg/localtags +hg commit -m "tags" -d "1000000 0" +hg tags +hg tip +
--- a/tests/test-tags.out Tue Mar 21 23:29:21 2006 -0800 +++ b/tests/test-tags.out Tue Mar 21 23:31:04 2006 -0800 @@ -12,3 +12,17 @@ 8216907a933d tip 8216907a933d+8a3ca90d111d+ tip M .hgtags +.hgtags:2: ignoring invalid tag +.hgtags:4: ignoring invalid tag +localtags:1: ignoring invalid tag +tip 4:fd868a874787a7b5af31e1675666ce691c803035 +first 0:0acdaf8983679e0aac16e811534eb49d7ee1f2b4 +changeset: 4:fd868a874787 +.hgtags:2: ignoring invalid tag +.hgtags:4: ignoring invalid tag +localtags:1: ignoring invalid tag +tag: tip +user: test +date: Mon Jan 12 13:46:40 1970 +0000 +summary: tags +