Refactor our per-file diff rendering code into a DiffRenderer class.

Review Request #4161 — Created May 23, 2013 and submitted

Information

Review Board
release-1.7.x

Reviewers

Refactor our per-file diff rendering code into a DiffRenderer class.

DiffRenderer is responsible for taking the output of get_diff_files, and
some configuration (highlighting, collapse state, etc.) and rendering
diff output. It separates out the various responsibilities of the old
function, such as computing the cache key and rendering to strings and
HttpResponses.

There's one DiffRenderer per thing to render. It's created, used, and
thrown away.

A DiffRenderer is accessed by get_diff_renderer or
get_diff_renderer_class, rather than relying on using DiffRenderer
directly, allowing for some extensibility.

The new tests rely on kgb for function spies.
Unit tests pass.

Tested various diffs.

Tested expanding and collapsing whole chunks, entire files, to headers, and lines at a time.

Tested diff fragments in comments.
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/diffviewer/views.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/diffutils.py
      Ignored Files:
        docs/codebase/getting-started.txt
    
    
  2. 
      
david
  1. Did you forget to add diffviewer/renderers.py ?
  2. 
      
chipx86
reviewbot
  1. This is a review from Review Bot.
      Tool: PEP8 Style Checker
      Processed Files:
        reviewboard/diffviewer/views.py
        reviewboard/diffviewer/renderers.py
        reviewboard/diffviewer/errors.py
        reviewboard/diffviewer/tests.py
        reviewboard/diffviewer/diffutils.py
      Ignored Files:
        docs/codebase/getting-started.txt
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-1.7.x (79b3b2c)