diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-10-13 13:40:00 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-10-13 13:42:37 +0800 |
commit | 3dbec78dbd8e80729cf208d1e68f550b7d7ba5a9 (patch) | |
tree | 70319dbb066258f887d9b628aa0e7ad7020964a9 /apps/patchwork/parser.py | |
parent | 9d22330effa8d433ec39edc37ca4e3a1e3206b85 (diff) | |
download | patchwork-3dbec78dbd8e80729cf208d1e68f550b7d7ba5a9.tar.bz2 patchwork-3dbec78dbd8e80729cf208d1e68f550b7d7ba5a9.tar.xz |
parser: Add support for rename-only patches
Yann E. MORIN reported a problem where patchwork drops patches with only
renames:
http://lists.busybox.net/pipermail/buildroot/2013-October/079999.html
This change fixes the issue by adding a new state for patch 'meta'
headers: header test which is not parsed as a hunk, but has the same
behaviour as a hunk in that it will cause the patchbuf to be populated.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/parser.py')
-rw-r--r-- | apps/patchwork/parser.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/apps/patchwork/parser.py b/apps/patchwork/parser.py index f460566..8295980 100644 --- a/apps/patchwork/parser.py +++ b/apps/patchwork/parser.py @@ -45,6 +45,7 @@ def parse_patch(text): # 3: patch header line 2 (+++) # 4: patch hunk header line (@@ line) # 5: patch hunk content + # 6: patch meta header (rename from/rename to) # # valid transitions: # 0 -> 1 (diff, ===, Index:) @@ -54,6 +55,9 @@ def parse_patch(text): # 3 -> 4 (@@ line) # 4 -> 5 (patch content) # 5 -> 1 (run out of lines from @@-specifed count) + # 1 -> 6 (rename from / rename to) + # 6 -> 2 (---) + # 6 -> 1 (other text) # # Suspected patch header is stored into buf, and appended to # patchbuf if we find a following hunk. Otherwise, append to @@ -85,6 +89,9 @@ def parse_patch(text): if line.startswith('--- '): state = 2 + if line.startswith('rename from ') or line.startswith('rename to '): + state = 6 + elif state == 2: if line.startswith('+++ '): state = 3 @@ -148,6 +155,20 @@ def parse_patch(text): else: state = 5 + elif state == 6: + if line.startswith('rename to ') or line.startswith('rename from '): + patchbuf += buf + line + buf = '' + + elif line.startswith('--- '): + patchbuf += buf + line + buf = '' + state = 2 + + else: + buf += line + state = 1 + else: raise Exception("Unknown state %d! (line '%s')" % (state, line)) |