def clean_hg(settings, student):
"""
cleans a Mercurial repository with the latest submission
"""
LOGGER.info("Using hg to clean up the directory for student %s", student['username'])
#Remove all untracked files and directories
#Override all options to enable the purge extension to clean the directory
cmd = "hg --config='extensions.purge=' purge --all --dirs --files"
timeout = int(settings['clean']['timeout']) or 5
subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
shell=True, timeout=timeout, cwd=student['directory'])
#Undo any changes to tracked files made since the last commit
cmd = "hg update -C"
timeout = int(settings['clean']['timeout']) or 5
subprocess.check_call(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
shell=True, timeout=timeout, cwd=student['directory'])
评论列表
文章目录