21
21
pygtk.require("2.0")
28
30
import bzrlib.errors as errors
29
from __init__ import gladefile
32
33
""" Display branch dialog and perform the needed operations. """
33
def __init__(self, path=None):
34
def __init__(self, gladefile, comm, dialog):
34
35
""" Initialize the Branch dialog. """
35
self.glade = gtk.glade.XML(gladefile, 'window_branch', 'olive-gtk')
36
self.gladefile = gladefile
37
self.glade = gtk.glade.XML(self.gladefile, 'window_branch', 'olive-gtk')
39
# Communication object
37
44
self.window = self.glade.get_widget('window_branch')
39
46
# Dictionary for signal_autoconnect
56
62
entry_location = self.glade.get_widget('entry_branch_location')
57
63
location = entry_location.get_text()
59
error_dialog(_('Missing branch location'),
65
self.dialog.error_dialog(_('Missing branch location'),
60
66
_('You must specify a branch location.'))
66
72
revno = spinbutton_revno.get_value_as_int()
67
73
revision_id = br_from.get_rev_id(revno)
75
self.comm.set_busy(self.window)
70
77
from bzrlib.transport import get_transport
72
79
br_from = Branch.open(location)
73
81
br_from.lock_read()
76
84
destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
77
85
to_transport = get_transport(destination)
78
87
to_transport.mkdir('.')
91
info_dialog(_('Branching successful'),
92
_('%d revision(s) branched.') % revs)
100
self.dialog.info_dialog(_('Branching successful'),
101
_('%d revision(s) branched.') % revs)
102
self.comm.refresh_right()
93
103
except errors.NonExistingSource, errmsg:
94
error_dialog(_('Non existing source'),
104
self.dialog.error_dialog(_('Non existing source'),
95
105
_("The location (%s)\ndoesn't exist.") % errmsg)
106
self.comm.set_busy(self.window, False)
97
108
except errors.TargetAlreadyExists, errmsg:
98
error_dialog(_('Target already exists'),
109
self.dialog.error_dialog(_('Target already exists'),
99
110
_('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
111
self.comm.set_busy(self.window, False)
101
113
except errors.NonExistingParent, errmsg:
102
error_dialog(_('Non existing parent directory'),
114
self.dialog.error_dialog(_('Non existing parent directory'),
103
115
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
116
self.comm.set_busy(self.window, False)
105
118
except errors.NonExistingRevision:
106
error_dialog(_('Non existing revision'),
119
self.dialog.error_dialog(_('Non existing revision'),
107
120
_("The revision you specified doesn't exist."))
121
self.comm.set_busy(self.window, False)
109
123
except errors.NotBranchError, errmsg:
110
error_dialog(_('Location is not a branch'),
124
self.dialog.error_dialog(_('Location is not a branch'),
111
125
_('The specified location has to be a branch.'))
126
self.comm.set_busy(self.window, False)