/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:
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 os
 
17
import sys
18
18
 
19
19
try:
20
20
    import pygtk
25
25
import gtk
26
26
import gtk.glade
27
27
 
28
 
from bzrlib.branch import Branch
29
28
import bzrlib.errors as errors
30
 
 
31
29
from __init__ import gladefile
32
 
from dialog import error_dialog, info_dialog
33
30
 
34
 
class BranchDialog:
 
31
class OliveBranch:
35
32
    """ Display branch dialog and perform the needed operations. """
36
33
    def __init__(self, path=None):
37
34
        """ Initialize the Branch dialog. """
60
57
        location = entry_location.get_text()
61
58
        if location is '':
62
59
            error_dialog(_('Missing branch location'),
63
 
                         _('You must specify a branch location.'))
 
60
                                     _('You must specify a branch location.'))
64
61
            return
65
62
        
66
63
        destination = self.filechooser.get_filename()
67
64
        
68
65
        spinbutton_revno = self.glade.get_widget('spinbutton_branch_revno')
69
66
        revno = spinbutton_revno.get_value_as_int()
 
67
        revision_id = br_from.get_rev_id(revno)
70
68
        
71
69
        try:
72
70
            from bzrlib.transport import get_transport
73
71
 
74
72
            br_from = Branch.open(location)
75
73
            br_from.lock_read()
76
 
            
77
 
            revision_id = br_from.get_rev_id(revno)
78
74
 
79
75
            try:
80
76
                destination = destination + '/' + os.path.basename(location.rstrip("/\\"))
84
80
                try:
85
81
                    dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
86
82
                    branch = dir.open_branch()
87
 
                    revs = branch.revno()
88
 
                except errors.NoSuchRevision:
 
83
                except NoSuchRevision:
89
84
                    to_transport.delete_tree('.')
90
85
                    raise
91
86
 
97
92
                        _('%d revision(s) branched.') % revs)
98
93
        except errors.NonExistingSource, errmsg:
99
94
            error_dialog(_('Non existing source'),
100
 
                         _("The location (%s)\ndoesn't exist.") % errmsg)
 
95
                                     _("The location (%s)\ndoesn't exist.") % errmsg)
101
96
            return
102
97
        except errors.TargetAlreadyExists, errmsg:
103
98
            error_dialog(_('Target already exists'),
104
 
                         _('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
 
99
                                     _('Target directory (%s)\nalready exists. Please select another target.') % errmsg)
105
100
            return
106
101
        except errors.NonExistingParent, errmsg:
107
102
            error_dialog(_('Non existing parent directory'),
108
 
                         _("The parent directory (%s)\ndoesn't exist.") % errmsg)
 
103
                                     _("The parent directory (%s)\ndoesn't exist.") % errmsg)
109
104
            return
110
105
        except errors.NonExistingRevision:
111
106
            error_dialog(_('Non existing revision'),
112
 
                         _("The revision you specified doesn't exist."))
 
107
                                     _("The revision you specified doesn't exist."))
113
108
            return
114
109
        except errors.NotBranchError, errmsg:
115
110
            error_dialog(_('Location is not a branch'),
116
 
                         _('The specified location has to be a branch.'))
 
111
                                     _('The specified location has to be a branch.'))
117
112
            return
118
113
        
 
114
 
119
115
    def close(self, widget=None):
120
116
        self.window.destroy()