~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Martin Pool
  • Date: 2005-09-01 11:32:14 UTC
  • Revision ID: mbp@sourcefrog.net-20050901113214-2d708aed5306e83b
- clean up nasty code for inserting the status summary into commit template

Show diffs side-by-side

added added

removed removed

Lines of Context:
950
950
            unchanged=False):
951
951
        from bzrlib.errors import PointlessCommit
952
952
        from bzrlib.msgeditor import edit_commit_message
 
953
        from bzrlib.status import show_status
 
954
        from cStringIO import StringIO
953
955
 
954
 
        ## Warning: shadows builtin file()
 
956
        b = find_branch('.')
 
957
        if selected_list:
 
958
            selected_list = [b.relpath(s) for s in selected_list]
 
959
            
955
960
        if not message and not file:
956
 
            # FIXME: Ugly; change status code to send to a provided function?
957
 
            
958
 
            import cStringIO
959
 
            stdout = sys.stdout
960
 
            catcher = cStringIO.StringIO()
961
 
            sys.stdout = catcher
962
 
            cmd_status().run(file_list=selected_list)
963
 
            info = catcher.getvalue()
964
 
            sys.stdout = stdout
965
 
            message = edit_commit_message(info)
 
961
            catcher = StringIO()
 
962
            show_status(b, specific_files=selected_list,
 
963
                        to_file=catcher)
 
964
            message = edit_commit_message(catcher.getvalue())
966
965
            
967
966
            if message is None:
968
 
                raise BzrCommandError("please specify a commit message",
969
 
                                      ["use either --message or --file"])
 
967
                raise BzrCommandError("please specify a commit message"
 
968
                                      " with either --message or --file")
970
969
        elif message and file:
971
970
            raise BzrCommandError("please specify either --message or --file")
972
971
        
974
973
            import codecs
975
974
            message = codecs.open(file, 'rt', bzrlib.user_encoding).read()
976
975
 
977
 
        b = find_branch('.')
978
 
        if selected_list:
979
 
            selected_list = [b.relpath(s) for s in selected_list]
980
 
            
981
976
        try:
982
977
            b.commit(message, verbose=verbose,
983
978
                     specific_files=selected_list,