~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/msgeditor.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Commit message editor support."""
29
29
    trace,
30
30
    )
31
31
from bzrlib.errors import BzrError, BadCommitMessageEncoding
32
 
from bzrlib.hooks import Hooks
 
32
from bzrlib.hooks import HookPoint, Hooks
33
33
 
34
34
 
35
35
def _get_editor():
42
42
    e = config.GlobalConfig().get_editor()
43
43
    if e is not None:
44
44
        yield e, config.config_filename()
45
 
        
 
45
 
46
46
    for varname in 'VISUAL', 'EDITOR':
47
47
        if varname in os.environ:
48
48
            yield os.environ[varname], '$' + varname
144
144
 
145
145
        if not msgfilename or not _run_editor(msgfilename):
146
146
            return None
147
 
        
 
147
 
148
148
        started = False
149
149
        msg = []
150
150
        lastline, nlines = 0, 0
247
247
    from StringIO import StringIO       # must be unicode-safe
248
248
    from bzrlib.status import show_tree_status
249
249
    status_tmp = StringIO()
250
 
    show_tree_status(working_tree, specific_files=specific_files, 
 
250
    show_tree_status(working_tree, specific_files=specific_files,
251
251
                     to_file=status_tmp, verbose=True)
252
252
    return status_tmp.getvalue()
253
253
 
283
283
    """A dictionary mapping hook name to a list of callables for message editor
284
284
    hooks.
285
285
 
286
 
    e.g. ['commit_message_template'] is the list of items to be called to 
 
286
    e.g. ['commit_message_template'] is the list of items to be called to
287
287
    generate a commit message template
288
288
    """
289
289
 
293
293
        These are all empty initially.
294
294
        """
295
295
        Hooks.__init__(self)
296
 
        # Introduced in 1.10:
297
 
        # Invoked to generate the commit message template shown in the editor
298
 
        # The api signature is:
299
 
        # (commit, message), and the function should return the new message
300
 
        # There is currently no way to modify the order in which 
301
 
        # template hooks are invoked
302
 
        self['commit_message_template'] = []
 
296
        self.create_hook(HookPoint('commit_message_template',
 
297
            "Called when a commit message is being generated. "
 
298
            "commit_message_template is called with the bzrlib.commit.Commit "
 
299
            "object and the message that is known so far. "
 
300
            "commit_message_template must return a new message to use (which "
 
301
            "could be the same as it was given. When there are multiple "
 
302
            "hooks registered for commit_message_template, they are chained "
 
303
            "with the result from the first passed into the second, and so "
 
304
            "on.", (1, 10), None))
303
305
 
304
306
 
305
307
hooks = MessageEditorHooks()