早合并和晚合并,冲突差多少
同样两条分支,如果分支只做了第一步就合回来(只改了 HOST),和拖到现在才合,冲突数各是多少?运行下面这段程序:
def classify(b, o, t):
if o == t:
return "same"
if o == b:
return "theirs"
if t == b:
return "ours"
return "conflict"
def kinds(base, ours, theirs):
return [classify(b, o, t)
for b, o, t in zip(base, ours, theirs)]
base = ['HOST = "localhost"', 'PORT = 8000', 'DEBUG = False',
'TIMEOUT = 30', 'RETRY = 1', 'LOG = "app.log"']
ours = ['HOST = "localhost"', 'PORT = 8080', 'DEBUG = True',
'TIMEOUT = 60', 'RETRY = 1', 'LOG = "main.log"']
theirs = ['HOST = "0.0.0.0"', 'PORT = 9000', 'DEBUG = True',
'TIMEOUT = 30', 'RETRY = 3', 'LOG = "sys.log"']
early = ['HOST = "0.0.0.0"', 'PORT = 8000', 'DEBUG = False',
'TIMEOUT = 30', 'RETRY = 1', 'LOG = "app.log"']
print(str(kinds(base, ours, early).count("conflict")) + "/" +
str(kinds(base, ours, theirs).count("conflict")))
全部评论