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