• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. RBTools 6.x
    2. Version 6.x
    3. Version 5.x
    4. Version 4.x
    5. Version 3.x
    6. Version 2.0
    7. Version 1.0
    8. Version 0.7
    9. Version 0.6
    10. Version 0.5
    11. RBTools Python API
    12. Module and Class References
    13. rbtools.diffs.tools.base.diff_file_result
  • Home
  • Installing RBTools
  • Authenticating to Review Board
  • rbt Command
  • Configuration
  • Creating Custom Command Aliases
  • Repository Configuration
  • Per-User Configuration
  • Azure DevOps / Team Foundation Server Configuration
  • Commands
  • alias
  • api-get
  • attach
  • clear-cache
  • close
  • diff
  • info
  • install
  • land
  • list-repo-types
  • login
  • logout
  • patch
  • post
  • publish
  • review
  • setup-completion
  • setup-repo
  • stamp
  • status
  • status-update
  • RBTools Workflows
  • Using RBTools with Git
  • Using RBTools With Perforce
  • Using RBTools with Jujutsu
  • Using RBTools with HCL ClearCase and IBM ClearCase
  • Using RBTools With Keysight SOS
  • RBTools Python API
  • Overview of the Python API Client
  • Common Use Cases
  • Module and Class References
  • rbtools
  • rbtools.deprecation
  • rbtools.api
  • rbtools.api.cache
  • rbtools.api.capabilities
  • rbtools.api.client
  • rbtools.api.decode
  • rbtools.api.decorators
  • rbtools.api.errors
  • rbtools.api.factory
  • rbtools.api.request
  • rbtools.api.transport
  • rbtools.api.transport.sync
  • rbtools.api.utils
  • rbtools.api.resource
  • rbtools.api.resource.base
  • rbtools.api.resource.base_archived_object
  • rbtools.api.resource.base_comment
  • rbtools.api.resource.base_diff_commit
  • rbtools.api.resource.base_review_group
  • rbtools.api.resource.base_review_request
  • rbtools.api.resource.base_review
  • rbtools.api.resource.base_user
  • rbtools.api.resource.mixins
  • rbtools.api.resource.api_token
  • rbtools.api.resource.archived_review_request
  • rbtools.api.resource.change
  • rbtools.api.resource.default_reviewer
  • rbtools.api.resource.diff_comment
  • rbtools.api.resource.diff_commit
  • rbtools.api.resource.diff_context
  • rbtools.api.resource.diff_file_attachment
  • rbtools.api.resource.diff
  • rbtools.api.resource.draft_diff_commit
  • rbtools.api.resource.draft_file_attachment
  • rbtools.api.resource.draft_screenshot
  • rbtools.api.resource.extension
  • rbtools.api.resource.file_attachment_comment
  • rbtools.api.resource.file_attachment
  • rbtools.api.resource.file_diff
  • rbtools.api.resource.general_comment
  • rbtools.api.resource.hosting_service_account
  • rbtools.api.resource.hosting_service
  • rbtools.api.resource.last_update
  • rbtools.api.resource.muted_review_request
  • rbtools.api.resource.oauth_application
  • rbtools.api.resource.oauth_token
  • rbtools.api.resource.plain_text
  • rbtools.api.resource.remote_repository
  • rbtools.api.resource.repository_branch
  • rbtools.api.resource.repository_commit
  • rbtools.api.resource.repository_group
  • rbtools.api.resource.repository_info
  • rbtools.api.resource.repository_user
  • rbtools.api.resource.repository
  • rbtools.api.resource.review_group_user
  • rbtools.api.resource.review_group
  • rbtools.api.resource.review_reply
  • rbtools.api.resource.review_request_draft
  • rbtools.api.resource.review_request
  • rbtools.api.resource.review
  • rbtools.api.resource.root
  • rbtools.api.resource.screenshot_comment
  • rbtools.api.resource.screenshot
  • rbtools.api.resource.search
  • rbtools.api.resource.server_info
  • rbtools.api.resource.session
  • rbtools.api.resource.status_update
  • rbtools.api.resource.user_file_attachment
  • rbtools.api.resource.user
  • rbtools.api.resource.validate_diff_commit
  • rbtools.api.resource.validate_diff
  • rbtools.api.resource.validation
  • rbtools.api.resource.watched_review_group
  • rbtools.api.resource.watched_review_request
  • rbtools.api.resource.watched
  • rbtools.api.resource.webhook
  • rbtools.clients
  • rbtools.clients.base
  • rbtools.clients.base.patch
  • rbtools.clients.base.registry
  • rbtools.clients.base.repository
  • rbtools.clients.base.scmclient
  • rbtools.clients.errors
  • rbtools.clients.bazaar
  • rbtools.clients.clearcase
  • rbtools.clients.cvs
  • rbtools.clients.git
  • rbtools.clients.mercurial
  • rbtools.clients.perforce
  • rbtools.clients.plastic
  • rbtools.clients.sos
  • rbtools.clients.svn
  • rbtools.clients.tfs
  • rbtools.config
  • rbtools.config.config
  • rbtools.config.loader
  • rbtools.diffs
  • rbtools.diffs.patches
  • rbtools.diffs.patcher
  • rbtools.diffs.tools
  • rbtools.diffs.tools.backends
  • rbtools.diffs.tools.backends.gnu
  • rbtools.diffs.tools.base
  • rbtools.diffs.tools.base.diff_file_result
  • rbtools.diffs.tools.base.diff_tool
  • rbtools.diffs.tools.errors
  • rbtools.diffs.tools.registry
  • rbtools.diffs.writers
  • rbtools.commands
  • rbtools.commands.main
  • rbtools.commands.base
  • rbtools.commands.base.commands
  • rbtools.commands.base.errors
  • rbtools.commands.base.options
  • rbtools.commands.base.output
  • rbtools.commands.alias
  • rbtools.commands.api_get
  • rbtools.commands.attach
  • rbtools.commands.clearcache
  • rbtools.commands.close
  • rbtools.commands.diff
  • rbtools.commands.info
  • rbtools.commands.install
  • rbtools.commands.land
  • rbtools.commands.list_repo_types
  • rbtools.commands.login
  • rbtools.commands.logout
  • rbtools.commands.patch
  • rbtools.commands.post
  • rbtools.commands.publish
  • rbtools.commands.review
  • rbtools.commands.setup_completion
  • rbtools.commands.setup_repo
  • rbtools.commands.stamp
  • rbtools.commands.status
  • rbtools.commands.status_update
  • rbtools.hooks
  • rbtools.hooks.common
  • rbtools.hooks.git
  • rbtools.testing
  • rbtools.testing.api
  • rbtools.testing.api.payloads
  • rbtools.testing.api.transport
  • rbtools.testing.commands
  • rbtools.testing.testcase
  • rbtools.testing.transport
  • rbtools.utils
  • rbtools.utils.aliases
  • rbtools.utils.browser
  • rbtools.utils.checks
  • rbtools.utils.commands
  • rbtools.utils.console
  • rbtools.utils.diffs
  • rbtools.utils.encoding
  • rbtools.utils.errors
  • rbtools.utils.filesystem
  • rbtools.utils.graphs
  • rbtools.utils.mimetypes
  • rbtools.utils.process
  • rbtools.utils.repository
  • rbtools.utils.review_request
  • rbtools.utils.source_tree
  • rbtools.utils.users
  • Glossary
  • General Index
  • Python Module Index
  • Release Notes
  • rbtools.diffs.tools.base.diff_file_result¶

    Classes for working with the result of a diff between files.

    Added in version 4.0.

    Classes

    DiffFileHeaderDict

    Parsed information from a diff file header.

    DiffFileResult(*, orig_path, modified_path, diff)

    The result of diffing a file.

    class rbtools.diffs.tools.base.diff_file_result.DiffFileHeaderDict[source]¶

    Bases: TypedDict

    Parsed information from a diff file header.

    This represents information found in a ---` or +++ header in a Unified Diff file.

    Added in version 4.0.

    __firstlineno__ = 22¶
    __static_attributes__ = ()¶
    extra: bytes¶

    Extra information shown after the filename.

    This will be empty if not present.

    Type:

    bytes

    marker: bytes¶

    The marker at the start of the header line.

    This will be --- or +++.

    Type:

    bytes

    path: bytes¶

    The path listed in the header line.

    Type:

    bytes

    class rbtools.diffs.tools.base.diff_file_result.DiffFileResult(*, orig_path: str, modified_path: str, diff: io.BytesIO, is_binary: bool = False, has_text_differences: bool = True, orig_file_header_line_num: int = 0, modified_file_header_line_num: int = 1, hunks_start_line_num: int = 2, file_header_re: re.Pattern = re.compile(b'^(?P<marker>---|\\+\\+\\+) (?P<path>.+?)((?:\\t| {2,})(?P<extra>.*))?$'))[source]¶

    Bases: object

    The result of diffing a file.

    This contains the stream of diff contents, flags indicating what type of diff this is, and whether any changes were found.

    There’s parsing helpers in here to extract the most relevant information from the diff, for use when assembling new SCM-specific diffs from the contents.

    Added in version 4.0.

    __firstlineno__ = 55¶
    __init__(*, orig_path: str, modified_path: str, diff: io.BytesIO, is_binary: bool = False, has_text_differences: bool = True, orig_file_header_line_num: int = 0, modified_file_header_line_num: int = 1, hunks_start_line_num: int = 2, file_header_re: re.Pattern = re.compile(b'^(?P<marker>---|\\+\\+\\+) (?P<path>.+?)((?:\\t| {2,})(?P<extra>.*))?$')) → None[source]¶

    Initialize the diff result.

    Parameters:
    • orig_path (str) –

      The original filename passed to the diff tool.

      This may be different from the information shown in the diff itself.

    • modified_path (str) –

      The modified filename passed to the diff tool.

      This may be different from the information shown in the diff itself.

    • diff (io.BytesIO) – A stream containing the full diff content.

    • is_binary (bool, optional) – Whether this represents a change to a binary file.

    • has_text_differences (bool, optional) – Whether differences were found in a text file.

    • orig_file_header_line_num (int, optional) –

      The line number containing the original line header.

      This is a hint for parsing. It shouldn’t need to be changed, but can be set by a diff tool if required.

    • modified_file_header_line_num (int, optional) –

      The line number containing the modified line header.

      This is a hint for parsing. It shouldn’t need to be changed, but can be set by a diff tool if required.

    • hunks_start_line_num (int, optional) –

      The starting line number containing the Unified Diff hunks.

      This is a hint for parsing. It shouldn’t need to be changed, but can be set by a diff tool if required.

    • file_header_re (re.Pattern, optional) –

      A regex used to parse file headers.

      This must capture marker, path, and extra groups for a standard Unified Diff original/modified file header line.

    __static_attributes__ = ('_line_offset_cache', 'diff', 'file_header_re', 'has_differences', 'has_text_differences', 'hunks_start_line_num', 'is_binary', 'modified_file_header_line_num', 'modified_path', 'orig_file_header_line_num', 'orig_path')¶
    diff: io.BytesIO¶

    A stream containing the full diff content.

    Consumers can read directly from this, but it’s recommended that they use one of the many available properties or functions for fetching content instead.

    Type:

    io.BytesIO

    has_differences: bool¶

    Whether any differences were found.

    If diffing against a binary file, this will always be True. Otherwise, it depends on the value of has_text_differences.

    Type:

    bool

    has_text_differences: bool¶

    Whether differences were found in a text file.

    This will be True if there were any changes at all to the file.

    This will be False if the files were identical, or if one or both files were binary.

    Type:

    bool

    property hunks: bytes[source]¶

    The full content of the diff hunks.

    This does not normalize line endings.

    Type:

    bytes

    hunks_start_line_num: int¶

    The starting line number containing the Unified Diff hunks.

    Type:

    int

    is_binary: bool¶

    Whether this represents a change to a binary file.

    Type:

    bool

    iter_hunk_lines(keep_newlines=False) → Iterator[bytes][source]¶

    Iterate through all hunk lines.

    Lines may optionally contain newlines.

    Note that any CRCRLF newlines will be converted to CRLF. While uncommon, CRCRLF can happen with some SCMs if editing and diffing code across two different operating systems (usually Windows and either Linux or macOS).

    Parameters:

    keep_newlines (bool) – Whether to keep newlines in yielded lines.

    Yields:

    bytes – Each line of bytes in the hunk data.

    property modified_file_header: bytes[source]¶

    The content of the modified file header.

    The format of this header may vary between diff tools.

    Type:

    bytes

    modified_file_header_line_num: int¶

    The line number containing the modified line header.

    Type:

    int

    modified_path: str¶

    The modified path passed to the diff tool.

    This may be different from the information shown in modified_file_header.

    Type:

    str

    property orig_file_header: bytes[source]¶

    The content of the original file header.

    The format of this header may vary between diff tools.

    Type:

    bytes

    orig_file_header_line_num: int¶

    The line number containing the original line header.

    Type:

    int

    orig_path: str¶

    The original path passed to the diff tool.

    This may be different from the information shown in orig_file_header.

    Type:

    str

    property parsed_modified_file_header: DiffFileHeaderDict | None[source]¶

    The extra contents on the file header.

    This is usually a timestamp, but its presence and format may vary between diff tools.

    See DiffFileHeaderDict for the contents of the dictionary.

    Type:

    dict

    property parsed_orig_file_header: DiffFileHeaderDict | None[source]¶

    The extra contents on the file header.

    This is usually a timestamp, but its presence and format may vary between diff tools.

    See DiffFileHeaderDict for the contents of the dictionary.

    Type:

    dict

    seek_diff_hunks() → None[source]¶

    Seek to the position of the diff hunks.

    This can be used by consumers to place the read offset at the correct position in order to perform operations on the hunk portion of the diff.

    If there are no text differences, this seeks to the beginning of the diff.

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2026 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • DiffFileHeaderDict
      • DiffFileHeaderDict.__firstlineno__
      • DiffFileHeaderDict.__static_attributes__
      • DiffFileHeaderDict.extra
      • DiffFileHeaderDict.marker
      • DiffFileHeaderDict.path
    • DiffFileResult
      • DiffFileResult.__firstlineno__
      • DiffFileResult.__init__()
      • DiffFileResult.__static_attributes__
      • DiffFileResult.diff
      • DiffFileResult.has_differences
      • DiffFileResult.has_text_differences
      • DiffFileResult.hunks
      • DiffFileResult.hunks_start_line_num
      • DiffFileResult.is_binary
      • DiffFileResult.iter_hunk_lines()
      • DiffFileResult.modified_file_header
      • DiffFileResult.modified_file_header_line_num
      • DiffFileResult.modified_path
      • DiffFileResult.orig_file_header
      • DiffFileResult.orig_file_header_line_num
      • DiffFileResult.orig_path
      • DiffFileResult.parsed_modified_file_header
      • DiffFileResult.parsed_orig_file_header
      • DiffFileResult.seek_diff_hunks()