/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: 2008-05-04 18:16:01 UTC
  • Revision ID: jelmer@samba.org-20080504181601-u5gh89q8l2we201l
Fix display of children in branchview.

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
 
 
32
 
import olive.backend.errors as errors
33
 
import olive.backend.info as info
 
22
 
 
23
import gtk
 
24
import gtk.glade
 
25
 
 
26
import bzrlib.errors as errors
 
27
 
 
28
from bzrlib.plugins.gtk.dialog import error_dialog
 
29
from guifiles import GLADEFILENAME
 
30
 
 
31
 
 
32
def info(location):
 
33
    """ Get info about branch, working tree, and repository
 
34
    
 
35
    :param location: the location of the branch/working tree/repository
 
36
    
 
37
    :return: the information in dictionary format
 
38
    
 
39
    The following informations are delivered (if available):
 
40
    ret['location']['lightcoroot']: Light checkout root
 
41
    ret['location']['sharedrepo']: Shared repository
 
42
    ret['location']['repobranch']: Repository branch
 
43
    ret['location']['cobranch']: Checkout of branch
 
44
    ret['location']['repoco']: Repository checkout
 
45
    ret['location']['coroot']: Checkout root
 
46
    ret['location']['branchroot']: Branch root
 
47
    ret['related']['parentbranch']: Parent branch
 
48
    ret['related']['publishbranch']: Publish to branch
 
49
    ret['format']['control']: Control format
 
50
    ret['format']['workingtree']: Working tree format
 
51
    ret['format']['branch']: Branch format
 
52
    ret['format']['repository']: Repository format
 
53
    ret['locking']['workingtree']: Working tree lock status
 
54
    ret['locking']['branch']: Branch lock status
 
55
    ret['locking']['repository']: Repository lock status
 
56
    ret['missing']['branch']: Missing revisions in branch
 
57
    ret['missing']['workingtree']: Missing revisions in working tree
 
58
    ret['wtstats']['unchanged']: Unchanged files
 
59
    ret['wtstats']['modified']: Modified files
 
60
    ret['wtstats']['added']: Added files
 
61
    ret['wtstats']['removed']: Removed files
 
62
    ret['wtstats']['renamed']: Renamed files
 
63
    ret['wtstats']['unknown']: Unknown files
 
64
    ret['wtstats']['ignored']: Ingnored files
 
65
    ret['wtstats']['subdirs']: Versioned subdirectories
 
66
    ret['brstats']['revno']: Revisions in branch
 
67
    ret['brstats']['commiters']: Number of commiters
 
68
    ret['brstats']['age']: Age of branch in days
 
69
    ret['brstats']['firstrev']: Time of first revision
 
70
    ret['brstats']['lastrev']: Time of last revision
 
71
    ret['repstats']['revisions']: Revisions in repository
 
72
    ret['repstats']['size']: Size of repository in bytes
 
73
    """
 
74
    import bzrlib.bzrdir as bzrdir
 
75
    
 
76
    import info_helper
 
77
    
 
78
    ret = {}
 
79
    try:
 
80
        a_bzrdir = bzrdir.BzrDir.open_containing(location)[0]
 
81
    except errors.NotBranchError:
 
82
        raise errors.NotBranchError(location)
 
83
 
 
84
    try:
 
85
        working = a_bzrdir.open_workingtree()
 
86
        working.lock_read()
 
87
        try:
 
88
            branch = working.branch
 
89
            repository = branch.repository
 
90
            control = working.bzrdir
 
91
            
 
92
            ret['location'] = info_helper.get_location_info(repository, branch, working)
 
93
            ret['related'] = info_helper.get_related_info(branch)
 
94
            ret['format'] = info_helper.get_format_info(control, repository, branch, working)
 
95
            ret['locking'] = info_helper.get_locking_info(repository, branch, working)
 
96
            ret['missing'] = {}
 
97
            ret['missing']['branch'] = info_helper.get_missing_revisions_branch(branch)
 
98
            ret['missing']['workingtree'] = info_helper.get_missing_revisions_working(working)
 
99
            ret['wtstats'] = info_helper.get_working_stats(working)
 
100
            ret['brstats'] = info_helper.get_branch_stats(branch)
 
101
            ret['repstats'] = info_helper.get_repository_stats(repository)
 
102
        finally:
 
103
            working.unlock()
 
104
            return ret
 
105
        return
 
106
    except (errors.NoWorkingTree, errors.NotLocalUrl):
 
107
        pass
 
108
 
 
109
    try:
 
110
        branch = a_bzrdir.open_branch()
 
111
        repository = branch.repository
 
112
        control = a_bzrdir
 
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, branch):
38
148
        """ Initialize the Informations window. """
39
 
        self.gladefile = gladefile
40
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_info', 'olive-gtk')
41
 
        
42
 
        # Communication object
43
 
        self.comm = comm
44
 
        # Dialog object
45
 
        self.dialog = dialog
 
149
        self.glade = gtk.glade.XML(GLADEFILENAME, 'window_info', 'olive-gtk')
46
150
        
47
151
        # Get the Informations window widget
48
152
        self.window = self.glade.get_widget('window_info')
50
154
        # Check if current location is a branch
51
155
        self.notbranch = False
52
156
        try:
53
 
            self.ret = info.info(self.comm.get_path())
 
157
            self.ret = info(branch.base)
54
158
        except errors.NotBranchError:
55
159
            self.notbranch = True
56
160
            return
57
 
        except:
58
 
            raise
59
161
        
60
162
        # Dictionary for signal_autoconnect
61
163
        dic = { "on_button_info_close_clicked": self.close,
451
553
    def display(self):
452
554
        """ Display the Informations window. """
453
555
        if self.notbranch:
454
 
            self.dialog.error_dialog(_('Directory is not a branch'),
455
 
                                     _('You can perform this action only in a branch.'))
 
556
            error_dialog(_('Directory is not a branch'),
 
557
                         _('You can perform this action only in a branch.'))
456
558
            self.close()
457
559
        else:
458
560
            self.window.show()