##// END OF EJS Templates
speed up generating changesets in journal log...
marcink -
r2012:ca39c02c beta
parent child Browse files
Show More
@@ -406,7 +406,8 b' def bool2icon(value):'
406
406
407
407
408 def action_parser(user_log, feed=False):
408 def action_parser(user_log, feed=False):
409 """This helper will action_map the specified string action into translated
409 """
410 This helper will action_map the specified string action into translated
410 fancy names with icons and links
411 fancy names with icons and links
411
412
412 :param user_log: user log instance
413 :param user_log: user log instance
@@ -422,65 +423,77 b' def action_parser(user_log, feed=False):'
422 action, action_params = x
423 action, action_params = x
423
424
424 def get_cs_links():
425 def get_cs_links():
425 revs_limit = 3 #display this amount always
426 revs_limit = 3 # display this amount always
426 revs_top_limit = 50 #show upto this amount of changesets hidden
427 revs_top_limit = 50 # show upto this amount of changesets hidden
427 revs = action_params.split(',')
428 revs_ids = action_params.split(',')
428 repo_name = user_log.repository.repo_name
429 repo_name = user_log.repository.repo_name
429
430
430 from rhodecode.model.scm import ScmModel
431 repo = user_log.repository.scm_instance
431 repo = user_log.repository.scm_instance
432
432
433 message = lambda rev: get_changeset_safe(repo, rev).message
433 message = lambda rev: rev.message
434 lnk = lambda rev, repo_name: (
435 link_to('r%s:%s' % (rev.revision, rev.short_id),
436 url('changeset_home', repo_name=repo_name,
437 revision=rev.raw_id),
438 title=tooltip(message(rev)), class_='tooltip')
439 )
440 # get only max revs_top_limit of changeset for performance/ui reasons
441 revs = [
442 x for x in repo.get_changesets(revs_ids[0],
443 revs_ids[:revs_top_limit][-1])
444 ]
445
434 cs_links = []
446 cs_links = []
435 cs_links.append(" " + ', '.join ([link_to(rev,
447 cs_links.append(" " + ', '.join(
436 url('changeset_home',
448 [lnk(rev, repo_name) for rev in revs[:revs_limit]]
437 repo_name=repo_name,
449 )
438 revision=rev), title=tooltip(message(rev)),
450 )
439 class_='tooltip') for rev in revs[:revs_limit] ]))
440
451
441 compare_view = (' <div class="compare_view tooltip" title="%s">'
452 compare_view = (
442 '<a href="%s">%s</a> '
453 ' <div class="compare_view tooltip" title="%s">'
443 '</div>' % (_('Show all combined changesets %s->%s' \
454 '<a href="%s">%s</a> </div>' % (
444 % (revs[0], revs[-1])),
455 _('Show all combined changesets %s->%s') % (
445 url('changeset_home', repo_name=repo_name,
456 revs_ids[0], revs_ids[-1]
446 revision='%s...%s' % (revs[0], revs[-1])
457 ),
447 ),
458 url('changeset_home', repo_name=repo_name,
448 _('compare view'))
459 revision='%s...%s' % (revs_ids[0], revs_ids[-1])
449 )
460 ),
461 _('compare view')
462 )
463 )
450
464
451 # if we have exactly one more than normally displayed:
465 # if we have exactly one more than normally displayed
452 # just display it, takes less space than displaying "and 1 more revisions"
466 # just display it, takes less space than displaying
453 if len(revs) == revs_limit + 1:
467 # "and 1 more revisions"
468 if len(revs_ids) == revs_limit + 1:
454 rev = revs[revs_limit]
469 rev = revs[revs_limit]
455 cs_links.append(", " + link_to(rev,
470 cs_links.append(", " + lnk(rev, repo_name))
456 url('changeset_home',
457 repo_name=repo_name,
458 revision=rev), title=tooltip(message(rev)),
459 class_='tooltip') )
460
471
461 # hidden-by-default ones
472 # hidden-by-default ones
462 if len(revs) > revs_limit + 1:
473 if len(revs_ids) > revs_limit + 1:
463 uniq_id = revs[0]
474 uniq_id = revs_ids[0]
464 html_tmpl = ('<span> %s '
475 html_tmpl = (
465 '<a class="show_more" id="_%s" href="#more">%s</a> '
476 '<span> %s <a class="show_more" id="_%s" '
466 '%s</span>')
477 'href="#more">%s</a> %s</span>'
478 )
467 if not feed:
479 if not feed:
468 cs_links.append(html_tmpl % (_('and'), uniq_id, _('%s more') \
480 cs_links.append(html_tmpl % (
469 % (len(revs) - revs_limit),
481 _('and'),
470 _('revisions')))
482 uniq_id, _('%s more') % (len(revs_ids) - revs_limit),
483 _('revisions')
484 )
485 )
471
486
472 if not feed:
487 if not feed:
473 html_tmpl = '<span id="%s" style="display:none">, %s </span>'
488 html_tmpl = '<span id="%s" style="display:none">, %s </span>'
474 else:
489 else:
475 html_tmpl = '<span id="%s"> %s </span>'
490 html_tmpl = '<span id="%s"> %s </span>'
476
491
477 morelinks = ', '.join([link_to(rev,
492 morelinks = ', '.join(
478 url('changeset_home',
493 [lnk(rev, repo_name) for rev in revs[revs_limit:]]
479 repo_name=repo_name, revision=rev),
494 )
480 title=message(rev), class_='tooltip')
481 for rev in revs[revs_limit:revs_top_limit]])
482
495
483 if len(revs) > revs_top_limit:
496 if len(revs_ids) > revs_top_limit:
484 morelinks += ', ...'
497 morelinks += ', ...'
485
498
486 cs_links.append(html_tmpl % (uniq_id, morelinks))
499 cs_links.append(html_tmpl % (uniq_id, morelinks))
@@ -493,31 +506,32 b' def action_parser(user_log, feed=False):'
493 return _('fork name ') + str(link_to(action_params, url('summary_home',
506 return _('fork name ') + str(link_to(action_params, url('summary_home',
494 repo_name=repo_name,)))
507 repo_name=repo_name,)))
495
508
496 action_map = {'user_deleted_repo':(_('[deleted] repository'), None),
509 action_map = {'user_deleted_repo': (_('[deleted] repository'), None),
497 'user_created_repo':(_('[created] repository'), None),
510 'user_created_repo': (_('[created] repository'), None),
498 'user_created_fork':(_('[created] repository as fork'), None),
511 'user_created_fork': (_('[created] repository as fork'), None),
499 'user_forked_repo':(_('[forked] repository'), get_fork_name),
512 'user_forked_repo': (_('[forked] repository'), get_fork_name),
500 'user_updated_repo':(_('[updated] repository'), None),
513 'user_updated_repo': (_('[updated] repository'), None),
501 'admin_deleted_repo':(_('[delete] repository'), None),
514 'admin_deleted_repo': (_('[delete] repository'), None),
502 'admin_created_repo':(_('[created] repository'), None),
515 'admin_created_repo': (_('[created] repository'), None),
503 'admin_forked_repo':(_('[forked] repository'), None),
516 'admin_forked_repo': (_('[forked] repository'), None),
504 'admin_updated_repo':(_('[updated] repository'), None),
517 'admin_updated_repo': (_('[updated] repository'), None),
505 'push':(_('[pushed] into'), get_cs_links),
518 'push': (_('[pushed] into'), get_cs_links),
506 'push_local':(_('[committed via RhodeCode] into'), get_cs_links),
519 'push_local': (_('[committed via RhodeCode] into'), get_cs_links),
507 'push_remote':(_('[pulled from remote] into'), get_cs_links),
520 'push_remote': (_('[pulled from remote] into'), get_cs_links),
508 'pull':(_('[pulled] from'), None),
521 'pull': (_('[pulled] from'), None),
509 'started_following_repo':(_('[started following] repository'), None),
522 'started_following_repo': (_('[started following] repository'), None),
510 'stopped_following_repo':(_('[stopped following] repository'), None),
523 'stopped_following_repo': (_('[stopped following] repository'), None),
511 }
524 }
512
525
513 action_str = action_map.get(action, action)
526 action_str = action_map.get(action, action)
514 if feed:
527 if feed:
515 action = action_str[0].replace('[', '').replace(']', '')
528 action = action_str[0].replace('[', '').replace(']', '')
516 else:
529 else:
517 action = action_str[0].replace('[', '<span class="journal_highlight">')\
530 action = action_str[0]\
518 .replace(']', '</span>')
531 .replace('[', '<span class="journal_highlight">')\
532 .replace(']', '</span>')
519
533
520 action_params_func = lambda :""
534 action_params_func = lambda: ""
521
535
522 if callable(action_str[1]):
536 if callable(action_str[1]):
523 action_params_func = action_str[1]
537 action_params_func = action_str[1]
@@ -568,7 +582,7 b' HasRepoPermissionAny, HasRepoPermissionA'
568 def gravatar_url(email_address, size=30):
582 def gravatar_url(email_address, size=30):
569 if (not str2bool(config['app_conf'].get('use_gravatar')) or
583 if (not str2bool(config['app_conf'].get('use_gravatar')) or
570 not email_address or email_address == 'anonymous@rhodecode.org'):
584 not email_address or email_address == 'anonymous@rhodecode.org'):
571 f=lambda a,l:min(l,key=lambda x:abs(x-a))
585 f = lambda a, l: min(l, key=lambda x: abs(x - a))
572 return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30]))
586 return url("/images/user%s.png" % f(size, [14, 16, 20, 24, 30]))
573
587
574 ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
588 ssl_enabled = 'https' == request.environ.get('wsgi.url_scheme')
@@ -582,7 +596,7 b' def gravatar_url(email_address, size=30)'
582 email_address = safe_str(email_address)
596 email_address = safe_str(email_address)
583 # construct the url
597 # construct the url
584 gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?"
598 gravatar_url = baseurl + hashlib.md5(email_address.lower()).hexdigest() + "?"
585 gravatar_url += urllib.urlencode({'d':default, 's':str(size)})
599 gravatar_url += urllib.urlencode({'d': default, 's': str(size)})
586
600
587 return gravatar_url
601 return gravatar_url
588
602
@@ -611,7 +625,7 b' class RepoPage(Page):'
611 # The self.page is the number of the current page.
625 # The self.page is the number of the current page.
612 # The first page has the number 1!
626 # The first page has the number 1!
613 try:
627 try:
614 self.page = int(page) # make it int() if we get it as a string
628 self.page = int(page) # make it int() if we get it as a string
615 except (ValueError, TypeError):
629 except (ValueError, TypeError):
616 self.page = 1
630 self.page = 1
617
631
@@ -761,10 +775,10 b' def fancy_file_stats(stats):'
761 return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
775 return ' '.join(map(map_getter, ['tr', 'br', 'tl', 'bl']))
762
776
763 d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (
777 d_a = '<div class="added %s" style="width:%s%%">%s</div>' % (
764 cgen('a'),a_p, a_v
778 cgen('a'), a_p, a_v
765 )
779 )
766 d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (
780 d_d = '<div class="deleted %s" style="width:%s%%">%s</div>' % (
767 cgen('d'),d_p, d_v
781 cgen('d'), d_p, d_v
768 )
782 )
769 return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
783 return literal('<div style="width:%spx">%s%s</div>' % (width, d_a, d_d))
770
784
@@ -815,12 +829,12 b' def urlify_commit(text_, repository=None'
815 # urlify changesets
829 # urlify changesets
816 text_ = urlify_changesets(text_, repository)
830 text_ = urlify_changesets(text_, repository)
817
831
818 def linkify_others(t,l):
832 def linkify_others(t, l):
819 urls = re.compile(r'(\<a.*?\<\/a\>)',)
833 urls = re.compile(r'(\<a.*?\<\/a\>)',)
820 links = []
834 links = []
821 for e in urls.split(t):
835 for e in urls.split(t):
822 if not urls.match(e):
836 if not urls.match(e):
823 links.append('<a class="message-link" href="%s">%s</a>' % (l,e))
837 links.append('<a class="message-link" href="%s">%s</a>' % (l, e))
824 else:
838 else:
825 links.append(e)
839 links.append(e)
826
840
General Comments 0
You need to be logged in to leave comments. Login now