/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/checkout.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-09-30 13:04:15 UTC
  • mto: (0.14.3 main)
  • mto: This revision was merged to the branch mainline in revision 86.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060930130415-aba4100709e11f0a
Loads of fixes. Pyflakes cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
import sys
 
17
import os
18
18
 
19
19
try:
20
20
    import pygtk
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)
29
 
 
 
24
 
 
25
import gtk
 
26
import gtk.glade
 
27
 
 
28
from bzrlib.branch import Branch
 
29
import bzrlib.bzrdir as bzrdir
30
30
import bzrlib.errors as errors
 
31
import bzrlib.osutils
 
32
 
 
33
from olive import gladefile
 
34
from dialog import error_dialog
31
35
 
32
36
class OliveCheckout:
33
37
    """ Display checkout dialog and perform the needed operations. """
34
 
    def __init__(self, gladefile, comm):
 
38
    def __init__(self, path=None):
35
39
        """ Initialize the Checkout dialog. """
36
 
        self.gladefile = gladefile
37
 
        self.glade = gtk.glade.XML(self.gladefile, 'window_checkout', 'olive-gtk')
38
 
        
39
 
        # Communication object
40
 
        self.comm = comm
 
40
        self.glade = gtk.glade.XML(gladefile, 'window_checkout', 'olive-gtk')
41
41
        
42
42
        self.window = self.glade.get_widget('window_checkout')
43
43
        
50
50
        
51
51
        # Save FileChooser state
52
52
        self.filechooser = self.glade.get_widget('filechooserbutton_checkout')
53
 
        self.filechooser.set_filename(self.comm.get_path())
 
53
        if path is not None:
 
54
            self.filechooser.set_filename(path)
54
55
 
55
56
    def display(self):
56
57
        """ Display the Checkout dialog. """
61
62
        location = entry_location.get_text()
62
63
        if location is '':
63
64
            error_dialog(_('Missing branch location'),
64
 
                                     _('You must specify a branch location.'))
 
65
                         _('You must specify a branch location.'))
65
66
            return
66
67
        
67
68
        destination = self.filechooser.get_filename()
68
69
        
69
70
        spinbutton_revno = self.glade.get_widget('spinbutton_checkout_revno')
70
71
        revno = spinbutton_revno.get_value_as_int()
71
 
        rev_id = source.get_rev_id(revno)
72
72
        
73
73
        checkbutton_lightweight = self.glade.get_widget('checkbutton_checkout_lightweight')
74
74
        lightweight = checkbutton_lightweight.get_active()
75
75
        
76
 
        self.comm.set_busy(self.window)
77
76
        try:
78
77
            source = Branch.open(location)
 
78
            rev_id = source.get_rev_id(revno)
79
79
            
80
80
            # if the source and destination are the same, 
81
81
            # and there is no working tree,
84
84
                bzrlib.osutils.abspath(location)):
85
85
                try:
86
86
                    source.bzrdir.open_workingtree()
87
 
                except NoWorkingTree:
 
87
                except errors.NoWorkingTree:
88
88
                    source.bzrdir.create_workingtree()
89
89
                    return
90
90
 
93
93
            os.mkdir(destination)
94
94
 
95
95
            old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
96
 
            bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
96
            bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
97
97
 
98
98
            try:
99
99
                if lightweight:
113
113
                bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
114
114
        except errors.NotBranchError, errmsg:
115
115
            error_dialog(_('Location is not a branch'),
116
 
                                     _('The specified location has to be a branch.'))
117
 
            self.comm.set_busy(self.window, False)
 
116
                         _('The specified location has to be a branch.'))
118
117
            return
119
118
        except errors.TargetAlreadyExists, errmsg:
120
119
            error_dialog(_('Target already exists'),
121
 
                                     _('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
122
 
            self.comm.set_busy(self.window, False)
 
120
                         _('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
123
121
            return
124
122
        except errors.NonExistingParent, errmsg:
125
123
            error_dialog(_('Non existing parent directory'),
126
 
                                     _("The parent directory (%s)\ndoesn't exist.") % errmsg)
127
 
            self.comm.set_busy(self.window, False)
 
124
                         _("The parent directory (%s)\ndoesn't exist.") % errmsg)
128
125
            return
129
 
        except:
130
 
            raise
131
126
        
132
127
        self.close()
133
128
        self.comm.refresh_right()