~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

Update test support, and remove deprecated functions pullable_revisions and get_intervening_revisions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Bazaar-NG -- distributed version control
2
 
 
3
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
4
2
 
5
3
# This program is free software; you can redistribute it and/or modify
6
4
# it under the terms of the GNU General Public License as published by
19
17
 
20
18
"""Commit message editor support."""
21
19
 
 
20
 
 
21
import errno
22
22
import os
23
 
import errno
24
23
from subprocess import call
 
24
import sys
25
25
 
26
26
import bzrlib.config as config
27
27
from bzrlib.errors import BzrError
28
28
 
 
29
 
29
30
def _get_editor():
30
31
    """Return a sequence of possible editor binaries for the current platform"""
31
32
    try:
42
43
    except KeyError:
43
44
        pass
44
45
 
45
 
    if os.name == "nt":
46
 
        yield "notepad.exe"
47
 
    elif os.name == "posix":
48
 
        yield "/usr/bin/vi"
 
46
    if sys.platform == 'win32':
 
47
        for editor in 'wordpad.exe', 'notepad.exe':
 
48
            yield editor
 
49
    else:
 
50
        for editor in ['vi', 'pico', 'nano', 'joe']:
 
51
            yield editor
49
52
 
50
53
 
51
54
def _run_editor(filename):
55
58
        try:
56
59
            x = call(edargs + [filename])
57
60
        except OSError, e:
58
 
           # ENOENT means no such editor
59
 
           if e.errno == errno.ENOENT:
 
61
           # We're searching for an editor, so catch safe errors and continue
 
62
           if e.errno in (errno.ENOENT, ):
60
63
               continue
61
64
           raise
62
65
        if x == 0:
65
68
            continue
66
69
        else:
67
70
            break
68
 
    raise BzrError("Could not start any editor. "
69
 
                   "Please specify $EDITOR or use ~/.bzr.conf/editor")
 
71
    raise BzrError("Could not start any editor.\nPlease specify one with:\n"
 
72
                   " - $BZR_EDITOR\n - editor=/some/path in %s\n - $EDITOR" % \
 
73
                    config.config_filename())
70
74
 
71
75
 
72
76
DEFAULT_IGNORE_LINE = "%(bar)s %(msg)s %(bar)s" % \
92
96
        if infotext is not None and infotext != "":
93
97
            hasinfo = True
94
98
            msgfile = file(msgfilename, "w")
95
 
            msgfile.write("\n\n%s\n\n%s" % (ignoreline, infotext))
 
99
            msgfile.write("\n%s\n\n%s" % (ignoreline, infotext))
96
100
            msgfile.close()
97
101
        else:
98
102
            hasinfo = False