Skip to content

Instantly share code, notes, and snippets.

@aisk
Created October 23, 2016 16:17
Show Gist options
  • Save aisk/eddfbf96d013c27880440be1db31d0dc to your computer and use it in GitHub Desktop.
Save aisk/eddfbf96d013c27880440be1db31d0dc to your computer and use it in GitHub Desktop.
#! /usr/bin/env python2.7
import os
import subprocess
import sys
import tempfile
def is_skipped_folder(cpython_repo, path):
skipped_folders = [
'.hgtags',
'Demo',
'Doc',
'Mac',
'Makefile',
'Misc',
'PCbuild',
'README',
'Tools',
'configure',
]
for skipped_folder in skipped_folders:
if path.startswith(os.path.join(cpython_repo, skipped_folder)):
return True
return False
def get_rev_file(path, rev):
filepath = tempfile.mktemp(prefix='merge_helper_', suffix='.py')
os.system('hg cat %s -r %s > %s' % (path, rev, filepath))
return filepath
def main(cpython_repo, pyston_repo, skip):
output = subprocess.check_output(['hg', 'status', cpython_repo, '--rev', 'v2.7.7:v2.7.8'])
diff_files = [line.split()[1] for line in output.splitlines()]
diff_files = filter(lambda x: not is_skipped_folder(cpython_repo, x), diff_files)
diff_files = sorted(diff_files)
for i, filepath in enumerate(diff_files):
if i < skip:
continue
pyston_filepath = os.path.join(pyston_repo, filepath.lstrip(cpython_repo))
print 'diff', i, ':', filepath
args = (get_rev_file(filepath, 'v2.7.7'), get_rev_file(filepath, 'v2.7.8'), pyston_filepath)
os.system('vimdiff %s %s %s' % args)
if __name__ == '__main__':
if len(sys.argv) != 4:
print 'Usage: ./merge_helper.py <cpython_hg_repo> <pyston_repo> <skip>'
sys.exit(1)
cpython_repo = sys.argv[1]
pyston_repo = sys.argv[2]
skip = int(sys.argv[3])
main(cpython_repo, pyston_repo, skip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment