/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 diff.py

  • Committer: Aaron Bentley
  • Date: 2008-02-23 07:26:04 UTC
  • Revision ID: aaron@aaronbentley.com-20080223072604-rcfgml20r2x4dbd2
Misc updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
 
47
47
class DiffFileView(gtk.ScrolledWindow):
 
48
    """Window for displaying diffs from a diff file"""
48
49
 
49
50
    def __init__(self):
50
51
        gtk.ScrolledWindow.__init__(self)
259
260
        self.parent_tree = None
260
261
 
261
262
    def show_diff(self, specific_files):
 
263
        """Show the diff for the specified files"""
262
264
        s = StringIO()
263
265
        show_diff_trees(self.parent_tree, self.rev_tree, s, specific_files,
264
266
                        old_label='', new_label='',
313
315
        self.treeview.append_column(column)
314
316
 
315
317
    def set_diff_text(self, lines):
 
318
        """Set the current diff from a list of lines
 
319
 
 
320
        :param lines: The diff to show, in unified diff format
 
321
        """
316
322
        # The diffs of the  selected file: a scrollable source or
317
323
        # text view
318
324
        self.diff_view = DiffFileView()
369
375
        self.treeview.expand_all()
370
376
 
371
377
    def set_file(self, file_path):
 
378
        """Select the current file to display"""
372
379
        tv_path = None
373
380
        for data in self.model:
374
381
            for child in data.iterchildren():
426
433
        self.diff.show_all()
427
434
 
428
435
    def _get_button_bar(self):
 
436
        """Return a button bar to use.
 
437
 
 
438
        :return: None, meaning that no button bar will be used.
 
439
        """
429
440
        return None
430
441
 
431
442
    def set_diff_text(self, description, lines):
 
443
        """Set the diff from a text.
 
444
 
 
445
        The diff must be in unified diff format, and will be parsed to
 
446
        determine filenames.
 
447
        """
432
448
        self.diff.set_diff_text(lines)
433
449
        self.set_title(description + " - bzrk diff")
434
450
 
453
469
        self.directive = directive
454
470
 
455
471
    def _get_button_bar(self):
 
472
        """The button bar has only the Merge button"""
456
473
        merge_button = gtk.Button('Merge')
457
474
        merge_button.show()
458
475
        merge_button.set_relief(gtk.RELIEF_NONE)
503
520
                                           gtk.RESPONSE_CANCEL,))
504
521
        try:
505
522
            result = d.run()
506
 
            if result == gtk.RESPONSE_OK:
507
 
                uri = d.get_current_folder_uri()
508
 
                return workingtree.WorkingTree.open(uri)
509
 
            else:
 
523
            if result != gtk.RESPONSE_OK:
510
524
                raise SelectCancelled()
 
525
            uri = d.get_current_folder_uri()
511
526
        finally:
512
527
            d.destroy()
 
528
        return workingtree.WorkingTree.open(uri)
513
529
 
514
530
 
515
531
def _iter_changes_to_status(source, target):