--- a/autoland/autoland/transplant.py
+++ b/autoland/autoland/transplant.py
@@ -11,18 +11,17 @@ REPO_CONFIG = {}
logger = logging.getLogger('autoland')
class HgCommandError(Exception):
def __init__(self, hg_args, out):
# we want to strip out any sensitive --config options
hg_args = map(lambda x: x if not x.startswith('bugzilla') else 'xxx',
hg_args)
- message = 'hg error in cmd: hg %s: %s' % (' '.join(hg_args),
- out.getvalue())
+ message = 'hg error in cmd: hg %s: %s' % (' '.join(hg_args), out)
super(self.__class__, self).__init__(message)
class Transplant(object):
"""Transplant a specified revision and ancestors to the specified tree."""
def __init__(self, tree, destination, rev):
# These values can appear in command arguments. Don't let unicode leak
@@ -112,19 +111,22 @@ class Transplant(object):
self.validate_descriptions(commit_descriptions)
return base_revision
def run_hg(self, args):
logger.info('rev: %s: executing: %s' % (self.source_rev, args))
out = hglib.util.BytesIO()
out_channels = {b'o': out.write, b'e': out.write}
ret = self.hg_repo.runcommand(args, {}, out_channels)
+ out = out.getvalue()
if ret:
- raise hglib.error.CommandError(args, ret, out, None)
- return out.getvalue()
+ if out:
+ logging.error(out.rstrip())
+ raise hglib.error.CommandError(args, ret, out, '')
+ return out
def run_hg_cmds(self, cmds):
last_result = ''
for cmd in cmds:
try:
last_result = self.run_hg(cmd)
except hglib.error.CommandError as e:
raise HgCommandError(cmd, e.out)
@@ -156,17 +158,17 @@ class Transplant(object):
['update', '--clean', '-r', remote_rev],
['pull', self.tree, '-r', self.source_rev],
['update', self.source_rev]]
for cmd in cmds:
try:
self.run_hg(cmd)
except hglib.error.CommandError as e:
- output = e.out.getvalue()
+ output = e.out
if 'no changes found' in output:
# we've already pulled this revision
continue
elif 'abort: no rebase in progress' in output:
# there was no rebase in progress, nothing to see here
continue
else:
raise HgCommandError(cmd, e.out)
@@ -208,17 +210,17 @@ class Transplant(object):
# our content, as there is no content in the destination to conflict
# with us.
if remote_tip == '0' * 12:
cmd.extend(['--tool', ':other'])
try:
self.run_hg(cmd)
except hglib.error.CommandError as e:
- if 'nothing to rebase' not in e.out.getvalue():
+ if 'nothing to rebase' not in e.out:
raise HgCommandError(cmd, e.out)
return self.run_hg_cmds([
['log', '-r', 'tip', '-T', '{node|short}']
])
def validate_descriptions(self, commit_descriptions):
# Match outgoing commit descriptions against incoming commit