Show More
@@ -257,28 +257,36 b' class localrepository(repo.repository):' | |||||
257 |
|
257 | |||
258 | def tags(self): |
|
258 | def tags(self): | |
259 | '''return a mapping of tag to node''' |
|
259 | '''return a mapping of tag to node''' | |
260 |
if |
|
260 | if self.tagscache: | |
|
261 | return self.tagscache | |||
|
262 | ||||
261 |
|
|
263 | self.tagscache = {} | |
262 |
|
264 | |||
263 |
|
|
265 | def readtags(lines, fn): | |
264 | if not line: |
|
266 | filetags = {} | |
265 | return |
|
267 | count = 0 | |
|
268 | ||||
|
269 | def warn(msg): | |||
|
270 | self.ui.warn(_("%s, line %s: %s\n") % (fn, count, msg)) | |||
|
271 | ||||
|
272 | for l in lines: | |||
|
273 | count += 1 | |||
|
274 | if not l: | |||
|
275 | continue | |||
266 | s = l.split(" ", 1) |
|
276 | s = l.split(" ", 1) | |
267 | if len(s) != 2: |
|
277 | if len(s) != 2: | |
268 |
|
|
278 | warn(_("cannot parse entry")) | |
269 |
|
|
279 | continue | |
270 | node, key = s |
|
280 | node, key = s | |
271 | key = util.tolocal(key.strip()) # stored in UTF-8 |
|
281 | key = util.tolocal(key.strip()) # stored in UTF-8 | |
272 | try: |
|
282 | try: | |
273 | bin_n = bin(node) |
|
283 | bin_n = bin(node) | |
274 | except TypeError: |
|
284 | except TypeError: | |
275 |
|
|
285 | warn(_("node '%s' is not well formed") % node) | |
276 |
|
|
286 | continue | |
277 | return |
|
|||
278 | if bin_n not in self.changelog.nodemap: |
|
287 | if bin_n not in self.changelog.nodemap: | |
279 |
|
|
288 | warn(_("tag '%s' refers to unknown node") % key) | |
280 |
|
|
289 | continue | |
281 | return |
|
|||
282 | self.tagscache[key] = bin_n |
|
290 | self.tagscache[key] = bin_n | |
283 |
|
291 | |||
284 |
|
|
292 | # read the tags file from each head, ending with the tip, | |
@@ -288,20 +296,13 b' class localrepository(repo.repository):' | |||||
288 |
|
|
296 | for rev, node, fnode in self._hgtagsnodes(): | |
289 |
|
|
297 | f = (f and f.filectx(fnode) or | |
290 |
|
|
298 | self.filectx('.hgtags', fileid=fnode)) | |
291 | count = 0 |
|
299 | readtags(f.data().splitlines(), f) | |
292 | for l in f.data().splitlines(): |
|
|||
293 | count += 1 |
|
|||
294 | parsetag(l, _("%s, line %d") % (str(f), count)) |
|
|||
295 |
|
300 | |||
296 |
|
|
301 | try: | |
297 |
|
|
302 | data = util.fromlocal(self.opener("localtags").read()) | |
298 | count = 0 |
|
|||
299 | for l in f: |
|
|||
300 |
|
|
303 | # localtags are stored in the local character set | |
301 |
|
|
304 | # while the internal tag table is stored in UTF-8 | |
302 | l = util.fromlocal(l) |
|
305 | readtags(data.splitlines(), "localtags") | |
303 | count += 1 |
|
|||
304 | parsetag(l, _("localtags, line %d") % count) |
|
|||
305 |
|
|
306 | except IOError: | |
306 |
|
|
307 | pass | |
307 |
|
308 |
General Comments 0
You need to be logged in to leave comments.
Login now