/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to revisionview.py

  • Committer: Adrian Wilkins
  • Date: 2008-04-24 15:26:14 UTC
  • mto: This revision was merged to the branch mainline in revision 470.
  • Revision ID: adrian.wilkins@gmail.com-20080424152614-2rnnljbro6vzqvf7
Detect the reserved null: revision in appropriate places. 

This removes a huge shower of stack traces that get dumped to console when 
you look at the bottom of a log.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import gtk
21
21
import pango
22
22
import gobject
23
 
import webbrowser
 
23
import subprocess
24
24
 
25
 
from bzrlib import trace
 
25
from bzrlib.plugins.gtk import icon_path
26
26
from bzrlib.osutils import format_date
27
 
try:
28
 
    from bzrlib.bencode import bdecode
29
 
except ImportError:
30
 
    from bzrlib.util.bencode import bdecode
31
 
from bzrlib.testament import Testament
32
 
 
33
 
from bzrlib.plugins.gtk import icon_path
 
27
from bzrlib.util.bencode import bdecode
34
28
 
35
29
try:
36
30
    from bzrlib.plugins.gtk import seahorse
44
38
PAGE_SIGNATURE = 2
45
39
PAGE_BUGS = 3
46
40
 
47
 
 
48
41
def _open_link(widget, uri):
49
 
    for cmd in ['sensible-browser', 'xdg-open']:
50
 
        if webbrowser._iscommand(cmd):
51
 
            webbrowser._tryorder.insert(0, '%s "%%s"' % cmd)
52
 
    webbrowser.open(uri)
 
42
    subprocess.Popen(['sensible-browser', uri], close_fds=True)
53
43
 
54
44
gtk.link_button_set_uri_hook(_open_link)
55
45
 
226
216
                                        "This revision has not been signed.")
227
217
 
228
218
    def show_signature(self, crypttext):
229
 
        (cleartext, key) = seahorse.verify(crypttext)
230
 
 
231
 
        assert cleartext is not None
232
 
 
233
 
        inv = self.repository.get_inventory(self.revision.revision_id)
234
 
        expected_testament = Testament(self.revision, inv).as_short_text()
235
 
        if expected_testament != cleartext:
236
 
            self.signature_image.set_from_file(icon_path("sign-bad.png"))
237
 
            self.signature_label.set_markup("<b>Signature does not match repository data</b>\n" +
238
 
                        "The signature plaintext is different from the expected testament plaintext.")
239
 
            return
 
219
        key = seahorse.verify(crypttext)
240
220
 
241
221
        if key and key.is_available():
242
222
            if key.is_trusted():
325
305
        )
326
306
    }
327
307
 
328
 
    def __init__(self, branch=None, repository=None):
 
308
    def __init__(self, branch=None):
329
309
        gtk.Notebook.__init__(self)
330
310
 
331
311
        self._revision = None
332
312
        self._branch = branch
333
 
        if branch is not None:
334
 
            self._repository = branch.repository
335
 
        else:
336
 
            self._repository = repository
337
313
 
338
314
        self._create_general()
339
315
        self._create_relations()
340
 
        # Disabled because testaments aren't verified yet:
341
316
        if has_seahorse:
342
317
            self._create_signature()
343
318
        self._create_file_info_view()
419
394
            self.timestamp.set_text(format_date(revision.timestamp,
420
395
                                                revision.timezone))
421
396
        try:
422
 
            self.branchnick.show()
423
 
            self.branchnick_label.show()
424
 
            self.branchnick.set_text(revision.properties['branch-nick'])
 
397
            self.branchnick_label.set_text(revision.properties['branch-nick'])
425
398
        except KeyError:
426
 
            self.branchnick.hide()
427
 
            self.branchnick_label.hide()
 
399
            self.branchnick_label.set_text("")
428
400
 
429
401
        self._add_parents_or_children(revision.parent_ids,
430
402
                                      self.parents_widgets,
431
403
                                      self.parents_table)
432
 
 
 
404
        
433
405
        file_info = revision.properties.get('file-info', None)
434
406
        if file_info is not None:
435
 
            try:
436
 
                file_info = bdecode(file_info.encode('UTF-8'))
437
 
            except ValueError:
438
 
                trace.note('Invalid per-file info for revision:%s, value: %r',
439
 
                           revision.revision_id, file_info)
440
 
                file_info = None
 
407
            file_info = bdecode(file_info.encode('UTF-8'))
441
408
 
442
409
        if file_info:
443
410
            if self._file_id is None:
521
488
        table.resize(max(len(revids), 1), 2)
522
489
 
523
490
        for idx, revid in enumerate(revids):
524
 
            align = gtk.Alignment(0.0, 0.0, 1, 1)
 
491
            align = gtk.Alignment(0.0, 0.0)
525
492
            widgets.append(align)
526
493
            table.attach(align, 1, 2, idx, idx + 1,
527
494
                                      gtk.EXPAND | gtk.FILL, gtk.FILL)
544
511
                hbox.pack_start(button, expand=False, fill=True)
545
512
                button.show()
546
513
 
547
 
            button = gtk.Button()
548
 
            revid_label = gtk.Label(str(revid))
549
 
            revid_label.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
550
 
            revid_label.set_alignment(0.0, 0.5)
551
 
            button.add(revid_label)
 
514
            button = gtk.Button(revid)
552
515
            button.connect("clicked",
553
 
                    lambda w, r: self.set_revision(self._repository.get_revision(r)), revid)
 
516
                    lambda w, r: self.set_revision(self._branch.repository.get_revision(r)), revid)
554
517
            button.set_use_underline(False)
555
 
            hbox.pack_start(button, expand=True, fill=True)
556
 
            button.show_all()
 
518
            hbox.pack_start(button, expand=False, fill=True)
 
519
            button.show()
557
520
 
558
521
    def _create_general(self):
559
522
        vbox = gtk.VBox(False, 6)
572
535
        vbox.show()
573
536
 
574
537
    def _create_signature(self):
575
 
        self.signature_table = SignatureTab(self._repository)
 
538
        self.signature_table = SignatureTab(self._branch.repository)
576
539
        self.append_page(self.signature_table, tab_label=gtk.Label('Signature'))
577
540
        self.connect_after('notify::revision', self._update_signature)
578
541
 
582
545
        self.table.set_col_spacings(6)
583
546
        self.table.show()
584
547
 
585
 
        row = 0
586
 
 
 
548
        align = gtk.Alignment(1.0, 0.5)
587
549
        label = gtk.Label()
588
 
        label.set_alignment(1.0, 0.5)
589
550
        label.set_markup("<b>Revision Id:</b>")
590
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
551
        align.add(label)
 
552
        self.table.attach(align, 0, 1, 0, 1, gtk.FILL, gtk.FILL)
 
553
        align.show()
591
554
        label.show()
592
555
 
 
556
        align = gtk.Alignment(0.0, 0.5)
593
557
        revision_id = gtk.Label()
594
 
        revision_id.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
595
 
        revision_id.set_alignment(0.0, 0.5)
596
558
        revision_id.set_selectable(True)
597
559
        self.connect('notify::revision', 
598
560
                lambda w, p: revision_id.set_text(self._revision.revision_id))
599
 
        self.table.attach(revision_id, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
561
        align.add(revision_id)
 
562
        self.table.attach(align, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
563
        align.show()
600
564
        revision_id.show()
601
565
 
602
 
        row += 1
 
566
        align = gtk.Alignment(1.0, 0.5)
603
567
        self.author_label = gtk.Label()
604
 
        self.author_label.set_alignment(1.0, 0.5)
605
568
        self.author_label.set_markup("<b>Author:</b>")
606
 
        self.table.attach(self.author_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
569
        align.add(self.author_label)
 
570
        self.table.attach(align, 0, 1, 1, 2, gtk.FILL, gtk.FILL)
 
571
        align.show()
607
572
        self.author_label.show()
608
573
 
 
574
        align = gtk.Alignment(0.0, 0.5)
609
575
        self.author = gtk.Label()
610
 
        self.author.set_ellipsize(pango.ELLIPSIZE_END)
611
 
        self.author.set_alignment(0.0, 0.5)
612
576
        self.author.set_selectable(True)
613
 
        self.table.attach(self.author, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
577
        align.add(self.author)
 
578
        self.table.attach(align, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
579
        align.show()
614
580
        self.author.show()
615
581
        self.author.hide()
616
582
 
617
 
        row += 1
 
583
        align = gtk.Alignment(1.0, 0.5)
618
584
        label = gtk.Label()
619
 
        label.set_alignment(1.0, 0.5)
620
585
        label.set_markup("<b>Committer:</b>")
621
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
586
        align.add(label)
 
587
        self.table.attach(align, 0, 1, 2, 3, gtk.FILL, gtk.FILL)
 
588
        align.show()
622
589
        label.show()
623
590
 
 
591
        align = gtk.Alignment(0.0, 0.5)
624
592
        self.committer = gtk.Label()
625
 
        self.committer.set_ellipsize(pango.ELLIPSIZE_END)
626
 
        self.committer.set_alignment(0.0, 0.5)
627
593
        self.committer.set_selectable(True)
628
 
        self.table.attach(self.committer, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
594
        align.add(self.committer)
 
595
        self.table.attach(align, 1, 2, 2, 3, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
596
        align.show()
629
597
        self.committer.show()
630
598
 
631
 
        row += 1
 
599
        align = gtk.Alignment(0.0, 0.5)
 
600
        label = gtk.Label()
 
601
        label.set_markup("<b>Branch nick:</b>")
 
602
        align.add(label)
 
603
        self.table.attach(align, 0, 1, 3, 4, gtk.FILL, gtk.FILL)
 
604
        label.show()
 
605
        align.show()
 
606
 
 
607
        align = gtk.Alignment(0.0, 0.5)
632
608
        self.branchnick_label = gtk.Label()
633
 
        self.branchnick_label.set_alignment(1.0, 0.5)
634
 
        self.branchnick_label.set_markup("<b>Branch nick:</b>")
635
 
        self.table.attach(self.branchnick_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
609
        self.branchnick_label.set_selectable(True)
 
610
        align.add(self.branchnick_label)
 
611
        self.table.attach(align, 1, 2, 3, 4, gtk.EXPAND | gtk.FILL, gtk.FILL)
636
612
        self.branchnick_label.show()
637
 
 
638
 
        self.branchnick = gtk.Label()
639
 
        self.branchnick.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
640
 
        self.branchnick.set_alignment(0.0, 0.5)
641
 
        self.branchnick.set_selectable(True)
642
 
        self.table.attach(self.branchnick, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
643
 
        self.branchnick.show()
644
 
 
645
 
        row += 1
 
613
        align.show()
 
614
 
 
615
        align = gtk.Alignment(1.0, 0.5)
646
616
        label = gtk.Label()
647
 
        label.set_alignment(1.0, 0.5)
648
617
        label.set_markup("<b>Timestamp:</b>")
649
 
        self.table.attach(label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
618
        align.add(label)
 
619
        self.table.attach(align, 0, 1, 4, 5, gtk.FILL, gtk.FILL)
 
620
        align.show()
650
621
        label.show()
651
622
 
 
623
        align = gtk.Alignment(0.0, 0.5)
652
624
        self.timestamp = gtk.Label()
653
 
        self.timestamp.set_ellipsize(pango.ELLIPSIZE_END)
654
 
        self.timestamp.set_alignment(0.0, 0.5)
655
625
        self.timestamp.set_selectable(True)
656
 
        self.table.attach(self.timestamp, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
626
        align.add(self.timestamp)
 
627
        self.table.attach(align, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
628
        align.show()
657
629
        self.timestamp.show()
658
630
 
659
 
        row += 1
 
631
        align = gtk.Alignment(1.0, 0.5)
660
632
        self.tags_label = gtk.Label()
661
 
        self.tags_label.set_alignment(1.0, 0.5)
662
633
        self.tags_label.set_markup("<b>Tags:</b>")
663
 
        self.table.attach(self.tags_label, 0, 1, row, row+1, gtk.FILL, gtk.FILL)
 
634
        align.add(self.tags_label)
 
635
        align.show()
 
636
        self.table.attach(align, 0, 1, 5, 6, gtk.FILL, gtk.FILL)
664
637
        self.tags_label.show()
665
638
 
 
639
        align = gtk.Alignment(0.0, 0.5)
666
640
        self.tags_list = gtk.Label()
667
 
        self.tags_list.set_ellipsize(pango.ELLIPSIZE_MIDDLE)
668
 
        self.tags_list.set_alignment(0.0, 0.5)
669
 
        self.table.attach(self.tags_list, 1, 2, row, row+1, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
641
        align.add(self.tags_list)
 
642
        self.table.attach(align, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, gtk.FILL)
 
643
        align.show()
670
644
        self.tags_list.show()
671
645
 
672
646
        self.connect('notify::revision', self._add_tags)