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
21
21
pygtk.require("2.0")
32
import olive.backend.errors as errors
33
import olive.backend.info as info
27
import bzrlib.errors as errors
29
from bzrlib.plugins.gtk import _i18n, icon_path
30
from bzrlib.plugins.gtk.dialog import error_dialog
34
""" Get info about branch, working tree, and repository
36
:param location: the location of the branch/working tree/repository
38
:return: the information in dictionary format
40
The following informations are delivered (if available):
41
ret['location']['lightcoroot']: Light checkout root
42
ret['location']['sharedrepo']: Shared repository
43
ret['location']['repobranch']: Repository branch
44
ret['location']['cobranch']: Checkout of branch
45
ret['location']['repoco']: Repository checkout
46
ret['location']['coroot']: Checkout root
47
ret['location']['branchroot']: Branch root
48
ret['related']['parentbranch']: Parent branch
49
ret['related']['publishbranch']: Publish to branch
50
ret['format']['control']: Control format
51
ret['format']['workingtree']: Working tree format
52
ret['format']['branch']: Branch format
53
ret['format']['repository']: Repository format
54
ret['locking']['workingtree']: Working tree lock status
55
ret['locking']['branch']: Branch lock status
56
ret['locking']['repository']: Repository lock status
57
ret['missing']['branch']: Missing revisions in branch
58
ret['missing']['workingtree']: Missing revisions in working tree
59
ret['wtstats']['unchanged']: Unchanged files
60
ret['wtstats']['modified']: Modified files
61
ret['wtstats']['added']: Added files
62
ret['wtstats']['removed']: Removed files
63
ret['wtstats']['renamed']: Renamed files
64
ret['wtstats']['unknown']: Unknown files
65
ret['wtstats']['ignored']: Ingnored files
66
ret['wtstats']['subdirs']: Versioned subdirectories
67
ret['brstats']['revno']: Revisions in branch
68
ret['brstats']['commiters']: Number of commiters
69
ret['brstats']['age']: Age of branch in days
70
ret['brstats']['firstrev']: Time of first revision
71
ret['brstats']['lastrev']: Time of last revision
72
ret['repstats']['revisions']: Revisions in repository
73
ret['repstats']['size']: Size of repository in bytes
75
import bzrlib.bzrdir as bzrdir
81
a_bzrdir = bzrdir.BzrDir.open_containing(location)[0]
82
except errors.NotBranchError:
83
raise errors.NotBranchError(location)
86
working = a_bzrdir.open_workingtree()
89
branch = working.branch
90
repository = branch.repository
91
control = working.bzrdir
93
ret['location'] = info_helper.get_location_info(repository, branch, working)
94
ret['related'] = info_helper.get_related_info(branch)
95
ret['format'] = info_helper.get_format_info(control, repository, branch, working)
96
ret['locking'] = info_helper.get_locking_info(repository, branch, working)
98
ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
99
ret['missing']['workingtree'] = info_helper.get_missing_revisions_working(working)
100
ret['wtstats'] = info_helper.get_working_stats(working)
101
ret['brstats'] = info_helper.get_branch_stats(branch)
102
ret['repstats'] = info_helper.get_repository_stats(repository)
107
except (errors.NoWorkingTree, errors.NotLocalUrl):
111
branch = a_bzrdir.open_branch()
112
repository = branch.repository
116
ret['location'] = info_helper.get_location_info(repository, branch)
117
ret['related'] = info_helper.get_related_info(branch)
118
ret['format'] = info_helper.get_format_info(control, repository, branch)
119
ret['locking'] = info_helper.get_locking_info(repository, branch)
120
ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
121
ret['brstats'] = info_helper.get_branch_stats(branch)
122
ret['repstats'] = info_helper.get_repository_stats(repository)
127
except errors.NotBranchError:
131
repository = a_bzrdir.open_repository()
132
repository.lock_read()
134
ret['location'] = info_helper.get_location_info(repository)
135
ret['format'] = info_helper.get_format_info(control, repository)
136
ret['locking'] = info_helper.get_locking_info(repository)
137
ret['repstats'] = info_helper.get_repository_stats(repository)
141
except errors.NoRepositoryPresent:
145
class InfoDialog(object):
36
146
""" Display Informations window and perform the needed actions. """
37
def __init__(self, gladefile, comm, dialog):
148
def __init__(self, branch):
38
149
""" Initialize the Informations window. """
39
self.gladefile = gladefile
40
self.glade = gtk.glade.XML(self.gladefile, 'window_info', 'olive-gtk')
42
# Communication object
47
# Get the Informations window widget
48
self.window = self.glade.get_widget('window_info')
50
150
# Check if current location is a branch
51
151
self.notbranch = False
53
self.ret = info.info(self.comm.get_path())
153
self.ret = info(branch.base)
54
154
except errors.NotBranchError:
55
155
self.notbranch = True
60
# Dictionary for signal_autoconnect
61
dic = { "on_button_info_close_clicked": self.close,
62
"on_expander_info_location_activate": self.activate,
63
"on_expander_info_related_activate": self.activate,
64
"on_expander_info_format_activate": self.activate,
65
"on_expander_info_locking_activate": self.activate,
66
"on_expander_info_missing_activate": self.activate,
67
"on_expander_info_wtstats_activate": self.activate,
68
"on_expander_info_brstats_activate": self.activate,
69
"on_expander_info_repstats_activate": self.activate }
71
# Connect the signals to the handlers
72
self.glade.signal_autoconnect(dic)
159
self.window = gtk.Dialog(title="Olive - Information",
163
self.window.set_icon_list(gtk.gdk.pixbuf_new_from_file(icon_path("oliveicon2.png")),
164
gtk.gdk.pixbuf_new_from_file(icon_path("olive-gtk.png")))
165
self.window.vbox.set_spacing(3)
166
self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL)
168
infokeylist = ( ('location', _i18n("Location"), (
169
('lightcoroot', _i18n("Light checkout root")),
170
('sharedrepo', _i18n("Shared repository")),
171
('repobranch', _i18n("Repository branch")),
172
('cobranch', _i18n("Checkout of branch")),
173
('repoco', _i18n("Repository checkout")),
174
('coroot', _i18n("Checkout root")),
175
('branchroot', _i18n("Branch root")),
177
('related', _i18n("Related branches"), (
178
('parentbranch', _i18n("Parent branch")),
179
('publishbranch', _i18n("Publish to branch")),
181
('format', _i18n("Format"), (
182
('control', _i18n("Control format")),
183
('workingtree', _i18n("Working tree format")),
184
('branch', _i18n("Branch format")),
185
('repository', _i18n("Repository format")),
187
('locking', _i18n("Lock status"), (
188
('workingtree', _i18n("Working tree lock status")),
189
('branch', _i18n("Branch lock status")),
190
('repository', _i18n("Repository lock status")),
192
#('missing', _i18n("Missing revisions"), (
193
# ('branch', _i18n("Missing revisions in branch")),
194
# ('workingtree', _i18n("Missing revisions in working tree")),
195
# )), # Missing is 'temporary' disabled
196
('wtstats', _i18n("In the working tree"), (
197
('unchanged', _i18n("Unchanged files")),
198
('modified', _i18n("Modified files")),
199
('added', _i18n("Added files")),
200
('removed', _i18n("Removed files")),
201
('renamed', _i18n("Renamed files")),
202
('unknown', _i18n("Unknown files")),
203
('ignored', _i18n("Ignored files")),
204
('subdirs', _i18n("Versioned subdirectories")),
206
('brstats', _i18n("Branch history"), (
207
('revno', _i18n("Revisions in branch")),
208
('commiters', _i18n("Number of commiters")),
209
('age', _i18n("Age of branch in days")),
210
('firstrev', _i18n("Time of first revision")),
211
('lastrev', _i18n("Time of last revision")),
213
('repstats', _i18n("Revision store"), (
214
('revisions', _i18n("Revisions in repository")),
215
('size', _i18n("Size of repository in bytes")),
74
219
# Generate status output
77
def _generate_info(self):
220
self._generate_info(infokeylist)
222
button_close = gtk.Button(stock=gtk.STOCK_CLOSE)
223
button_close.connect('clicked', self.close)
224
self.window.action_area.pack_end(button_close)
225
self.window.set_focus(button_close)
227
def _generate_info(self, infokeylist):
78
228
""" Generate 'bzr info' output. """
80
if self.ret.has_key('location'):
82
e = self.glade.get_widget('expander_info_location')
83
if self.ret['location'].has_key('lightcoroot'):
84
ll = self.glade.get_widget('label_info_location_lightcoroot_label')
85
l = self.glade.get_widget('label_info_location_lightcoroot')
86
l.set_text(self.ret['location']['lightcoroot'])
93
if self.ret['location'].has_key('sharedrepo'):
94
ll = self.glade.get_widget('label_info_location_sharedrepo_label')
95
l = self.glade.get_widget('label_info_location_sharedrepo')
96
l.set_text(self.ret['location']['sharedrepo'])
103
if self.ret['location'].has_key('repobranch'):
104
ll = self.glade.get_widget('label_info_location_repobranch_label')
105
l = self.glade.get_widget('label_info_location_repobranch')
106
l.set_text(self.ret['location']['repobranch'])
113
if self.ret['location'].has_key('cobranch'):
114
ll = self.glade.get_widget('label_info_location_cobranch_label')
115
l = self.glade.get_widget('label_info_location_cobranch')
116
l.set_text(self.ret['location']['cobranch'])
123
if self.ret['location'].has_key('repoco'):
124
ll = self.glade.get_widget('label_info_location_repoco_label')
125
l = self.glade.get_widget('label_info_location_repoco')
126
l.set_text(self.ret['location']['repoco'])
133
if self.ret['location'].has_key('coroot'):
134
ll = self.glade.get_widget('label_info_location_coroot_label')
135
l = self.glade.get_widget('label_info_location_coroot')
136
l.set_text(self.ret['location']['coroot'])
143
if self.ret['location'].has_key('branchroot'):
144
ll = self.glade.get_widget('label_info_location_branchroot_label')
145
l = self.glade.get_widget('label_info_location_branchroot')
146
l.set_text(self.ret['location']['branchroot'])
154
if self.ret.has_key('related'):
156
e = self.glade.get_widget('expander_info_related')
157
if self.ret['related'].has_key('parentbranch'):
158
ll = self.glade.get_widget('label_info_related_parentbranch_label')
159
l = self.glade.get_widget('label_info_related_parentbranch')
160
l.set_text(self.ret['related']['parentbranch'])
167
if self.ret['related'].has_key('publishbranch'):
168
ll = self.glade.get_widget('label_info_related_publishbranch_label')
169
l = self.glade.get_widget('label_info_related_publishbranch')
170
l.set_text(self.ret['related']['publishbranch'])
178
if self.ret.has_key('format'):
180
e = self.glade.get_widget('expander_info_format')
181
if self.ret['format'].has_key('control'):
182
ll = self.glade.get_widget('label_info_format_control_label')
183
l = self.glade.get_widget('label_info_format_control')
184
l.set_text(self.ret['format']['control'])
191
if self.ret['format'].has_key('workingtree'):
192
ll = self.glade.get_widget('label_info_format_workingtree_label')
193
l = self.glade.get_widget('label_info_format_workingtree')
194
l.set_text(self.ret['format']['workingtree'])
201
if self.ret['format'].has_key('branch'):
202
ll = self.glade.get_widget('label_info_format_branch_label')
203
l = self.glade.get_widget('label_info_format_branch')
204
l.set_text(self.ret['format']['branch'])
211
if self.ret['format'].has_key('repository'):
212
ll = self.glade.get_widget('label_info_format_repository_label')
213
l = self.glade.get_widget('label_info_format_repository')
214
l.set_text(self.ret['format']['repository'])
222
if self.ret.has_key('locking'):
224
e = self.glade.get_widget('expander_info_locking')
225
if self.ret['locking'].has_key('workingtree'):
226
ll = self.glade.get_widget('label_info_locking_workingtree_label')
227
l = self.glade.get_widget('label_info_locking_workingtree')
228
l.set_text(self.ret['locking']['workingtree'])
235
if self.ret['locking'].has_key('branch'):
236
ll = self.glade.get_widget('label_info_locking_branch_label')
237
l = self.glade.get_widget('label_info_locking_branch')
238
l.set_text(self.ret['locking']['branch'])
245
if self.ret['locking'].has_key('repository'):
246
ll = self.glade.get_widget('label_info_locking_repository_label')
247
l = self.glade.get_widget('label_info_locking_repository')
248
l.set_text(self.ret['locking']['repository'])
255
# missing - temporary disabled
257
if self.ret.has_key('missing'):
259
e = self.glade.get_widget('expander_info_missing')
260
if self.ret['missing'].has_key('branch'):
261
ll = self.glade.get_widget('label_info_missing_branch_label')
262
l = self.glade.get_widget('label_info_missing_branch')
263
l.set_text(self.ret['missing']['branch'])
264
ll.set_markup('<b>' + ll.get_text() + '</b>')
271
if self.ret['missing'].has_key('workingtree'):
272
ll = self.glade.get_widget('label_info_missing_workingtree_label')
273
l = self.glade.get_widget('label_info_missing_workingtree')
274
l.set_text(self.ret['missing']['branch'])
275
ll.set_markup('<b>' + ll.get_text() + '</b>')
284
if self.ret.has_key('wtstats'):
286
e = self.glade.get_widget('expander_info_wtstats')
287
if self.ret['wtstats'].has_key('unchanged'):
288
ll = self.glade.get_widget('label_info_wtstats_unchanged_label')
289
l = self.glade.get_widget('label_info_wtstats_unchanged')
290
l.set_text(str(self.ret['wtstats']['unchanged']))
297
if self.ret['wtstats'].has_key('modified'):
298
ll = self.glade.get_widget('label_info_wtstats_modified_label')
299
l = self.glade.get_widget('label_info_wtstats_modified')
300
l.set_text(str(self.ret['wtstats']['modified']))
307
if self.ret['wtstats'].has_key('added'):
308
ll = self.glade.get_widget('label_info_wtstats_added_label')
309
l = self.glade.get_widget('label_info_wtstats_added')
310
l.set_text(str(self.ret['wtstats']['added']))
317
if self.ret['wtstats'].has_key('removed'):
318
ll = self.glade.get_widget('label_info_wtstats_removed_label')
319
l = self.glade.get_widget('label_info_wtstats_removed')
320
l.set_text(str(self.ret['wtstats']['removed']))
327
if self.ret['wtstats'].has_key('renamed'):
328
ll = self.glade.get_widget('label_info_wtstats_renamed_label')
329
l = self.glade.get_widget('label_info_wtstats_renamed')
330
l.set_text(str(self.ret['wtstats']['renamed']))
337
if self.ret['wtstats'].has_key('unknown'):
338
ll = self.glade.get_widget('label_info_wtstats_unknown_label')
339
l = self.glade.get_widget('label_info_wtstats_unknown')
340
l.set_text(str(self.ret['wtstats']['unknown']))
347
if self.ret['wtstats'].has_key('ignored'):
348
ll = self.glade.get_widget('label_info_wtstats_ignored_label')
349
l = self.glade.get_widget('label_info_wtstats_ignored')
350
l.set_text(str(self.ret['wtstats']['ignored']))
357
if self.ret['wtstats'].has_key('subdirs'):
358
ll = self.glade.get_widget('label_info_wtstats_subdirs_label')
359
l = self.glade.get_widget('label_info_wtstats_subdirs')
360
l.set_text(str(self.ret['wtstats']['subdirs']))
368
if self.ret.has_key('brstats'):
370
e = self.glade.get_widget('expander_info_brstats')
371
if self.ret['brstats'].has_key('revno'):
372
ll = self.glade.get_widget('label_info_brstats_revno_label')
373
l = self.glade.get_widget('label_info_brstats_revno')
374
l.set_text(str(self.ret['brstats']['revno']))
381
if self.ret['brstats'].has_key('commiters'):
382
ll = self.glade.get_widget('label_info_brstats_commiters_label')
383
l = self.glade.get_widget('label_info_brstats_commiters')
384
l.set_text(str(self.ret['brstats']['commiters']))
391
if self.ret['brstats'].has_key('age'):
392
ll = self.glade.get_widget('label_info_brstats_age_label')
393
l = self.glade.get_widget('label_info_brstats_age')
394
l.set_text('%d days' % self.ret['brstats']['age'])
401
if self.ret['brstats'].has_key('firstrev'):
402
ll = self.glade.get_widget('label_info_brstats_firstrev_label')
403
l = self.glade.get_widget('label_info_brstats_firstrev')
404
l.set_text(self.ret['brstats']['firstrev'])
411
if self.ret['brstats'].has_key('lastrev'):
412
ll = self.glade.get_widget('label_info_brstats_lastrev_label')
413
l = self.glade.get_widget('label_info_brstats_lastrev')
414
l.set_text(self.ret['brstats']['lastrev'])
422
if self.ret.has_key('repstats'):
424
e = self.glade.get_widget('expander_info_repstats')
425
if self.ret['repstats'].has_key('revisions'):
426
ll = self.glade.get_widget('label_info_repstats_revisions_label')
427
l = self.glade.get_widget('label_info_repstats_revisions')
428
l.set_text(str(self.ret['repstats']['revisions']))
435
if self.ret['repstats'].has_key('size'):
436
ll = self.glade.get_widget('label_info_repstats_size_label')
437
l = self.glade.get_widget('label_info_repstats_size')
438
l.set_text('%d KiB' % (self.ret['repstats']['size'] / 1024))
229
for key, keystring, subkeylist in infokeylist:
230
if self.ret.has_key(key):
232
for subkey, subkeystring in subkeylist:
233
if self.ret[key].has_key(subkey):
238
exec "exp_%s = gtk.Expander('<b>%s</b>')"%(key, keystring)
239
eval("exp_%s.set_use_markup(True)"%key)
240
eval("exp_%s.connect('activate', self.activate)"%key)
242
exec "alignment_%s = gtk.Alignment()"%key
243
eval("alignment_%s.set_padding(0, 0, 24, 0)"%key)
244
eval("exp_%s.add(alignment_%s)"%(key, key))
246
exec "table_%s = gtk.Table(tablelength, 2)"%key
247
eval("table_%s.set_col_spacings(12)"%key)
248
eval("alignment_%s.add(table_%s)"%(key, key))
251
for subkey, subkeystring in subkeylist:
252
if self.ret[key].has_key(subkey):
253
exec "%s_%s_label = gtk.Label('%s:')"%(key,subkey, subkeystring)
254
eval("table_%s.attach(%s_%s_label, 0, 1, %i, %i, gtk.FILL)"%(key, key, subkey, tablepos, tablepos + 1))
255
eval("%s_%s_label.set_alignment(0, 0.5)"%(key, subkey))
257
exec "%s_%s = gtk.Label('%s')"%(key, subkey, str(self.ret[key][subkey]))
258
eval("table_%s.attach(%s_%s, 1, 2, %i, %i, gtk.FILL)"%(key, key, subkey, tablepos, tablepos + 1))
259
eval("%s_%s.set_alignment(0, 0.5)"%(key, subkey))
261
eval("exp_%s.set_expanded(True)"%key)
262
eval("self.window.vbox.pack_start(exp_%s, False, True, 0)"%key)
446
264
def activate(self, expander):
447
265
""" Redraw the window. """