Add DiffCommit model for review requests with commit histories.
Review Request #6815 — Created Jan. 20, 2015 and submitted
The
DiffSetmodel has been updated to be able to contain several
DiffCommitsin addition toFileDiffs. TheDiffCommitmodel
represents a single commit in distributed version control system
(DVCS). EachDiffCommithas one or moreFileDiffsthat belong to
it (as well as theDiffSet).Add an evolution to add a foreign key on the
FileDiffmodel to point
to an optionalDiffCommitmodel. Also add an evolution to add a
RelationCounterFieldto theDiffSetmodel that counts the number
ofDiffCommitsit currently has.Update the
reviewboard.diffviewer.adminmodule to add the ability to
view individualDiffCommits. TheDiffCommitscan be as inline
models of theDiffSetmodel and haveFileDiffas an inline model.Add unit tests for creating empty
DiffSetsas well as creating
DiffCommitsfrom.difffiles and uploading via the
UploadDiffCommitform.Updated the
ValidateDiffResourcewith respect to the new refactoring
of theDiffSetManager.
Unit tests pass.
Applied evolution successfully.
| Description | From | Last Updated |
|---|---|---|
|
Can you add a docstring to this? |
|
|
|
User-visible strings typically use double quotes, so the original version of this is preferred. We also try to avoid changing … |
|
|
|
The labels in these forms have inconsistent casing. For example, "Parent Diff" vs. "Commit type" below. This is not a … |
|
|
|
This can probably be removed, I think? Looks like the argument defaults and order are all the same as the … |
|
|
|
While ''' technically works, docstrings traditionally always use """. |
|
|
|
"Parent commit ID" might be a bit more consistent here. |
|
|
|
Can you go into some detail on what this is checking? |
|
|
|
id is a reserved keyword in Python, so we should call this something different. merge_parent_id probably. |
|
|
|
Should use _(...) |
|
|
|
ValidationError can take lists of errors and display them appropriately, so you can pass errors directly to it. |
|
|
|
clean_* functions are expected to return the result. Django will handle updating cleaned_data. |
|
|
|
Should this be "DiffSetManager"? |
|
|
|
Instead of referencing the parameter, how about "Creates a list of FileDiffs for a list of files."? |
|
|
|
When this gets turned into documentation via Sphinx down the road, it's probably going to appear as a paragraph with … |
|
|
|
The "F" in "parent_diff_File_contents" should be lowercase. |
|
|
|
If save is False, we'll never actually save any of the merge parents, since they're not returned anywhere. Is this … |
|
|
|
We can reduce database overhead by using bulk_create. The code will be similar, but you'd create a local instance of … |
|
|
|
Does this not fit on one line? |
|
|
|
No blank line needed here. |
|
|
|
This looks like a constant, but it's really a function. Checking with how Django uses these, I think this should … |
|
|
|
Should wrap in _(...) |
|
|
|
Blank line between these. |
|
|
|
Private functions should go after the public ones. |
|
|
|
Attributes should go before properties/functions. Same with ones below. |
|
|
|
Can we add the comment here about the conversion to UTC as well? |
|
|
|
Can you add a docstring for this class? |
|
|
|
This is really an API detail. I think it should be limited to the resources, rather than having the support … |
|
|
|
Should also go after all public functions. |
|
|
|
The nose import is old, but both of these should go before the froms, in alphabetical order. |
|
|
|
'MergeParent' imported but unused |
|
|
|
This can easily fit on one line. |
|
|
|
from reviewboard.diffviewer.models import (DiffCommit, DiffSet, DiffSetHistory, FileDiff) |
SM smacleod | |
|
This isn't long enough, author will most likely be of the form Firstname LastName <email> and emails can be like … |
SM smacleod | |
|
Length, same as above. |
SM smacleod | |
|
Label and help text need to be updated. |
SM smacleod | |
|
It's not obvious to me why this is a good place to find permissions errors? In fact it seems like … |
SM smacleod | |
|
Too short |
SM smacleod | |
|
This should go before the from statements. |
|
|
|
Col: 1 W391 blank line at end of file |
|
|
|
'ValidationError' imported but unused |
|
|
|
The raise is over-indented. Missing a %s. |
|
|
|
Maybe put the comment before the assert. |
|
|
|
We should have a docstring on this describing its purpose. |
|
|
|
Over-indentation problems. |
|
|
|
"Testing", and no trailing period. |
|
|
|
Too many blank lines. |
|
|
|
"Testing", and no trailing period. |
|
|
|
If we're just grabbing the commit_id from each of these, you can probably do: commit.merge_parent_ids.values_list('commit_id', flat=True) |
|
|
|
'os' imported but unused |
|
- People:
-
Some new code, so some new comments. Sorry! :) Looking great, though.
-
-
User-visible strings typically use double quotes, so the original version of this is preferred. We also try to avoid changing localized strings unless we really need to, to help keep translators from wanting to kill us in our sleep.
-
The labels in these forms have inconsistent casing. For example, "Parent Diff" vs. "Commit type" below. This is not a new problem, but one we should address here.
Looking at other forms, it seems we're more standardized now on sentence casing (e.g., "Parent diff"), so I'd update all the field labels for that.
-
This can probably be removed, I think? Looks like the argument defaults and order are all the same as the parent's, so we'll fall back on that.
-
-
-
-
idis a reserved keyword in Python, so we should call this something different.merge_parent_idprobably. -
-
ValidationErrorcan take lists of errors and display them appropriately, so you can passerrorsdirectly to it. -
-
-
-
When this gets turned into documentation via Sphinx down the road, it's probably going to appear as a paragraph with lots of dashes inbetween the key names. For that, you'll need to use a ReST-style list, like:
When calling blah blah: * basedir * diffset_history * base_commit_id -
-
We can reduce database overhead by using
bulk_create. The code will be similar, but you'd create a local instance ofMergeParent(no.objects.create()), put those into a list, and then create them in one go afterward usingMergeParent.objects.bulk_create(merge_parents) -
-
This looks like a constant, but it's really a function. Checking with how Django uses these, I think this should be called
validate_commit_id.Hmm, I also wonder if this should just go in a validators.py, so it's a bit more reusable without needing to reference
DiffCommit. What do you think? -
-
- Change Summary:
-
Fix issues.
- Commit:
-
0c5cb14621b2bb291857d4a61fb45a93b2e8de44aebd320826947a5c0d7489274e420e334ab31a23
- Diff:
-
Revision 2 (+612 -112)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
-
At about the 75% through this review my brain was just shutting it down. I gave it my best shot but I should probably look over everything again at some point.
-
-
This isn't long enough, author will most likely be of the form
Firstname LastName <email>and emails can be like 254 characters alone. -
-
-
It's not obvious to me why this is a good place to find permissions errors? In fact it seems like a really strange place?
What am I missing?
-
Aside: I know we do this all over the code base, but reading PEP8 today, this is actually frowned upon (including more than one import on the same line like that)
-
- Change Summary:
-
Remove some stuff that shouldn't have been in the diff.
- Diff:
-
Revision 3 (+601 -158)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
- Change Summary:
-
Fix Steven's issues. Split out author/committer fields into name and email fields
- Diff:
-
Revision 4 (+645 -158)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
- Change Summary:
-
DiffCommitForm->UploadDiffCommitFormAdd
author_dateandcommitter_datefields which are backed by_utcand_offsetfields that store the time in UTC and the original UTC offset, respectively.Add
UploadDiffCommitFormTeststests. - Description:
-
The
DiffSetmodel has been updated to be able to contain severalDiffCommitsin addition toFileDiffs. TheDiffCommitmodelrepresents a single commit in distributed version control system (DVCS). Each DiffCommithas one or moreFileDiffsthat belong toit (as well as the DiffSet).Add an evolution to add a foreign key on the
FileDiffmodel to pointto an optional DiffCommitmodel. Also add an evolution to add aRelationCounterFieldto theDiffSetmodel that counts the numberof DiffCommitsit currently has.Update the
reviewboard.diffviewer.adminmodule to add the ability toview individual DiffCommits. TheDiffCommitscan be as inlinemodels of the DiffSetmodel and haveFileDiffas an inline model.Add unit tests for creating empty
DiffSetsas well as creating~ DiffCommitsfrom.difffiles.~ DiffCommitsfrom.difffiles and uploading via the+ UploadDiffCommitform. - Diff:
-
Revision 6 (+826 -157)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
- Change Summary:
-
Use
mergeandchangein lieu ofMandCoutside of the model. - Diff:
-
Revision 7 (+825 -157)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
-
-
If
saveisFalse, we'll never actually save any of the merge parents, since they're not returned anywhere. Is this okay? If so, we should be sure to document it in the docstring. -
-
-
-
-
-
This is really an API detail. I think it should be limited to the resources, rather than having the support here and in the form. Internally, everything else should be solely using the constants.
-
-
-
-
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py -
-
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
- Change Summary:
-
If the
committer_date_utcfield is set toNone, also set thecommitter_date_offsetfield toNonefor consistency. - Diff:
-
Revision 11 (+844 -160)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
- Change Summary:
-
Rebased on top of latest master. Address Christian's issues.
- Description:
-
The
DiffSetmodel has been updated to be able to contain severalDiffCommitsin addition toFileDiffs. TheDiffCommitmodelrepresents a single commit in distributed version control system (DVCS). Each DiffCommithas one or moreFileDiffsthat belong toit (as well as the DiffSet).Add an evolution to add a foreign key on the
FileDiffmodel to pointto an optional DiffCommitmodel. Also add an evolution to add aRelationCounterFieldto theDiffSetmodel that counts the numberof DiffCommitsit currently has.Update the
reviewboard.diffviewer.adminmodule to add the ability toview individual DiffCommits. TheDiffCommitscan be as inlinemodels of the DiffSetmodel and haveFileDiffas an inline model.Add unit tests for creating empty
DiffSetsas well as creatingDiffCommitsfrom.difffiles and uploading via theUploadDiffCommitform.+ + Updated the
ValidateDiffResourcewith respect to the new refactoring+ of the DiffSetManager. - Diff:
-
Revision 13 (+844 -162)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/webapi/resources/validate_diff.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/webapi/resources/validate_diff.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py -
- Change Summary:
-
Fixed PEP8
- Diff:
-
Revision 14 (+844 -163)
-
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/webapi/resources/validate_diff.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/webapi/resources/validate_diff.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py
Tool: Pyflakes Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py Tool: PEP8 Style Checker Processed Files: reviewboard/diffviewer/admin.py reviewboard/diffviewer/models.py reviewboard/diffviewer/tests.py reviewboard/diffviewer/evolutions/__init__.py reviewboard/diffviewer/forms.py reviewboard/diffviewer/evolutions/add_commit_history_fields.py reviewboard/diffviewer/managers.py