/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/commit.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:
19
19
import codecs
20
20
 
21
21
import bzrlib
22
 
import bzrlib.errors as errors
 
22
from bzrlib.errors import NoSuchFile
23
23
 
24
 
from errors import (EmptyMessageError, NoMessageNoFileError,
25
 
                    NoChangesToCommitError, ConflictsInTreeError,
26
 
                    StrictCommitError, BoundBranchOutOfDate,
27
 
                    LocalRequiresBoundBranch, NotBranchError, NonExistingParent,
 
24
from errors import ( LocalRequiresBoundBranch, NotBranchError, NonExistingParent,
28
25
                    PathPrefixNotCreated, NoLocationKnown,
29
26
                    DivergedBranchesError)
30
27
 
31
 
def commit(selected_list, message=None, file=None, unchanged=False,
 
28
def commit(selected_list, message=None, unchanged=False,
32
29
           strict=False, local=False):
33
30
    """ Command to commit changes into the branch.
34
31
    
47
44
    from bzrlib.builtins import tree_files
48
45
    from bzrlib.commit import NullCommitReporter
49
46
 
50
 
    try:
51
 
        tree, selected_list = tree_files(selected_list)
52
 
    except errors.NotBranchError:
53
 
        raise NotBranchError
 
47
    tree, selected_list = tree_files(selected_list)
54
48
    
55
49
    if local and not tree.branch.get_bound_location():
56
50
        raise LocalRequiresBoundBranch
57
 
    if message is None and not file:
58
 
        if message is None:
59
 
            raise NoMessageNoFileError
60
 
    elif message and file:
61
 
        raise NoMessageNoFileError
62
 
 
63
 
    if file:
64
 
        message = codecs.open(file, 'rt', bzrlib.user_encoding).read()
65
 
 
66
 
    if message == "":
67
 
        raise EmptyMessageError
68
 
 
 
51
 
 
52
    assert message is not None and len(message) > 0
 
53
 
 
54
    # FIXME: This should be a GtkCommitReporter!
69
55
    reporter = NullCommitReporter()
70
56
 
71
 
    try:
72
 
        tree.commit(message, specific_files=selected_list,
 
57
    tree.commit(message, specific_files=selected_list,
73
58
                    allow_pointless=unchanged, strict=strict, local=local,
74
59
                    reporter=reporter)
75
 
    except errors.PointlessCommit:
76
 
        raise NoChangesToCommitError
77
 
    except errors.ConflictsInTree:
78
 
        raise ConflictsInTreeError
79
 
    except errors.StrictCommitFailed:
80
 
        raise StrictCommitError
81
 
    except errors.BoundBranchOutOfDate, e:
82
 
        raise BoundBranchOutOfDate(str(e))
83
60
 
84
61
def push(branch, location=None, remember=False, overwrite=False,
85
62
         create_prefix=False):
100
77
    from bzrlib.branch import Branch
101
78
    from bzrlib.transport import get_transport
102
79
        
103
 
    try:
104
 
        br_from = Branch.open_containing(branch)[0]
105
 
    except errors.NotBranchError:
106
 
        raise NotBranchError(branch)
107
 
    except:
108
 
        raise
 
80
    br_from = Branch.open_containing(branch)[0]
109
81
    
110
82
    stored_loc = br_from.get_push_location()
111
83
    if location is None:
125
97
    try:
126
98
        dir_to = bzrlib.bzrdir.BzrDir.open(location_url)
127
99
        br_to = dir_to.open_branch()
128
 
    except errors.NotBranchError:
 
100
    except NotBranchError:
129
101
        # create a branch.
130
102
        transport = transport.clone('..')
131
103
        if not create_prefix:
132
104
            try:
133
105
                relurl = transport.relpath(location_url)
134
106
                transport.mkdir(relurl)
135
 
            except errors.NoSuchFile:
 
107
            except NoSuchFile:
136
108
                raise NonExistingParent(location)
137
109
        else:
138
110
            current = transport.base
142
114
                    transport, relpath = needed[-1]
143
115
                    transport.mkdir(relpath)
144
116
                    needed.pop()
145
 
                except errors.NoSuchFile:
 
117
                except NoSuchFile:
146
118
                    new_transport = transport.clone('..')
147
119
                    needed.append((new_transport,
148
120
                                   new_transport.relpath(transport.base)))
157
129
        try:
158
130
            try:
159
131
                tree_to = dir_to.open_workingtree()
160
 
            except errors.NotLocalUrl:
 
132
            except NotLocalUrl:
161
133
                # FIXME - what to do here? how should we warn the user?
162
134
                #warning('This transport does not update the working '
163
135
                #        'tree of: %s' % (br_to.base,))
164
136
                count = br_to.pull(br_from, overwrite)
165
 
            except errors.NoWorkingTree:
 
137
            except NoWorkingTree:
166
138
                count = br_to.pull(br_from, overwrite)
167
139
            else:
168
140
                count = tree_to.pull(br_from, overwrite)
169
 
        except errors.DivergedBranches:
 
141
        except DivergedBranches:
170
142
            raise DivergedBranchesError
171
143
    
172
144
    return count