这次合并有几处冲突

👁️ 4 人浏览 💬 0 人评论 ❤️ 添加收藏

同一格,两个人都动了

我改的

他改的

两条分支都改过 config.py,逐行对照如下:

行  共同祖先            我这边(ours)         对方(theirs)
 1  HOST = "localhost"  同                   HOST = "0.0.0.0"
 2  PORT = 8000         PORT = 8080          PORT = 9000
 3  DEBUG = False       DEBUG = True         DEBUG = True
 4  TIMEOUT = 30        TIMEOUT = 60         同
 5  RETRY = 1           同                   RETRY = 3
 6  LOG = "app.log"     LOG = "main.log"     LOG = "sys.log"

下面这段程序把每一行归了个类。运行它,看有几行是冲突:

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"']
print(kinds(base, ours, theirs).count("conflict"))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论