changeset 5979:0bb4fa32a75a

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.
author domruf <dominikruf@gmail.com>
date Tue, 03 May 2016 00:12:55 +0200
parents 97bbc2824b32
children 7edd336f88d7
files kallithea/lib/hooks.py
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/lib/hooks.py	Wed Jun 15 23:38:57 2016 +0200
+++ b/kallithea/lib/hooks.py	Tue May 03 00:12:55 2016 +0200
@@ -83,8 +83,7 @@
            '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 @@
         _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 @@
         _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 @@
     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 @@
     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