Beispiel #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
Beispiel #2
0
    def getlog(self, ctx, gnode):
        if ctx.rev() is None:
            msg = None
            if self.unicodestar:
                # The Unicode symbol is a black star:
                msg = u'\u2605 ' + _('Working Directory') + u' \u2605'
            else:
                msg = '*** ' + _('Working Directory') + ' ***'

            for pctx in ctx.parents():
                if self.repo._branchheads and pctx.node() not in self.repo._branchheads:
                    text = _('Not a head revision!')
                    msg += " " + qtlib.markup(text, fg='red', weight='bold')

            return msg

        msg = ctx.longsummary()

        if ctx.thgmqunappliedpatch():
            effects = qtlib.geteffect('log.unapplied_patch')
            text = qtlib.applyeffects(' %s ' % ctx._patchname, effects)
            # qtlib.markup(msg, fg=UNAPPLIED_PATCH_COLOR)
            msg = qtlib.markup(msg)
            return hglib.tounicode(text + ' ') + msg
        if ctx.hidden():
            return qtlib.markup(msg, fg=HIDDENREV_COLOR)

        parts = []
        if ctx.thgbranchhead():
            branchu = hglib.tounicode(ctx.branch())
            effects = qtlib.geteffect('log.branch')
            parts.append(qtlib.applyeffects(u' %s ' % branchu, effects))

        for mark in ctx.bookmarks():
            style = 'log.bookmark'
            if mark == self.repo._bookmarkcurrent:
                bn = self.repo._bookmarks[self.repo._bookmarkcurrent]
                if bn in self.repo.dirstate.parents():
                    style = 'log.curbookmark'
            marku = hglib.tounicode(mark)
            effects = qtlib.geteffect(style)
            parts.append(qtlib.applyeffects(u' %s ' % marku, effects))

        for tag in ctx.thgtags():
            if self.repo.thgmqtag(tag):
                style = 'log.patch'
            else:
                style = 'log.tag'
            tagu = hglib.tounicode(tag)
            effects = qtlib.geteffect(style)
            parts.append(qtlib.applyeffects(u' %s ' % tagu, effects))

        if msg:
            if ctx.thgwdparent():
                msg = qtlib.markup(msg, weight='bold')
            else:
                msg = qtlib.markup(msg)
            parts.append(hglib.tounicode(msg))

        return ' '.join(parts)
Beispiel #3
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
Beispiel #4
0
    def getlog(self, ctx, gnode):
        if ctx.rev() is None:
            msg = None
            if self.unicodestar:
                # The Unicode symbol is a black star:
                msg = u'\u2605 ' + _('Working Directory') + u' \u2605'
            else:
                msg = '*** ' + _('Working Directory') + ' ***'

            for pctx in ctx.parents():
                if self.repo._branchheads and pctx.node(
                ) not in self.repo._branchheads:
                    text = _('Not a head revision!')
                    msg += " " + qtlib.markup(text, fg='red', weight='bold')

            return msg

        msg = ctx.longsummary()

        if ctx.thgmqunappliedpatch():
            effects = qtlib.geteffect('log.unapplied_patch')
            text = qtlib.applyeffects(' %s ' % ctx._patchname, effects)
            # qtlib.markup(msg, fg=UNAPPLIED_PATCH_COLOR)
            msg = qtlib.markup(msg)
            return hglib.tounicode(text + ' ') + msg

        parts = []
        if ctx.thgbranchhead():
            branchu = hglib.tounicode(ctx.branch())
            effects = qtlib.geteffect('log.branch')
            parts.append(qtlib.applyeffects(u' %s ' % branchu, effects))

        for mark in ctx.bookmarks():
            style = 'log.bookmark'
            if mark == self.repo._bookmarkcurrent:
                bn = self.repo._bookmarks[self.repo._bookmarkcurrent]
                if bn in self.repo.dirstate.parents():
                    style = 'log.curbookmark'
            marku = hglib.tounicode(mark)
            effects = qtlib.geteffect(style)
            parts.append(qtlib.applyeffects(u' %s ' % marku, effects))

        for tag in ctx.thgtags():
            if self.repo.thgmqtag(tag):
                style = 'log.patch'
            else:
                style = 'log.tag'
            tagu = hglib.tounicode(tag)
            effects = qtlib.geteffect(style)
            parts.append(qtlib.applyeffects(u' %s ' % tagu, effects))

        if msg:
            if ctx.thgwdparent():
                msg = qtlib.markup(msg, weight='bold')
            else:
                msg = qtlib.markup(msg)
            parts.append(hglib.tounicode(msg))

        return ' '.join(parts)
Beispiel #5
0
 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)
Beispiel #6
0
 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)
Beispiel #7
0
    def getlog(self, ctx, gnode):
        if ctx.rev() is None:
            msg = None
            if self.unicodestar:
                # The Unicode symbol is a black star:
                msg = u"\u2605 " + _("Working Directory") + u" \u2605"
            else:
                msg = "*** " + _("Working Directory") + " ***"

            for pctx in ctx.parents():
                if self.repo._branchheads and pctx.node() not in self.repo._branchheads:
                    text = _("Not a head revision!")
                    msg += " " + qtlib.markup(text, fg="red", weight="bold")

            return msg

        msg = ctx.longsummary()

        if ctx.thgmqunappliedpatch():
            effects = qtlib.geteffect("log.unapplied_patch")
            text = qtlib.applyeffects(" %s " % ctx._patchname, effects)
            # qtlib.markup(msg, fg=UNAPPLIED_PATCH_COLOR)
            msg = qtlib.markup(msg)
            return hglib.tounicode(text + " ") + msg

        parts = []
        if ctx.thgbranchhead():
            branchu = hglib.tounicode(ctx.branch())
            effects = qtlib.geteffect("log.branch")
            parts.append(qtlib.applyeffects(u" %s " % branchu, effects))

        for mark in ctx.bookmarks():
            style = "log.bookmark"
            if mark == self.repo._bookmarkcurrent:
                bn = self.repo._bookmarks[self.repo._bookmarkcurrent]
                if bn in self.repo.dirstate.parents():
                    style = "log.curbookmark"
            marku = hglib.tounicode(mark)
            effects = qtlib.geteffect(style)
            parts.append(qtlib.applyeffects(u" %s " % marku, effects))

        for tag in ctx.thgtags():
            if self.repo.thgmqtag(tag):
                style = "log.patch"
            else:
                style = "log.tag"
            tagu = hglib.tounicode(tag)
            effects = qtlib.geteffect(style)
            parts.append(qtlib.applyeffects(u" %s " % tagu, effects))

        if msg:
            if ctx.thgwdparent():
                msg = qtlib.markup(msg, weight="bold")
            else:
                msg = qtlib.markup(msg)
            parts.append(hglib.tounicode(msg))

        return " ".join(parts)
Beispiel #8
0
 def updatestatus(self):
     items = self.cslist.curitems
     count = items and len(items) or 0
     countstr = qtlib.markup(_("%s patches") % count, weight='bold')
     if count:
         self.targetcombo.setVisible(True)
         text = _('%s will be imported to ') % countstr
     else:
         self.targetcombo.setVisible(False)
         text = qtlib.markup(_('Nothing to import'), weight='bold',
                             fg='red')
     self.status.setText(text)
Beispiel #9
0
 def updatestatus(self):
     items = self.cslist.curitems
     count = items and len(items) or 0
     countstr = qtlib.markup(_("%s patches") % count, weight='bold')
     if count:
         self.targetcombo.setVisible(True)
         text = _('%s will be imported to ') % countstr
     else:
         self.targetcombo.setVisible(False)
         text = qtlib.markup(_('Nothing to import'),
                             weight='bold',
                             fg='red')
     self.status.setText(text)
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
0
    def update(self, target=None, style=None, custom=None, repo=None):
        SummaryBase.update(self, target, custom, repo)

        if style is not None:
            self.csstyle = style

        if self.revlabel is None:
            self.revlabel = QLabel()
            self.revlabel.linkActivated.connect(self.linkActivated)
            self.layout().addWidget(self.revlabel, 0, Qt.AlignTop)

        if 'expandable' in self.csstyle and self.csstyle['expandable']:
            if self.expand_btn.parentWidget() is None:
                self.expand_btn.clicked.connect(lambda: self.update())
                margin = QHBoxLayout()
                margin.setMargin(3)
                margin.addWidget(self.expand_btn, 0, Qt.AlignTop)
                self.layout().insertLayout(0, margin)
            self.expand_btn.setShown(True)
        elif self.expand_btn.parentWidget() is not None:
            self.expand_btn.setHidden(True)

        interact = Qt.LinksAccessibleByMouse

        if 'selectable' in self.csstyle and self.csstyle['selectable']:
            interact |= Qt.TextBrowserInteraction

        self.revlabel.setTextInteractionFlags(interact)

        # build info
        contents = self.csstyle.get('contents', ())
        if 'expandable' in self.csstyle and self.csstyle['expandable'] \
                                        and self.expand_btn.is_collapsed():
            contents = contents[0:1]

        if 'margin' in self.csstyle:
            margin = self.csstyle['margin']
            assert isinstance(margin, (int, long))
            buf = '<table style="margin: %spx">' % margin
        else:
            buf = '<table>'

        for item in contents:
            markups = self.get_markup(item)
            if not markups:
                continue
            label = qtlib.markup(self.get_label(item), weight='bold')
            if isinstance(markups, basestring):
                markups = [
                    markups,
                ]
            buf += PANEL_TMPL % (label, markups.pop(0))
            for markup in markups:
                buf += PANEL_TMPL % ('&nbsp;', markup)
        buf += '</table>'
        self.revlabel.setText(buf)

        return True
Beispiel #13
0
 def preset_func(widget, item, value):
     if item == "rev":
         revnum, revid = value
         revid = qtlib.markup(revid, **mono)
         if revnum is not None and revid is not None:
             return "%s (%s)" % (revnum, revid)
         return "%s" % revid
     elif item in ("revid", "graft", "transplant"):
         return qtlib.markup(value, **mono)
     elif item in ("revnum", "p4", "close", "converted"):
         return str(value)
     elif item == "svn":
         # svn is always in utf-8 because ctx.extra() isn't converted
         return unicode(value, "utf-8", "replace")
     elif item in ("rawbranch", "branch"):
         opts = dict(fg="black", bg="#aaffaa")
         return qtlib.markup(" %s " % value, **opts)
     elif item in ("rawtags", "tags"):
         opts = dict(fg="black", bg="#ffffaa")
         tags = [qtlib.markup(" %s " % tag, **opts) for tag in value]
         return " ".join(tags)
     elif item in ("desc", "summary", "user", "shortuser", "date", "age"):
         return qtlib.markup(value)
     elif item == "dateage":
         return qtlib.markup("%s (%s)" % value)
     elif item == "obsolete":
         opts = dict(fg="black", bg="#ff8566")
         obsoletestates = [qtlib.markup(" %s " % state, **opts) for state in value]
         return " ".join(obsoletestates)
     raise UnknownItem(item)
Beispiel #14
0
 def preset_func(widget, item, value):
     if item == 'rev':
         revnum, revid = value
         revid = qtlib.markup(revid, **mono)
         if revnum is not None and revid is not None:
             return '%s (%s)' % (revnum, revid)
         return '%s' % revid
     elif item in ('revid', 'graft', 'transplant'):
         return qtlib.markup(value, **mono)
     elif item in ('revnum', 'p4', 'close', 'converted'):
         return str(value)
     elif item == 'svn':
         # svn is always in utf-8 because ctx.extra() isn't converted
         return unicode(value, 'utf-8', 'replace')
     elif item in ('rawbranch', 'branch'):
         opts = dict(fg='black', bg='#aaffaa')
         return qtlib.markup(' %s ' % value, **opts)
     elif item in ('rawtags', 'tags'):
         opts = dict(fg='black', bg='#ffffaa')
         tags = [qtlib.markup(' %s ' % tag, **opts) for tag in value]
         return ' '.join(tags)
     elif item in ('desc', 'summary', 'user', 'shortuser', 'date',
                   'age'):
         return qtlib.markup(value)
     elif item == 'dateage':
         return qtlib.markup('%s (%s)' % value)
     elif item == 'obsolete':
         opts = dict(fg='black', bg='#ff8566')
         obsoletestates = [
             qtlib.markup(' %s ' % state, **opts) for state in value
         ]
         return ' '.join(obsoletestates)
     raise UnknownItem(item)
Beispiel #15
0
 def preset_func(widget, item, value):
     if item == 'rev':
         revnum, revid = value
         revid = qtlib.markup(revid, **mono)
         if revnum is not None and revid is not None:
             return '%s (%s)' % (revnum, revid)
         return '%s' % revid
     elif item in ('revid', 'graft', 'transplant', 'mqoriginalparent'):
         return qtlib.markup(value, **mono)
     elif item in ('revnum', 'p4', 'close', 'converted'):
         return str(value)
     elif item == 'svn':
         # svn is always in utf-8 because ctx.extra() isn't converted
         return unicode(value, 'utf-8', 'replace')
     elif item in ('rawbranch', 'branch'):
         opts = dict(fg='black', bg='#aaffaa')
         return qtlib.markup(' %s ' % value, **opts)
     elif item == 'tags':
         opts = dict(fg='black', bg='#ffffaa')
         tags = [qtlib.markup(' %s ' % tag, **opts) for tag in value]
         return ' '.join(tags)
     elif item in ('desc', 'summary', 'user', 'shortuser',
                   'date', 'age'):
         return qtlib.markup(value)
     elif item == 'dateage':
         return qtlib.markup('%s (%s)' % value)
     elif item == 'obsolete':
         opts = dict(fg='black', bg='#ff8566')
         obsoletestates = [qtlib.markup(' %s ' % state, **opts)
                           for state in value]
         return ' '.join(obsoletestates)
     raise UnknownItem(item)
Beispiel #16
0
 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)
Beispiel #17
0
    def update(self, target=None, style=None, custom=None, repo=None):
        SummaryBase.update(self, target, custom, repo)

        if style is not None:
            self.csstyle = style

        if self.revlabel is None:
            self.revlabel = QLabel()
            self.revlabel.linkActivated.connect(
                 lambda s: self.linkActivated.emit(s))
            self.layout().addWidget(self.revlabel, alignment=Qt.AlignTop)

        if 'expandable' in self.csstyle and self.csstyle['expandable']:
            if self.expand_btn.parentWidget() is None:
                self.expand_btn.clicked.connect(lambda: self.update())
                margin = QHBoxLayout()
                margin.setMargin(3)
                margin.addWidget(self.expand_btn, alignment=Qt.AlignTop)
                self.layout().insertLayout(0, margin)
            self.expand_btn.setShown(True)
        elif self.expand_btn.parentWidget() is not None:
            self.expand_btn.setHidden(True)

        interact = Qt.LinksAccessibleByMouse

        if 'selectable' in self.csstyle and self.csstyle['selectable']:
            interact |= Qt.TextBrowserInteraction

        self.revlabel.setTextInteractionFlags(interact)

        # build info
        contents = self.csstyle.get('contents', ())
        if 'expandable' in self.csstyle and self.csstyle['expandable'] \
                                        and self.expand_btn.is_collapsed():
            contents = contents[0:1]

        if 'margin' in self.csstyle:
            margin = self.csstyle['margin']
            assert isinstance(margin, (int, long))
            buf = '<table style="margin: %spx">' % margin
        else:
            buf = '<table>'

        for item in contents:
            markups = self.get_markup(item)
            if not markups:
                continue
            label = qtlib.markup(self.get_label(item), weight='bold')
            if isinstance(markups, basestring):
                markups = [markups,]
            buf += PANEL_TMPL % (label, markups.pop(0))
            for markup in markups:
                buf += PANEL_TMPL % ('&nbsp;', markup)
        buf += '</table>'
        self.revlabel.setText(buf)

        return True
Beispiel #18
0
 def preview(self):
     if self.updatecslist():
         striprevs = self.cslist.curitems
         cstext = _("<b>%d changesets</b> will be stripped") % len(striprevs)
         self.status.setText(cstext)
         self.strip_btn.setEnabled(True)
     else:
         self.cslist.clear()
         self.cslist.updatestatus()
         cstext = qtlib.markup(_('Unknown revision!'), fg='red',
                               weight='bold')
         self.status.setText(cstext)
         self.strip_btn.setDisabled(True)
Beispiel #19
0
    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)
Beispiel #20
0
 def preview(self):
     if self.updatecslist():
         striprevs = self.cslist.curitems
         cstext = ngettext(
             "<b>%d changeset</b> will be stripped",
             "<b>%d changesets</b> will be stripped",
             len(striprevs)) % len(striprevs)
         self.status.setText(cstext)
     else:
         self.cslist.clear()
         self.cslist.updatestatus()
         cstext = qtlib.markup(_('Unknown revision!'), fg='red',
                               weight='bold')
         self.status.setText(cstext)
     self.commandChanged.emit()
Beispiel #21
0
 def preview(self):
     if self.updatecslist():
         striprevs = self.cslist.curitems
         cstext = ngettext("<b>%d changeset</b> will be stripped",
                           "<b>%d changesets</b> will be stripped",
                           len(striprevs)) % len(striprevs)
         self.status.setText(cstext)
         self.strip_btn.setEnabled(True)
     else:
         self.cslist.clear()
         self.cslist.updatestatus()
         cstext = qtlib.markup(_('Unknown revision!'),
                               fg='red',
                               weight='bold')
         self.status.setText(cstext)
         self.strip_btn.setDisabled(True)
Beispiel #22
0
def revid_markup(revid, **kargs):
    opts = dict(family='monospace', size='9pt')
    opts.update(kargs)
    return qtlib.markup(revid, **opts)
Beispiel #23
0
 def branch_markup(branch):
     opts = dict(fg='black', bg='#aaffaa')
     return qtlib.markup(' %s ' % branch, **opts)
Beispiel #24
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)
Beispiel #25
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)
Beispiel #26
0
def revid_markup(revid, **kargs):
    opts = dict(family='monospace', size='9pt')
    opts.update(kargs)
    return qtlib.markup(revid, **opts)
Beispiel #27
0
 def branch_markup(branch):
     opts = dict(fg='black', bg='#aaffaa')
     return qtlib.markup(' %s ' % branch, **opts)
Beispiel #28
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)
Beispiel #29
0
 def branch_markup(branch):
     opts = dict(fg="black", bg="#aaffaa")
     return qtlib.markup(" %s " % branch, **opts)
Beispiel #30
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)
Beispiel #31
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)