~bzr-pqm/bzr/bzr.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (C) 2005 by Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

"""Test commit message editor.
"""

import os
import sys

from bzrlib.branch import Branch
from bzrlib.msgeditor import make_commit_message_template
from bzrlib.tests import TestCaseInTempDir

from bzrlib.tests.treeshape import build_tree_contents


def make_uncommitted_tree():
    """Build a branch with uncommitted changes in the cwd."""
    b = Branch.initialize('.')
    working_tree = b.working_tree()
    filename = u'hell\u00d8'
    build_tree_contents([(filename, 'contents of hello')])
    working_tree.add(filename)
    return working_tree


class MsgEditorTest(TestCaseInTempDir):

    def test_commit_template(self):
        """Test building a commit message template"""
        working_tree = make_uncommitted_tree()
        template = make_commit_message_template(working_tree, None)
        self.assertEqualDiff(template,
u"""\
added:
  hell\u00d8
""")