diff options
| author | Petr Vorel <petr.vorel@gmail.com> | 2019-06-04 17:56:39 +0200 |
|---|---|---|
| committer | Stephen Finucane <stephen@that.guru> | 2019-06-04 17:19:58 +0100 |
| commit | ecbe3fc5f1c91cfa19dab77d527897e2122f5096 (patch) | |
| tree | 8e53961f88761be6e2f1e59f1752d475ceb6d20c | |
| parent | fc1d7505991474b07638a87c0834157d12e1e476 (diff) | |
| download | patchwork-ecbe3fc5f1c91cfa19dab77d527897e2122f5096.tar patchwork-ecbe3fc5f1c91cfa19dab77d527897e2122f5096.tar.gz | |
parser: Remove duplicity
commit fc1d750 copied lines added in 753e457.
Make sense to define it on single place (DRY).
Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
| -rw-r--r-- | patchwork/parser.py | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/patchwork/parser.py b/patchwork/parser.py index 7d7b571..7dc66bc 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -37,6 +37,15 @@ list_id_headers = ['List-ID', 'X-Mailing-List', 'X-list'] SERIES_DELAY_INTERVAL = 10 +# @see https://git-scm.com/docs/git-diff#_generating_patches_with_p +EXTENDED_HEADER_LINES = ( + 'old mode ', 'new mode ', + 'deleted file mode ', 'new file mode ', + 'copy from ', 'copy to ', + 'rename from ', 'rename to ', + 'similarity index ', 'dissimilarity index ', + 'new file mode ', 'index ') + logger = logging.getLogger(__name__) @@ -780,17 +789,7 @@ def parse_patch(content): buf += line if line.startswith('--- '): state = 2 - - # extended header lines - # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p - if line.startswith(('old mode ', 'new mode ', - 'deleted file mode ', - 'new file mode ', - 'copy from ', 'copy to ', - 'rename from ', 'rename to ', - 'similarity index ', - 'dissimilarity index ', - 'new file mode ', 'index ')): + if line.startswith(EXTENDED_HEADER_LINES): state = 6 elif state == 2: if line.startswith('+++ '): @@ -851,16 +850,7 @@ def parse_patch(content): else: state = 5 elif state == 6: - # extended header lines - # @see https://git-scm.com/docs/git-diff#_generating_patches_with_p - if line.startswith(('old mode ', 'new mode ', - 'deleted file mode ', - 'new file mode ', - 'copy from ', 'copy to ', - 'rename from ', 'rename to ', - 'similarity index ', - 'dissimilarity index ', - 'new file mode ', 'index ')): + if line.startswith(EXTENDED_HEADER_LINES): patchbuf += buf + line buf = '' elif line.startswith('--- '): |