/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: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-20 13:02:35 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060820130235-62c9c5753f5d8774
Gettext support added.

2006-08-20  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * po/hu.po: added Hungarian traslation
    * Added gettext support to all files.
    * genpot.sh: added olive-gtk.pot generator script

Show diffs side-by-side

added added

removed removed

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