/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: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

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