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

  • Committer: Jelmer Vernooij
  • Date: 2006-09-06 00:23:46 UTC
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060906002346-73aa11b52d4d7b96
Load plugins on startup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
except:
30
30
    sys.exit(1)
31
31
 
32
 
import olive.backend.errors as errors
33
 
import olive.backend.info as info
 
32
import bzrlib.errors as errors
 
33
 
 
34
def info(location):
 
35
    """ Get info about branch, working tree, and repository
 
36
    
 
37
    :param location: the location of the branch/working tree/repository
 
38
    
 
39
    :return: the information in dictionary format
 
40
    
 
41
    The following informations are delivered (if available):
 
42
    ret['location']['lightcoroot']: Light checkout root
 
43
    ret['location']['sharedrepo']: Shared repository
 
44
    ret['location']['repobranch']: Repository branch
 
45
    ret['location']['cobranch']: Checkout of branch
 
46
    ret['location']['repoco']: Repository checkout
 
47
    ret['location']['coroot']: Checkout root
 
48
    ret['location']['branchroot']: Branch root
 
49
    ret['related']['parentbranch']: Parent branch
 
50
    ret['related']['publishbranch']: Publish to branch
 
51
    ret['format']['control']: Control format
 
52
    ret['format']['workingtree']: Working tree format
 
53
    ret['format']['branch']: Branch format
 
54
    ret['format']['repository']: Repository format
 
55
    ret['locking']['workingtree']: Working tree lock status
 
56
    ret['locking']['branch']: Branch lock status
 
57
    ret['locking']['repository']: Repository lock status
 
58
    ret['missing']['branch']: Missing revisions in branch
 
59
    ret['missing']['workingtree']: Missing revisions in working tree
 
60
    ret['wtstats']['unchanged']: Unchanged files
 
61
    ret['wtstats']['modified']: Modified files
 
62
    ret['wtstats']['added']: Added files
 
63
    ret['wtstats']['removed']: Removed files
 
64
    ret['wtstats']['renamed']: Renamed files
 
65
    ret['wtstats']['unknown']: Unknown files
 
66
    ret['wtstats']['ignored']: Ingnored files
 
67
    ret['wtstats']['subdirs']: Versioned subdirectories
 
68
    ret['brstats']['revno']: Revisions in branch
 
69
    ret['brstats']['commiters']: Number of commiters
 
70
    ret['brstats']['age']: Age of branch in days
 
71
    ret['brstats']['firstrev']: Time of first revision
 
72
    ret['brstats']['lastrev']: Time of last revision
 
73
    ret['repstats']['revisions']: Revisions in repository
 
74
    ret['repstats']['size']: Size of repository in bytes
 
75
    """
 
76
    import bzrlib.bzrdir as bzrdir
 
77
    
 
78
    import info_helper
 
79
    
 
80
    ret = {}
 
81
    try:
 
82
        a_bzrdir = bzrdir.BzrDir.open_containing(location)[0]
 
83
    except errors.NotBranchError:
 
84
        raise NotBranchError(location)
 
85
 
 
86
    try:
 
87
        working = a_bzrdir.open_workingtree()
 
88
        working.lock_read()
 
89
        try:
 
90
            branch = working.branch
 
91
            repository = branch.repository
 
92
            control = working.bzrdir
 
93
            
 
94
            ret['location'] = info_helper.get_location_info(repository, branch, working)
 
95
            ret['related'] = info_helper.get_related_info(branch)
 
96
            ret['format'] = info_helper.get_format_info(control, repository, branch, working)
 
97
            ret['locking'] = info_helper.get_locking_info(repository, branch, working)
 
98
            ret['missing'] = {}
 
99
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
 
100
            ret['missing']['workingtree'] = info_helper.get_missing_revisions_working(working)
 
101
            ret['wtstats'] = info_helper.get_working_stats(working)
 
102
            ret['brstats'] = info_helper.get_branch_stats(branch)
 
103
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
104
        finally:
 
105
            working.unlock()
 
106
            return ret
 
107
        return
 
108
    except (errors.NoWorkingTree, errors.NotLocalUrl):
 
109
        pass
 
110
 
 
111
    try:
 
112
        branch = a_bzrdir.open_branch()
 
113
        branch.lock_read()
 
114
        try:
 
115
            ret['location'] = info_helper.get_location_info(repository, branch)
 
116
            ret['related'] = info_helper.get_related_info(branch)
 
117
            ret['format'] = info_helper.get_format_info(control, repository, branch)
 
118
            ret['locking'] = info_helper.get_locking_info(repository, branch)
 
119
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
 
120
            ret['brstats'] = info_helper.get_branch_stats(branch)
 
121
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
122
        finally:
 
123
            branch.unlock()
 
124
            return ret
 
125
        return
 
126
    except errors.NotBranchError:
 
127
        pass
 
128
 
 
129
    try:
 
130
        repository = a_bzrdir.open_repository()
 
131
        repository.lock_read()
 
132
        try:
 
133
            ret['location'] = info_helper.get_location_info(repository)
 
134
            ret['format'] = info_helper.get_format_info(control, repository)
 
135
            ret['locking'] = info_helper.get_locking_info(repository)
 
136
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
137
        finally:
 
138
            repository.unlock()
 
139
            return ret
 
140
        return
 
141
    except errors.NoRepositoryPresent:
 
142
        pass
 
143
 
34
144
 
35
145
class OliveInfo:
36
146
    """ Display Informations window and perform the needed actions. """
50
160
        # Check if current location is a branch
51
161
        self.notbranch = False
52
162
        try:
53
 
            self.ret = info.info(self.comm.get_path())
 
163
            self.ret = info(self.comm.get_path())
54
164
        except errors.NotBranchError:
55
165
            self.notbranch = True
56
166
            return
57
 
        except:
58
 
            raise
59
167
        
60
168
        # Dictionary for signal_autoconnect
61
169
        dic = { "on_button_info_close_clicked": self.close,
84
192
                ll = self.glade.get_widget('label_info_location_lightcoroot_label')
85
193
                l = self.glade.get_widget('label_info_location_lightcoroot')
86
194
                l.set_text(self.ret['location']['lightcoroot'])
 
195
                ll.set_markup('<b>' + ll.get_text() + '</b>')
87
196
                ll.show()
88
197
                l.show()
89
198
                if not display:
94
203
                ll = self.glade.get_widget('label_info_location_sharedrepo_label')
95
204
                l = self.glade.get_widget('label_info_location_sharedrepo')
96
205
                l.set_text(self.ret['location']['sharedrepo'])
 
206
                ll.set_markup('<b>' + ll.get_text() + '</b>')
97
207
                ll.show()
98
208
                l.show()
99
209
                if not display:
104
214
                ll = self.glade.get_widget('label_info_location_repobranch_label')
105
215
                l = self.glade.get_widget('label_info_location_repobranch')
106
216
                l.set_text(self.ret['location']['repobranch'])
 
217
                ll.set_markup('<b>' + ll.get_text() + '</b>')
107
218
                ll.show()
108
219
                l.show()
109
220
                if not display:
114
225
                ll = self.glade.get_widget('label_info_location_cobranch_label')
115
226
                l = self.glade.get_widget('label_info_location_cobranch')
116
227
                l.set_text(self.ret['location']['cobranch'])
 
228
                ll.set_markup('<b>' + ll.get_text() + '</b>')
117
229
                ll.show()
118
230
                l.show()
119
231
                if not display:
124
236
                ll = self.glade.get_widget('label_info_location_repoco_label')
125
237
                l = self.glade.get_widget('label_info_location_repoco')
126
238
                l.set_text(self.ret['location']['repoco'])
 
239
                ll.set_markup('<b>' + ll.get_text() + '</b>')
127
240
                ll.show()
128
241
                l.show()
129
242
                if not display:
134
247
                ll = self.glade.get_widget('label_info_location_coroot_label')
135
248
                l = self.glade.get_widget('label_info_location_coroot')
136
249
                l.set_text(self.ret['location']['coroot'])
 
250
                ll.set_markup('<b>' + ll.get_text() + '</b>')
137
251
                ll.show()
138
252
                l.show()
139
253
                if not display:
144
258
                ll = self.glade.get_widget('label_info_location_branchroot_label')
145
259
                l = self.glade.get_widget('label_info_location_branchroot')
146
260
                l.set_text(self.ret['location']['branchroot'])
 
261
                ll.set_markup('<b>' + ll.get_text() + '</b>')
147
262
                ll.show()
148
263
                l.show()
149
264
                if not display:
158
273
                ll = self.glade.get_widget('label_info_related_parentbranch_label')
159
274
                l = self.glade.get_widget('label_info_related_parentbranch')
160
275
                l.set_text(self.ret['related']['parentbranch'])
 
276
                ll.set_markup('<b>' + ll.get_text() + '</b>')
161
277
                ll.show()
162
278
                l.show()
163
279
                if not display:
168
284
                ll = self.glade.get_widget('label_info_related_publishbranch_label')
169
285
                l = self.glade.get_widget('label_info_related_publishbranch')
170
286
                l.set_text(self.ret['related']['publishbranch'])
 
287
                ll.set_markup('<b>' + ll.get_text() + '</b>')
171
288
                ll.show()
172
289
                l.show()
173
290
                if not display:
182
299
                ll = self.glade.get_widget('label_info_format_control_label')
183
300
                l = self.glade.get_widget('label_info_format_control')
184
301
                l.set_text(self.ret['format']['control'])
 
302
                ll.set_markup('<b>' + ll.get_text() + '</b>')
185
303
                ll.show()
186
304
                l.show()
187
305
                if not display:
192
310
                ll = self.glade.get_widget('label_info_format_workingtree_label')
193
311
                l = self.glade.get_widget('label_info_format_workingtree')
194
312
                l.set_text(self.ret['format']['workingtree'])
 
313
                ll.set_markup('<b>' + ll.get_text() + '</b>')
195
314
                ll.show()
196
315
                l.show()
197
316
                if not display:
202
321
                ll = self.glade.get_widget('label_info_format_branch_label')
203
322
                l = self.glade.get_widget('label_info_format_branch')
204
323
                l.set_text(self.ret['format']['branch'])
 
324
                ll.set_markup('<b>' + ll.get_text() + '</b>')
205
325
                ll.show()
206
326
                l.show()
207
327
                if not display:
212
332
                ll = self.glade.get_widget('label_info_format_repository_label')
213
333
                l = self.glade.get_widget('label_info_format_repository')
214
334
                l.set_text(self.ret['format']['repository'])
 
335
                ll.set_markup('<b>' + ll.get_text() + '</b>')
215
336
                ll.show()
216
337
                l.show()
217
338
                if not display:
226
347
                ll = self.glade.get_widget('label_info_locking_workingtree_label')
227
348
                l = self.glade.get_widget('label_info_locking_workingtree')
228
349
                l.set_text(self.ret['locking']['workingtree'])
 
350
                ll.set_markup('<b>' + ll.get_text() + '</b>')
229
351
                ll.show()
230
352
                l.show()
231
353
                if not display:
236
358
                ll = self.glade.get_widget('label_info_locking_branch_label')
237
359
                l = self.glade.get_widget('label_info_locking_branch')
238
360
                l.set_text(self.ret['locking']['branch'])
 
361
                ll.set_markup('<b>' + ll.get_text() + '</b>')
239
362
                ll.show()
240
363
                l.show()
241
364
                if not display:
246
369
                ll = self.glade.get_widget('label_info_locking_repository_label')
247
370
                l = self.glade.get_widget('label_info_locking_repository')
248
371
                l.set_text(self.ret['locking']['repository'])
 
372
                ll.set_markup('<b>' + ll.get_text() + '</b>')
249
373
                ll.show()
250
374
                l.show()
251
375
                if not display:
288
412
                ll = self.glade.get_widget('label_info_wtstats_unchanged_label')
289
413
                l = self.glade.get_widget('label_info_wtstats_unchanged')
290
414
                l.set_text(str(self.ret['wtstats']['unchanged']))
 
415
                ll.set_markup('<b>' + ll.get_text() + '</b>')
291
416
                ll.show()
292
417
                l.show()
293
418
                if not display:
298
423
                ll = self.glade.get_widget('label_info_wtstats_modified_label')
299
424
                l = self.glade.get_widget('label_info_wtstats_modified')
300
425
                l.set_text(str(self.ret['wtstats']['modified']))
 
426
                ll.set_markup('<b>' + ll.get_text() + '</b>')
301
427
                ll.show()
302
428
                l.show()
303
429
                if not display:
308
434
                ll = self.glade.get_widget('label_info_wtstats_added_label')
309
435
                l = self.glade.get_widget('label_info_wtstats_added')
310
436
                l.set_text(str(self.ret['wtstats']['added']))
 
437
                ll.set_markup('<b>' + ll.get_text() + '</b>')
311
438
                ll.show()
312
439
                l.show()
313
440
                if not display:
318
445
                ll = self.glade.get_widget('label_info_wtstats_removed_label')
319
446
                l = self.glade.get_widget('label_info_wtstats_removed')
320
447
                l.set_text(str(self.ret['wtstats']['removed']))
 
448
                ll.set_markup('<b>' + ll.get_text() + '</b>')
321
449
                ll.show()
322
450
                l.show()
323
451
                if not display:
328
456
                ll = self.glade.get_widget('label_info_wtstats_renamed_label')
329
457
                l = self.glade.get_widget('label_info_wtstats_renamed')
330
458
                l.set_text(str(self.ret['wtstats']['renamed']))
 
459
                ll.set_markup('<b>' + ll.get_text() + '</b>')
331
460
                ll.show()
332
461
                l.show()
333
462
                if not display:
338
467
                ll = self.glade.get_widget('label_info_wtstats_unknown_label')
339
468
                l = self.glade.get_widget('label_info_wtstats_unknown')
340
469
                l.set_text(str(self.ret['wtstats']['unknown']))
 
470
                ll.set_markup('<b>' + ll.get_text() + '</b>')
341
471
                ll.show()
342
472
                l.show()
343
473
                if not display:
348
478
                ll = self.glade.get_widget('label_info_wtstats_ignored_label')
349
479
                l = self.glade.get_widget('label_info_wtstats_ignored')
350
480
                l.set_text(str(self.ret['wtstats']['ignored']))
 
481
                ll.set_markup('<b>' + ll.get_text() + '</b>')
351
482
                ll.show()
352
483
                l.show()
353
484
                if not display:
358
489
                ll = self.glade.get_widget('label_info_wtstats_subdirs_label')
359
490
                l = self.glade.get_widget('label_info_wtstats_subdirs')
360
491
                l.set_text(str(self.ret['wtstats']['subdirs']))
 
492
                ll.set_markup('<b>' + ll.get_text() + '</b>')
361
493
                ll.show()
362
494
                l.show()
363
495
                if not display:
372
504
                ll = self.glade.get_widget('label_info_brstats_revno_label')
373
505
                l = self.glade.get_widget('label_info_brstats_revno')
374
506
                l.set_text(str(self.ret['brstats']['revno']))
 
507
                ll.set_markup('<b>' + ll.get_text() + '</b>')
375
508
                ll.show()
376
509
                l.show()
377
510
                if not display:
382
515
                ll = self.glade.get_widget('label_info_brstats_commiters_label')
383
516
                l = self.glade.get_widget('label_info_brstats_commiters')
384
517
                l.set_text(str(self.ret['brstats']['commiters']))
 
518
                ll.set_markup('<b>' + ll.get_text() + '</b>')
385
519
                ll.show()
386
520
                l.show()
387
521
                if not display:
392
526
                ll = self.glade.get_widget('label_info_brstats_age_label')
393
527
                l = self.glade.get_widget('label_info_brstats_age')
394
528
                l.set_text('%d days' % self.ret['brstats']['age'])
 
529
                ll.set_markup('<b>' + ll.get_text() + '</b>')
395
530
                ll.show()
396
531
                l.show()
397
532
                if not display:
402
537
                ll = self.glade.get_widget('label_info_brstats_firstrev_label')
403
538
                l = self.glade.get_widget('label_info_brstats_firstrev')
404
539
                l.set_text(self.ret['brstats']['firstrev'])
 
540
                ll.set_markup('<b>' + ll.get_text() + '</b>')
405
541
                ll.show()
406
542
                l.show()
407
543
                if not display:
412
548
                ll = self.glade.get_widget('label_info_brstats_lastrev_label')
413
549
                l = self.glade.get_widget('label_info_brstats_lastrev')
414
550
                l.set_text(self.ret['brstats']['lastrev'])
 
551
                ll.set_markup('<b>' + ll.get_text() + '</b>')
415
552
                ll.show()
416
553
                l.show()
417
554
                if not display:
426
563
                ll = self.glade.get_widget('label_info_repstats_revisions_label')
427
564
                l = self.glade.get_widget('label_info_repstats_revisions')
428
565
                l.set_text(str(self.ret['repstats']['revisions']))
 
566
                ll.set_markup('<b>' + ll.get_text() + '</b>')
429
567
                ll.show()
430
568
                l.show()
431
569
                if not display:
436
574
                ll = self.glade.get_widget('label_info_repstats_size_label')
437
575
                l = self.glade.get_widget('label_info_repstats_size')
438
576
                l.set_text('%d KiB' % (self.ret['repstats']['size'] / 1024))
 
577
                ll.set_markup('<b>' + ll.get_text() + '</b>')
439
578
                ll.show()
440
579
                l.show()
441
580
                if not display: