Side by Side Diff

Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(365)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Side by Side Diff: codereview/engine.py

Issue 7888: Adding variable column width setting Base URL: http://rietveld.googlecode.com/svn/trunk/
Patch Set: Created 17 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | codereview/models.py » ('j') | codereview/views.py » ('J')
('i') | ('e') | ('c') | ('s')
OLDNEW
1 # Copyright 2008 Google Inc. 1 # Copyright 2008 Google Inc.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 162 matching lines...) | | Loading...
173 url = base 173 url = base
174 if not url.endswith('/'): 174 if not url.endswith('/'):
175 url += '/' 175 url += '/'
176 url += filename 176 url += filename
177 if rev is not None: 177 if rev is not None:
178 url += '?rev=%s' % rev 178 url += '?rev=%s' % rev
179 return url 179 return url
180 180
181 181
182 DEFAULT_CONTEXT = 10 182 DEFAULT_CONTEXT = 10
183 183 DEFAULT_COLUMN_WIDTH = 80
184 184
185 def RenderDiffTableRows(request, old_lines, chunks, patch, 185 def RenderDiffTableRows(request, old_lines, chunks, patch,
186 colwidth=80, debug=False, context=DEFAULT_CONTEXT): 186 colwidth=DEFAULT_COLUMN_WIDTH, debug=False, context=DEFA ULT_CONTEXT):
Andi Albrecht 2008年11月04日 14:11:29 Line too long and missing blank line above "def Re
Line too long and missing blank line above "def RenderDiffTableRows..."
187 """Render the HTML table rows for a side-by-side diff for a patch. 187 """Render the HTML table rows for a side-by-side diff for a patch.
188 188
189 Args: 189 Args:
190 request: Django Request object. 190 request: Django Request object.
191 old_lines: List of lines representing the original file. 191 old_lines: List of lines representing the original file.
192 chunks: List of chunks as returned by patching.ParsePatchToChunks(). 192 chunks: List of chunks as returned by patching.ParsePatchToChunks().
193 patch: A models.Patch instance. 193 patch: A models.Patch instance.
194 colwidth: Optional column width (default 80). 194 colwidth: Optional column width (default 80).
195 debug: Optional debugging flag (default False). 195 debug: Optional debugging flag (default False).
196 context: Maximum number of rows surrounding a change (default CONTEXT). 196 context: Maximum number of rows surrounding a change (default CONTEXT).
197 197
198 Yields: 198 Yields:
199 Strings, each of which represents the text rendering one complete 199 Strings, each of which represents the text rendering one complete
200 pair of lines of the side-by-side diff, possibly including comments. 200 pair of lines of the side-by-side diff, possibly including comments.
201 Each yielded string may consist of several <tr> elements. 201 Each yielded string may consist of several <tr> elements.
202 """ 202 """
203 rows = _RenderDiffTableRows(request, old_lines, chunks, patch, 203 rows = _RenderDiffTableRows(request, old_lines, chunks, patch,
204 colwidth, debug) 204 colwidth, debug)
205 return _CleanupTableRowsGenerator(rows, context) 205 return _CleanupTableRowsGenerator(rows, context)
206 206
207 207
208 def RenderDiff2TableRows(request, old_lines, old_patch, new_lines, new_patch, 208 def RenderDiff2TableRows(request, old_lines, old_patch, new_lines, new_patch,
209 colwidth=80, debug=False, context=DEFAULT_CONTEXT): 209 colwidth=DEFAULT_COLUMN_WIDTH, debug=False, context=DEF AULT_CONTEXT):
210 """Render the HTML table rows for a side-by-side diff between two patches. 210 """Render the HTML table rows for a side-by-side diff between two patches.
211 211
212 Args: 212 Args:
213 request: Django Request object. 213 request: Django Request object.
214 old_lines: List of lines representing the patched file on the left. 214 old_lines: List of lines representing the patched file on the left.
215 old_patch: The models.Patch instance corresponding to old_lines. 215 old_patch: The models.Patch instance corresponding to old_lines.
216 new_lines: List of lines representing the patched file on the right. 216 new_lines: List of lines representing the patched file on the right.
217 new_patch: The models.Patch instance corresponding to new_lines. 217 new_patch: The models.Patch instance corresponding to new_lines.
218 colwidth: Optional column width (default 80). 218 colwidth: Optional column width (default 80).
219 debug: Optional debugging flag (default False). 219 debug: Optional debugging flag (default False).
(...skipping 77 matching lines...) | | Loading...
297 'style="background:lightblue">' 297 'style="background:lightblue">'
298 '(...skipping <span id="skipcount-%d">%d</span> matching lines...) ' 298 '(...skipping <span id="skipcount-%d">%d</span> matching lines...) '
299 '<span id="skiplinks-%d">%s</span>' 299 '<span id="skiplinks-%d">%s</span>'
300 '</td></tr>\n' % (last_id, last_id, skip, 300 '</td></tr>\n' % (last_id, last_id, skip,
301 last_id, expand_link)) 301 last_id, expand_link))
302 for t in buffer[-context:]: 302 for t in buffer[-context:]:
303 yield t 303 yield t
304 304
305 305
306 def _RenderDiff2TableRows(request, old_lines, old_patch, new_lines, new_patch, 306 def _RenderDiff2TableRows(request, old_lines, old_patch, new_lines, new_patch,
307 colwidth=80, debug=False): 307 colwidth=DEFAULT_COLUMN_WIDTH, debug=False):
308 """Internal version of RenderDiff2TableRows(). 308 """Internal version of RenderDiff2TableRows().
309 309
310 Args: 310 Args:
311 The same as for RenderDiff2TableRows. 311 The same as for RenderDiff2TableRows.
312 312
313 Yields: 313 Yields:
314 Tuples (tag, row) where tag is an indication of the row type. 314 Tuples (tag, row) where tag is an indication of the row type.
315 """ 315 """
316 old_dict = {} 316 old_dict = {}
317 new_dict = {} 317 new_dict = {}
(...skipping 51 matching lines...) | | Loading...
369 comment.complete(request.patch) 369 comment.complete(request.patch)
370 if comment.left: 370 if comment.left:
371 dct = old_dict 371 dct = old_dict
372 else: 372 else:
373 dct = new_dict 373 dct = new_dict
374 dct.setdefault(comment.lineno, []).append(comment) 374 dct.setdefault(comment.lineno, []).append(comment)
375 return old_dict, new_dict 375 return old_dict, new_dict
376 376
377 377
378 def _RenderDiffTableRows(request, old_lines, chunks, patch, 378 def _RenderDiffTableRows(request, old_lines, chunks, patch,
379 colwidth=80, debug=False): 379 colwidth=DEFAULT_COLUMN_WIDTH, debug=False):
380 """Internal version of RenderDiffTableRows(). 380 """Internal version of RenderDiffTableRows().
381 381
382 Args: 382 Args:
383 The same as for RenderDiffTableRows. 383 The same as for RenderDiffTableRows.
384 384
385 Yields: 385 Yields:
386 Tuples (tag, row) where tag is an indication of the row type. 386 Tuples (tag, row) where tag is an indication of the row type.
387 """ 387 """
388 old_dict = {} 388 old_dict = {}
389 new_dict = {} 389 new_dict = {}
390 if patch: 390 if patch:
391 old_dict, new_dict = _GetComments(request) 391 old_dict, new_dict = _GetComments(request)
392 old_max, new_max = _ComputeLineCounts(old_lines, chunks) 392 old_max, new_max = _ComputeLineCounts(old_lines, chunks)
393 return _TableRowGenerator(patch, old_dict, old_max, 'old', 393 return _TableRowGenerator(patch, old_dict, old_max, 'old',
394 patch, new_dict, new_max, 'new', 394 patch, new_dict, new_max, 'new',
395 patching.PatchChunks(old_lines, chunks), 395 patching.PatchChunks(old_lines, chunks),
396 colwidth, debug) 396 colwidth, debug)
397 397
398 398
399 def _TableRowGenerator(old_patch, old_dict, old_max, old_snapshot, 399 def _TableRowGenerator(old_patch, old_dict, old_max, old_snapshot,
400 new_patch, new_dict, new_max, new_snapshot, 400 new_patch, new_dict, new_max, new_snapshot,
401 triple_iterator, colwidth=80, debug=False): 401 triple_iterator, colwidth=DEFAULT_COLUMN_WIDTH, debug=Fal se):
402 """Helper function to render side-by-side table rows. 402 """Helper function to render side-by-side table rows.
403 403
404 Args: 404 Args:
405 old_patch: First models.Patch instance. 405 old_patch: First models.Patch instance.
406 old_dict: Dictionary with line numbers as keys and comments as values (left) 406 old_dict: Dictionary with line numbers as keys and comments as values (left)
407 old_max: Line count of the patch on the left. 407 old_max: Line count of the patch on the left.
408 old_snapshot: A tag used in the comments form. 408 old_snapshot: A tag used in the comments form.
409 new_patch: Second models.Patch instance. 409 new_patch: Second models.Patch instance.
410 new_dict: Same as old_dict, but for the right side. 410 new_dict: Same as old_dict, but for the right side.
411 new_max: Line count of the patch on the right. 411 new_max: Line count of the patch on the right.
(...skipping 383 matching lines...) | | Loading...
795 Args: 795 Args:
796 text: a string. 796 text: a string.
797 797
798 Returns: 798 Returns:
799 A db.Text instance. 799 A db.Text instance.
800 """ 800 """
801 try: 801 try:
802 return db.Text(text, encoding='utf-8') 802 return db.Text(text, encoding='utf-8')
803 except UnicodeDecodeError: 803 except UnicodeDecodeError:
804 return db.Text(text, encoding='latin-1') 804 return db.Text(text, encoding='latin-1')
OLDNEW
« no previous file with comments | « no previous file | codereview/models.py » ('j') | codereview/views.py » ('J')
Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /