Example #1
0
    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
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
 def team_text(self):
     return get_plural_text(self.team_owner_count, _('team'), _('teams'))
Example #5
0
 def person_text(self):
     return get_plural_text(
         self.person_owner_count, _('person'), _('people'))
Example #6
0
 def branch_text(self):
     return get_plural_text(
         self.branch_count, _('active branch'), _('active branches'))
Example #7
0
 def committer_text(self):
     return get_plural_text(self.committer_count, _('person'), _('people'))
Example #8
0
 def team_text(self):
     return get_plural_text(self.team_owner_count, _('team'), _('teams'))
Example #9
0
 def branch_text(self):
     return get_plural_text(self.branch_count, _('active branch'),
                            _('active branches'))
Example #10
0
 def person_text(self):
     return get_plural_text(self.person_owner_count, _('person'),
                            _('people'))
Example #11
0
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
Example #12
0
 def mergequeues(self):
     return Link('+merge-queues',
                 get_plural_text(self.mergequeue_count, 'merge queue',
                                 'merge queues'),
                 site='code')
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
Example #14
0
 def commit_text(self):
     return get_plural_text(self.commit_count, _('commit'), _('commits'))
Example #15
0
 def commit_text(self):
     return get_plural_text(self.commit_count, _('commit'), _('commits'))
Example #16
0
 def committer_text(self):
     return get_plural_text(self.committer_count, _('person'), _('people'))
 def mergequeues(self):
     return Link("+merge-queues", get_plural_text(self.mergequeue_count, "merge queue", "merge queues"), site="code")