"都动过"和"真冲突"差几行
数两个数:两边都动过的行数,和其中真正冲突的行数。运行下面这段程序:
def classify(b, o, t):
if o == t:
return "same"
if o == b:
return "theirs"
if t == b:
return "ours"
return "conflict"
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"']
both = sum(1 for b, o, t in zip(base, ours, theirs)
if o != b and t != b)
conf = sum(1 for b, o, t in zip(base, ours, theirs)
if classify(b, o, t) == "conflict")
print(str(both) + "/" + str(conf))
全部评论