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

Merged an approved request (single clicking bookmark).

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
import gtk
26
26
import gtk.glade
27
27
 
 
28
from bzrlib.branch import Branch
28
29
import bzrlib.errors as errors
29
30
 
30
 
from __init__ import gladefile
31
 
from dialog import error_dialog
 
31
from dialog import error_dialog, info_dialog, warning_dialog
 
32
from errors import show_bzr_error
 
33
from olive.guifiles import GLADEFILENAME
 
34
 
32
35
 
33
36
class MergeDialog:
34
37
    """ Display the Merge dialog and perform the needed actions. """
35
 
    def __init__(self, wt, wtpath):
 
38
    def __init__(self, wt, wtpath,default_branch_path=None):
36
39
        """ Initialize the Merge dialog. """
37
 
        self.glade = gtk.glade.XML(gladefile, 'window_merge', 'olive-gtk')
 
40
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk')
38
41
        
39
42
        self.window = self.glade.get_widget('window_merge')
40
43
        
48
51
 
49
52
        self.wt = wt
50
53
        self.wtpath = wtpath
 
54
        
 
55
        # Get some widgets
 
56
        self.entry = self.glade.get_widget('entry_merge')
 
57
        if default_branch_path:
 
58
            self.entry.set_text(default_branch_path)
51
59
 
52
60
    def display(self):
53
61
        """ Display the Add file(s) dialog. """
54
62
        self.window.show_all()
55
63
 
 
64
    @show_bzr_error
56
65
    def merge(self, widget):
57
 
        print "DEBUG: Merge button pressed."
 
66
        branch = self.entry.get_text()
 
67
        if branch == "":
 
68
            error_dialog(_('Branch not given'),
 
69
                         _('Please specify a branch to merge from.'))
 
70
            return
 
71
 
 
72
        other_branch = Branch.open_containing(branch)[0]
 
73
 
 
74
        try:
 
75
            conflicts = self.wt.merge_from_branch(other_branch)
 
76
        except errors.BzrCommandError, errmsg:
 
77
            error_dialog(_('Bazaar command error'), str(errmsg))
 
78
            return
 
79
        
 
80
        self.close()
 
81
        if conflicts == 0:
 
82
            # No conflicts found.
 
83
            info_dialog(_('Merge successful'),
 
84
                        _('All changes applied successfully.'))
 
85
        else:
 
86
            # There are conflicts to be resolved.
 
87
            warning_dialog(_('Conflicts encountered'),
 
88
                           _('Please resolve the conflicts manually before committing.'))
58
89
    
59
90
    def open(self, widget):
60
 
        print "DEBUG: Open branch button pressed."
61
 
    
 
91
        fcd = gtk.FileChooserDialog(title="Please select a folder",
 
92
                                    parent=self.window,
 
93
                                    action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
 
94
                                    buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
 
95
                                             gtk.STOCK_OPEN, gtk.RESPONSE_OK))
 
96
        fcd.set_default_response(gtk.RESPONSE_OK)
 
97
        
 
98
        if fcd.run() == gtk.RESPONSE_OK:
 
99
            self.entry.set_text(fcd.get_filename())
 
100
        
 
101
        fcd.destroy()
 
102
        
62
103
    def close(self, widget=None):
63
104
        self.window.destroy()