/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-27 19:10:00 UTC
  • mto: (0.14.1 main)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060927191000-2b5382eda85d82e4
Fixed a context menu bug; set release date.

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'])
87
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
88
195
                ll.show()
89
196
                l.show()
90
197
                if not display:
95
202
                ll = self.glade.get_widget('label_info_location_sharedrepo_label')
96
203
                l = self.glade.get_widget('label_info_location_sharedrepo')
97
204
                l.set_text(self.ret['location']['sharedrepo'])
98
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
99
205
                ll.show()
100
206
                l.show()
101
207
                if not display:
106
212
                ll = self.glade.get_widget('label_info_location_repobranch_label')
107
213
                l = self.glade.get_widget('label_info_location_repobranch')
108
214
                l.set_text(self.ret['location']['repobranch'])
109
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
110
215
                ll.show()
111
216
                l.show()
112
217
                if not display:
117
222
                ll = self.glade.get_widget('label_info_location_cobranch_label')
118
223
                l = self.glade.get_widget('label_info_location_cobranch')
119
224
                l.set_text(self.ret['location']['cobranch'])
120
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
121
225
                ll.show()
122
226
                l.show()
123
227
                if not display:
128
232
                ll = self.glade.get_widget('label_info_location_repoco_label')
129
233
                l = self.glade.get_widget('label_info_location_repoco')
130
234
                l.set_text(self.ret['location']['repoco'])
131
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
132
235
                ll.show()
133
236
                l.show()
134
237
                if not display:
139
242
                ll = self.glade.get_widget('label_info_location_coroot_label')
140
243
                l = self.glade.get_widget('label_info_location_coroot')
141
244
                l.set_text(self.ret['location']['coroot'])
142
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
143
245
                ll.show()
144
246
                l.show()
145
247
                if not display:
150
252
                ll = self.glade.get_widget('label_info_location_branchroot_label')
151
253
                l = self.glade.get_widget('label_info_location_branchroot')
152
254
                l.set_text(self.ret['location']['branchroot'])
153
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
154
255
                ll.show()
155
256
                l.show()
156
257
                if not display:
165
266
                ll = self.glade.get_widget('label_info_related_parentbranch_label')
166
267
                l = self.glade.get_widget('label_info_related_parentbranch')
167
268
                l.set_text(self.ret['related']['parentbranch'])
168
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
169
269
                ll.show()
170
270
                l.show()
171
271
                if not display:
176
276
                ll = self.glade.get_widget('label_info_related_publishbranch_label')
177
277
                l = self.glade.get_widget('label_info_related_publishbranch')
178
278
                l.set_text(self.ret['related']['publishbranch'])
179
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
180
279
                ll.show()
181
280
                l.show()
182
281
                if not display:
191
290
                ll = self.glade.get_widget('label_info_format_control_label')
192
291
                l = self.glade.get_widget('label_info_format_control')
193
292
                l.set_text(self.ret['format']['control'])
194
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
195
293
                ll.show()
196
294
                l.show()
197
295
                if not display:
202
300
                ll = self.glade.get_widget('label_info_format_workingtree_label')
203
301
                l = self.glade.get_widget('label_info_format_workingtree')
204
302
                l.set_text(self.ret['format']['workingtree'])
205
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
206
303
                ll.show()
207
304
                l.show()
208
305
                if not display:
213
310
                ll = self.glade.get_widget('label_info_format_branch_label')
214
311
                l = self.glade.get_widget('label_info_format_branch')
215
312
                l.set_text(self.ret['format']['branch'])
216
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
217
313
                ll.show()
218
314
                l.show()
219
315
                if not display:
224
320
                ll = self.glade.get_widget('label_info_format_repository_label')
225
321
                l = self.glade.get_widget('label_info_format_repository')
226
322
                l.set_text(self.ret['format']['repository'])
227
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
228
323
                ll.show()
229
324
                l.show()
230
325
                if not display:
239
334
                ll = self.glade.get_widget('label_info_locking_workingtree_label')
240
335
                l = self.glade.get_widget('label_info_locking_workingtree')
241
336
                l.set_text(self.ret['locking']['workingtree'])
242
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
243
337
                ll.show()
244
338
                l.show()
245
339
                if not display:
250
344
                ll = self.glade.get_widget('label_info_locking_branch_label')
251
345
                l = self.glade.get_widget('label_info_locking_branch')
252
346
                l.set_text(self.ret['locking']['branch'])
253
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
254
347
                ll.show()
255
348
                l.show()
256
349
                if not display:
261
354
                ll = self.glade.get_widget('label_info_locking_repository_label')
262
355
                l = self.glade.get_widget('label_info_locking_repository')
263
356
                l.set_text(self.ret['locking']['repository'])
264
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
265
357
                ll.show()
266
358
                l.show()
267
359
                if not display:
304
396
                ll = self.glade.get_widget('label_info_wtstats_unchanged_label')
305
397
                l = self.glade.get_widget('label_info_wtstats_unchanged')
306
398
                l.set_text(str(self.ret['wtstats']['unchanged']))
307
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
308
399
                ll.show()
309
400
                l.show()
310
401
                if not display:
315
406
                ll = self.glade.get_widget('label_info_wtstats_modified_label')
316
407
                l = self.glade.get_widget('label_info_wtstats_modified')
317
408
                l.set_text(str(self.ret['wtstats']['modified']))
318
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
319
409
                ll.show()
320
410
                l.show()
321
411
                if not display:
326
416
                ll = self.glade.get_widget('label_info_wtstats_added_label')
327
417
                l = self.glade.get_widget('label_info_wtstats_added')
328
418
                l.set_text(str(self.ret['wtstats']['added']))
329
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
330
419
                ll.show()
331
420
                l.show()
332
421
                if not display:
337
426
                ll = self.glade.get_widget('label_info_wtstats_removed_label')
338
427
                l = self.glade.get_widget('label_info_wtstats_removed')
339
428
                l.set_text(str(self.ret['wtstats']['removed']))
340
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
341
429
                ll.show()
342
430
                l.show()
343
431
                if not display:
348
436
                ll = self.glade.get_widget('label_info_wtstats_renamed_label')
349
437
                l = self.glade.get_widget('label_info_wtstats_renamed')
350
438
                l.set_text(str(self.ret['wtstats']['renamed']))
351
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
352
439
                ll.show()
353
440
                l.show()
354
441
                if not display:
359
446
                ll = self.glade.get_widget('label_info_wtstats_unknown_label')
360
447
                l = self.glade.get_widget('label_info_wtstats_unknown')
361
448
                l.set_text(str(self.ret['wtstats']['unknown']))
362
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
363
449
                ll.show()
364
450
                l.show()
365
451
                if not display:
370
456
                ll = self.glade.get_widget('label_info_wtstats_ignored_label')
371
457
                l = self.glade.get_widget('label_info_wtstats_ignored')
372
458
                l.set_text(str(self.ret['wtstats']['ignored']))
373
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
374
459
                ll.show()
375
460
                l.show()
376
461
                if not display:
381
466
                ll = self.glade.get_widget('label_info_wtstats_subdirs_label')
382
467
                l = self.glade.get_widget('label_info_wtstats_subdirs')
383
468
                l.set_text(str(self.ret['wtstats']['subdirs']))
384
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
385
469
                ll.show()
386
470
                l.show()
387
471
                if not display:
396
480
                ll = self.glade.get_widget('label_info_brstats_revno_label')
397
481
                l = self.glade.get_widget('label_info_brstats_revno')
398
482
                l.set_text(str(self.ret['brstats']['revno']))
399
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
400
483
                ll.show()
401
484
                l.show()
402
485
                if not display:
407
490
                ll = self.glade.get_widget('label_info_brstats_commiters_label')
408
491
                l = self.glade.get_widget('label_info_brstats_commiters')
409
492
                l.set_text(str(self.ret['brstats']['commiters']))
410
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
411
493
                ll.show()
412
494
                l.show()
413
495
                if not display:
418
500
                ll = self.glade.get_widget('label_info_brstats_age_label')
419
501
                l = self.glade.get_widget('label_info_brstats_age')
420
502
                l.set_text('%d days' % self.ret['brstats']['age'])
421
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
422
503
                ll.show()
423
504
                l.show()
424
505
                if not display:
429
510
                ll = self.glade.get_widget('label_info_brstats_firstrev_label')
430
511
                l = self.glade.get_widget('label_info_brstats_firstrev')
431
512
                l.set_text(self.ret['brstats']['firstrev'])
432
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
433
513
                ll.show()
434
514
                l.show()
435
515
                if not display:
440
520
                ll = self.glade.get_widget('label_info_brstats_lastrev_label')
441
521
                l = self.glade.get_widget('label_info_brstats_lastrev')
442
522
                l.set_text(self.ret['brstats']['lastrev'])
443
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
444
523
                ll.show()
445
524
                l.show()
446
525
                if not display:
455
534
                ll = self.glade.get_widget('label_info_repstats_revisions_label')
456
535
                l = self.glade.get_widget('label_info_repstats_revisions')
457
536
                l.set_text(str(self.ret['repstats']['revisions']))
458
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
459
537
                ll.show()
460
538
                l.show()
461
539
                if not display:
466
544
                ll = self.glade.get_widget('label_info_repstats_size_label')
467
545
                l = self.glade.get_widget('label_info_repstats_size')
468
546
                l.set_text('%d KiB' % (self.ret['repstats']['size'] / 1024))
469
 
                ll.set_markup('<b>' + ll.get_text() + '</b>')
470
547
                ll.show()
471
548
                l.show()
472
549
                if not display: