21
21
pygtk.require("2.0")
30
import olive.backend.init as init
31
import olive.backend.errors as errors
28
import bzrlib.errors as errors
29
from __init__ import gladefile
34
32
""" Display branch dialog and perform the needed operations. """
35
def __init__(self, gladefile, comm, dialog):
33
def __init__(self, path=None):
36
34
""" Initialize the Branch dialog. """
37
self.gladefile = gladefile
38
self.glade = gtk.glade.XML(self.gladefile, 'window_branch', 'olive-gtk')
40
# Communication object
35
self.glade = gtk.glade.XML(gladefile, 'window_branch', 'olive-gtk')
45
37
self.window = self.glade.get_widget('window_branch')
47
39
# Dictionary for signal_autoconnect
72
65
spinbutton_revno = self.glade.get_widget('spinbutton_branch_revno')
73
66
revno = spinbutton_revno.get_value_as_int()
67
revision_id = br_from.get_rev_id(revno)
77
self.comm.set_busy(self.window)
79
revs = init.branch(location, destination, revno)
70
from bzrlib.transport import get_transport
72
br_from = Branch.open(location)
76
destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
77
to_transport = get_transport(destination)
78
to_transport.mkdir('.')
81
dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
82
branch = dir.open_branch()
83
except NoSuchRevision:
84
to_transport.delete_tree('.')
91
info_dialog(_('Branching successful'),
92
_('%d revision(s) branched.') % revs)
80
93
except errors.NonExistingSource, errmsg:
81
self.dialog.error_dialog(_('Non existing source'),
94
error_dialog(_('Non existing source'),
82
95
_("The location (%s)\ndoesn't exist.") % errmsg)
83
self.comm.set_busy(self.window, False)
85
97
except errors.TargetAlreadyExists, errmsg:
86
self.dialog.error_dialog(_('Target already exists'),
98
error_dialog(_('Target already exists'),
87
99
_('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
88
self.comm.set_busy(self.window, False)
90
101
except errors.NonExistingParent, errmsg:
91
self.dialog.error_dialog(_('Non existing parent directory'),
102
error_dialog(_('Non existing parent directory'),
92
103
_("The parent directory (%s)\ndoesn't exist.") % errmsg)
93
self.comm.set_busy(self.window, False)
95
105
except errors.NonExistingRevision:
96
self.dialog.error_dialog(_('Non existing revision'),
106
error_dialog(_('Non existing revision'),
97
107
_("The revision you specified doesn't exist."))
98
self.comm.set_busy(self.window, False)
100
109
except errors.NotBranchError, errmsg:
101
self.dialog.error_dialog(_('Location is not a branch'),
110
error_dialog(_('Location is not a branch'),
102
111
_('The specified location has to be a branch.'))
103
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
115
def close(self, widget=None):
114
116
self.window.destroy()