/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: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from subprocess import call
24
24
import sys
25
25
 
26
 
from . import (
 
26
from bzrlib import (
27
27
    cmdline,
28
28
    config,
29
29
    osutils,
31
31
    transport,
32
32
    ui,
33
33
    )
34
 
from .errors import BzrError
35
 
from .hooks import Hooks
36
 
from .sixish import (
37
 
    StringIO,
38
 
    )
39
 
 
40
 
 
41
 
class BadCommitMessageEncoding(BzrError):
42
 
 
43
 
    _fmt = 'The specified commit message contains characters unsupported by '\
44
 
        'the current encoding.'
 
34
from bzrlib.errors import BzrError, BadCommitMessageEncoding
 
35
from bzrlib.hooks import Hooks
45
36
 
46
37
 
47
38
def _get_editor():
48
39
    """Return a sequence of possible editor binaries for the current platform"""
49
40
    try:
50
 
        yield os.environ["BRZ_EDITOR"], '$BRZ_EDITOR'
 
41
        yield os.environ["BZR_EDITOR"], '$BZR_EDITOR'
51
42
    except KeyError:
52
43
        pass
53
44
 
74
65
        try:
75
66
            ## mutter("trying editor: %r", (edargs +[filename]))
76
67
            x = call(edargs + [filename])
77
 
        except OSError as e:
 
68
        except OSError, e:
78
69
            if candidate_source is not None:
79
70
                # We tried this editor because some user configuration (an
80
71
                # environment variable or config file) said to try it.  Let
91
82
        else:
92
83
            break
93
84
    raise BzrError("Could not start any editor.\nPlease specify one with:\n"
94
 
                   " - $BRZ_EDITOR\n - editor=/some/path in %s\n"
 
85
                   " - $BZR_EDITOR\n - editor=/some/path in %s\n"
95
86
                   " - $VISUAL\n - $EDITOR" % \
96
87
                    config.config_filename())
97
88
 
162
153
        if edited_content == reference_content:
163
154
            if not ui.ui_factory.confirm_action(
164
155
                u"Commit message was not edited, use anyway",
165
 
                "breezy.msgeditor.unchanged",
 
156
                "bzrlib.msgeditor.unchanged",
166
157
                {}):
167
158
                # Returning "" makes cmd_commit raise 'empty commit message
168
159
                # specified' which is a reasonable error, given the user has
212
203
        if msgfilename is not None:
213
204
            try:
214
205
                os.unlink(msgfilename)
215
 
            except IOError as e:
 
206
            except IOError, e:
216
207
                trace.warning(
217
208
                    "failed to unlink %s: %s; ignored", msgfilename, e)
218
209
 
264
255
    # TODO: Rather than running the status command, should prepare a draft of
265
256
    # the revision to be committed, then pause and ask the user to
266
257
    # confirm/write a message.
267
 
    from .status import show_tree_status
 
258
    from StringIO import StringIO       # must be unicode-safe
 
259
    from bzrlib.status import show_tree_status
268
260
    status_tmp = StringIO()
269
261
    show_tree_status(working_tree, specific_files=specific_files,
270
262
                     to_file=status_tmp, verbose=True)
282
274
    # TODO: Rather than running the status command, should prepare a draft of
283
275
    # the revision to be committed, then pause and ask the user to
284
276
    # confirm/write a message.
285
 
    from .diff import show_diff_trees
 
277
    from StringIO import StringIO       # must be unicode-safe
 
278
    from bzrlib.diff import show_diff_trees
286
279
 
287
280
    template = make_commit_message_template(working_tree, specific_files)
288
281
    template = template.encode(output_encoding, "replace")
310
303
 
311
304
        These are all empty initially.
312
305
        """
313
 
        Hooks.__init__(self, "breezy.msgeditor", "hooks")
 
306
        Hooks.__init__(self, "bzrlib.msgeditor", "hooks")
314
307
        self.add_hook('set_commit_message',
315
308
            "Set a fixed commit message. "
316
309
            "set_commit_message is called with the "
317
 
            "breezy.commit.Commit object (so you can also change e.g. revision "
 
310
            "bzrlib.commit.Commit object (so you can also change e.g. revision "
318
311
            "properties by editing commit.builder._revprops) and the message "
319
312
            "so far. set_commit_message must return the message to use or None"
320
313
            " if it should use the message editor as normal.", (2, 4))
321
314
        self.add_hook('commit_message_template',
322
315
            "Called when a commit message is being generated. "
323
 
            "commit_message_template is called with the breezy.commit.Commit "
 
316
            "commit_message_template is called with the bzrlib.commit.Commit "
324
317
            "object and the message that is known so far. "
325
318
            "commit_message_template must return a new message to use (which "
326
319
            "could be the same as it was given). When there are multiple "