Show More
@@ -24,7 +24,6 b' import json' | |||
|
24 | 24 | import logging |
|
25 | 25 | import collections |
|
26 | 26 | import importlib |
|
27 | import subprocess | |
|
28 | 27 | |
|
29 | 28 | from httplib import HTTPConnection |
|
30 | 29 | |
@@ -33,7 +32,7 b' import mercurial.scmutil' | |||
|
33 | 32 | import mercurial.node |
|
34 | 33 | import simplejson as json |
|
35 | 34 | |
|
36 | from vcsserver import exceptions | |
|
35 | from vcsserver import exceptions, subprocessio, settings | |
|
37 | 36 | |
|
38 | 37 | log = logging.getLogger(__name__) |
|
39 | 38 | |
@@ -385,16 +384,19 b' def _run_command(arguments):' | |||
|
385 | 384 | :param arguments: sequence of program arguments (including the program name) |
|
386 | 385 | :type arguments: list[str] |
|
387 | 386 | """ |
|
388 | # TODO(skreft): refactor this method and all the other similar ones. | |
|
389 | # Probably this should be using subprocessio. | |
|
390 | process = subprocess.Popen( | |
|
391 | arguments, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
|
392 | stdout, stderr = process.communicate() | |
|
393 | 387 | |
|
394 | if process.returncode != 0: | |
|
395 | raise Exception( | |
|
396 | 'Command %s exited with exit code %s: stderr:%s' % ( | |
|
397 | arguments, process.returncode, stderr)) | |
|
388 | cmd = arguments | |
|
389 | try: | |
|
390 | gitenv = os.environ.copy() | |
|
391 | _opts = {'env': gitenv, 'shell': False, 'fail_on_stderr': False} | |
|
392 | p = subprocessio.SubprocessIOChunker(cmd, **_opts) | |
|
393 | stdout = ''.join(p) | |
|
394 | except (EnvironmentError, OSError) as err: | |
|
395 | cmd = ' '.join(cmd) # human friendly CMD | |
|
396 | tb_err = ("Couldn't run git command (%s).\n" | |
|
397 | "Original error was:%s\n" % (cmd, err)) | |
|
398 | log.exception(tb_err) | |
|
399 | raise Exception(tb_err) | |
|
398 | 400 | |
|
399 | 401 | return stdout |
|
400 | 402 | |
@@ -433,21 +435,21 b' def git_post_receive(unused_repo_path, r' | |||
|
433 | 435 | branches.append(push_ref['name']) |
|
434 | 436 | |
|
435 | 437 | # Fix up head revision if needed |
|
436 |
cmd = [ |
|
|
438 | cmd = [settings.GIT_EXECUTABLE, 'show', 'HEAD'] | |
|
437 | 439 | try: |
|
438 | 440 | _run_command(cmd) |
|
439 | 441 | except Exception: |
|
440 |
cmd = [ |
|
|
442 | cmd = [settings.GIT_EXECUTABLE, 'symbolic-ref', 'HEAD', | |
|
441 | 443 | 'refs/heads/%s' % push_ref['name']] |
|
442 | 444 | print("Setting default branch to %s" % push_ref['name']) |
|
443 | 445 | _run_command(cmd) |
|
444 | 446 | |
|
445 |
cmd = [ |
|
|
447 | cmd = [settings.GIT_EXECUTABLE, 'for-each-ref', '--format=%(refname)', | |
|
446 | 448 | 'refs/heads/*'] |
|
447 | 449 | heads = _run_command(cmd) |
|
448 | 450 | heads = heads.replace(push_ref['ref'], '') |
|
449 | 451 | heads = ' '.join(head for head in heads.splitlines() if head) |
|
450 |
cmd = [ |
|
|
452 | cmd = [settings.GIT_EXECUTABLE, 'log', '--reverse', '--pretty=format:%H', | |
|
451 | 453 | '--', push_ref['new_rev'], '--not', heads] |
|
452 | 454 | git_revs.extend(_run_command(cmd).splitlines()) |
|
453 | 455 | elif push_ref['new_rev'] == empty_commit_id: |
@@ -457,7 +459,7 b' def git_post_receive(unused_repo_path, r' | |||
|
457 | 459 | if push_ref['name'] not in branches: |
|
458 | 460 | branches.append(push_ref['name']) |
|
459 | 461 | |
|
460 |
cmd = [ |
|
|
462 | cmd = [settings.GIT_EXECUTABLE, 'log', | |
|
461 | 463 | '{old_rev}..{new_rev}'.format(**push_ref), |
|
462 | 464 | '--reverse', '--pretty=format:%H'] |
|
463 | 465 | git_revs.extend(_run_command(cmd).splitlines()) |
General Comments 0
You need to be logged in to leave comments.
Login now