Changeset - 5a38b9084a9e
[Not reviewed]
default
0 2 0
domruf - 9 years ago 2016-06-15 18:33:27
dominikruf@gmail.com
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.
2 files changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/hooks.py
Show inline comments
 
@@ -194,14 +194,13 @@ def log_push_action(ui, repo, **kwargs):
 
        kw = {'pushed_revs': revs}
 
        kw.update(ex)
 
        callback(**kw)
 

	
 
    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
 
        _http_ret = HTTPLockedRC(ex.repository, locked_by)
 
        if str(_http_ret.code).startswith('2'):
 
            #2xx Codes don't raise exceptions
kallithea/tests/other/manual_test_vcs_operations.py
Show inline comments
 
@@ -480,13 +480,13 @@ class TestVCSOperations(TestController):
 
        r = Repository.get_by_repo_name(fork_name)
 
        uid = User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id
 
        assert r.locked[0] == uid
 

	
 
        #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)
 
        assert r.locked == [None, None]
 

	
 
    #TODO: fix me ! somehow during tests hooks don't get called on Git
0 comments (0 inline, 0 general)