Jump to >

reviewboard.diffviewer.models.diffset

DiffSet model definiton.

class DiffSet(*args, **kwargs)[source]

A revisioned collection of FileDiffs.

property is_commit_series_finalized[source]

Whether the commit series represented by this DiffSet is finalized.

When a commit series is finalized, no more DiffCommits can be added to it.

finalize_commit_series(cumulative_diff, validation_info, parent_diff=None, request=None, validate=True, save=False)[source]

Finalize the commit series represented by this DiffSet.

Parameters
  • cumulative_diff (bytes) – The cumulative diff of the entire commit series.

  • validation_info (dict) – The parsed validation information.

  • parent_diff (bytes, optional) – The parent diff of the cumulative diff, if any.

  • request (django.http.HttpRequest, optional) – The HTTP request from the client, if any.

  • validate (bool, optional) – Whether or not the cumulative diff (and optional parent diff) should be validated, up to and including file existence checks.

  • save (bool, optional) –

    Whether to save the model after finalization. Defaults to False.

    If True, only the extra_data field will be updated.

    If False, the caller must save this model.

Returns

The list of created FileDiffs.

Return type

list of reviewboard.diffviewer.models.filediff.FileDiff

Raises

django.core.exceptions.ValidationError – The commit series failed validation.

get_total_line_counts()[source]

Return the total line counts of all child FileDiffs.

Returns

A dictionary with the following keys:

  • raw_insert_count

  • raw_delete_count

  • insert_count

  • delete_count

  • replace_count

  • equal_count

  • total_line_count

Each entry maps to the sum of that line count type for all child FileDiffs.

Return type

dict

property per_commit_files[source]

The files limited to per-commit diffs.

This will cache the results for future lookups. If the set of all files has already been fetched with prefetch_related(), no queries will be performed.

property cumulative_files[source]

The files limited to the cumulative diff.

This will cache the results for future lookups. If the set of all files has been already been fetched with prefetch_related(), no queries will be incurred.

update_revision_from_history(diffset_history)[source]

Update the revision of this diffset based on a diffset history.

This will determine the appropriate revision to use for the diffset, based on how many other diffsets there are in the history. If there aren’t any, the revision will be set to 1.

Parameters

diffset_history (reviewboard.diffviewer.models.diffset_history.DiffSetHistory) – The diffset history used to compute the new revision.

Raises

ValueError – The revision already has a valid value set, and cannot be updated.

save(**kwargs)[source]

Save this diffset.

This will set an initial revision of 1 if this is the first diffset in the history, and will set it to on more than the most recent diffset otherwise.

Parameters

**kwargs (dict) – Extra arguments for the save call.