Diff3

Diff3[ancestor,first,second]

attempts to resolve two different sets of edits from a common ancestor.

Diff3[ancestor,first,second,format]

represents the diffs in the indicated format.

Details and Options

  • Diff3 produces results for the following types of expressions:
  • lists{}returns differences between two lists
    text"text", File["fname.txt"]returns differences in individual characters, words or lines between two blocks of text
    biomolecular sequencesBioSequence[]returns differences in letter strings between two biomolecular sequences
    cellsCell[], CellObject[]returns differences in content, styles and options between two cells
    notebooksNotebook[], NotebookObject[], File["fname.nb"]returns differences in cells and options between two notebooks
  • Diff3 returns a DiffObject.
  • Diff3 uses a variant of SequenceAlignment that allows alignment of three lists or strings.
  • Diff3 takes all the same options as Diff.
  • If the diffs between ancestor and each of the edits can be applied in sequence to produce a combined result, then using DiffApply on the resulting DiffObject will apply both sets of changes. Otherwise, the DiffObject will include conflict markers and be unusable by DiffApply.
  • Diff3[ancestor,first,second] is equivalent to Diff3[ancestor,first,second,"DiffObjectViewer"], which produces a viewer with a popup menu allowing you to interactively select between different formats. Other values of format display as the given format, without the ability to interactively change the view type.
  • Some values of format use abstract visualizations to depict the nature and extent of the changes among ancestor, first and second:
  • "ArrayPlot"display a merged list of elements in an array plot, with colored array cells annotating the changes
    "SideBySideSummary"display ancestor, first and second as separate sequences of colored array cells with long, unchanged sequences elided
    "UnifiedSummary"display ancestor, first and second as a combined sequence of colored array cells with long, unchanged sequences elided
  • Other acceptable values of format include:
  • "Details"produce a textual description of each change
    "DiffObjectViewer"display in a panel with an interactive format setting
    "SideBySide"display elements of ancestor, first and second in aligned, side-by-side columns
    "SummaryBox"display as a DiffObject summary box
  • Some values of format will only work with a subset of expression types.
  • Diff3[ancestor,edit1,edit2][format] is equivalent to Diff3[ancestor,edit1,edit2,format].

Examples

open allclose all

Basic Examples  (2)

Find and visualize the sequence of changes that can merge two different sets of edits together:

It is not always possible to merge two different sets of edits together:

Get details about the conflicts:

Properties & Relations  (2)

When a three-way diff contains no conflicts, DiffApply will apply both sets of edits:

When a three-way diff contains conflicts, DiffApply will return a Failure object:

Wolfram Research (2024), Diff3, Wolfram Language function, https://reference.wolfram.com/language/ref/Diff3.html.

Text

Wolfram Research (2024), Diff3, Wolfram Language function, https://reference.wolfram.com/language/ref/Diff3.html.

CMS

Wolfram Language. 2024. "Diff3." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Diff3.html.

APA

Wolfram Language. (2024). Diff3. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Diff3.html

BibTeX

@misc{reference.wolfram_2024_diff3, author="Wolfram Research", title="{Diff3}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Diff3.html}", note=[Accessed: 09-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_diff3, organization={Wolfram Research}, title={Diff3}, year={2024}, url={https://reference.wolfram.com/language/ref/Diff3.html}, note=[Accessed: 09-October-2024 ]}