def fetch_changes(repo_path, up_commit='<STR_LIT>'):
last_up_commit = None<EOL>prevcwd = os.getcwd()<EOL>try:<EOL><INDENT>gitexe = '<STR_LIT>'<EOL>os.chdir(repo_path)<EOL>old_sources_timestamp = sources_latest_timestamp('<STR_LIT:.>')<EOL>shell_command([gitexe, '<STR_LIT>'])<EOL>last_up_commit = subprocess.check_output(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>shell_command([gitexe, '<STR_LIT>', up_commit])<EOL>up_commit = subprocess.check_output(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL>new_sources_timestamp = sources_latest_timestamp('<STR_LIT:.>')<EOL>if old_sources_timestamp < new_sources_timestamp:<EOL><INDENT>with open('<STR_LIT>', '<STR_LIT:w>') as up_commit_file:<EOL><INDENT>up_commit_file.write(up_commit)<EOL><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>os.chdir(prevcwd)<EOL><DEDENT>return last_up_commit, up_commit<EOL>
Fetch latest changes from stage and touch .timestamp
if any python sources have been modified.