/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-30 10:21:43 UTC
  • Revision ID: jelmer@samba.org-20060930102143-c0ef64d6ca860c21
Merge some files from Olive and bzr-gtk.

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