##// END OF EJS Templates
http: deliver hook output to client
Maxim Khitrov -
r11469:c37f35d7 stable
parent child Browse files
Show More
@@ -98,7 +98,10 b' def _exthook(ui, repo, name, cmd, args, '
98 98 cwd = repo.root
99 99 else:
100 100 cwd = os.getcwd()
101 r = util.system(cmd, environ=env, cwd=cwd)
101 if 'HG_URL' in env and env['HG_URL'].startswith('remote:http'):
102 r = util.system(cmd, environ=env, cwd=cwd, out=ui)
103 else:
104 r = util.system(cmd, environ=env, cwd=cwd)
102 105 if r:
103 106 desc, r = util.explain_exit(r)
104 107 if throw:
@@ -366,13 +366,16 b' def set_hgexecutable(path):'
366 366 global _hgexecutable
367 367 _hgexecutable = path
368 368
369 def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None):
369 def system(cmd, environ={}, cwd=None, onerr=None, errprefix=None, out=None):
370 370 '''enhanced shell command execution.
371 371 run with environment maybe modified, maybe in different dir.
372 372
373 373 if command fails and onerr is None, return status. if ui object,
374 374 print error message and return status, else raise onerr object as
375 exception.'''
375 exception.
376
377 if out is specified, it is assumed to be a file-like object that has a
378 write() method. stdout and stderr will be redirected to out.'''
376 379 def py2shell(val):
377 380 'convert python object into string that is useful to shell'
378 381 if val is None or val is False:
@@ -386,8 +389,17 b' def system(cmd, environ={}, cwd=None, on'
386 389 env = dict(os.environ)
387 390 env.update((k, py2shell(v)) for k, v in environ.iteritems())
388 391 env['HG'] = hgexecutable()
389 rc = subprocess.call(cmd, shell=True, close_fds=closefds,
390 env=env, cwd=cwd)
392 if out is None:
393 rc = subprocess.call(cmd, shell=True, close_fds=closefds,
394 env=env, cwd=cwd)
395 else:
396 proc = subprocess.Popen(cmd, shell=True, close_fds=closefds,
397 env=env, cwd=cwd, stdout=subprocess.PIPE,
398 stderr=subprocess.STDOUT)
399 for line in proc.stdout:
400 out.write(line)
401 proc.wait()
402 rc = proc.returncode
391 403 if sys.platform == 'OpenVMS' and rc & 1:
392 404 rc = 0
393 405 if rc and onerr:
@@ -39,11 +39,9 b' req'
39 39 echo % expect success
40 40 echo 'allow_push = *' >> .hg/hgrc
41 41 echo '[hooks]' >> .hg/hgrc
42 echo 'changegroup = python ../printenv.py changegroup 0 ../urls' >> .hg/hgrc
42 echo 'changegroup = python ../printenv.py changegroup 0' >> .hg/hgrc
43 43 req
44 44
45 cat ../urls
46
47 45 hg rollback
48 46 echo % expect authorization error: all users denied
49 47 echo '[web]' > .hg/hgrc
@@ -23,8 +23,8 b' remote: adding changesets'
23 23 remote: adding manifests
24 24 remote: adding file changes
25 25 remote: added 1 changesets with 1 changes to 1 files
26 remote: changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http
26 27 % serve errors
27 changegroup hook: HG_NODE=ba677d0156c1196c1a699fa53f390dcfc3ce3872 HG_SOURCE=serve HG_URL=remote:http
28 28 rolling back to revision 0 (undo serve)
29 29 % expect authorization error: all users denied
30 30 abort: authorization failed
General Comments 0
You need to be logged in to leave comments. Login now