ในที่สุดฉันก็แก้ปัญหานี้โดยใช้วิธีการคล้ายกับอาร์ตี้
ขั้นตอนที่ 1:ระเบิดแพตช์เป็นแพทช์แยกจำนวนมากหนึ่งสำหรับแต่ละก้อน
ฉันใช้สคริปต์นี้เพื่อทำสิ่งนี้:
#!/usr/bin/python2
import sys
header = []
writing_header = False
patchnum = 0
patch = open(sys.argv[1], "r")
out = open("/dev/null", "w")
for line in patch.readlines():
    if line.startswith("diff"):
        header = []
        writing_header = True
    if line.startswith("@@"):
        out.close()
        out = open(str(patchnum) + ".diff", "w")
        patchnum += 1
        writing_header = False
        out.writelines(header)
    if writing_header:
        header.append(line)
    else:
        out.write(line)
out.close()
ตัวอย่างการใช้งาน:
$ cd directory_containing_patch
$ mkdir foo
$ cd foo
$ explode.py ../huge_patch.diff
นี้จะเติมไดเรกทอรีปัจจุบันด้วยไฟล์ที่เรียกว่า 0.diff 1.diff และ cetera
ขั้นตอนที่ 2:ใช้แต่ละโปรแกรมแก้ไขโดยยกเลิกโปรแกรมปรับปรุงที่นำไปใช้แล้ว
ฉันใช้สคริปต์นี้เพื่อทำสิ่งนี้:
#!/bin/bash
if [[ $# -ne 1 || ! -d "${1}/" ]]; then
    echo "Usage: $0 dirname"
    exit 1
fi
find "$1" -name \*.diff | while read f; do
    OUTPUT=$(patch -s -p1 -r- -i"$f")
    if [ $? -eq 0 ]; then
        rm "$f"
    else
        if echo "$OUTPUT" | grep -q "Reversed (or previously applied) patch detected!"; then
            rm "$f"
        fi
    fi
done
ตัวอย่างการใช้งาน:
$ cd directory_containing_code
$ apply_patches.bash directory_containing_patch/foo
การดำเนินการนี้จะลบแพทช์ใด ๆ ที่สร้างขึ้นก่อนหน้านี้ซึ่งใช้อย่างหมดจดหรือถูกใช้ไปแล้ว แพทช์ใด ๆ ที่เหลืออยู่fooจะถูกปฏิเสธที่จะต้องทำการตรวจสอบและผสานด้วยตนเอง