Commit 8c416436 authored by Michal Čihař's avatar Michal Čihař

Implement config editing for mercurial

Issue #511
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 6bbb522c
......@@ -259,7 +259,10 @@ class VCSHgTest(VCSGitTest):
return
def test_set_committer(self):
return
self.repo.set_committer('Foo Bar', 'foo@example.net')
self.assertEqual(
self.repo.get_config('ui', 'username'), 'Foo Bar <foo@example.net>'
)
def test_revision(self):
return
......
......@@ -24,6 +24,7 @@ import subprocess
import os.path
import email.utils
import re
import ConfigParser
from dateutil import parser
from weblate.trans.util import get_clean_env
......@@ -550,10 +551,15 @@ class HgRepository(Repository):
def set_config(self, section, key, value):
"""
Set entry in local configuration.
TODO: Need to edit INI file
"""
self.execute(['config', section, key, value])
filename = os.path.join(self.path, '.hg', 'hgrc')
config = ConfigParser.RawConfigParser()
config.read(filename)
if not config.has_section(section):
config.add_section(section)
config.set(section, key, value)
with open(filename, 'w') as handle:
config.write(handle)
def set_committer(self, name, mail):
"""
......
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