Fix git parser assuming header presence and order.

Review Request #7263 — Created April 29, 2015 and submitted

smacleod
Review Board
release-2.0.x
7264
0bcd91a...
reviewboard
chipx86
The git diff format does not specify the order of extended headers or
that certain headers must appear with others. We were assuming some
ordering and header dependencies that while true in the git case are
not true for git diffs generated by mercurial.

We now parse all of the headers at once ignoring order and then act on
them after the header parsing is complete. The GitDiffParser should
now properly parse a mercurial generated git diff.

Unit tests pass, hg git diff parses.

Description From Last Updated

Assuming these aren't constants, they should be defined in __init__.

chipx86chipx86

]) on the next line, and trailing comma on the string, so it's easier to extend down the road.

chipx86chipx86

Let's pull self.lines[linenum] out into a local line variable, to avoid repeated lookups.

chipx86chipx86

Col: 9 E303 too many blank lines (2)

reviewbotreviewbot
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/diffviewer/parser.py
        reviewboard/scmtools/git.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/diffviewer/parser.py
        reviewboard/scmtools/git.py
    
    
  2. reviewboard/scmtools/git.py (Diff revision 1)
     
     
    Col: 9
     E303 too many blank lines (2)
    
  3. 
      
brennie
  1. This looks great! I'm happy once Review Bot is happy.

  2. 
      
chipx86
  1. 
      
  2. reviewboard/diffviewer/parser.py (Diff revision 1)
     
     
     

    Assuming these aren't constants, they should be defined in __init__.

  3. reviewboard/scmtools/git.py (Diff revision 1)
     
     

    ]) on the next line, and trailing comma on the string, so it's easier to extend down the road.

  4. reviewboard/scmtools/git.py (Diff revision 1)
     
     
     
     

    Let's pull self.lines[linenum] out into a local line variable, to avoid repeated lookups.

  5. 
      
SM
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/diffviewer/parser.py
        reviewboard/scmtools/git.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/diffviewer/parser.py
        reviewboard/scmtools/git.py
    
    
  2. 
      
chipx86
  1. Ship It!
  2. 
      
SM
reviewbot
  1. Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/diffviewer/parser.py
        reviewboard/scmtools/git.py
    
    
    
    Tool: Pyflakes
    Processed Files:
        reviewboard/diffviewer/parser.py
        reviewboard/scmtools/git.py
    
    
  2. 
      
SM
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.0.x (fe4f5ac)
Loading...