Exemplo n.º 1
0
 def grep_wait(self, thread, q, model, search_hbox, regexp, frame):
     """
     Handle all the messages currently in the queue (if any).
     """
     text = ''
     while q.qsize():
         data, label = q.get(0)
         data = gtklib.markup_escape_text(hglib.toutf(data))
         if label == 'grep.match':
             text += '<span foreground="red"><b>%s</b></span>' % data
         else:
             text += data
     
     for line in text.splitlines():
         try:
             (path, revid, text) = line.split(':', 2)
             desc, user = self.get_rev_desc(long(revid))
         except ValueError:
             continue
         if self.tabwidth:
             text = text.expandtabs(self.tabwidth)
         model.append((revid, text, desc, hglib.toutf(path)))
     if thread.isAlive():
         return True
     else:
         if threading.activeCount() == 1:
             self.stop_button.set_sensitive(False)
         frame._mythread = None
         search_hbox.set_sensitive(True)
         regexp.grab_focus()
         self.stbar.end()
         return False
Exemplo n.º 2
0
 def get_rev_desc(self, rev):
     if rev in self.changedesc:
         return self.changedesc[rev]
     ctx = self.repo[rev]
     author = hglib.toutf(hglib.username(ctx.user()))
     date = hglib.toutf(hglib.displaytime(ctx.date()))
     text = hglib.tounicode(ctx.description()).replace(u'\0', '')
     lines = text.splitlines()
     summary = hglib.toutf(lines and lines[0] or '')
     desc = gtklib.markup_escape_text('%s@%s %s "%s"' % \
                                      (author, rev, date, summary))
     self.changedesc[rev] = (desc, author)
     return self.changedesc[rev]
Exemplo n.º 3
0
    def refresh(self):
        """
        Refresh the list of patches.
        This operation will try to keep selection state.
        """
        if not self.mqloaded:
            return

        # store selected patch name
        selname = None
        model, paths = self.list.get_selection().get_selected_rows()
        if len(paths) > 0:
            selname = model[paths[0]][MQ_NAME]

        # clear model data
        self.model.clear()

        # insert 'qparent' row
        top = None
        if self.get_property('show-qparent'):
            top = self.model.append((INDEX_QPARENT, None, None, None, None))

        # add patches
        from hgext import mq
        q = self.repo.mq
        q.parse_series()
        applied = set([p.name for p in q.applied])
        for index, patchname in enumerate(q.series):
            stat = patchname in applied and 'A' or 'U'
            try:
                msg = hglib.toutf(mq.patchheader(q.join(patchname)).message[0])
                msg_esc = gtklib.markup_escape_text(msg)
            except IndexError:
                msg = msg_esc = None
            iter = self.model.append((index, stat, patchname, msg, msg_esc))
            if stat == 'A':
                top = iter

        # insert separator
        if top:
            row = self.model.insert_after(top, (INDEX_SEPARATOR, None, None, None, None))
            self.separator_pos = self.model.get_path(row)[0]

        # restore patch selection
        if selname:
            iter = self.get_iter_by_patchname(selname)
            if iter:
                self.list.get_selection().select_iter(iter)

        # update UI sensitives
        self.update_sensitives()
Exemplo n.º 4
0
    def set_result(self, text, style=None):
        """
        Put text message and icon in the progress bar.

        style: String. If passed 'succeed', 'green' or 'ok', green
               text and succeed icon will be shown.  If passed 'error',
               'failed', 'fail' or 'red', red text and error icon will be shown.
        """
        markup = '<span foreground="%s" weight="%s">%%s</span>'
        if style in ('succeed', 'green', 'ok'):
            markup = markup % (gtklib.DGREEN, 'bold')
            icons = {'succeed': True}
        elif style in ('error', 'failed', 'fail', 'red'):
            markup = markup % (gtklib.DRED, 'bold')
            icons = {'error': True}
        else:
            markup = markup % (gtklib.NORMAL, 'normal')
            icons = {}
        text = gtklib.markup_escape_text(text)
        self.rlabel.set_markup(markup % text)
        self.set_icons(**icons)
Exemplo n.º 5
0
    def refresh(self):
        """
        Refresh the list of patches.
        This operation will try to keep selection state.
        """
        if not self.pbranch:
            return

        # store selected patch name
        selname = None
        model, paths = self.list.get_selection().get_selected_rows()
        if len(paths) > 0:
            selname = model[paths[0]][M_NAME]

        # compute model data
        self.model.clear()
        opts = {'tips': True}
        mgr = self.pbranch.patchmanager(self.repo.ui, self.repo, opts)
        graph = mgr.graphforopts(opts)
        if not self.get_property('show-internal-branches'):
            graph = mgr.patchonlygraph(graph)
        names = None
        patch_list = graph.topolist(names)
        in_lines = []
        if patch_list:
            dep_list = [patch_list[0]]
        cur_branch = self.repo['.'].branch()
        patch_status = {}
        for name in patch_list:
            patch_status[name] = self.pstatus(name)
        for name in patch_list:
            parents = graph.deps(name)

            # Node properties
            if name in dep_list: 
                node_column = dep_list.index(name)
            else:
                node_column = len(dep_list)
            node_colour = patch_status[name] and '#ff0000' or 0
            node_status = (name == cur_branch) and 4 or 0
            node = (node_column, node_colour, node_status)
            
            # Find next dependency list
            my_deps = []
            for p in parents:
                if p not in dep_list:
                    my_deps.append(p)
            next_dep_list = dep_list[:]
            next_dep_list[node_column:node_column+1] = my_deps
            
            # Dependency lines
            shift = len(parents) - 1
            out_lines = []
            for p in parents:
                dep_column = next_dep_list.index(p)
                colour = 0 # black
                if patch_status[p]:
                    colour = '#ff0000' # red
                style = 0 # solid lines
                out_lines.append((node_column, dep_column, colour, style))
            for lines in in_lines:
                (start_column, end_column, colour, style) = lines
                if end_column == node_column:
                    # Deps to current patch end here
                    pass
                else:
                    # Find line continuations
                    dep = dep_list[end_column]
                    dep_column = next_dep_list.index(dep)
                    out_lines.append((end_column, dep_column, colour, style))
                    
            stat = patch_status[name] and 'M' or 'C' # patch status
            patchname = name
            msg = self.pmessage(name) # summary
            if msg:
                msg_esc = gtklib.markup_escape_text(msg) # escaped summary (utf-8)
                title = msg.split('\n')[0]
            else:
                msg_esc = None
                title = None
            self.model.append((node, in_lines, out_lines, patchname, stat,
                               title, msg, msg_esc))
            # Loop
            in_lines = out_lines
            dep_list = next_dep_list


        # restore patch selection
        if selname:
            iter = self.get_iter_by_patchname(selname)
            if iter:
                self.list.get_selection().select_iter(iter)

        # update UI sensitives
        self.update_sensitives()

        # report status
        status_text = ''
        idle_text = None
        if self.has_patch():
            status_text = self.pending_merges() \
                and _('pending pmerges') \
                or _('no pending pmerges')
        self.statusbar.set_text(status_text, 'pbranch')
        self.statusbar.set_idle_text(idle_text)