# HG changeset patch # User domruf # Date 2016-05-03 00:12:55 # Node ID 0bb4fa32a75a5fc3c18a2ae399d52ba8b2a67976 # Parent 97bbc2824b32d878e4f0194b28fbe8f110d8c0bd tests: Mercurial hooks must use ui.status for messages sent to the client Mercurial changed so sys.stdout and sys.stderr now are intercepted instead of being sent to the client. That caused a regression that manual_test_vcs_operations.py test_push_new_file_hg caught - we no longer reported 'Repository size' to the user. The issue was introduced by a Mercurial change, but the fix is backwards compatible with Mercurial 2.9. The fix is to use ui.status everywhere. ui is a Mercurial thing, but handle_git_receive also creates a ui object for Git hooks so ui.status can be used there too. diff --git a/kallithea/lib/hooks.py b/kallithea/lib/hooks.py --- a/kallithea/lib/hooks.py +++ b/kallithea/lib/hooks.py @@ -83,8 +83,7 @@ def repo_size(ui, repo, hooktype=None, * 'Last revision is now r%s:%s\n') % ( size_hg_f, size_root_f, size_total_f, last_cs.rev(), last_cs.hex()[:12] ) - - sys.stdout.write(msg) + ui.status(msg) def pre_push(ui, repo, **kwargs): @@ -100,7 +99,7 @@ def pre_push(ui, repo, **kwargs): _http_ret = HTTPLockedRC(ex.repository, locked_by) if str(_http_ret.code).startswith('2'): #2xx Codes don't raise exceptions - sys.stdout.write(_http_ret.title) + ui.status(_http_ret.title) else: raise _http_ret @@ -116,7 +115,7 @@ def pre_pull(ui, repo, **kwargs): _http_ret = HTTPLockedRC(ex.repository, locked_by) if str(_http_ret.code).startswith('2'): #2xx Codes don't raise exceptions - sys.stdout.write(_http_ret.title) + ui.status(_http_ret.title) else: raise _http_ret @@ -144,14 +143,14 @@ def log_pull_action(ui, repo, **kwargs): if ex.make_lock is not None and ex.make_lock: Repository.lock(Repository.get_by_repo_name(ex.repository), user.user_id) #msg = 'Made lock on repo `%s`' % repository - #sys.stdout.write(msg) + #ui.status(msg) 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 - sys.stdout.write(_http_ret.title) + ui.status(_http_ret.title) return 0 @@ -200,14 +199,14 @@ 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 - sys.stdout.write(msg) + ui.status(msg) 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 - sys.stdout.write(_http_ret.title) + ui.status(_http_ret.title) return 0