/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/branch.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-27 18:08:35 UTC
  • mto: (0.12.2 olive)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060927180835-4c295d9bb936623a
Turn some windows into dialogs.
Remove the diffwindow code from olive, 
switched to using the one from bzr-gtk instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
except:
28
28
    sys.exit(1)
29
29
 
30
 
import olive.backend.init as init
31
 
import olive.backend.errors as errors
 
30
import bzrlib.errors as errors
32
31
 
33
32
class OliveBranch:
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')
39
38
        
40
39
        # Communication object
41
40
        self.comm = comm
42
 
        # Dialog object
43
 
        self.dialog = dialog
44
41
        
45
42
        self.window = self.glade.get_widget('window_branch')
46
43
        
63
60
        entry_location = self.glade.get_widget('entry_branch_location')
64
61
        location = entry_location.get_text()
65
62
        if location is '':
66
 
            self.dialog.error_dialog(_('Missing branch location'),
 
63
            error_dialog(_('Missing branch location'),
67
64
                                     _('You must specify a branch location.'))
68
65
            return
69
66
        
71
68
        
72
69
        spinbutton_revno = self.glade.get_widget('spinbutton_branch_revno')
73
70
        revno = spinbutton_revno.get_value_as_int()
74
 
        if revno == 0:
75
 
            revno = None
 
71
        revision_id = br_from.get_rev_id(revno)
76
72
        
77
73
        self.comm.set_busy(self.window)
78
74
        try:
79
 
            revs = init.branch(location, destination, revno)
 
75
            from bzrlib.transport import get_transport
 
76
 
 
77
            br_from = Branch.open(location)
 
78
 
 
79
            br_from.lock_read()
 
80
 
 
81
            try:
 
82
                destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
 
83
                to_transport = get_transport(destination)
 
84
 
 
85
                to_transport.mkdir('.')
 
86
 
 
87
                try:
 
88
                    dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
 
89
                    branch = dir.open_branch()
 
90
                except NoSuchRevision:
 
91
                    to_transport.delete_tree('.')
 
92
                    raise
 
93
 
 
94
            finally:
 
95
                br_from.unlock()
 
96
                
 
97
            self.close()
 
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)
84
105
            return
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)
89
110
            return
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)
94
115
            return
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)
99
120
            return
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)
104
125
            return
105
 
        except:
106
 
            raise
107
126
        
108
 
        self.close()
109
 
        self.dialog.info_dialog(_('Branching successful'),
110
 
                                _('%d revision(s) branched.') % revs)
111
 
        self.comm.refresh_right()
112
127
 
113
128
    def close(self, widget=None):
114
129
        self.window.destroy()