Link #! /usr/bin/env python # coding: utf-8 # Here is what you have to do before running this codes # You need to grab newest stable version of chromium and name as new_chromium import os import subprocess import shutil import errno import difflib import sys found = False src_folder = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) dest_folder= os.getcwd() while not found: dest_folder = raw_input("Enter full path of new chromium folder (ex) /ruser/update_chromium/src: ") if not os.path.isdir(dest_folder): print(dest_folder, 'This folder has not been found. Enter correct path. ') else: print("All Rakuten files are moved to the destination dir completely") found = True #git diff --name-status stable_branch feature/rakuten_android file_name = "diff.txt" try: os.remove(file_name) except OSError: pass f = open(file_name, "w")["git", "diff", "--name-status", "65.0.3325.109", "rakuten/develop"], stdout=f) lines = [] with open(file_name) as f: lines = f.readlines() lines = [x.strip() for x in lines] lines.sort() def copy_file_or_create_path(source, target): try: shutil.copy2(source, target) except IOError as e: if e.errno != errno.ENOENT: raise os.makedirs(os.path.dirname(target)) copy_file_or_create_path(source, target) for x in lines: if "A\t" in x: path = x.replace("A\t", "") target = os.path.join(dest_folder, path) if not os.path.exists(target): source = os.path.join(src_folder, path) copy_file_or_create_path(source, target) elif "M\t" in x: path = x.replace("M\t", "") source = os.path.join(src_folder, path) target = os.path.join(dest_folder, path) if path.endswith('.png'): try: copy_file_or_create_path(source, target) except IOError as e: print(e) except: print("other error") else: if sys.argv[1] == "diff":["git", "difftool", "65.0.3325.109", source])[sys.argv[1], source, target]) elif sys.argv[1] == "merge":["meld", source, target]) else: print(source) # file1 = open(source, 'r') # file2 = open(target, 'r') # diff = difflib.ndiff(file1.readlines(), file2.readlines()) # delta = ''.join(x[2:] for x in diff if x.startswith('- ')) # print(delta)