reviewboard.diffviewer.models.filediff¶
FileDiff model definition.
- class FileDiff(*args, **kwargs)[source]¶
Bases:
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.
- diffset[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- commit[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- source_file[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- dest_file[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- source_revision[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- dest_detail[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- binary[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- status[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- diff64[source]¶
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]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- diff_hash[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- parent_diff64[source]¶
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]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- parent_diff_hash[source]¶
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parent
is aForwardManyToOneDescriptor
instance.
- extra_data[source]¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property source_file_display[source]¶
The displayed filename for the source/original file.
This may be different than
source_file
, as the associatedSCMTool
may normalize it for display.- Type:
- property dest_file_display[source]¶
The displayed filename for the destination/modified file.
This may be different than
dest_file
, as the associatedSCMTool
may normalize it for display.- Type:
- property is_symlink[source]¶
Whether this file represents a symlink.
This represents the value of the
is_symlink
key inextra_data
.New in version 4.0.6.
- Type:
- property old_symlink_target[source]¶
The old target for the symlink.
This represents the value of the
old_symlink_target
key inextra_data
.New in version 4.0.6.
- Type:
- property new_symlink_target[source]¶
The new target for the symlink.
This represents the value of the
new_symlink_target
key inextra_data
.New in version 4.0.6.
- Type:
- property old_unix_mode[source]¶
The old UNIX permissions mode for the file.
This represents the value of the
old_unix_mode
key inextra_data
. It is stored as a string representing an octal.New in version 4.0.6.
- Type:
- property new_unix_mode[source]¶
The new UNIX permissions mode for the file.
This represents the value of the
new_unix_mode
key inextra_data
. It is stored as a string representing an octal.New in version 4.0.6.
- Type:
- property orig_sha1[source]¶
The computed SHA1 hash of the original file.
This may be
None
, in which case it will be populated when the diff is next viewed.
- property patched_sha1[source]¶
The computed SHA1 hash of the patched file.
This may be
None
, in which case it will be populated when the diff is next viewed.
- property orig_sha256[source]¶
The computed SHA256 hash of the original file.
This may be
None
, in which case it will be populated when the diff is next viewed.New in version 4.0.
- property patched_sha256[source]¶
The computed SHA256 hash of the patched file.
This may be
None
, in which case it will be populated when the diff is next viewed.New in version 4.0.
- property encoding[source]¶
The encoding of the source and patched file.
This will check the
encoding
key inextra_data
. If not available, then this will beNone
.New in version 4.0.
- get_line_counts()[source]¶
Return the stored line counts for the diff.
This will return all the types of line counts that can be set.
- Returns:
A dictionary with the following keys:
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
. Onlyraw_insert_count
,raw_delete_count
insert_count
, anddelete_count
are guaranteed to have values set.If there isn’t a processed number of inserts or deletes stored, then
insert_count
anddelete_count
will be equal to the raw versions.- Return type:
- 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]¶
Set the line counts on the FileDiff.
There are many types of useful line counts that can be set.
- Parameters:
raw_insert_count (
int
, optional) –The insert count on the original patch.
This will be set on the
reviewboard.diffviewer.models.raw_file_diff_data.RawFileDiffData
as well.raw_delete_count (
int
, optional) –The delete count in the original patch.
This will be set on the
reviewboard.diffviewer.models.raw_file_diff_data.RawFileDiffData
as well.insert_count (
int
, optional) – The number of lines that were inserted in the diff.delete_count (
int
, optional) – The number of lines that were deleted in the diff.replace_count (
int
, optional) – The number of lines that were replaced in the diff.equal_count (
int
, optional) – The number of lines that were identical in the diff.total_line_count (
int
, optional) – The total line count.
- get_ancestors(minimal, filediffs=None, update=True)[source]¶
Return the ancestors of this FileDiff.
This will update the ancestors of this
FileDiff
and all its ancestors if they are not already cached.- Parameters:
minimal (
bool
) –Whether or not the minimal set of ancestors are returned.
The minimal set of ancestors does not include ancestors where the file was deleted. In other words, if a file is deleted and then re-created, the deletion will not appear in the re-created file’s ancestor list.
filediffs (
iterable
ofFileDiff
, optional) – An optional list of FileDiffs to check for ancestors so that a query does not have to be performed.update (
bool
, optional) –Whether or not to cache the results in the database.
If
True
and the results have not already been cached, this FileDiff and its ancestors will all be updated.
- Returns:
The ancestor
FileDiffs
, in application order.- Return type:
- get_repository()[source]¶
Return the repository this diff applies to.
New in version 4.0.
- Returns:
The repository used for any operations for this FileDiff.
- Return type:
- get_base_filediff(base_commit, ancestors=None)[source]¶
Return the base FileDiff within a commit range.
This looks through the FileDiff’s ancestors, looking for the most recent one that equals or precedes
base_commit
.- Parameters:
base_commit (
reviewboard.diffviewer.models.diffcommit.DiffCommit
) – The newest commit that the resulting base FileDiff can be associated with.ancestors (
list
ofFileDiff
, optional) – A pre-fetched list of FileDiff ancestors. If not provided, a list will be fetched.
- Returns:
The base FileDiff, if one could be found.
None
will be returned if no base could be found.- Return type:
- __str__()[source]¶
Return a human-readable representation of the model.
- Returns:
A human-readable representation of the model.
- Return type:
- __annotations__ = {}¶
- added_attachments¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- comments¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- commit_id¶
- diff_hash_id¶
- diffset_id¶
- get_diff64_base64()¶
- get_extra_data_json()¶
- get_parent_diff64_base64()¶
- get_status_display(*, field=<django.db.models.fields.CharField: status>)¶
- id¶
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- interdiff_comments¶
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
- legacy_diff_hash_id¶
- legacy_parent_diff_hash_id¶
- parent_diff_hash_id¶
- set_extra_data_json(json)¶