/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: 2007-02-01 15:50:40 UTC
  • Revision ID: jelmer@samba.org-20070201155040-3hq4mfbxs99kzazy
add framework for tests.

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