30
import olive.backend.init as init
31
import olive.backend.errors as errors
30
import bzrlib.errors as errors
34
33
""" Display branch dialog and perform the needed operations. """
35
def __init__(self, gladefile, comm, dialog):
34
def __init__(self, gladefile, comm):
36
35
""" Initialize the Branch dialog. """
37
36
self.gladefile = gladefile
38
37
self.glade = gtk.glade.XML(self.gladefile, 'window_branch', 'olive-gtk')
40
39
# Communication object
45
42
self.window = self.glade.get_widget('window_branch')
72
69
spinbutton_revno = self.glade.get_widget('spinbutton_branch_revno')
73
70
revno = spinbutton_revno.get_value_as_int()
71
revision_id = br_from.get_rev_id(revno)
77
73
self.comm.set_busy(self.window)
79
revs = init.branch(location, destination, revno)
75
from bzrlib.transport import get_transport
77
br_from = Branch.open(location)
82
destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
83
to_transport = get_transport(destination)
85
to_transport.mkdir('.')
88
dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
89
branch = dir.open_branch()
90
except NoSuchRevision:
91
to_transport.delete_tree('.')
98
info_dialog(_('Branching successful'),
99
_('%d revision(s) branched.') % revs)
100
self.comm.refresh_right()
80
101
except errors.NonExistingSource, errmsg:
81
self.dialog.error_dialog(_('Non existing source'),
102
error_dialog(_('Non existing source'),
82
103
_("The location (%s)\ndoesn't exist.") % errmsg)
83
104
self.comm.set_busy(self.window, False)
85
106
except errors.TargetAlreadyExists, errmsg:
86
self.dialog.error_dialog(_('Target already exists'),
107
error_dialog(_('Target already exists'),
87
108
_('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
88
109
self.comm.set_busy(self.window, False)
90
111
except errors.NonExistingParent, errmsg:
91
self.dialog.error_dialog(_('Non existing parent directory'),
112
error_dialog(_('Non existing parent directory'),
92
113
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
93
114
self.comm.set_busy(self.window, False)
95
116
except errors.NonExistingRevision:
96
self.dialog.error_dialog(_('Non existing revision'),
117
error_dialog(_('Non existing revision'),
97
118
_("The revision you specified doesn't exist."))
98
119
self.comm.set_busy(self.window, False)
100
121
except errors.NotBranchError, errmsg:
101
self.dialog.error_dialog(_('Location is not a branch'),
122
error_dialog(_('Location is not a branch'),
102
123
_('The specified location has to be a branch.'))
103
124
self.comm.set_busy(self.window, False)
109
self.dialog.info_dialog(_('Branching successful'),
110
_('%d revision(s) branched.') % revs)
111
self.comm.refresh_right()
113
128
def close(self, widget=None):
114
129
self.window.destroy()