/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-27 18:08:35 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927180835-4c295d9bb936623a
Turn some windows into dialogs.
Remove the diffwindow code from olive, 
switched to using the one from bzr-gtk instead.

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. """
37
 
    def __init__(self, gladefile, comm, dialog):
 
147
    def __init__(self, gladefile, comm):
38
148
        """ Initialize the Informations window. """
39
149
        self.gladefile = gladefile
40
150
        self.glade = gtk.glade.XML(self.gladefile, 'window_info', 'olive-gtk')
41
151
        
42
152
        # Communication object
43
153
        self.comm = comm
44
 
        # Dialog object
45
 
        self.dialog = dialog
46
154
        
47
155
        # Get the Informations window widget
48
156
        self.window = self.glade.get_widget('window_info')
50
158
        # Check if current location is a branch
51
159
        self.notbranch = False
52
160
        try:
53
 
            self.ret = info.info(self.comm.get_path())
 
161
            self.ret = info(self.comm.get_path())
54
162
        except errors.NotBranchError:
55
163
            self.notbranch = True
56
164
            return
57
 
        except:
58
 
            raise
59
165
        
60
166
        # Dictionary for signal_autoconnect
61
167
        dic = { "on_button_info_close_clicked": self.close,
451
557
    def display(self):
452
558
        """ Display the Informations window. """
453
559
        if self.notbranch:
454
 
            self.dialog.error_dialog(_('Directory is not a branch'),
 
560
            error_dialog(_('Directory is not a branch'),
455
561
                                     _('You can perform this action only in a branch.'))
456
562
            self.close()
457
563
        else: