# HG changeset patch # User domruf # Date 1466008407 -7200 # 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 -r 4949076c8bb2 -r 5a38b9084a9e kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py Thu Jul 28 16:28:34 2016 +0200 +++ b/kallithea/lib/hooks.py Wed Jun 15 18:33:27 2016 +0200 @@ -197,8 +197,7 @@ 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 -r 4949076c8bb2 -r 5a38b9084a9e kallithea/tests/other/manual_test_vcs_operations.py --- a/kallithea/tests/other/manual_test_vcs_operations.py Thu Jul 28 16:28:34 2016 +0200 +++ b/kallithea/tests/other/manual_test_vcs_operations.py Wed Jun 15 18:33:27 2016 +0200 @@ -483,7 +483,7 @@ #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)