Show More
@@ -126,18 +126,6 b' def show_changeset(ui, repo, rev=0, chan' | |||||
126 | ui.status("summary: %s\n" % description[0]) |
|
126 | ui.status("summary: %s\n" % description[0]) | |
127 | ui.status("\n") |
|
127 | ui.status("\n") | |
128 |
|
128 | |||
129 | def tags_load(repo): |
|
|||
130 | repo.lookup(0) # prime the cache |
|
|||
131 | i = repo.tags.items() |
|
|||
132 | n = [] |
|
|||
133 | for e in i: |
|
|||
134 | try: |
|
|||
135 | l = repo.changelog.rev(e[1]) |
|
|||
136 | except KeyError: |
|
|||
137 | l = -2 |
|
|||
138 | n.append((l, e)) |
|
|||
139 | return n |
|
|||
140 |
|
||||
141 | def help(ui, cmd=None): |
|
129 | def help(ui, cmd=None): | |
142 | '''show help for a given command or all commands''' |
|
130 | '''show help for a given command or all commands''' | |
143 | if cmd: |
|
131 | if cmd: | |
@@ -328,17 +316,15 b' def identify(ui, repo):' | |||||
328 | """print information about the working copy""" |
|
316 | """print information about the working copy""" | |
329 | (c, a, d, u) = repo.diffdir(repo.root) |
|
317 | (c, a, d, u) = repo.diffdir(repo.root) | |
330 | mflag = (c or a or d or u) and "+" or "" |
|
318 | mflag = (c or a or d or u) and "+" or "" | |
331 |
parents = [p |
|
319 | parents = [p for p in repo.dirstate.parents() if p != hg.nullid] | |
332 | if parent != hg.nullid] |
|
|||
333 | if not parents: |
|
320 | if not parents: | |
334 |
ui. |
|
321 | ui.write("unknown\n") | |
335 | return |
|
322 | return | |
336 |
|
323 | |||
337 | tstring = '' |
|
324 | tstring = '' | |
338 | if not ui.quiet: |
|
325 | if not ui.quiet: | |
339 | taglist = [e[1] for e in tags_load(repo)] |
|
326 | tags = sum(map(repo.nodetags, parents), []) | |
340 |
tstring = " |
|
327 | tstring = " " + ' + '.join(tags) | |
341 | if e[0] != 'tip' and e[1] in parents]) |
|
|||
342 |
|
328 | |||
343 | hexfunc = ui.verbose and hg.hex or hg.short |
|
329 | hexfunc = ui.verbose and hg.hex or hg.short | |
344 | pstring = '+'.join([hexfunc(parent) for parent in parents]) |
|
330 | pstring = '+'.join([hexfunc(parent) for parent in parents]) | |
@@ -544,17 +530,15 b' def status(ui, repo):' | |||||
544 |
|
530 | |||
545 | def tags(ui, repo): |
|
531 | def tags(ui, repo): | |
546 | """list repository tags""" |
|
532 | """list repository tags""" | |
547 | n = tags_load(repo) |
|
533 | ||
548 |
|
534 | l = repo.tagslist() | ||
549 | n.sort() |
|
535 | l.reverse() | |
550 | n.reverse() |
|
536 | for t,n in l: | |
551 | i = [ e[1] for e in n ] |
|
|||
552 | for k, n in i: |
|
|||
553 | try: |
|
537 | try: | |
554 | r = repo.changelog.rev(n) |
|
538 | r = repo.changelog.rev(n) | |
555 | except KeyError: |
|
539 | except KeyError: | |
556 | r = "?" |
|
540 | r = "?" | |
557 |
print "%-30s %5d:%s" % ( |
|
541 | print "%-30s %5d:%s" % (t, repo.changelog.rev(n), hg.hex(n)) | |
558 |
|
542 | |||
559 | def tip(ui, repo): |
|
543 | def tip(ui, repo): | |
560 | """show the tip revision""" |
|
544 | """show the tip revision""" |
@@ -334,7 +334,8 b' class localrepository:' | |||||
334 | self.manifest = manifest(self.opener) |
|
334 | self.manifest = manifest(self.opener) | |
335 | self.changelog = changelog(self.opener) |
|
335 | self.changelog = changelog(self.opener) | |
336 | self.ignorelist = None |
|
336 | self.ignorelist = None | |
337 | self.tags = None |
|
337 | self.tagscache = None | |
|
338 | self.nodetagscache = None | |||
338 |
|
339 | |||
339 | if not self.remote: |
|
340 | if not self.remote: | |
340 | self.dirstate = dirstate(self.opener, ui, self.root) |
|
341 | self.dirstate = dirstate(self.opener, ui, self.root) | |
@@ -355,9 +356,10 b' class localrepository:' | |||||
355 | if pat.search(f): return True |
|
356 | if pat.search(f): return True | |
356 | return False |
|
357 | return False | |
357 |
|
358 | |||
358 |
def |
|
359 | def tags(self): | |
359 | if self.tags is None: |
|
360 | '''return a mapping of tag to node''' | |
360 |
|
|
361 | if not self.tagscache: | |
|
362 | self.tagscache = {} | |||
361 | try: |
|
363 | try: | |
362 | # read each head of the tags file, ending with the tip |
|
364 | # read each head of the tags file, ending with the tip | |
363 | # and add each tag found to the map, with "newer" ones |
|
365 | # and add each tag found to the map, with "newer" ones | |
@@ -369,11 +371,35 b' class localrepository:' | |||||
369 | for l in fl.revision(r).splitlines(): |
|
371 | for l in fl.revision(r).splitlines(): | |
370 | if l: |
|
372 | if l: | |
371 | n, k = l.split(" ") |
|
373 | n, k = l.split(" ") | |
372 | self.tags[k] = bin(n) |
|
374 | self.tagscache[k] = bin(n) | |
373 | except KeyError: pass |
|
375 | except KeyError: pass | |
374 | self.tags['tip'] = self.changelog.tip() |
|
376 | self.tagscache['tip'] = self.changelog.tip() | |
|
377 | ||||
|
378 | return self.tagscache | |||
|
379 | ||||
|
380 | def tagslist(self): | |||
|
381 | '''return a list of tags ordered by revision''' | |||
|
382 | l = [] | |||
|
383 | for t,n in self.tags().items(): | |||
|
384 | try: | |||
|
385 | r = self.changelog.rev(n) | |||
|
386 | except: | |||
|
387 | r = -2 # sort to the beginning of the list if unknown | |||
|
388 | l.append((r,t,n)) | |||
|
389 | l.sort() | |||
|
390 | return [(t,n) for r,t,n in l] | |||
|
391 | ||||
|
392 | def nodetags(self, node): | |||
|
393 | '''return the tags associated with a node''' | |||
|
394 | if not self.nodetagscache: | |||
|
395 | self.nodetagscache = {} | |||
|
396 | for t,n in self.tags().items(): | |||
|
397 | self.nodetagscache.setdefault(n,[]).append(t) | |||
|
398 | return self.nodetagscache.get(node, []) | |||
|
399 | ||||
|
400 | def lookup(self, key): | |||
375 | try: |
|
401 | try: | |
376 | return self.tags[key] |
|
402 | return self.tags()[key] | |
377 | except KeyError: |
|
403 | except KeyError: | |
378 | return self.changelog.lookup(key) |
|
404 | return self.changelog.lookup(key) | |
379 |
|
405 |
@@ -523,12 +523,8 b' class hgweb:' | |||||
523 | cl = self.repo.changelog |
|
523 | cl = self.repo.changelog | |
524 | mf = cl.read(cl.tip())[0] |
|
524 | mf = cl.read(cl.tip())[0] | |
525 |
|
525 | |||
526 | self.repo.lookup(0) # prime the cache |
|
526 | i = self.repo.tagslist() | |
527 |
i |
|
527 | i.reverse() | |
528 | n = [ (cl.rev(e[1]), e) for e in i ] # sort by revision |
|
|||
529 | n.sort() |
|
|||
530 | n.reverse() |
|
|||
531 | i = [ e[1] for e in n ] |
|
|||
532 |
|
528 | |||
533 | def entries(): |
|
529 | def entries(): | |
534 | parity = 0 |
|
530 | parity = 0 |
General Comments 0
You need to be logged in to leave comments.
Login now