default implementation uses :attr:`resolutions`.
"""
resolved = True
- sh = shell.Shell()
files = set()
- for status in sh.eval("git", "ls-files", "--unmerged").splitlines():
+ for status in shell.eval("git", "ls-files", "--unmerged").splitlines():
files.add(status.split()[-1])
for file in files:
# check for newline mismatch
# HACK: using git diff to tell if files are binary or not
- if not len(sh.eval("git", "diff", file).splitlines()) == 1 and util.mixed_newlines(file):
+ if not len(shell.eval("git", "diff", file).splitlines()) == 1 and util.mixed_newlines(file):
# this code only works on Unix
def get_newline(filename):
f = open(filename, "U")
return f.newlines
def create_reference(id):
f = tempfile.NamedTemporaryFile(prefix="wizardResolve", delete=False)
- sh.call("git", "cat-file", "blob", ":%d:%s" % (id, file), stdout=f)
+ shell.call("git", "cat-file", "blob", ":%d:%s" % (id, file), stdout=f)
f.close()
return get_newline(f.name), f.name
def convert(filename, dest_nl):
logging.info("Remerging %s", file)
with open(file, "wb") as f:
try:
- sh.call("git", "merge-file", "--stdout", our_file, common_file, their_file, stdout=f)
+ shell.call("git", "merge-file", "--stdout", our_file, common_file, their_file, stdout=f)
logging.info("New merge was clean")
- sh.call("git", "add", file)
+ shell.call("git", "add", file)
continue
except shell.CallError:
pass
logging.info("Did resolution with spec:\n" + spec)
open(file, "w").write(contents)
if not resolve.is_conflict(contents):
- sh.call("git", "add", file)
+ shell.call("git", "add", file)
else:
resolved = False
else:
"""
Database backups for MySQL using the :command:`mysqldump` utility.
"""
- sh = shell.Shell()
outfile = os.path.join(outdir, "db.sql")
try:
- sh.call("mysqldump", "--compress", "-r", outfile, *get_mysql_args(deployment.dsn))
- sh.call("gzip", "--best", outfile)
+ shell.call("mysqldump", "--compress", "-r", outfile, *get_mysql_args(deployment.dsn))
+ shell.call("gzip", "--best", outfile)
except shell.CallError as e:
raise BackupFailure(e.stderr)
"""
Database restoration for MySQL by piping SQL commands into :command:`mysql`.
"""
- sh = shell.Shell()
if not os.path.exists(backup_dir):
raise RestoreFailure("Backup %s doesn't exist", backup_dir.rpartition("/")[2])
sql = open(os.path.join(backup_dir, "db.sql"), 'w+')
- sh.call("gunzip", "-c", os.path.join(backup_dir, "db.sql.gz"), stdout=sql)
+ shell.call("gunzip", "-c", os.path.join(backup_dir, "db.sql.gz"), stdout=sql)
sql.seek(0)
- sh.call("mysql", *get_mysql_args(deployment.dsn), stdin=sql)
+ shell.call("mysql", *get_mysql_args(deployment.dsn), stdin=sql)
sql.close()
def remove_database(deployment):
Generic database removal function. Actually, not so generic because we
go and check if we're on scripts and if we are run a different command.
"""
- sh = shell.Shell()
if deployment.dsn.host == "sql.mit.edu":
try:
- sh.call("/mit/scripts/sql/bin/drop-database", deployment.dsn.database)
+ shell.call("/mit/scripts/sql/bin/drop-database", deployment.dsn.database)
return
except shell.CallError:
pass