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