Esempio n. 1
0
def nomarkup(widget, item, value):
    def revline_markup(revnum, revid, summary, highlight=None, branch=None):
        summary = qtlib.markup(summary)
        if revid:
            rev = revid_markup('%s (%s)' % (revnum, revid))
            return '%s %s' % (rev, summary)
        else:
            revnum = qtlib.markup(revnum)
            return '%s - %s' % (revnum, summary)

    csets = []
    if item == 'ishead':
        if value is False:
            text = _('Not a head revision!')
            return qtlib.markup(text, fg='red', weight='bold')
        raise csinfo.UnknownItem(item)
    elif item == 'isclose':
        if value is True:
            text = _('Head is closed!')
            return qtlib.markup(text, fg='red', weight='bold')
        raise csinfo.UnknownItem(item)
    for cset in value:
        if isinstance(cset, basestring):
            csets.append(revid_markup(cset))
        else:
            csets.append(revline_markup(*cset))
    return csets
Esempio n. 2
0
        def markup_func(widget, item, value):
            if item == 'rev':
                text, rev = value
                if self.wizard() and self.wizard().parentbackout:
                    return '%s (%s)' % (text, rev)
                else:
                    return '<a href="view">%s</a> (%s)' % (text, rev)
            elif item == 'parents':

                def branch_markup(branch):
                    opts = dict(fg='black', bg='#aaffaa')
                    return qtlib.markup(' %s ' % branch, **opts)

                csets = []
                for rnum, rid, branch, pctx in value:
                    line = '%s (%s)' % (rnum, rid)
                    if branch:
                        line = '%s %s' % (line, branch_markup(branch))
                    msg = widget.info.get_data('summary', widget, pctx,
                                               widget.custom)
                    if msg:
                        line = '%s %s' % (line, msg)
                    csets.append(line)
                return csets
            raise csinfo.UnknownItem()
Esempio n. 3
0
 def datafunc(widget, item, ctx):
     if item in ('item', 'item_l'):
         if not isinstance(ctx, patchctx):
             return True
         revid = widget.get_data('revid')
         if not revid:
             return widget.target
         filename = os.path.basename(widget.target)
         return filename, revid
     raise csinfo.UnknownItem(item)
Esempio n. 4
0
def label_func(widget, item, ctx):
    if item == 'cset':
        if type(ctx.rev()) is str:
            return _('Patch:')
        return _('Changeset:')
    elif item == 'parents':
        return _('Parent:')
    elif item == 'children':
        return _('Child:')
    elif item == 'patch':
        return _('Patch:')
    raise csinfo.UnknownItem(item)
Esempio n. 5
0
 def data_func(widget, item, ctx):
     if item == 'rev':
         return _('Working Directory'), str(ctx)
     elif item == 'parents':
         parents = []
         cbranch = ctx.branch()
         for pctx in ctx.parents():
             branch = None
             if hasattr(pctx, 'branch') and pctx.branch() != cbranch:
                 branch = pctx.branch()
             parents.append((str(pctx.rev()), str(pctx), branch, pctx))
         return parents
     raise csinfo.UnknownItem()
Esempio n. 6
0
 def markupfunc(widget, item, value):
     if item in ('item', 'item_l'):
         if not isinstance(widget.ctx, patchctx):
             if item == 'item':
                 return widget.get_markup('rev')
             return widget.get_markup('revnum')
         mono = dict(face='monospace', size='9000')
         if isinstance(value, basestring):
             return qtlib.markup(value, **mono)
         filename = qtlib.markup(value[0])
         revid = qtlib.markup(value[1], **mono)
         if item == 'item':
             return '%s (%s)' % (filename, revid)
         return filename
     raise csinfo.UnknownItem(item)
Esempio n. 7
0
def markup_func(widget, item, value):
    def link_markup(revnum, revid, enable=True):
        mrevid = revid_markup('%s (%s)' % (revnum, revid))
        if not enable:
            return mrevid
        link = 'cset:%s' % revid
        return '<a href="%s">%s</a>' % (link, mrevid)

    def revline_markup(revnum,
                       revid,
                       summary,
                       highlight=None,
                       branch=None,
                       link=True):
        def branch_markup(branch):
            opts = dict(fg='black', bg='#aaffaa')
            return qtlib.markup(' %s ' % branch, **opts)

        summary = qtlib.markup(summary)
        if branch:
            branch = branch_markup(branch)
        if revid:
            rev = link_markup(revnum, revid, link)
            if branch:
                return '%s %s %s' % (rev, branch, summary)
            return '%s %s' % (rev, summary)
        else:
            revnum = qtlib.markup(revnum)
            if branch:
                return '%s - %s %s' % (revnum, branch, summary)
            return '%s - %s' % (revnum, summary)

    if item in ('cset', 'graft', 'transplant', 'patch', 'p4', 'svn',
                'converted'):
        link = item != 'cset'
        if isinstance(value, basestring):
            return revid_markup(value)
        return revline_markup(link=link, *value)
    elif item in ('parents', 'children'):
        csets = []
        for cset in value:
            if isinstance(cset, basestring):
                csets.append(revid_markup(cset))
            else:
                csets.append(revline_markup(*cset))
        return csets
    raise csinfo.UnknownItem(item)
Esempio n. 8
0
 def label_func(widget, item, ctx):
     if item == 'rev':
         return _('Revision:')
     elif item == 'parents':
         return _('Parents')
     raise csinfo.UnknownItem()
Esempio n. 9
0
 def markup_func(widget, item, value):
     if item == 'ishead' and value is False:
         text = _('Not a head, backout will create a new head!')
         return qtlib.markup(text, fg='red', weight='bold')
     raise csinfo.UnknownItem(item)
Esempio n. 10
0
 def labelfunc(widget, item, ctx):
     if item in ('item', 'item_l'):
         if not isinstance(ctx, patchctx):
             return _('Revision:')
         return _('Patch:')
     raise csinfo.UnknownItem(item)
Esempio n. 11
0
def data_func(widget, item, ctx):
    def summary_line(desc):
        desc = desc.replace('\0', '').split('\n')[0]
        return hglib.tounicode(desc)[:80]

    def revline_data(ctx, hl=False, branch=None):
        if isinstance(ctx, basestring):
            return ctx
        desc = ctx.description()
        return (str(ctx.rev()), str(ctx), summary_line(desc), hl, branch)

    if item == 'cset':
        return revline_data(ctx)
    elif item == 'branch':
        value = hglib.tounicode(ctx.branch())
        return value != 'default' and value or None
    elif item == 'parents':
        # TODO: need to put 'diff to other' checkbox
        #pindex = self.diff_other_parent() and 1 or 0
        pindex = 0  # always show diff with first parent
        pctxs = ctx.parents()
        parents = []
        for pctx in pctxs:
            highlight = len(pctxs) == 2 and pctx == pctxs[pindex]
            branch = None
            if hasattr(pctx, 'branch') and pctx.branch() != ctx.branch():
                branch = pctx.branch()
            parents.append(revline_data(pctx, highlight, branch))
        return parents
    elif item == 'children':
        children = []
        for cctx in ctx.children():
            branch = None
            if hasattr(cctx, 'branch') and cctx.branch() != ctx.branch():
                branch = cctx.branch()
            children.append(revline_data(cctx, branch=branch))
        return children
    elif item in ('graft', 'transplant', 'p4', 'svn', 'converted'):
        ts = widget.get_data(item, usepreset=True)
        if not ts:
            return None
        try:
            tctx = ctx._repo[ts]
            return revline_data(tctx)
        except (error.LookupError, error.RepoLookupError, error.RepoError):
            return ts
    elif item == 'patch':
        if hasattr(ctx, '_patchname'):
            desc = ctx.description()
            return (ctx._patchname, str(ctx), summary_line(desc))
        return None
    elif item == 'ishead':
        if ctx.rev() is None:
            ctx = ctx.p1()
        childbranches = [cctx.branch() for cctx in ctx.children()]
        return ctx.branch() not in childbranches
    elif item == 'isclose':
        if ctx.rev() is None:
            ctx = ctx.p1()
        return ctx.extra().get('close') is not None
    raise csinfo.UnknownItem(item)
Esempio n. 12
0
 def markup_func(widget, item, value):
     if item == 'ishead' and value is False:
         text = _('Not a head revision!')
         return qtlib.markup(text, fg='red', weight='bold')
     raise csinfo.UnknownItem(item)