/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright (C) 2006 by Szilveszter Farkas (Phanatic)
# Some parts of the code are:
# Copyright (C) 2005, 2006 by Canonical Ltd

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import codecs

import bzrlib
import bzrlib.errors as errors

from errors import (EmptyMessageError, NoMessageNoFileError,
                    NoChangesToCommitError, ConflictsInTreeError,
                    StrictCommitError, BoundBranchOutOfDate,
                    LocalRequiresBoundBranch, NotBranchError)

def commit(selected_list, message=None, file=None, unchanged=False,
           strict=False, local=False):
    """ Command to commit changes into the branch.
    
    :param selected_list: list of files you want to commit (at least the top working directory has to specified)
    
    :param message: commit message
    
    :param file: the file which contains the commit message
    
    :param unchanged: force commit if nothing has changed since the last commit
    
    :param strict: refuse to commit if there are unknown files in the working tree
    
    :param local: perform a local only commit in a bound branch
    """
    from bzrlib.builtins import tree_files
    from bzrlib.commit import NullCommitReporter

    try:
        tree, selected_list = tree_files(selected_list)
    except errors.NotBranchError:
        raise NotBranchError
    
    if local and not tree.branch.get_bound_location():
        raise LocalRequiresBoundBranch()
    if message is None and not file:
        if message is None:
            raise NoMessageNoFileError
    elif message and file:
        raise NoMessageNoFileError

    if file:
        message = codecs.open(file, 'rt', bzrlib.user_encoding).read()

    if message == "":
        raise EmptyMessageError

    reporter = NullCommitReporter()

    try:
        tree.commit(message, specific_files=selected_list,
                    allow_pointless=unchanged, strict=strict, local=local,
                    reporter=reporter)
    except errors.PointlessCommit:
        raise NoChangesToCommitError
    except errors.ConflictsInTree:
        raise ConflictsInTreeError
    except errors.StrictCommitFailed:
        raise StrictCommitError
    except errors.BoundBranchOutOfDate, e:
        raise BoundBranchOutOfDate(str(e))