def link(self, view_name): """The link to the diff should show the line count. Stale diffs will have a stale-diff css class. Diffs with conflicts will have a conflict-diff css class. Diffs with neither will have clean-diff css class. The title of the diff will show the number of lines added or removed if available. :param view_name: If not None, the link will point to the page with that name on this object. """ diff = self._context conflict_text = '' if diff.has_conflicts: conflict_text = _(' (has conflicts)') count_text = '' added = diff.added_lines_count removed = diff.removed_lines_count if (added is not None and removed is not None): count_text = ' (+%d/-%d)' % (added, removed) file_text = '' diffstat = diff.diffstat if diffstat is not None: file_count = len(diffstat) basic_file_text = get_plural_text(file_count, _('%d file modified'), _('%d files modified')) basic_file_text = basic_file_text % file_count diffstat_text = '<br/>'.join( structured('%s (+%s/-%s)', path, added, removed).escapedtext for path, (added, removed) in sorted(diffstat.items())) file_text = ( '<div class="collapsible"><span>%s</span><div>%s</div></div>' % (basic_file_text, diffstat_text)) args = { 'line_count': _('%s lines') % diff.diff_lines_count, 'conflict_text': conflict_text, 'count_text': count_text, 'url': self.url(view_name), } # Under normal circumstances, there will be an associated file, # however if the diff is empty, then there is no alias to link to. if args['url'] is None: return structured( '<span class="empty-diff">' '%(line_count)s</span>', **args).escapedtext else: return structured( '<a href="%(url)s" class="diff-link">' '%(line_count)s%(count_text)s%(conflict_text)s' '</a>', **args).escapedtext + file_text
def link(self, view_name): """The link to the diff should show the line count. Stale diffs will have a stale-diff css class. Diffs with conflicts will have a conflict-diff css class. Diffs with neither will have clean-diff css class. The title of the diff will show the number of lines added or removed if available. :param view_name: If not None, the link will point to the page with that name on this object. """ diff = self._context conflict_text = '' if diff.has_conflicts: conflict_text = _(' (has conflicts)') count_text = '' added = diff.added_lines_count removed = diff.removed_lines_count if (added is not None and removed is not None): count_text = ' (+%d/-%d)' % (added, removed) file_text = '' diffstat = diff.diffstat if diffstat is not None: file_count = len(diffstat) file_text = get_plural_text( file_count, _(' %d file modified'), _(' %d files modified')) file_text = file_text % file_count args = { 'line_count': _('%s lines') % diff.diff_lines_count, 'file_text': file_text, 'conflict_text': conflict_text, 'count_text': count_text, 'url': self.url(view_name), } # Under normal circumstances, there will be an associated file, # however if the diff is empty, then there is no alias to link to. if args['url'] is None: return ( '<span class="empty-diff">' '%(line_count)s</span>' % args) else: return ( '<a href="%(url)s" class="diff-link">' '%(line_count)s%(count_text)s%(file_text)s%(conflict_text)s' '</a>' % args)
def link(self, view_name): """The link to the diff should show the line count. Stale diffs will have a stale-diff css class. Diffs with conflicts will have a conflict-diff css class. Diffs with neither will have clean-diff css class. The title of the diff will show the number of lines added or removed if available. :param view_name: If not None, the link will point to the page with that name on this object. """ diff = self._context conflict_text = '' if diff.has_conflicts: conflict_text = _(' (has conflicts)') count_text = '' added = diff.added_lines_count removed = diff.removed_lines_count if (added is not None and removed is not None): count_text = ' (+%d/-%d)' % (added, removed) file_text = '' diffstat = diff.diffstat if diffstat is not None: file_count = len(diffstat) file_text = get_plural_text(file_count, _(' %d file modified'), _(' %d files modified')) file_text = file_text % file_count args = { 'line_count': _('%s lines') % diff.diff_lines_count, 'file_text': file_text, 'conflict_text': conflict_text, 'count_text': count_text, 'url': self.url(view_name), } # Under normal circumstances, there will be an associated file, # however if the diff is empty, then there is no alias to link to. if args['url'] is None: return ('<span class="empty-diff">' '%(line_count)s</span>' % args) else: return ( '<a href="%(url)s" class="diff-link">' '%(line_count)s%(count_text)s%(file_text)s%(conflict_text)s' '</a>' % args)
def team_text(self): return get_plural_text(self.team_owner_count, _('team'), _('teams'))
def person_text(self): return get_plural_text( self.person_owner_count, _('person'), _('people'))
def branch_text(self): return get_plural_text( self.branch_count, _('active branch'), _('active branches'))
def committer_text(self): return get_plural_text(self.committer_count, _('person'), _('people'))
def branch_text(self): return get_plural_text(self.branch_count, _('active branch'), _('active branches'))
def person_text(self): return get_plural_text(self.person_owner_count, _('person'), _('people'))
def word_differences_count(count): """Express "`count` differences" in words. For example, "1 package", or "2 packages" and so on. """ return get_plural_text(count, "%d package", "%d packages") % count
def mergequeues(self): return Link('+merge-queues', get_plural_text(self.mergequeue_count, 'merge queue', 'merge queues'), site='code')
def commit_text(self): return get_plural_text(self.commit_count, _('commit'), _('commits'))
def mergequeues(self): return Link("+merge-queues", get_plural_text(self.mergequeue_count, "merge queue", "merge queues"), site="code")