/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-10-20 11:18:37 UTC
  • Revision ID: Szilveszter.Farkas@gmail.com-20061020111837-e2a99e1d4db9f0f7
Removed completed TODO items.

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