From fce29b88da2207f2fba6c3aff3961d40f3f47122 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sun, 13 Jul 2014 04:46:11 +0200 Subject: [PATCH] Improve patchupdate.py to detect changes even when regular diff files without git header are used. --- debian/tools/patchupdate.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/debian/tools/patchupdate.py b/debian/tools/patchupdate.py index ec0f4961..7517a262 100755 --- a/debian/tools/patchupdate.py +++ b/debian/tools/patchupdate.py @@ -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()