/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-27 19:11:59 UTC
  • mfrom: (0.8.90 merge)
  • mto: (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 103.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060927191159-cc4e54f613575779
Merge all changes. Release 0.11.0.

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 OliveCheckout:
34
33
    """ Display checkout dialog and perform the needed operations. """
71
70
        
72
71
        spinbutton_revno = self.glade.get_widget('spinbutton_checkout_revno')
73
72
        revno = spinbutton_revno.get_value_as_int()
74
 
        if revno == 0:
75
 
            revno = None
 
73
        rev_id = source.get_rev_id(revno)
76
74
        
77
75
        checkbutton_lightweight = self.glade.get_widget('checkbutton_checkout_lightweight')
78
76
        lightweight = checkbutton_lightweight.get_active()
79
77
        
80
78
        self.comm.set_busy(self.window)
81
79
        try:
82
 
            init.checkout(location, destination, revno, lightweight)
 
80
            source = Branch.open(location)
 
81
            
 
82
            # if the source and destination are the same, 
 
83
            # and there is no working tree,
 
84
            # then reconstitute a branch
 
85
            if (bzrlib.osutils.abspath(destination) ==
 
86
                bzrlib.osutils.abspath(location)):
 
87
                try:
 
88
                    source.bzrdir.open_workingtree()
 
89
                except NoWorkingTree:
 
90
                    source.bzrdir.create_workingtree()
 
91
                    return
 
92
 
 
93
            destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
 
94
            
 
95
            os.mkdir(destination)
 
96
 
 
97
            old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
 
98
            bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
 
99
 
 
100
            try:
 
101
                if lightweight:
 
102
                    checkout = bzrdir.BzrDirMetaFormat1().initialize(destination)
 
103
                    bzrlib.branch.BranchReferenceFormat().initialize(checkout, source)
 
104
                else:
 
105
                    checkout_branch = bzrlib.bzrdir.BzrDir.create_branch_convenience(
 
106
                        destination, force_new_tree=False)
 
107
                    checkout = checkout_branch.bzrdir
 
108
                    checkout_branch.bind(source)
 
109
                    if rev_id is not None:
 
110
                        rh = checkout_branch.revno_history()
 
111
                        checkout_branch.set_revno_history(rh[:rh.index(rev_id) + 1])
 
112
 
 
113
                checkout.create_workingtree(rev_id)
 
114
            finally:
 
115
                bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
83
116
        except errors.NotBranchError, errmsg:
84
117
            self.dialog.error_dialog(_('Location is not a branch'),
85
118
                                     _('The specified location has to be a branch.'))