/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

  • Committer: Jelmer Vernooij
  • Date: 2008-06-28 16:59:50 UTC
  • mto: This revision was merged to the branch mainline in revision 516.
  • Revision ID: jelmer@samba.org-20080628165950-18kv7bdykgf1f1jf
Fix import in olive.

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