/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: John Arbash Meinel
  • Date: 2006-09-20 14:51:03 UTC
  • mfrom: (0.8.23 version_info)
  • mto: This revision was merged to the branch mainline in revision 2028.
  • Revision ID: john@arbash-meinel.com-20060920145103-02725c6d6c886040
[merge] version-info plugin, and cleanup for layout in bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
71
71
        else:
72
72
            break
73
73
    raise BzrError("Could not start any editor.\nPlease specify one with:\n"
74
 
                   " - $BZR_EDITOR\n - editor=/some/path in %s\n"
75
 
                   " - $VISUAL\n - $EDITOR" % \
 
74
                   " - $BZR_EDITOR\n - editor=/some/path in %s\n - $EDITOR" % \
76
75
                    config.config_filename())
77
76
 
78
77
 
80
79
    { 'bar' : '-' * 14, 'msg' : 'This line and the following will be ignored' }
81
80
 
82
81
 
83
 
def edit_commit_message(infotext, ignoreline=DEFAULT_IGNORE_LINE,
84
 
                        start_message=None):
 
82
def edit_commit_message(infotext, ignoreline=DEFAULT_IGNORE_LINE):
85
83
    """Let the user edit a commit message in a temp file.
86
84
 
87
85
    This is run if they don't give a message or
91
89
        Text to be displayed at bottom of message for
92
90
        the user's reference; currently similar to
93
91
        'bzr status'.
94
 
 
95
 
    ignoreline:
96
 
        The separator to use above the infotext.
97
 
 
98
 
    start_message:
99
 
        The text to place above the separator, if any. This will not be
100
 
        removed from the message after the user has edited it.
101
92
    """
102
93
    import tempfile
103
94
 
104
95
    msgfilename = None
105
96
    try:
106
97
        tmp_fileno, msgfilename = tempfile.mkstemp(prefix='bzr_log.', dir=u'.')
107
 
        msgfile = os.fdopen(tmp_fileno, 'w')
108
 
        try:
109
 
            if start_message is not None:
110
 
                msgfile.write("%s\n" % start_message.encode(
111
 
                                           bzrlib.user_encoding, 'replace'))
112
 
 
113
 
            if infotext is not None and infotext != "":
114
 
                hasinfo = True
115
 
                msgfile.write("\n\n%s\n\n%s" % (ignoreline,
116
 
                              infotext.encode(bzrlib.user_encoding,
117
 
                                                    'replace')))
118
 
            else:
119
 
                hasinfo = False
120
 
        finally:
 
98
        msgfile = os.close(tmp_fileno)
 
99
        if infotext is not None and infotext != "":
 
100
            hasinfo = True
 
101
            msgfile = file(msgfilename, "w")
 
102
            msgfile.write("\n\n%s\n\n%s" % (ignoreline,
 
103
                infotext.encode(bzrlib.user_encoding, 'replace')))
121
104
            msgfile.close()
 
105
        else:
 
106
            hasinfo = False
122
107
 
123
108
        if not _run_editor(msgfilename):
124
109
            return None