-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerger.py
executable file
·110 lines (86 loc) · 2.76 KB
/
merger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
import os
import argparse
from subprocess import call
def build_difference(fbranch, froot, fhead, sbranch, sroot, shead):
get_changelist(fbranch, froot, fhead)
get_changelist(sbranch, sroot, shead)
fchangelist = read_changelist(fbranch)
schangelist = read_changelist(sbranch)
diff(fbranch, fchangelist, sbranch, schangelist)
def diff(fbranch, fchange_list, sbranch, schange_list):
fbranch_unique_commits = []
sbranch_unique_commits = []
for line in fchange_list:
found = False
for line2 in schange_list:
if line == line2:
found = True
if found == False:
fbranch_unique_commits.append(line)
for line in schange_list:
found = False
for line2 in fchange_list:
if line == line2:
found = True
if found == False:
sbranch_unique_commits.append(line)
print("#####################################################################\n")
print("Unique commits in " + fbranch + " :\n")
for line in fbranch_unique_commits:
print(line + "\n")
print("#####################################################################\n")
print("Unique commits in " + sbranch + " :\n")
for line in sbranch_unique_commits:
print(line + "\n")
def read_changelist(branch):
lines = []
with open(branch + ".txt") as file:
for line in file:
line = line.strip()
lines.append(line)
return lines
def get_changelist(branch, root, head):
try:
os.remove(branch + ".txt")
except OSError as e:
pass
status = call("git checkout " + branch,cwd=os.path.dirname(os.path.realpath(__file__)), shell=True)
status = call("git pull", cwd=os.path.dirname(os.path.realpath(__file__)), shell=True)
status = call("git log --pretty=format:%s {0}..{1} > {2}.txt".format(root, head, branch), cwd=os.path.dirname(os.path.realpath(__file__)), shell=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Helper script for diffing the commits."
)
parser.add_argument(
"--froot",
nargs="?",
default="-"
)
parser.add_argument(
"--fhead",
nargs="?",
default="-"
)
parser.add_argument(
"--fbranch",
nargs="?",
default="master"
)
parser.add_argument(
"--sbranch",
nargs="?",
default="r-4.2.x"
)
parser.add_argument(
"--sroot",
nargs="?",
default=""
)
parser.add_argument(
"--shead",
nargs="?",
default=""
)
args = parser.parse_args()
build_difference(args.fbranch, args.froot, args.fhead, args.sbranch, args.sroot, args.shead)