/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: 2011-03-11 23:00:17 UTC
  • mfrom: (719.1.3 bzr-gtk)
  • Revision ID: jelmer@canonical.com-20110311230017-yexxy58qe5f8fegx
Merge translations.

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