Refactor our per-file diff rendering code into a DiffRenderer class.
Review Request #4161 — Created May 23, 2013 and submitted — Latest diff uploaded
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.