• 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 5.x
    2. Version 5.x
    3. Version 4.x
    4. Version 3.x
    5. Version 2.0
    6. Version 1.0
    7. Version 0.7
    8. Version 0.6
    9. Version 0.5
    10. RBTools Python API
    11. Module and Class References
    12. rbtools.diffs.tools.base.diff_file_result
  • Home
  • Installing RBTools
  • rbt Command
  • Configuration
  • Authenticating to Review Board
  • Repository Configuration
  • Per-User Configuration
  • Team Foundation Server Configuration
  • Commands
  • alias
  • api-get
  • attach
  • clear-cache
  • close
  • diff
  • install
  • land
  • list-repo-types
  • login
  • logout
  • patch
  • post
  • publish
  • review
  • setup-completion
  • setup-repo
  • stamp
  • status
  • status-update
  • RBTools Workflows
  • Using RBTools With Cliosoft SOS
  • Using RBTools with Git
  • Using RBTools with HCL VersionVault and IBM ClearCase
  • Using RBTools With Perforce
  • RBTools Python API
  • Overview of the Python API Client
  • Tutorial
  • Resource-Specific Functionality
  • 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.resource
  • rbtools.api.transport
  • rbtools.api.transport.sync
  • rbtools.api.utils
  • 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
  • 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.

    New 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.

    New in version 4.0.

    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

    extra: bytes¶

    Extra information shown after the filename.

    This will be empty if not present.

    Type:

    bytes

    __closed__ = False¶
    __extra_items__ = None¶
    __mutable_keys__ = frozenset({'extra', 'marker', 'path'})¶
    __optional_keys__ = frozenset({})¶
    __orig_bases__ = (<function TypedDict>,)¶
    __readonly_keys__ = frozenset({})¶
    __required_keys__ = frozenset({'extra', 'marker', 'path'})¶
    __total__ = True¶
    class rbtools.diffs.tools.base.diff_file_result.DiffFileResult(*, orig_path: str, modified_path: str, diff: 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: 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.

    New in version 4.0.

    __init__(*, orig_path: str, modified_path: str, diff: 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: 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.

    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

    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

    diff: 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

    is_binary: bool¶

    Whether this represents a change to a binary file.

    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

    orig_file_header_line_num: int¶

    The line number containing the original line header.

    Type:

    int

    modified_file_header_line_num: int¶

    The line number containing the modified line header.

    Type:

    int

    hunks_start_line_num: int¶

    The starting line number containing the Unified Diff hunks.

    Type:

    int

    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

    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

    property parsed_orig_file_header: Optional[DiffFileHeaderDict][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 modified_file_header: bytes[source]¶

    The content of the modified file header.

    The format of this header may vary between diff tools.

    Type:

    bytes

    property parsed_modified_file_header: Optional[DiffFileHeaderDict][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 hunks: bytes[source]¶

    The full content of the diff hunks.

    This does not normalize line endings.

    Type:

    bytes

    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.

    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-2025 Beanbag, Inc. All rights reserved.

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

    On this page

    • [Top]
    • DiffFileHeaderDict
      • DiffFileHeaderDict.marker
      • DiffFileHeaderDict.path
      • DiffFileHeaderDict.extra
      • DiffFileHeaderDict.__closed__
      • DiffFileHeaderDict.__extra_items__
      • DiffFileHeaderDict.__mutable_keys__
      • DiffFileHeaderDict.__optional_keys__
      • DiffFileHeaderDict.__orig_bases__
      • DiffFileHeaderDict.__readonly_keys__
      • DiffFileHeaderDict.__required_keys__
      • DiffFileHeaderDict.__total__
    • DiffFileResult
      • DiffFileResult.__init__()
      • DiffFileResult.orig_path
      • DiffFileResult.modified_path
      • DiffFileResult.diff
      • DiffFileResult.is_binary
      • DiffFileResult.has_text_differences
      • DiffFileResult.orig_file_header_line_num
      • DiffFileResult.modified_file_header_line_num
      • DiffFileResult.hunks_start_line_num
      • DiffFileResult.has_differences
      • DiffFileResult.orig_file_header
      • DiffFileResult.parsed_orig_file_header
      • DiffFileResult.modified_file_header
      • DiffFileResult.parsed_modified_file_header
      • DiffFileResult.hunks
      • DiffFileResult.iter_hunk_lines()
      • DiffFileResult.seek_diff_hunks()