/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 branch.py

  • Committer: Jelmer Vernooij
  • Date: 2008-06-29 19:07:23 UTC
  • mto: This revision was merged to the branch mainline in revision 515.
  • Revision ID: jelmer@samba.org-20080629190723-l8mzg9x4oec0lhsl
Return cleartext from seahorse module

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
import gtk
26
26
 
27
 
from bzrlib import (
28
 
    errors,
29
 
    )
 
27
from errors import show_bzr_error
 
28
 
30
29
from bzrlib.branch import Branch
31
 
from bzrlib.transport import get_transport
32
 
 
 
30
import bzrlib.errors as errors
33
31
 
34
32
from bzrlib.plugins.gtk import _i18n
35
33
 
36
 
from bzrlib.plugins.gtk.dialog import error_dialog, info_dialog
37
 
from bzrlib.plugins.gtk.errors import show_bzr_error
38
 
from bzrlib.plugins.gtk.branchbox import BranchSelectionBox
 
34
from dialog import error_dialog, info_dialog
39
35
 
 
36
from branchbox import BranchSelectionBox
40
37
 
41
38
class BranchDialog(gtk.Dialog):
42
39
    """ New implementation of the Branch dialog. """
47
44
                                  parent=parent,
48
45
                                  flags=0,
49
46
                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
50
 
 
 
47
        
51
48
        # Get arguments
52
49
        self.path = path
53
 
 
 
50
        
54
51
        # Create the widgets
55
52
        self._button_branch = gtk.Button(_i18n("_Branch"), use_underline=True)
56
53
        self._remote_branch = BranchSelectionBox()
65
62
        self._hbox_revision = gtk.HBox()
66
63
        self._entry_revision = gtk.Entry()
67
64
        self._entry_nick = gtk.Entry()
68
 
 
 
65
        
69
66
        # Set callbacks
70
67
        self._button_branch.connect('clicked', self._on_branch_clicked)
71
68
        self._button_revision.connect('clicked', self._on_revision_clicked)
81
78
        self._table.attach(self._filechooser, 1, 2, 1, 2)
82
79
        self._table.attach(self._entry_nick, 1, 2, 2, 3)
83
80
        self._table.attach(self._hbox_revision, 1, 2, 3, 4)
84
 
 
 
81
        
85
82
        # Set properties
86
83
        self._image_browse = gtk.Image()
87
84
        self._image_browse.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_BUTTON)
97
94
            self._remote_branch.set_url(remote_path)
98
95
        if self.path is not None:
99
96
            self._filechooser.set_filename(self.path)
100
 
 
 
97
        
101
98
        # Pack some widgets
102
99
        self._hbox_revision.pack_start(self._entry_revision, True, True)
103
100
        self._hbox_revision.pack_start(self._button_revision, False, False)
104
101
        self.vbox.add(self._table)
105
102
        self.action_area.pack_end(self._button_branch)
106
 
 
 
103
        
107
104
        # Show the dialog
108
105
        self.vbox.show_all()
109
 
 
 
106
    
110
107
    def _get_last_revno(self):
111
108
        """ Get the revno of the last revision (if any). """
112
109
        try:
114
111
            return br.revno()
115
112
        except:
116
113
            pass
117
 
 
 
114
    
118
115
    def _on_revision_clicked(self, button):
119
116
        """ Browse for revision button clicked handler. """
120
117
        from revbrowser import RevisionBrowser
121
 
 
122
 
 
 
118
        
 
119
        
123
120
        try:
124
121
            br = self._remote_branch.get_branch()
125
122
        except:
128
125
        response = revb.run()
129
126
        if response != gtk.RESPONSE_NONE:
130
127
            revb.hide()
131
 
 
 
128
    
132
129
            if response == gtk.RESPONSE_OK:
133
130
                if revb.selected_revno is not None:
134
131
                    self._entry_revision.set_text(revb.selected_revno)
135
 
 
 
132
        
136
133
            revb.destroy()
137
 
 
 
134
    
138
135
    @show_bzr_error
139
136
    def _on_branch_clicked(self, button):
140
137
        """ Branch button clicked handler. """
143
140
            error_dialog(_i18n('Missing branch location'),
144
141
                         _i18n('You must specify a branch location.'))
145
142
            return
146
 
 
 
143
        
147
144
        destination = self._filechooser.get_filename()
148
145
        try:
149
146
            revno = int(self._entry_revision.get_text())
150
147
        except:
151
148
            revno = None
152
 
 
 
149
        
153
150
        nick = self._entry_nick.get_text()
154
151
        if nick is '':
155
152
            nick = os.path.basename(location.rstrip("/\\"))
156
 
 
 
153
        
157
154
        br_from = Branch.open(location)
158
 
 
 
155
        
159
156
        br_from.lock_read()
160
157
        try:
 
158
            from bzrlib.transport import get_transport
 
159
 
161
160
            revision_id = br_from.get_rev_id(revno)
162
161
 
163
162
            basis_dir = None
164
 
 
 
163
            
165
164
            to_location = destination + os.sep + nick
166
165
            to_transport = get_transport(to_location)
167
 
 
 
166
            
168
167
            to_transport.mkdir('.')
169
 
 
 
168
            
170
169
            try:
171
170
                # preserve whatever source format we have.
172
171
                dir = br_from.bzrdir.sprout(to_transport.base,
179
178
                raise
180
179
        finally:
181
180
            br_from.unlock()
182
 
 
 
181
                
183
182
        info_dialog(_i18n('Branching successful'),
184
183
                    _i18n('%d revision(s) branched.') % revs)
185
 
 
 
184
        
186
185
        self.response(gtk.RESPONSE_OK)
187
 
 
 
186
    
188
187
    def _on_branch_changed(self, widget, event):
189
188
        """ We try to get the last revision if focus lost. """
190
189
        rev = self._get_last_revno()