~bialix/qbzr/code-layout

« back to all changes in this revision

Viewing changes to lib/revisionmessagebrowser.py

  • Committer: Alexander Belchenko
  • Date: 2009-11-19 16:12:57 UTC
  • mfrom: (1109.1.4 Bug-485314)
  • Revision ID: bialix@ukr.net-20091119161257-t2f8bk1mt1mlvw2n
revisionmessagebrowser.py: restore view of branch nick, tags, and list of fixed bugs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
from bzrlib.plugins.qbzr.lib.logwidget import LogList
51
51
''')
52
52
 
 
53
 
53
54
def htmlencode(string):
54
55
    return "<br/>".join(
55
56
           string.replace("&", "&amp;")
58
59
                 .replace("\"", "&quot;")
59
60
                 .splitlines())
60
61
 
 
62
 
61
63
_email_re = lazy_regex.lazy_compile(r'([a-z0-9_\-.+]+@[a-z0-9_\-.+]+)', re.IGNORECASE)
62
64
_link1_re = lazy_regex.lazy_compile(r'([\s>])(https?)://([^\s<>{}()]+[^\s.,<>{}()])', re.IGNORECASE)
63
65
_link2_re = lazy_regex.lazy_compile(r'(\s)www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^ <>{}()\n\r]*[^., <>{}()\n\r]?)?)', re.IGNORECASE)
64
66
_tag_re = lazy_regex.lazy_compile(r'[, ]')
65
67
_start_of_line_whitespace_re = lazy_regex.lazy_compile(r'(?m)^ +')
66
68
 
 
69
 
67
70
def htmlize(text):
68
71
    text = htmlencode(text)
69
72
    text = _start_of_line_whitespace_re.sub(lambda m: "&nbsp;" * len(m.group()), text)
73
76
    text = _link2_re.sub('\\1<a href="http://www.\\2.\\3\\4">www.\\2.\\3\\4</a>', text)
74
77
    return text
75
78
 
 
79
 
 
80
def quote_tag(tag):
 
81
    if _tag_re.search(tag):
 
82
        return '"%s"' % tag
 
83
    return tag
 
84
 
 
85
 
76
86
class RevisionMessageBrowser(QtGui.QTextBrowser):
77
87
    """Widget to display revision metadata and messages."""
78
88
    
81
91
        _display_revids = []
82
92
        _all_loaded_revs = {}
83
93
 
84
 
        
85
94
        boxsize = self.fontMetrics().ascent()
86
95
        center = boxsize * 0.5
87
96
        dotsize = 0.7
218
227
                             '</tr>') % prop)
219
228
            text.append('</table>')
220
229
            
221
 
        
222
230
            text.append('<div style="margin-top:0.5em; '
223
231
                                    'margin-left:%spx;">%s</div>' 
224
232
                        % (margin_left + 2 , message))
244
252
            authors = rev.properties.get('author')
245
253
        if authors:
246
254
            props.append((gettext("Author:"), htmlize(authors)))
247
 
        
 
255
 
 
256
        branch_nick = rev.properties.get('branch-nick')
 
257
        if branch_nick:
 
258
            props.append((gettext("Branch:"), htmlize(branch_nick)))
 
259
 
 
260
        tags = self.get_tags(rev.revision_id)
 
261
        if tags:
 
262
            tags = map(quote_tag, tags)
 
263
            props.append((gettext("Tags:"), htmlencode(", ".join(tags))))
 
264
 
 
265
        bugs = []
 
266
        for bug in rev.properties.get('bugs', '').split('\n'):
 
267
            if bug:
 
268
                url, status = bug.split(' ', 1)
 
269
                bugs.append('<a href="%(url)s">%(url)s</a> %(status)s' % (
 
270
                    dict(url=url, status=gettext(status))))
 
271
        if bugs:
 
272
            props.append((ngettext("Bug:", "Bugs:", len(bugs)), ", ".join(bugs)))
 
273
 
248
274
        foreign_attribs = None
249
275
        if isinstance(rev, foreign.ForeignRevision):
250
276
            foreign_attribs = \
291
317
        # Normaly, we don't know how to do this.
292
318
        return None
293
319
 
 
320
    def get_tags(self, revid):
 
321
        return None
 
322
 
294
323
    def setSource(self, uri):
295
324
        pass
296
 
    
 
325
 
297
326
 
298
327
class LogListRevisionMessageBrowser(RevisionMessageBrowser):
299
328
    """RevisionMessageBrowser customized to work with LogList"""
300
 
    
301
329
 
302
 
    
303
330
    def __init__(self, log_list, parent=None):
304
331
        super(LogListRevisionMessageBrowser, self).__init__(parent)
305
332
        self.log_list = log_list
350
377
 
351
378
    def get_color(self, revid):
352
379
        return self.log_list.graph_provider.revid_rev[revid].color
 
380
 
 
381
    def get_tags(self, revid):
 
382
        return self.log_list.graph_provider.tags.get(revid)