Convert all print statements to use options.stdout.

Needed to fix a few function calls to make it work.

BUG=54084
TEST=unit tests

Review URL: http://codereview.chromium.org/3303004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@58287 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 15 years ago
parent 21779a56e6
commit f5d37bf92e

@ -24,12 +24,13 @@ class DiffFilterer(object):
original_prefix = "--- " original_prefix = "--- "
working_prefix = "+++ " working_prefix = "+++ "
def __init__(self, relpath): def __init__(self, relpath, stdout):
# Note that we always use '/' as the path separator to be # Note that we always use '/' as the path separator to be
# consistent with svn's cygwin-style output on Windows # consistent with svn's cygwin-style output on Windows
self._relpath = relpath.replace("\\", "/") self._relpath = relpath.replace("\\", "/")
self._current_file = "" self._current_file = ""
self._replacement_file = "" self._replacement_file = ""
self._stdout = stdout
def SetCurrentFile(self, current_file): def SetCurrentFile(self, current_file):
self._current_file = current_file self._current_file = current_file
@ -37,19 +38,18 @@ class DiffFilterer(object):
# consistent with svn's cygwin-style output on Windows # consistent with svn's cygwin-style output on Windows
self._replacement_file = posixpath.join(self._relpath, current_file) self._replacement_file = posixpath.join(self._relpath, current_file)
def ReplaceAndPrint(self, line): def _Replace(self, line):
print(line.replace(self._current_file, self._replacement_file)) return line.replace(self._current_file, self._replacement_file)
def Filter(self, line): def Filter(self, line):
if (line.startswith(self.index_string)): if (line.startswith(self.index_string)):
self.SetCurrentFile(line[len(self.index_string):]) self.SetCurrentFile(line[len(self.index_string):])
self.ReplaceAndPrint(line) line = self._Replace(line)
else: else:
if (line.startswith(self.original_prefix) or if (line.startswith(self.original_prefix) or
line.startswith(self.working_prefix)): line.startswith(self.working_prefix)):
self.ReplaceAndPrint(line) line = self._Replace(line)
else: self._stdout.write(line + '\n')
print line
### SCM abstraction layer ### SCM abstraction layer
@ -165,7 +165,6 @@ class GitWrapper(SCMWrapper):
Raises: Raises:
Error: if can't get URL for relative path. Error: if can't get URL for relative path.
""" """
if args: if args:
raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args)) raise gclient_utils.Error("Unsupported argument(s): %s" % ",".join(args))
@ -187,7 +186,7 @@ class GitWrapper(SCMWrapper):
printed_path = False printed_path = False
verbose = [] verbose = []
if options.verbose: if options.verbose:
print("\n_____ %s%s" % (self.relpath, rev_str)) options.stdout.write("\n_____ %s%s\n" % (self.relpath, rev_str))
verbose = ['--verbose'] verbose = ['--verbose']
printed_path = True printed_path = True
@ -202,13 +201,13 @@ class GitWrapper(SCMWrapper):
rev_type = "hash" rev_type = "hash"
if not os.path.exists(self.checkout_path): if not os.path.exists(self.checkout_path):
self._Clone(revision, url, options.verbose) self._Clone(revision, url, options)
files = self._Run(['ls-files']).split() files = self._Run(['ls-files']).split()
file_list.extend([os.path.join(self.checkout_path, f) for f in files]) file_list.extend([os.path.join(self.checkout_path, f) for f in files])
if not verbose: if not verbose:
# Make the output a little prettier. It's nice to have some whitespace # Make the output a little prettier. It's nice to have some whitespace
# between projects when cloning. # between projects when cloning.
print "" options.stdout.write('\n')
return return
if not os.path.exists(os.path.join(self.checkout_path, '.git')): if not os.path.exists(os.path.join(self.checkout_path, '.git')):
@ -268,16 +267,16 @@ class GitWrapper(SCMWrapper):
# Hackish but at that point, git is known to work so just checking for # Hackish but at that point, git is known to work so just checking for
# 502 in stderr should be fine. # 502 in stderr should be fine.
if '502' in e.stderr: if '502' in e.stderr:
print str(e) options.stdout.write(str(e) + '\n')
print "Sleeping 15 seconds and retrying..." options.stdout.write('Sleeping 15 seconds and retrying...\n')
time.sleep(15) time.sleep(15)
continue continue
raise raise
if verbose: if verbose:
print remote_output.strip() options.stdout.write(remote_output.strip() + '\n')
# git remote update prints to stderr when used with --verbose # git remote update prints to stderr when used with --verbose
print remote_err.strip() options.stdout.write(remote_err.strip() + '\n')
# This is a big hammer, debatable if it should even be here... # This is a big hammer, debatable if it should even be here...
if options.force or options.reset: if options.force or options.reset:
@ -286,15 +285,15 @@ class GitWrapper(SCMWrapper):
if current_type == 'detached': if current_type == 'detached':
# case 0 # case 0
self._CheckClean(rev_str) self._CheckClean(rev_str)
self._CheckDetachedHead(rev_str) self._CheckDetachedHead(rev_str, options)
self._Run(['checkout', '--quiet', '%s^0' % revision]) self._Run(['checkout', '--quiet', '%s^0' % revision])
if not printed_path: if not printed_path:
print("\n_____ %s%s" % (self.relpath, rev_str)) options.stdout.write('\n_____ %s%s\n' % (self.relpath, rev_str))
elif current_type == 'hash': elif current_type == 'hash':
# case 1 # case 1
if scm.GIT.IsGitSvn(self.checkout_path) and upstream_branch is not None: if scm.GIT.IsGitSvn(self.checkout_path) and upstream_branch is not None:
# Our git-svn branch (upstream_branch) is our upstream # Our git-svn branch (upstream_branch) is our upstream
self._AttemptRebase(upstream_branch, files, verbose=options.verbose, self._AttemptRebase(upstream_branch, files, options,
newbase=revision, printed_path=printed_path) newbase=revision, printed_path=printed_path)
printed_path = True printed_path = True
else: else:
@ -304,19 +303,19 @@ class GitWrapper(SCMWrapper):
upstream_branch = 'origin' upstream_branch = 'origin'
if options.revision or deps_revision: if options.revision or deps_revision:
upstream_branch = revision upstream_branch = revision
self._AttemptRebase(upstream_branch, files=files, self._AttemptRebase(upstream_branch, files, options,
verbose=options.verbose, printed_path=printed_path) printed_path=printed_path)
printed_path = True printed_path = True
elif rev_type == 'hash': elif rev_type == 'hash':
# case 2 # case 2
self._AttemptRebase(upstream_branch, files, verbose=options.verbose, self._AttemptRebase(upstream_branch, files, options,
newbase=revision, printed_path=printed_path) newbase=revision, printed_path=printed_path)
printed_path = True printed_path = True
elif revision.replace('heads', 'remotes/origin') != upstream_branch: elif revision.replace('heads', 'remotes/origin') != upstream_branch:
# case 4 # case 4
new_base = revision.replace('heads', 'remotes/origin') new_base = revision.replace('heads', 'remotes/origin')
if not printed_path: if not printed_path:
print("\n_____ %s%s" % (self.relpath, rev_str)) options.stdout.write('\n_____ %s%s\n' % (self.relpath, rev_str))
switch_error = ("Switching upstream branch from %s to %s\n" switch_error = ("Switching upstream branch from %s to %s\n"
% (upstream_branch, new_base) + % (upstream_branch, new_base) +
"Please merge or rebase manually:\n" + "Please merge or rebase manually:\n" +
@ -327,7 +326,8 @@ class GitWrapper(SCMWrapper):
# case 3 - the default case # case 3 - the default case
files = self._Run(['diff', upstream_branch, '--name-only']).split() files = self._Run(['diff', upstream_branch, '--name-only']).split()
if verbose: if verbose:
print "Trying fast-forward merge to branch : %s" % upstream_branch options.stdout.write('Trying fast-forward merge to branch : %s\n' %
upstream_branch)
try: try:
merge_output, merge_err = scm.GIT.Capture(['merge', '--ff-only', merge_output, merge_err = scm.GIT.Capture(['merge', '--ff-only',
upstream_branch], upstream_branch],
@ -336,18 +336,18 @@ class GitWrapper(SCMWrapper):
except gclient_utils.CheckCallError, e: except gclient_utils.CheckCallError, e:
if re.match('fatal: Not possible to fast-forward, aborting.', e.stderr): if re.match('fatal: Not possible to fast-forward, aborting.', e.stderr):
if not printed_path: if not printed_path:
print("\n_____ %s%s" % (self.relpath, rev_str)) options.stdout.write('\n_____ %s%s\n' % (self.relpath, rev_str))
printed_path = True printed_path = True
while True: while True:
try: try:
# TODO(maruel): That can't work.
action = str(raw_input("Cannot fast-forward merge, attempt to " action = str(raw_input("Cannot fast-forward merge, attempt to "
"rebase? (y)es / (q)uit / (s)kip : ")) "rebase? (y)es / (q)uit / (s)kip : "))
except ValueError: except ValueError:
gclient_utils.Error('Invalid Character') gclient_utils.Error('Invalid Character')
continue continue
if re.match(r'yes|y', action, re.I): if re.match(r'yes|y', action, re.I):
self._AttemptRebase(upstream_branch, files, self._AttemptRebase(upstream_branch, files, options,
verbose=options.verbose,
printed_path=printed_path) printed_path=printed_path)
printed_path = True printed_path = True
break break
@ -357,36 +357,37 @@ class GitWrapper(SCMWrapper):
"cd %s && git " % self.checkout_path "cd %s && git " % self.checkout_path
+ "rebase %s" % upstream_branch) + "rebase %s" % upstream_branch)
elif re.match(r'skip|s', action, re.I): elif re.match(r'skip|s', action, re.I):
print "Skipping %s" % self.relpath options.stdout.write('Skipping %s\n' % self.relpath)
return return
else: else:
print "Input not recognized" options.stdout.write('Input not recognized\n')
elif re.match("error: Your local changes to '.*' would be " elif re.match("error: Your local changes to '.*' would be "
"overwritten by merge. Aborting.\nPlease, commit your " "overwritten by merge. Aborting.\nPlease, commit your "
"changes or stash them before you can merge.\n", "changes or stash them before you can merge.\n",
e.stderr): e.stderr):
if not printed_path: if not printed_path:
print("\n_____ %s%s" % (self.relpath, rev_str)) options.stdout.write('\n_____ %s%s\n' % (self.relpath, rev_str))
printed_path = True printed_path = True
raise gclient_utils.Error(e.stderr) raise gclient_utils.Error(e.stderr)
else: else:
# Some other problem happened with the merge # Some other problem happened with the merge
logging.error("Error during fast-forward merge in %s!" % self.relpath) logging.error("Error during fast-forward merge in %s!" % self.relpath)
print e.stderr options.stdout.write(e.stderr + '\n')
raise raise
else: else:
# Fast-forward merge was successful # Fast-forward merge was successful
if not re.match('Already up-to-date.', merge_output) or verbose: if not re.match('Already up-to-date.', merge_output) or verbose:
if not printed_path: if not printed_path:
print("\n_____ %s%s" % (self.relpath, rev_str)) options.stdout.write('\n_____ %s%s\n' % (self.relpath, rev_str))
printed_path = True printed_path = True
print merge_output.strip() print merge_output.strip()
if merge_err: if merge_err:
print "Merge produced error output:\n%s" % merge_err.strip() options.stdout.write('Merge produced error output:\n%s\n' %
merge_err.strip())
if not verbose: if not verbose:
# Make the output a little prettier. It's nice to have some # Make the output a little prettier. It's nice to have some
# whitespace between projects when syncing. # whitespace between projects when syncing.
print "" options.stdout.write('\n')
file_list.extend([os.path.join(self.checkout_path, f) for f in files]) file_list.extend([os.path.join(self.checkout_path, f) for f in files])
@ -399,7 +400,8 @@ class GitWrapper(SCMWrapper):
% (self.relpath, rev_str)) % (self.relpath, rev_str))
if verbose: if verbose:
print "Checked out revision %s" % self.revinfo(options, (), None) options.stdout.write('Checked out revision %s\n' %
self.revinfo(options, (), None))
def revert(self, options, args, file_list): def revert(self, options, args, file_list):
"""Reverts local modifications. """Reverts local modifications.
@ -410,7 +412,8 @@ class GitWrapper(SCMWrapper):
if not os.path.isdir(path): if not os.path.isdir(path):
# revert won't work if the directory doesn't exist. It needs to # revert won't work if the directory doesn't exist. It needs to
# checkout instead. # checkout instead.
print("\n_____ %s is missing, synching instead" % self.relpath) options.stdout.write('\n_____ %s is missing, synching instead\n' %
self.relpath)
# Don't reuse the args. # Don't reuse the args.
return self.update(options, [], file_list) return self.update(options, [], file_list)
@ -435,8 +438,9 @@ class GitWrapper(SCMWrapper):
def status(self, options, args, file_list): def status(self, options, args, file_list):
"""Display status information.""" """Display status information."""
if not os.path.isdir(self.checkout_path): if not os.path.isdir(self.checkout_path):
print('\n________ couldn\'t run status in %s:\nThe directory ' options.stdout.write(
'does not exist.' % self.checkout_path) ('\n________ couldn\'t run status in %s:\nThe directory '
'does not exist.\n') % self.checkout_path)
else: else:
merge_base = self._Run(['merge-base', 'HEAD', 'origin']) merge_base = self._Run(['merge-base', 'HEAD', 'origin'])
self._Run(['diff', '--name-status', merge_base], redirect_stdout=False) self._Run(['diff', '--name-status', merge_base], redirect_stdout=False)
@ -449,7 +453,7 @@ class GitWrapper(SCMWrapper):
base_url = self.url base_url = self.url
return base_url[:base_url.rfind('/')] + url return base_url[:base_url.rfind('/')] + url
def _Clone(self, revision, url, verbose=False): def _Clone(self, revision, url, options):
"""Clone a git repository from the given URL. """Clone a git repository from the given URL.
Once we've cloned the repo, we checkout a working branch if the specified Once we've cloned the repo, we checkout a working branch if the specified
@ -457,10 +461,10 @@ class GitWrapper(SCMWrapper):
leave HEAD detached as it makes future updates simpler -- in this case the leave HEAD detached as it makes future updates simpler -- in this case the
user should first create a new branch or switch to an existing branch before user should first create a new branch or switch to an existing branch before
making changes in the repo.""" making changes in the repo."""
if not verbose: if not options.verbose:
# git clone doesn't seem to insert a newline properly before printing # git clone doesn't seem to insert a newline properly before printing
# to stdout # to stdout
print "" options.stdout.write('\n')
clone_cmd = ['clone'] clone_cmd = ['clone']
if revision.startswith('refs/heads/'): if revision.startswith('refs/heads/'):
@ -469,7 +473,7 @@ class GitWrapper(SCMWrapper):
else: else:
clone_cmd.append('--no-checkout') clone_cmd.append('--no-checkout')
detach_head = True detach_head = True
if verbose: if options.verbose:
clone_cmd.append('--verbose') clone_cmd.append('--verbose')
clone_cmd.extend([url, self.checkout_path]) clone_cmd.extend([url, self.checkout_path])
@ -485,21 +489,21 @@ class GitWrapper(SCMWrapper):
# read". In the meantime, just make sure .git exists. # read". In the meantime, just make sure .git exists.
if (e.args[0] == 'git command clone returned 128' and if (e.args[0] == 'git command clone returned 128' and
os.path.exists(os.path.join(self.checkout_path, '.git'))): os.path.exists(os.path.join(self.checkout_path, '.git'))):
print str(e) options.stdout.write(str(e) + '\n')
print "Retrying..." options.stdout.write('Retrying...\n')
continue continue
raise e raise e
if detach_head: if detach_head:
# Squelch git's very verbose detached HEAD warning and use our own # Squelch git's very verbose detached HEAD warning and use our own
self._Run(['checkout', '--quiet', '%s^0' % revision]) self._Run(['checkout', '--quiet', '%s^0' % revision])
print \ options.stdout.write(
"Checked out %s to a detached HEAD. Before making any commits\n" \ ('Checked out %s to a detached HEAD. Before making any commits\n'
"in this repo, you should use 'git checkout <branch>' to switch to\n" \ 'in this repo, you should use \'git checkout <branch>\' to switch to\n'
"an existing branch or use 'git checkout origin -b <branch>' to\n" \ 'an existing branch or use \'git checkout origin -b <branch>\' to\n'
"create a new branch for your work." % revision 'create a new branch for your work.') % revision)
def _AttemptRebase(self, upstream, files, verbose=False, newbase=None, def _AttemptRebase(self, upstream, files, options, newbase=None,
branch=None, printed_path=False): branch=None, printed_path=False):
"""Attempt to rebase onto either upstream or, if specified, newbase.""" """Attempt to rebase onto either upstream or, if specified, newbase."""
files.extend(self._Run(['diff', upstream, '--name-only']).split()) files.extend(self._Run(['diff', upstream, '--name-only']).split())
@ -507,16 +511,16 @@ class GitWrapper(SCMWrapper):
if newbase: if newbase:
revision = newbase revision = newbase
if not printed_path: if not printed_path:
print "\n_____ %s : Attempting rebase onto %s..." % (self.relpath, options.stdout.write('\n_____ %s : Attempting rebase onto %s...\n' % (
revision) self.relpath, revision))
printed_path = True printed_path = True
else: else:
print "Attempting rebase onto %s..." % revision options.stdout.write('Attempting rebase onto %s...\n' % revision)
# Build the rebase command here using the args # Build the rebase command here using the args
# git rebase [options] [--onto <newbase>] <upstream> [<branch>] # git rebase [options] [--onto <newbase>] <upstream> [<branch>]
rebase_cmd = ['rebase'] rebase_cmd = ['rebase']
if verbose: if options.verbose:
rebase_cmd.append('--verbose') rebase_cmd.append('--verbose')
if newbase: if newbase:
rebase_cmd.extend(['--onto', newbase]) rebase_cmd.extend(['--onto', newbase])
@ -549,7 +553,7 @@ class GitWrapper(SCMWrapper):
"cd %s && git " % self.checkout_path "cd %s && git " % self.checkout_path
+ "%s" % ' '.join(rebase_cmd)) + "%s" % ' '.join(rebase_cmd))
elif re.match(r'show|s', rebase_action, re.I): elif re.match(r'show|s', rebase_action, re.I):
print "\n%s" % e.stderr.strip() options.stdout.write('\n%s\n' % e.stderr.strip())
continue continue
else: else:
gclient_utils.Error("Input not recognized") gclient_utils.Error("Input not recognized")
@ -559,8 +563,9 @@ class GitWrapper(SCMWrapper):
"Fix the conflict and run gclient again.\n" "Fix the conflict and run gclient again.\n"
"See 'man git-rebase' for details.\n") "See 'man git-rebase' for details.\n")
else: else:
print e.stdout.strip() options.stdout.write(e.stdout.strip() + '\n')
print "Rebase produced error output:\n%s" % e.stderr.strip() options.stdout.write('Rebase produced error output:\n%s\n' %
e.stderr.strip())
raise gclient_utils.Error("Unrecognized error, please merge or rebase " raise gclient_utils.Error("Unrecognized error, please merge or rebase "
"manually.\ncd %s && git " % "manually.\ncd %s && git " %
self.checkout_path self.checkout_path
@ -568,11 +573,12 @@ class GitWrapper(SCMWrapper):
print rebase_output.strip() print rebase_output.strip()
if rebase_err: if rebase_err:
print "Rebase produced error output:\n%s" % rebase_err.strip() options.stdout.write('Rebase produced error output:\n%s\n' %
if not verbose: rebase_err.strip())
if not options.verbose:
# Make the output a little prettier. It's nice to have some # Make the output a little prettier. It's nice to have some
# whitespace between projects when syncing. # whitespace between projects when syncing.
print "" options.stdout.write('\n')
@staticmethod @staticmethod
def _CheckMinVersion(min_version): def _CheckMinVersion(min_version):
@ -610,7 +616,7 @@ class GitWrapper(SCMWrapper):
'\tPlease commit, stash, or reset.\n' '\tPlease commit, stash, or reset.\n'
% (self.relpath, rev_str)) % (self.relpath, rev_str))
def _CheckDetachedHead(self, rev_str): def _CheckDetachedHead(self, rev_str, options):
# HEAD is detached. Make sure it is safe to move away from (i.e., it is # HEAD is detached. Make sure it is safe to move away from (i.e., it is
# reference by a commit). If not, error out -- most likely a rebase is # reference by a commit). If not, error out -- most likely a rebase is
# in progress, try to detect so we can give a better error. # in progress, try to detect so we can give a better error.
@ -632,7 +638,9 @@ class GitWrapper(SCMWrapper):
# Let's just save off the commit so we can proceed. # Let's just save off the commit so we can proceed.
name = "saved-by-gclient-" + self._Run(["rev-parse", "--short", "HEAD"]) name = "saved-by-gclient-" + self._Run(["rev-parse", "--short", "HEAD"])
self._Run(["branch", name]) self._Run(["branch", name])
print ("\n_____ found an unreferenced commit and saved it as '%s'" % name) options.stdout.write(
'\n_____ found an unreferenced commit and saved it as \'%s\'\n' %
name)
def _GetCurrentBranch(self): def _GetCurrentBranch(self):
# Returns name of current branch or None for detached HEAD # Returns name of current branch or None for detached HEAD
@ -699,7 +707,7 @@ class SVNWrapper(SCMWrapper):
command = ['svn', 'diff', '-x', '--ignore-eol-style'] command = ['svn', 'diff', '-x', '--ignore-eol-style']
command.extend(args) command.extend(args)
filterer = DiffFilterer(self.relpath) filterer = DiffFilterer(self.relpath, options.stdout)
gclient_utils.CheckCallAndFilter(command, cwd=path, always=False, gclient_utils.CheckCallAndFilter(command, cwd=path, always=False,
print_stdout=False, filter_fn=filterer.Filter, print_stdout=False, filter_fn=filterer.Filter,
stdout=options.stdout) stdout=options.stdout)
@ -716,7 +724,8 @@ class SVNWrapper(SCMWrapper):
checkout_path = os.path.join(self._root_dir, self.relpath) checkout_path = os.path.join(self._root_dir, self.relpath)
git_path = os.path.join(self._root_dir, self.relpath, '.git') git_path = os.path.join(self._root_dir, self.relpath, '.git')
if os.path.exists(git_path): if os.path.exists(git_path):
print("________ found .git directory; skipping %s" % self.relpath) options.stdout.write('________ found .git directory; skipping %s\n' %
self.relpath)
return return
if args: if args:
@ -776,7 +785,8 @@ class SVNWrapper(SCMWrapper):
can_switch = ((from_info['Repository Root'] != to_info['Repository Root']) can_switch = ((from_info['Repository Root'] != to_info['Repository Root'])
and (from_info['UUID'] == to_info['UUID'])) and (from_info['UUID'] == to_info['UUID']))
if can_switch: if can_switch:
print('\n_____ relocating %s to a new checkout' % self.relpath) options.stdout.write('\n_____ relocating %s to a new checkout\n' %
self.relpath)
# We have different roots, so check if we can switch --relocate. # We have different roots, so check if we can switch --relocate.
# Subversion only permits this if the repository UUIDs match. # Subversion only permits this if the repository UUIDs match.
# Perform the switch --relocate, then rewrite the from_url # Perform the switch --relocate, then rewrite the from_url
@ -804,7 +814,8 @@ class SVNWrapper(SCMWrapper):
'there is local changes in %s. Delete the directory and ' 'there is local changes in %s. Delete the directory and '
'try again.') % (url, checkout_path)) 'try again.') % (url, checkout_path))
# Ok delete it. # Ok delete it.
print('\n_____ switching %s to a new checkout' % self.relpath) options.stdout.write('\n_____ switching %s to a new checkout\n' %
self.relpath)
gclient_utils.RemoveDirectory(checkout_path) gclient_utils.RemoveDirectory(checkout_path)
# We need to checkout. # We need to checkout.
command = ['checkout', url, checkout_path] command = ['checkout', url, checkout_path]
@ -816,7 +827,7 @@ class SVNWrapper(SCMWrapper):
# number of the existing directory, then we don't need to bother updating. # number of the existing directory, then we don't need to bother updating.
if not options.force and str(from_info['Revision']) == revision: if not options.force and str(from_info['Revision']) == revision:
if options.verbose or not forced_revision: if options.verbose or not forced_revision:
print('\n_____ %s%s' % (self.relpath, rev_str)) options.stdout.write('\n_____ %s%s\n' % (self.relpath, rev_str))
return return
command = ['update', checkout_path] command = ['update', checkout_path]
@ -862,7 +873,8 @@ class SVNWrapper(SCMWrapper):
if not os.path.isdir(path): if not os.path.isdir(path):
# svn revert won't work if the directory doesn't exist. It needs to # svn revert won't work if the directory doesn't exist. It needs to
# checkout instead. # checkout instead.
print("\n_____ %s is missing, synching instead" % self.relpath) options.stdout.write('\n_____ %s is missing, synching instead\n' %
self.relpath)
# Don't reuse the args. # Don't reuse the args.
return self.update(options, [], file_list) return self.update(options, [], file_list)
@ -881,7 +893,7 @@ class SVNWrapper(SCMWrapper):
if logging.getLogger().isEnabledFor(logging.INFO): if logging.getLogger().isEnabledFor(logging.INFO):
logging.info('%s%s' % (file[0], file[1])) logging.info('%s%s' % (file[0], file[1]))
else: else:
print(file_path) options.stdout.write(file_path + '\n')
# Flush at least 10 seconds between line writes. We wait at least 10 # Flush at least 10 seconds between line writes. We wait at least 10
# seconds to avoid overloading the reader that called us with output, # seconds to avoid overloading the reader that called us with output,
# which can slow busy readers down. # which can slow busy readers down.
@ -933,9 +945,9 @@ class SVNWrapper(SCMWrapper):
command = ['status'] + args command = ['status'] + args
if not os.path.isdir(path): if not os.path.isdir(path):
# svn status won't work if the directory doesn't exist. # svn status won't work if the directory doesn't exist.
print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " options.stdout.write(
"does not exist." ('\n________ couldn\'t run \'%s\' in \'%s\':\nThe directory '
% (' '.join(command), path)) 'does not exist.') % (' '.join(command), path))
# There's no file list to retrieve. # There's no file list to retrieve.
else: else:
self._RunAndGetFileList(command, options, file_list) self._RunAndGetFileList(command, options, file_list)

Loading…
Cancel
Save