Message ID | 20190604155639.10934-1-petr.vorel@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1] parser: Remove duplicity | expand |
On Tue, 2019-06-04 at 17:56 +0200, Petr Vorel wrote: > commit fc1d750 copied lines added in 753e457. > Make sense to define it on single place (DRY). I thought about doing this and just didn't. Now that two people have had the idea though, let's do it. Applied. Thanks! :) Stephen > > Signed-off-by: Petr Vorel <petr.vorel@gmail.com> > --- > patchwork/parser.py | 33 ++++++++++++--------------------- > 1 file changed, 12 insertions(+), 21 deletions(-) > > diff --git a/patchwork/parser.py b/patchwork/parser.py > index 7d7b571..2cd7f6f 100644 > --- a/patchwork/parser.py > +++ b/patchwork/parser.py > @@ -37,6 +37,16 @@ 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 +790,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 +851,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('--- '):
Hi Stephen, > I thought about doing this and just didn't. Now that two people have > had the idea though, let's do it. Applied. Unfortunately I introduced "E128 continuation line under-indented for visual indent" PEP8 failure for python 2.7 [1]. I'm running this fix, I'll send it once it's proved it works. I'm sorry, I'll be careful to finish travis builds before sending a patch. Kind regards, Petr [1] https://travis-ci.org/pevik/patchwork/jobs/541312338 [2] https://travis-ci.org/pevik/patchwork/builds/541323511
On Tue, 2019-06-04 at 18:23 +0200, Petr Vorel wrote: > Hi Stephen, > > > I thought about doing this and just didn't. Now that two people have > > had the idea though, let's do it. Applied. > Unfortunately I introduced "E128 continuation line under-indented for visual > indent" PEP8 failure for python 2.7 [1]. I'm running this fix, I'll send it once > it's proved it works. > > I'm sorry, I'll be careful to finish travis builds before sending a patch. It's all good - I broke the rules slightly and just force pushed a fix to that rule. I should have checked it myself, tbh, but rushed things slightly. Should be good now though. Stephen > > Kind regards, > Petr > > [1] https://travis-ci.org/pevik/patchwork/jobs/541312338 > [2] https://travis-ci.org/pevik/patchwork/builds/541323511
Hi Stephen, > > > I thought about doing this and just didn't. Now that two people have > > > had the idea though, let's do it. Applied. > > Unfortunately I introduced "E128 continuation line under-indented for visual > > indent" PEP8 failure for python 2.7 [1]. I'm running this fix, I'll send it once > > it's proved it works. > > I'm sorry, I'll be careful to finish travis builds before sending a patch. > It's all good - I broke the rules slightly and just force pushed a fix > to that rule. I should have checked it myself, tbh, but rushed things > slightly. Should be good now though. Thanks a lot for a fix (master passed :)). Kind regards, Petr
diff --git a/patchwork/parser.py b/patchwork/parser.py index 7d7b571..2cd7f6f 100644 --- a/patchwork/parser.py +++ b/patchwork/parser.py @@ -37,6 +37,16 @@ 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 +790,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 +851,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('--- '):
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> --- patchwork/parser.py | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-)