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