import argparse import sys from automergetool.amt_utils import REPORT_NONE, REPORT_SOLVED, REPORT_UNSOLVED, REPORT_FULL, ConflictsWalker def parse_arguments(): """Parses the arguments passed on invocation in a dict and return it""" parser = argparse.ArgumentParser( description="A tool to resolve dummy conflicts") parser.add_argument('-m', '--merged', required=True) parser.add_argument( '-r', '--report', choices=[REPORT_NONE, REPORT_SOLVED, REPORT_UNSOLVED, REPORT_FULL], default=REPORT_UNSOLVED, required=False) parser.add_argument('-v', '--verbose', required=False, action='store_true') return parser.parse_args() if __name__ == '__main__': args = parse_arguments() walker = ConflictsWalker(args.merged, 'dbg', args.report, args.verbose) while walker.has_more_conflicts(): continue walker.end() sys.exit(walker.get_merge_status())
lines_local = conflict.local_lines() lines_base = conflict.base_lines() lines_remote = conflict.remote_lines() if len(lines_local) != len(lines_base): return if len(lines_remote) != len(lines_base): return lines_count = len(lines_base) resolution = "" for l in range(lines_count): if lines_local[l] == lines_base[l]: if lines_remote[l] != "": resolution += lines_remote[l] elif lines_remote[l] == lines_base[l]: if lines_local[l] != "": resolution += lines_local[l] else: # neither match, harder conflict, return early return # all lines solved :) conflict.resolve(resolution) if __name__ == '__main__': args = parse_arguments() walker = ConflictsWalker(args.merged, 'woven', args.report, args.verbose) while walker.has_more_conflicts(): handle_conflict(walker.next_conflict()) walker.end() sys.exit(walker.get_merge_status())
prompt += ">>>>>>> REMOTE\n" + conflict.remote prompt += "Select action : \n" prompt += " - [1] Remote First\n" prompt += " - [2] Local First\n" prompt += " - [3] Remote Only\n" prompt += " - [4] Local Only\n" prompt += " - [0] Ignore conflict\n" prompt += "»" choice = user_input(prompt) if choice == '0': use_order = ORDER_NONE elif choice == '1': use_order = ORDER_REMOTE_FIRST elif choice == '2': use_order = ORDER_LOCAL_FIRST elif choice == '3': use_order = ORDER_REMOTE_ONLY elif choice == '4': use_order = ORDER_LOCAL_ONLY return use_order if __name__ == '__main__': args = parse_arguments() walker = ConflictsWalker(args.merged, 'adds', args.report, args.verbose) while walker.has_more_conflicts(): handle_conflict(walker.next_conflict(), lambda c: get_order(c, args.order), args.whitespace) walker.end() sys.exit(walker.get_merge_status())