Skip to content

[utils] Rename print_command argument. #2846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/build-script
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def call_without_sleeping(command, dry_run=False):
# Don't mutate the caller's copy of the arguments.
command = ["caffeinate"] + list(command)

shell.call(command, dry_run=dry_run, print_command=False)
shell.call(command, dry_run=dry_run, echo=False)


# Main entry point for the preset mode.
Expand Down
4 changes: 2 additions & 2 deletions utils/profdata_merge/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
toolchain = host_toolchain()
LLVM_PROFDATA_PATH = toolchain.llvm_profdata
_profdata_help = shell.capture([LLVM_PROFDATA_PATH, 'merge', '-help'],
print_command=False)
echo=False)
LLVM_PROFDATA_SUPPORTS_SPARSE = 'sparse' in _profdata_help


Expand Down Expand Up @@ -64,7 +64,7 @@ def merge_file_buffer(self):
llvm_cmd.append("-sparse")
llvm_cmd += cleaned_files
self.report(llvm_cmd)
ret = shell.call(llvm_cmd, print_command=False)
ret = shell.call(llvm_cmd, echo=False)
if ret != 0:
self.report("llvm profdata command failed -- Exited with code %d"
% ret, level=logging.ERROR)
Expand Down
2 changes: 1 addition & 1 deletion utils/recursive-lipo
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def merge_lipo_files(src_root_dirs, file_list, copy_verbatim_subpaths,
else:
print("-- Running lipo %s" % dest_path)
shell.call(lipo_cmd + ["-output", dest_path] + file_paths,
print_command=verbose)
echo=verbose)
else:
# Multiple instances are different, and they're not executable.
print(
Expand Down
42 changes: 21 additions & 21 deletions utils/swift_build_support/swift_build_support/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _coerce_dry_run(dry_run_override):
return dry_run_override


def _print_command(dry_run, command, env=None, prompt="+ "):
def _echo_command(dry_run, command, env=None, prompt="+ "):
output = []
if env is not None:
output += ['env'] + [_quote("%s=%s" % (k, v)) for k, v in env]
Expand All @@ -59,7 +59,7 @@ def _print_command(dry_run, command, env=None, prompt="+ "):
file.flush()


def call(command, stderr=None, env=None, dry_run=None, print_command=True):
def call(command, stderr=None, env=None, dry_run=None, echo=True):
"""
call(command, ...) -> str

Expand All @@ -68,8 +68,8 @@ def call(command, stderr=None, env=None, dry_run=None, print_command=True):
This function will raise an exception on any command failure.
"""
dry_run = _coerce_dry_run(dry_run)
if dry_run or print_command:
_print_command(dry_run, command, env=env)
if dry_run or echo:
_echo_command(dry_run, command, env=env)
if dry_run:
return
_env = None
Expand All @@ -88,7 +88,7 @@ def call(command, stderr=None, env=None, dry_run=None, print_command=True):
"': " + e.strerror)


def capture(command, stderr=None, env=None, dry_run=None, print_command=True):
def capture(command, stderr=None, env=None, dry_run=None, echo=True):
"""
capture(command, ...) -> str

Expand All @@ -97,8 +97,8 @@ def capture(command, stderr=None, env=None, dry_run=None, print_command=True):
This function will raise an exception on any command failure.
"""
dry_run = _coerce_dry_run(dry_run)
if dry_run or print_command:
_print_command(dry_run, command, env=env)
if dry_run or echo:
_echo_command(dry_run, command, env=env)
if dry_run:
return
_env = None
Expand All @@ -118,44 +118,44 @@ def capture(command, stderr=None, env=None, dry_run=None, print_command=True):


@contextmanager
def pushd(path, dry_run=None, print_command=True):
def pushd(path, dry_run=None, echo=True):
dry_run = _coerce_dry_run(dry_run)
old_dir = os.getcwd()
if dry_run or print_command:
_print_command(dry_run, ["pushd", path])
if dry_run or echo:
_echo_command(dry_run, ["pushd", path])
if not dry_run:
os.chdir(path)
yield
if dry_run or print_command:
_print_command(dry_run, ["popd"])
if dry_run or echo:
_echo_command(dry_run, ["popd"])
if not dry_run:
os.chdir(old_dir)


def makedirs(path, dry_run=None, print_command=True):
def makedirs(path, dry_run=None, echo=True):
dry_run = _coerce_dry_run(dry_run)
if dry_run or print_command:
_print_command(dry_run, ['mkdir', '-p', path])
if dry_run or echo:
_echo_command(dry_run, ['mkdir', '-p', path])
if dry_run:
return
if not os.path.isdir(path):
os.makedirs(path)


def rmtree(path, dry_run=None, print_command=True):
def rmtree(path, dry_run=None, echo=True):
dry_run = _coerce_dry_run(dry_run)
if dry_run or print_command:
_print_command(dry_run, ['rm', '-rf', path])
if dry_run or echo:
_echo_command(dry_run, ['rm', '-rf', path])
if dry_run:
return
if os.path.exists(path):
shutil.rmtree(path)


def copytree(src, dest, dry_run=None, print_command=True):
def copytree(src, dest, dry_run=None, echo=True):
dry_run = _coerce_dry_run(dry_run)
if dry_run or print_command:
_print_command(dry_run, ['cp', '-r', src, dest])
if dry_run or echo:
_echo_command(dry_run, ['cp', '-r', src, dest])
if dry_run:
return
shutil.copytree(src, dest)
20 changes: 10 additions & 10 deletions utils/update-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,23 @@ def update_working_copy(repo_path, branch):
return

print("--- Updating '" + repo_path + "' ---")
with shell.pushd(repo_path, dry_run=False, print_command=False):
with shell.pushd(repo_path, dry_run=False, echo=False):
if branch:
status = shell.capture(['git', 'status', '--porcelain'],
print_command=False)
echo=False)
if status:
print("Please, commit your changes.")
print(status)
exit(1)
shell.call(['git', 'checkout', branch], print_command=False)
shell.call(['git', 'checkout', branch], echo=False)

# Prior to Git 2.6, this is the way to do a "git pull
# --rebase" that respects rebase.autostash. See
# http://stackoverflow.com/a/30209750/125349
shell.call(["git", "fetch"], print_command=False)
shell.call(["git", "rebase", "FETCH_HEAD"], print_command=False)
shell.call(["git", "fetch"], echo=False)
shell.call(["git", "rebase", "FETCH_HEAD"], echo=False)
shell.call(["git", "submodule", "update", "--recursive"],
print_command=False)
echo=False)


def obtain_additional_swift_sources(
Expand All @@ -118,7 +118,7 @@ def obtain_additional_swift_sources(
print("--- Skipping '" + dir_name + "' ---")
continue
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False,
print_command=False):
echo=False):
if not os.path.isdir(os.path.join(dir_name, ".git")):
print("--- Cloning '" + dir_name + "' ---")
if with_ssh is True:
Expand All @@ -127,10 +127,10 @@ def obtain_additional_swift_sources(
remote = "https://github.com/" + repo + '.git'
if skip_history:
shell.call(['git', 'clone', '--recursive', '--depth', '1',
remote, dir_name], print_command=False)
remote, dir_name], echo=False)
else:
shell.call(['git', 'clone', '--recursive', remote,
dir_name], print_command=False)
dir_name], echo=False)
if branch:
if branch == "master" or branch == "stable":
repo_branch = MASTER_BRANCHES[dir_name]
Expand All @@ -145,7 +145,7 @@ def obtain_additional_swift_sources(
".git"
shell.call(['git', '--git-dir', src_path, '--work-tree',
os.path.join(SWIFT_SOURCE_ROOT, dir_name),
'checkout', repo_branch], print_command=False)
'checkout', repo_branch], echo=False)


def main():
Expand Down