/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-13 20:19:31 UTC
  • mfrom: (0.8.79 main)
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060913201931-23adba246d4d6529
Merge main branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
    pygtk.require("2.0")
22
22
except:
23
23
    pass
24
 
 
25
 
import gtk
26
 
import gtk.glade
 
24
try:
 
25
    import gtk
 
26
    import gtk.glade
 
27
except:
 
28
    sys.exit(1)
27
29
 
28
30
import bzrlib.errors as errors
29
 
from __init__ import gladefile
30
31
 
31
32
class OliveBranch:
32
33
    """ Display branch dialog and perform the needed operations. """
33
 
    def __init__(self, path=None):
 
34
    def __init__(self, gladefile, comm, dialog):
34
35
        """ Initialize the Branch dialog. """
35
 
        self.glade = gtk.glade.XML(gladefile, 'window_branch', 'olive-gtk')
36
 
 
 
36
        self.gladefile = gladefile
 
37
        self.glade = gtk.glade.XML(self.gladefile, 'window_branch', 'olive-gtk')
 
38
        
 
39
        # Communication object
 
40
        self.comm = comm
 
41
        # Dialog object
 
42
        self.dialog = dialog
 
43
        
37
44
        self.window = self.glade.get_widget('window_branch')
38
45
        
39
46
        # Dictionary for signal_autoconnect
45
52
        
46
53
        # Save FileChooser state
47
54
        self.filechooser = self.glade.get_widget('filechooserbutton_branch')
48
 
        if path is not None:
49
 
            self.filechooser.set_filename(path)
 
55
        self.filechooser.set_filename(self.comm.get_path())
50
56
 
51
57
    def display(self):
52
58
        """ Display the Branch dialog. """
56
62
        entry_location = self.glade.get_widget('entry_branch_location')
57
63
        location = entry_location.get_text()
58
64
        if location is '':
59
 
            error_dialog(_('Missing branch location'),
 
65
            self.dialog.error_dialog(_('Missing branch location'),
60
66
                                     _('You must specify a branch location.'))
61
67
            return
62
68
        
66
72
        revno = spinbutton_revno.get_value_as_int()
67
73
        revision_id = br_from.get_rev_id(revno)
68
74
        
 
75
        self.comm.set_busy(self.window)
69
76
        try:
70
77
            from bzrlib.transport import get_transport
71
78
 
72
79
            br_from = Branch.open(location)
 
80
 
73
81
            br_from.lock_read()
74
82
 
75
83
            try:
76
84
                destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
77
85
                to_transport = get_transport(destination)
 
86
 
78
87
                to_transport.mkdir('.')
79
88
 
80
89
                try:
88
97
                br_from.unlock()
89
98
                
90
99
            self.close()
91
 
            info_dialog(_('Branching successful'),
92
 
                        _('%d revision(s) branched.') % revs)
 
100
            self.dialog.info_dialog(_('Branching successful'),
 
101
                                _('%d revision(s) branched.') % revs)
 
102
            self.comm.refresh_right()
93
103
        except errors.NonExistingSource, errmsg:
94
 
            error_dialog(_('Non existing source'),
 
104
            self.dialog.error_dialog(_('Non existing source'),
95
105
                                     _("The location (%s)\ndoesn't exist.") % errmsg)
 
106
            self.comm.set_busy(self.window, False)
96
107
            return
97
108
        except errors.TargetAlreadyExists, errmsg:
98
 
            error_dialog(_('Target already exists'),
 
109
            self.dialog.error_dialog(_('Target already exists'),
99
110
                                     _('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
 
111
            self.comm.set_busy(self.window, False)
100
112
            return
101
113
        except errors.NonExistingParent, errmsg:
102
 
            error_dialog(_('Non existing parent directory'),
 
114
            self.dialog.error_dialog(_('Non existing parent directory'),
103
115
                                     _("The parent directory (%s)\ndoesn't exist.") % errmsg)
 
116
            self.comm.set_busy(self.window, False)
104
117
            return
105
118
        except errors.NonExistingRevision:
106
 
            error_dialog(_('Non existing revision'),
 
119
            self.dialog.error_dialog(_('Non existing revision'),
107
120
                                     _("The revision you specified doesn't exist."))
 
121
            self.comm.set_busy(self.window, False)
108
122
            return
109
123
        except errors.NotBranchError, errmsg:
110
 
            error_dialog(_('Location is not a branch'),
 
124
            self.dialog.error_dialog(_('Location is not a branch'),
111
125
                                     _('The specified location has to be a branch.'))
 
126
            self.comm.set_busy(self.window, False)
112
127
            return
113
128
        
114
129