/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/backend/init.py

  • Committer: Jelmer Vernooij
  • Date: 2006-09-04 23:33:13 UTC
  • mto: (0.8.83 merge)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: jelmer@samba.org-20060904233313-f8d303ec87f6de13
Eliminate olive.backend.errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
import bzrlib
23
23
import bzrlib.bzrdir as bzrdir
24
 
import bzrlib.errors as errors
25
24
 
26
25
from bzrlib.branch import Branch
27
26
 
28
 
from errors import (AlreadyBranchError, BranchExistsWithoutWorkingTree,
29
 
                    NonExistingParent, NonExistingRevision,
30
 
                    NonExistingSource, NotBranchError, TargetAlreadyExists)
 
27
from bzrlib.errors import (AlreadyBranchError, BranchExistsWithoutWorkingTree)
31
28
 
32
29
def branch(from_location, to_location, revision=None):
33
30
    """ Create a branch from a local/remote location.
42
39
    """
43
40
    from bzrlib.transport import get_transport
44
41
 
45
 
    try:
46
 
        br_from = Branch.open(from_location)
47
 
    except OSError, e:
48
 
        if e.errno == errno.ENOENT:
49
 
            raise NonExistingSource(from_location)
50
 
        else:
51
 
            raise
52
 
    except errors.NotBranchError:
53
 
        raise NotBranchError(from_location)
 
42
    br_from = Branch.open(from_location)
54
43
 
55
44
    br_from.lock_read()
56
45
 
65
54
        name = None
66
55
        to_transport = get_transport(to_location)
67
56
 
68
 
        try:
69
 
            to_transport.mkdir('.')
70
 
        except errors.FileExists:
71
 
            raise TargetAlreadyExists(to_location)
72
 
        except errors.NoSuchFile:
73
 
            raise NonExistingParent(to_location)
 
57
        to_transport.mkdir('.')
74
58
 
75
59
        try:
76
60
            dir = br_from.bzrdir.sprout(to_transport.base, revision_id, basis_dir)
77
61
            branch = dir.open_branch()
78
 
        except errors.NoSuchRevision:
 
62
        except NoSuchRevision:
79
63
            to_transport.delete_tree('.')
80
 
            raise NonExistingRevision(from_location, revision[0])
 
64
            raise
81
65
 
82
66
        if name:
83
67
            branch.control_files.put_utf8('branch-name', name)
97
81
    
98
82
    :param lightweight: perform a lightweight checkout (be aware!)
99
83
    """
100
 
    try:
101
 
        source = Branch.open(branch_location)
102
 
    except errors.NotBranchError:
103
 
        raise NotBranchError(branch_location)
 
84
    source = Branch.open(branch_location)
104
85
    
105
86
    if revision is not None:
106
87
        revision_id = source.get_rev_id(revision)
114
95
        bzrlib.osutils.abspath(branch_location)):
115
96
        try:
116
97
            source.bzrdir.open_workingtree()
117
 
        except errors.NoWorkingTree:
 
98
        except NoWorkingTree:
118
99
            source.bzrdir.create_workingtree()
119
100
            return
120
101
 
121
102
    to_location = to_location + '/' + os.path.basename(branch_location.rstrip("/\\"))
122
103
    
123
 
    try:
124
 
        os.mkdir(to_location)
125
 
    except OSError, e:
126
 
        if e.errno == errno.EEXIST:
127
 
            raise TargetAlreadyExists(to_location)
128
 
        if e.errno == errno.ENOENT:
129
 
            raise NonExistingParent(to_location)
130
 
        else:
131
 
            raise
 
104
    os.mkdir(to_location)
132
105
 
133
106
    old_format = bzrlib.bzrdir.BzrDirFormat.get_default_format()
134
107
    bzrlib.bzrdir.BzrDirFormat.set_default_format(bzrdir.BzrDirMetaFormat1())
164
137
 
165
138
    try:
166
139
        existing_bzrdir = bzrdir.BzrDir.open(location)
167
 
    except errors.NotBranchError:
 
140
    except NotBranchError:
168
141
        bzrdir.BzrDir.create_branch_convenience(location, format=format)
169
142
    else:
170
143
        if existing_bzrdir.has_branch():