~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

- new commit --strict option

Show diffs side-by-side

added added

removed removed

Lines of Context:
1006
1006
    """
1007
1007
    # TODO: Run hooks on tree to-be-committed, and after commit.
1008
1008
 
1009
 
    # TODO: Strict commit that fails if there are unknown or deleted files.
 
1009
    # TODO: Strict commit that fails if there are deleted files.
 
1010
    #       (what does "deleted files" mean ??)
 
1011
 
1010
1012
    # TODO: Give better message for -s, --summary, used by tla people
1011
1013
 
1012
1014
    # XXX: verbose currently does nothing
1018
1020
                     Option('file', type=str, 
1019
1021
                            argname='msgfile',
1020
1022
                            help='file containing commit message'),
 
1023
                     Option('strict',
 
1024
                            help="refuse to commit if there are unknown "
 
1025
                            "files in the working tree."),
1021
1026
                     ]
1022
1027
    aliases = ['ci', 'checkin']
1023
1028
 
1024
1029
    def run(self, message=None, file=None, verbose=True, selected_list=None,
1025
 
            unchanged=False):
1026
 
        from bzrlib.errors import PointlessCommit, ConflictsInTree
 
1030
            unchanged=False, strict=False):
 
1031
        from bzrlib.errors import (PointlessCommit, ConflictsInTree,
 
1032
                StrictCommitFailed)
1027
1033
        from bzrlib.msgeditor import edit_commit_message
1028
1034
        from bzrlib.status import show_status
1029
1035
        from cStringIO import StringIO
1052
1058
                raise BzrCommandError("empty commit message specified")
1053
1059
            
1054
1060
        try:
1055
 
            b.commit(message,
1056
 
                     specific_files=selected_list,
1057
 
                     allow_pointless=unchanged)
 
1061
            b.commit(message, specific_files=selected_list,
 
1062
                     allow_pointless=unchanged, strict=strict)
1058
1063
        except PointlessCommit:
1059
1064
            # FIXME: This should really happen before the file is read in;
1060
1065
            # perhaps prepare the commit; get the message; then actually commit
1063
1068
        except ConflictsInTree:
1064
1069
            raise BzrCommandError("Conflicts detected in working tree.  "
1065
1070
                'Use "bzr conflicts" to list, "bzr resolve FILE" to resolve.')
 
1071
        except StrictCommitFailed:
 
1072
            raise BzrCommandError("Commit refused because there are unknown "
 
1073
                                  "files in the working tree.")
1066
1074
 
1067
1075
 
1068
1076
class cmd_check(Command):