/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 olive/commit.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-10-03 06:44:48 UTC
  • mfrom: (0.8.98 merge)
  • mto: (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 103.
  • Revision ID: Szilveszter.Farkas@gmail.com-20061003064448-8cf3c9cc653346ab
Merge from the merge branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import sys
18
 
 
19
17
try:
20
18
    import pygtk
21
19
    pygtk.require("2.0")
22
20
except:
23
21
    pass
24
 
try:
25
 
    import gtk
26
 
    import gtk.glade
27
 
    import gobject
28
 
    import pango
29
 
except:
30
 
    sys.exit(1)
31
22
 
32
 
from bzrlib import version_info
 
23
import gtk
 
24
import gtk.glade
 
25
import gobject
 
26
import pango
33
27
 
34
28
import bzrlib.errors as errors
35
 
from bzrlib.workingtree import WorkingTree
 
29
 
 
30
from dialog import error_dialog
 
31
from olive import gladefile
36
32
 
37
33
class OliveCommit:
38
34
    """ Display Commit dialog and perform the needed actions. """
39
 
    def __init__(self, gladefile, comm, dialog):
 
35
    def __init__(self, wt, wtpath):
40
36
        """ Initialize the Commit dialog. """
41
 
        self.gladefile = gladefile
42
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_commit', 'olive-gtk')
43
 
        
44
 
        # Communication object
45
 
        self.comm = comm
46
 
        # Dialog object
47
 
        self.dialog = dialog
48
 
        
 
37
        self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
 
38
        
 
39
        self.wt = wt
 
40
        self.wtpath = wtpath
 
41
 
49
42
        # Get some important widgets
50
43
        self.window = self.glade.get_widget('window_commit')
51
44
        self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
52
45
        self.textview = self.glade.get_widget('textview_commit')
53
46
        self.file_view = self.glade.get_widget('treeview_commit_select')
54
47
 
55
 
        # Check if current location is a branch
56
 
        try:
57
 
            (self.wt, path) = WorkingTree.open_containing(self.comm.get_path())
58
 
            branch = self.wt.branch
59
 
        except errors.NotBranchError:
60
 
            self.notbranch = True
61
 
            return
62
 
        except:
63
 
            raise
64
 
 
65
 
        file_id = self.wt.path2id(path)
 
48
        file_id = self.wt.path2id(wtpath)
66
49
 
67
50
        self.notbranch = False
68
51
        if file_id is None:
71
54
        
72
55
        # Set the delta
73
56
        self.old_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
74
 
        if version_info < (0, 9):
75
 
            self.delta = compare_trees(self.old_tree, self.wt)
76
 
        else:
77
 
            self.delta = self.wt.changes_from(self.old_tree)
 
57
        self.delta = self.wt.changes_from(self.old_tree)
78
58
        
79
59
        # Dictionary for signal_autoconnect
80
60
        dic = { "on_button_commit_commit_clicked": self.commit,
89
69
    def display(self):
90
70
        """ Display the Push dialog. """
91
71
        if self.notbranch:
92
 
            self.dialog.error_dialog(_('Directory is not a branch'),
93
 
                                     _('You can perform this action only in a branch.'))
 
72
            error_dialog(_('Directory is not a branch'),
 
73
                         _('You can perform this action only in a branch.'))
94
74
            self.close()
95
75
        else:
96
 
            from bzrlib.branch import Branch
97
 
            branch = Branch.open_containing(self.comm.get_path())[0]
98
 
 
99
 
            if branch.get_bound_location() is not None:
 
76
            if self.wt.branch.get_bound_location() is not None:
100
77
                # we have a checkout, so the local commit checkbox must appear
101
78
                self.checkbutton_local.show()
102
79
            
104
81
            self.window.show()
105
82
            
106
83
    
107
 
    # This code is from Jelmer Vernooij's bzr-gtk branch
108
84
    def _create_file_view(self):
109
85
        self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
110
86
                                        gobject.TYPE_STRING,
141
117
            it = self.file_store.iter_next(it)
142
118
 
143
119
        return ret
144
 
    # end of bzr-gtk code
145
120
    
146
121
    def _toggle_commit(self, cell, path, model):
147
122
        model[path][0] = not model[path][0]
157
132
        
158
133
        specific_files = self._get_specific_files()
159
134
        
160
 
        self.comm.set_busy(self.window)
161
 
        # merged from Jelmer Vernooij's olive integration branch
162
135
        try:
163
136
            self.wt.commit(message, 
164
137
                           allow_pointless=checkbutton_force.get_active(),
166
139
                           local=self.checkbutton_local.get_active(),
167
140
                           specific_files=specific_files)
168
141
        except errors.NotBranchError:
169
 
            self.dialog.error_dialog(_('Directory is not a branch'),
170
 
                                     _('You can perform this action only in a branch.'))
171
 
            self.comm.set_busy(self.window, False)
 
142
            error_dialog(_('Directory is not a branch'),
 
143
                         _('You can perform this action only in a branch.'))
172
144
            return
173
145
        except errors.LocalRequiresBoundBranch:
174
 
            self.dialog.error_dialog(_('Directory is not a checkout'),
175
 
                                     _('You can perform local commit only on checkouts.'))
176
 
            self.comm.set_busy(self.window, False)
 
146
            error_dialog(_('Directory is not a checkout'),
 
147
                         _('You can perform local commit only on checkouts.'))
177
148
            return
178
149
        except errors.PointlessCommit:
179
 
            self.dialog.error_dialog(_('No changes to commit'),
180
 
                                     _('Try force commit if you want to commit anyway.'))
181
 
            self.comm.set_busy(self.window, False)
 
150
            error_dialog(_('No changes to commit'),
 
151
                         _('Try force commit if you want to commit anyway.'))
182
152
            return
183
153
        except errors.ConflictsInTree:
184
 
            self.dialog.error_dialog(_('Conflicts in tree'),
185
 
                                     _('You need to resolve the conflicts before committing.'))
186
 
            self.comm.set_busy(self.window, False)
 
154
            error_dialog(_('Conflicts in tree'),
 
155
                         _('You need to resolve the conflicts before committing.'))
187
156
            return
188
157
        except errors.StrictCommitFailed:
189
 
            self.dialog.error_dialog(_('Strict commit failed'),
190
 
                                     _('There are unknown files in the working tree.\nPlease add or delete them.'))
191
 
            self.comm.set_busy(self.window, False)
 
158
            error_dialog(_('Strict commit failed'),
 
159
                         _('There are unknown files in the working tree.\nPlease add or delete them.'))
192
160
            return
193
161
        except errors.BoundBranchOutOfDate, errmsg:
194
 
            self.dialog.error_dialog(_('Bound branch is out of date'),
195
 
                                     _('%s') % errmsg)
196
 
            self.comm.set_busy(self.window, False)
197
 
            return
198
 
        except:
199
 
            raise
 
162
            error_dialog(_('Bound branch is out of date'),
 
163
                         _('%s') % errmsg)
 
164
            return
 
165
        except errors.BzrError, msg:
 
166
            error_dialog(_('Unknown bzr error'), str(msg))
 
167
            return
 
168
        except Exception, msg:
 
169
            error_dialog(_('Unknown error'), str(msg))
 
170
            return
200
171
        
201
172
        self.close()
202
 
        self.comm.refresh_right()
203
173
        
204
174
    def close(self, widget=None):
205
175
        self.window.destroy()