Split DiffChunkGenerator into a general-purpose RawDiffChunkGenerator.

Review Request #7093 — Created March 19, 2015 and submitted

Information

Review Board
release-2.5.x
3b0ad74...

Reviewers

DiffChunkGenerator is a very useful and powerful class for producing a
set of chunks we can directly use for rendering diffs. To use it, it
required the whole diff machinery: FileDiff models, DiffSet,
repositories, the patching process, etc. That made it impractical for
any usage beyond showing diffs of files in a repository.

This change splits the heavy processing out into a RawDiffChunkGenerator
class, which can be used to generate chunks from any two strings.

DiffChunkGenerator subclasses RawDiffChunkGenerator, doing all the work
of handling interdiffs and generating suitable content from FileDiffs to
pass down to the RawDiffChunkGenerator functions.

Along with this, DiffOpcodeGenerator no longer needs FileDiffs as well.
It only ever needed the diff content stored on them, for interdiff
processing, so we just pass that directly in DiffChunkGenerator.

Browsed diffs and interdiffs, comparing them to versions without the path.
This covered all types of changes, including indentation. I didn't see any
differences in behavior.

Tested with raw strings, and got chunks out of them.

Unit tests pass.

Description From Last Updated

Col: 1 E303 too many blank lines (3)

reviewbotreviewbot

'os' imported but unused

reviewbotreviewbot

"Generate"

brenniebrennie

I know this isn't in the change, but aren't there also "replace" chunks?

brenniebrennie

You should use encoding_list=None and assign encoding_list to [] if it is None in the function.

brenniebrennie

"Generate"

brenniebrennie

Again, replace sections?

brenniebrennie

"Create"

brenniebrennie

Should be "Return".

brenniebrennie

Line needs b''

brenniebrennie

Blank line between these.

brenniebrennie
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/diffviewer/opcode_generator.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/chunk_generator.py
        reviewboard/diffviewer/diffutils.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/diffviewer/opcode_generator.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/chunk_generator.py
        reviewboard/diffviewer/diffutils.py
    
    
  2. Col: 1
     E303 too many blank lines (3)
    
  3. reviewboard/diffviewer/tests.py (Diff revision 1)
     
     
     'os' imported but unused
    
  4. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/diffviewer/opcode_generator.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/chunk_generator.py
        reviewboard/diffviewer/diffutils.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/diffviewer/opcode_generator.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/chunk_generator.py
        reviewboard/diffviewer/diffutils.py
    
    
  2. 
      
brennie
  1. 
      
  2. "Generate"

    1. IIRC, we only use that mood for functions, not classes. I'm not sure where it even says anything about this in the PEP though. Should get David's opinion.

  3. reviewboard/diffviewer/chunk_generator.py (Diff revision 2)
     
     
     

    I know this isn't in the change, but aren't there also "replace" chunks?

  4. You should use encoding_list=None and assign encoding_list to [] if it is None in the function.

  5. "Generate"

  6. Again, replace sections?

  7. Should be "Return".

  8. reviewboard/diffviewer/tests.py (Diff revision 2)
     
     

    Line needs b''

  9. reviewboard/diffviewer/tests.py (Diff revision 2)
     
     
     

    Blank line between these.

  10. 
      
chipx86
reviewbot
  1. Tool: Pyflakes
    Processed Files:
        reviewboard/diffviewer/opcode_generator.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/chunk_generator.py
        reviewboard/diffviewer/diffutils.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        reviewboard/diffviewer/opcode_generator.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/chunk_generator.py
        reviewboard/diffviewer/diffutils.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.5.x (c246d7a)
Loading...