# HG changeset patch # User domruf # Date 2016-06-15 18:33:27 # Node ID 5a38b9084a9e284b9d37000cdb20d817846bc2a8 # Parent 4949076c8bb29f528e2ee599432c412b9ad8a47e hooks: fix encoding problems of lock release ui messages The vcs test test_push_unlocks_repository_hg would fail when waitress tried to append a unicode chunk to the byte stream. The unicode string came from the 'Released lock on repo' message passed to ui.status from the push hook. ui.status do however follow the Mercurial convention and expects a byte string. We solve the problem by applying safe_str. Patch modified by Mads Kiilerich. diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py +++ b/kallithea/lib/hooks.py @@ -197,8 +197,7 @@ def log_push_action(ui, repo, **kwargs): if ex.make_lock is not None and not ex.make_lock: Repository.unlock(Repository.get_by_repo_name(ex.repository)) - msg = 'Released lock on repo `%s`\n' % ex.repository - ui.status(msg) + ui.status(safe_str('Released lock on repo `%s`\n' % ex.repository)) if ex.locked_by[0]: locked_by = User.get(ex.locked_by[0]).username diff --git a/kallithea/tests/other/manual_test_vcs_operations.py b/kallithea/tests/other/manual_test_vcs_operations.py --- a/kallithea/tests/other/manual_test_vcs_operations.py +++ b/kallithea/tests/other/manual_test_vcs_operations.py @@ -483,7 +483,7 @@ class TestVCSOperations(TestController): #push is ok and repo is now unlocked stdout, stderr = _add_files_and_push('hg', DEST, clone_url=clone_url.split()[0]) - assert ('remote: Released lock on repo `%s`' % fork_name) in stdout + assert str('remote: Released lock on repo `%s`' % fork_name) in stdout #we need to cleanup the Session Here ! Session.remove() r = Repository.get_by_repo_name(fork_name)