Jump to >

reviewboard.diffviewer.models

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

Bases: django.db.models.base.Model

Deprecated, legacy class for base64-encoded diff data.

This is no longer populated, and exists solely to store legacy data that has not been migrated to RawFileDiffData.

binary

Property-like class used to store/retrieve Base64 values.

This works much like a property, and takes care of encoding strings for storage and decoding them on retrieval. It’s set internally by Base64Field in place of the normal field attribute.

filediffs[source]
get_binary_base64()[source]
get_extra_data_json()[source]
objects = <django.db.models.manager.Manager object>[source]
parent_filediffs[source]
set_extra_data_json(json)[source]
class RawFileDiffData(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Stores raw diff data as binary content in the database.

This is the class used in Review Board 2.5+ to store diff content. Unlike in previous versions, the content is not base64-encoded. Instead, it is stored either as bzip2-compressed data (if the resulting compressed data is smaller than the raw data), or as the raw data itself.

COMPRESSION_BZIP2 = u'B'[source]
COMPRESSION_CHOICES = ((u'B', _(u'BZip2-compressed')),)[source]
objects = <reviewboard.diffviewer.managers.RawFileDiffDataManager object>[source]
content[source]

Returns the content of the diff.

The content will be uncompressed (if necessary) and returned as the raw set of bytes originally uploaded.

insert_count[source]
delete_count[source]
recalculate_line_counts(tool)[source]

Recalculates the insert_count and delete_count values.

This will attempt to re-parse the stored diff and fetch the line counts through the parser.

filediffs[source]
get_compression_display(**morekwargs)[source]
get_extra_data_json()[source]
parent_filediffs[source]
set_extra_data_json(json)[source]
class FileDiff(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A diff of a single file.

This contains the patch and information needed to produce original and patched versions of a single file in a repository.

COPIED = u'C'[source]
DELETED = u'D'[source]
MODIFIED = u'M'[source]
MOVED = u'V'[source]
STATUSES = ((u'C', _(u'Copied')), (u'D', _(u'Deleted')), (u'M', _(u'Modified')), (u'V', _(u'Moved')))[source]
diffset[source]
diff64

Property-like class used to store/retrieve Base64 values.

This works much like a property, and takes care of encoding strings for storage and decoding them on retrieval. It’s set internally by Base64Field in place of the normal field attribute.

legacy_diff_hash[source]
diff_hash[source]
parent_diff64

Property-like class used to store/retrieve Base64 values.

This works much like a property, and takes care of encoding strings for storage and decoding them on retrieval. It’s set internally by Base64Field in place of the normal field attribute.

legacy_parent_diff_hash[source]
parent_diff_hash[source]
objects = <reviewboard.diffviewer.managers.FileDiffManager object>[source]
source_file_display[source]
dest_file_display[source]
deleted[source]
copied[source]
moved[source]
modified[source]

Whether this file is a modification to an existing file.

is_new[source]
status_string[source]

The FileDiff’s status as a human-readable string.

diff[source]
parent_diff[source]
is_parent_diff_empty(cache_only=False)[source]

Return whether or not the parent diff is empty.

Parameters:cache_only (bool, optional) – Whether or not to only use cached results.
Returns:Whether or not the parent diff is empty. This is true if either there is no parent diff or if the parent diff has no insertions and no deletions.
Return type:bool
orig_sha1[source]
patched_sha1[source]
get_line_counts()[source]

Returns the stored line counts for the diff.

This will return all the types of line counts that can be set:

  • raw_insert_count
  • raw_delete_count
  • insert_count
  • delete_count
  • replace_count
  • equal_count
  • total_line_count

These are not all guaranteed to have values set, and may instead be None. Only raw_insert_count, raw_delete_count insert_count, and delete_count are guaranteed to have values set.

If there isn’t a processed number of inserts or deletes stored, then insert_count and delete_count will be equal to the raw versions.

set_line_counts(raw_insert_count=None, raw_delete_count=None, insert_count=None, delete_count=None, replace_count=None, equal_count=None, total_line_count=None)[source]

Sets the line counts on the FileDiff.

There are many types of useful line counts that can be set.

raw_insert_count and raw_delete_count correspond to the raw inserts and deletes in the actual patch, which will be set both in this FileDiff and in the associated RawFileDiffData.

The other counts are stored exclusively in FileDiff, as they are more render-specific.

__str__()[source]
__unicode__()[source]
added_attachments[source]
comments[source]
get_diff64_base64()[source]
get_extra_data_json()[source]
get_parent_diff64_base64()[source]
get_status_display(**morekwargs)[source]
interdiff_comments[source]
set_extra_data_json(json)[source]
class DiffSet(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A revisioned collection of FileDiffs.

history[source]
repository[source]
objects = <reviewboard.diffviewer.managers.DiffSetManager object>[source]
get_total_line_counts()[source]

Returns the total line counts from all files in this diffset.

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.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.
__str__()[source]
__unicode__()[source]
files[source]
get_extra_data_json()[source]
get_next_by_timestamp(**morekwargs)[source]
get_previous_by_timestamp(**morekwargs)[source]
review_request_draft[source]
review_set[source]
set_extra_data_json(json)[source]
class DiffSetHistory(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A collection of diffsets.

This gives us a way to store and keep track of multiple revisions of diffsets belonging to an object.

__str__()[source]
__unicode__()[source]
diffsets[source]
get_extra_data_json()[source]
get_next_by_timestamp(**morekwargs)[source]
get_previous_by_timestamp(**morekwargs)[source]
objects = <django.db.models.manager.Manager object>[source]
review_request[source]
set_extra_data_json(json)[source]