Commit 1bf5097a authored by maruel@chromium.org's avatar maruel@chromium.org

Enforce unicode commit message.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6928037

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@84289 0039d316-1c4b-4281-b951-d872f2087c98
parent 04d22591
......@@ -295,9 +295,12 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
def commit(self, commit_message, user):
logging.info('Committing patch for %s' % user)
assert self.commit_user
assert isinstance(commit_message, unicode)
handle, commit_filename = tempfile.mkstemp(text=True)
try:
os.write(handle, commit_message)
# Shouldn't assume default encoding is UTF-8. But really, if you are using
# anything else, you are living in another world.
os.write(handle, commit_message.encode('utf-8'))
os.close(handle)
# When committing, svn won't update the Revision metadata of the checkout,
# so if svn commit returns "Committed revision 3.", svn info will still
......@@ -427,6 +430,7 @@ class GitCheckoutBase(CheckoutBase):
Subclass needs to dcommit or push.
"""
assert isinstance(commit_message, unicode)
self._check_call_git(['commit', '--amend', '-m', commit_message])
return self._check_output_git(['rev-parse', 'HEAD']).strip()
......
......@@ -199,7 +199,7 @@ class BaseTest(fake_repos.FakeReposTestBase):
# Verify that the patch is applied even for read only checkout.
self.assertTree(self.get_trunk(True), root)
fake_author = self.FAKE_REPOS.USERS[1][0]
revision = co.commit('msg', fake_author)
revision = co.commit(u'msg', fake_author)
# Nothing changed.
self.assertTree(self.get_trunk(True), root)
......@@ -498,11 +498,11 @@ class RawCheckout(SvnBaseTest):
# Verify that the patch is applied even for read only checkout.
self.assertTree(self.get_trunk(True), root)
if read_only:
revision = co.commit('msg', self.FAKE_REPOS.USERS[1][0])
revision = co.commit(u'msg', self.FAKE_REPOS.USERS[1][0])
self.assertEquals('FAKE', revision)
else:
try:
co.commit('msg', self.FAKE_REPOS.USERS[1][0])
co.commit(u'msg', self.FAKE_REPOS.USERS[1][0])
self.fail()
except NotImplementedError:
pass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment