Improve patchupdate.py to detect changes even when regular diff files without git header are used.

This commit is contained in:
Sebastian Lackner 2014-07-13 04:46:11 +02:00
parent f6dd1f3d0d
commit fce29b88da

View File

@ -42,6 +42,24 @@ def causal_time_smaller(a, b):
def causal_time_relation(a, b):
return causal_time_smaller(a, b) or causal_time_smaller(b, a)
def lsdiff(f):
files = set()
with open(f) as fp:
for line in fp:
if line.startswith("diff --git "):
tmp = line.strip().split(" ")
if len(tmp) == 4 and tmp[3].startswith("b/"):
files.add(tmp[3][2:])
else:
print "** Unable to parse patch git header in %s: %s" % (f, line)
exit(1)
elif line.startswith("+++ b/"):
files.add(line[6:].strip())
elif line.startswith("+++ "):
print "** Unable to parse patch header in %s: %s" % (f, line)
exit(1)
return files
def verify_dependencies(all_patches):
max_patches = max(all_patches.keys()) + 1
@ -87,16 +105,6 @@ def verify_dependencies(all_patches):
print "** Both patches modify the same file %s" % f
exit(1)
def lsdiff(f):
with open(f) as fp:
for line in fp:
if line.startswith("diff --git "):
tmp = line.strip().split(" ")
if len(tmp) == 4 and tmp[3].startswith("b/"):
yield tmp[3][2:]
else:
print "** Unable to parse patch git header in %s: %s" % (f, line)
def download(url):
with contextlib.closing(urllib.urlopen(url)) as fp:
return fp.read()