##// END OF EJS Templates
mergetools: add new conflict marker format with diffs in...
mergetools: add new conflict marker format with diffs in I use 3-way conflict markers. Often when I resolve them, I manually compare one the base with one side and apply the differences to the other side. That can be hard when the conflict marker is large. This patch introduces a new type of conflict marker, which I'm hoping will make it easier to resolve conflicts. The new format uses `<<<<<<<` and `>>>>>>>` to open and close the markers, just like our existing 2-way and 3-way conflict markers. Instead of having 2 or 3 snapshots (left+right or left+base+right), it has a sequence of diffs. A diff looks like this: ``` ------- base +++++++ left a -b +c d ``` A diff that adds one side ("diff from nothing") has a `=======` header instead and does not have have `+` prefixed on its lines. A regular 3-way merge can be viewed as adding one side plus a diff between the base and the other side. It thus has two ways of being represented, depending on which side is being diffed: ``` <<<<<<< ======= left contents on left ------- base +++++++ right contents on -left +right >>>>>>> ``` or ``` <<<<<<< ------- base +++++++ left contents on -right +left ======= right contents on right >>>>>>> ``` I've made it so the new merge tool tries to pick a version that has the most common lines (no difference in the example above). I've called the new tool "mergediff" to stick to the convention of starting with "merge" if the tool tries a regular 3-way merge. The idea came from my pet VCS (placeholder name `jj`), which has support for octopus merges and other ways of ending up with merges of more than 3 versions. I wanted to be able to represent such conflicts in the working copy and therefore thought of this format (although I have not yet implemented it in my VCS). I then attended a meeting with Larry McVoy, who said BitKeeper has an option (`bk smerge -g`) for showing a similar format, which reminded me to actually attempt this in Mercurial. Differential Revision: https://phab.mercurial-scm.org/D9551

File last commit:

r44031:2e017696 default
r46724:bdc2bf68 default
Show More
cbor.txt
130 lines | 3.8 KiB | text/plain | TextLexer
Mercurial uses Concise Binary Object Representation (CBOR)
(RFC 7049) for various data formats.
This document describes the subset of CBOR that Mercurial uses and
gives recommendations for appropriate use of CBOR within Mercurial.
Type Limitations
================
Major types 0 and 1 (unsigned integers and negative integers) MUST be
fully supported.
Major type 2 (byte strings) MUST be fully supported. However, there
are limitations around the use of indefinite-length byte strings.
(See below.)
Major type 3 (text strings) are NOT supported.
Major type 4 (arrays) MUST be supported. However, values are limited
to the set of types described in the "Container Types" section below.
And indefinite-length arrays are NOT supported.
Major type 5 (maps) MUST be supported. However, key values are limited
to the set of types described in the "Container Types" section below.
And indefinite-length maps are NOT supported.
Major type 6 (semantic tagging of major types) can be used with the
following semantic tag values:
258
Mathematical finite set. Suitable for representing Python's
``set`` type.
All other semantic tag values are not allowed.
Major type 7 (simple data types) can be used with the following
type values:
20
False
21
True
22
Null
31
Break stop code (for indefinite-length items).
All other simple data type values (including every value requiring the
1 byte extension) are disallowed.
Indefinite-Length Byte Strings
==============================
Indefinite-length byte strings (major type 2) are allowed. However,
they MUST NOT occur inside a container type (such as an array or map).
i.e. they can only occur as the "top-most" element in a stream of
values.
Encoders and decoders SHOULD *stream* indefinite-length byte strings.
i.e. an encoder or decoder SHOULD NOT buffer the entirety of a long
byte string value when indefinite-length byte strings are being used
if it can be avoided. Mercurial MAY use extremely long indefinite-length
byte strings and buffering the source or destination value COULD lead to
memory exhaustion.
Chunks in an indefinite-length byte string SHOULD NOT exceed 2^20
bytes.
Container Types
===============
Mercurial may use the array (major type 4), map (major type 5), and
set (semantic tag 258 plus major type 4 array) container types.
An array may contain any supported type as values.
A map MUST only use the following types as keys:
* unsigned integers (major type 0)
* negative integers (major type 1)
* byte strings (major type 2) (but not indefinite-length byte strings)
* false (simple type 20)
* true (simple type 21)
* null (simple type 22)
A map MUST only use the following types as values:
* all types supported as map keys
* arrays
* maps
* sets
A set may only use the following types as values:
* all types supported as map keys
It is recommended that keys in maps and values in sets and arrays all
be of a uniform type.
Avoiding Large Byte Strings
===========================
The use of large byte strings is discouraged, especially in scenarios where
the total size of the byte string may by unbound for some inputs (e.g. when
representing the content of a tracked file). It is highly recommended to use
indefinite-length byte strings for these purposes.
Since indefinite-length byte strings cannot be nested within an outer
container (such as an array or map), to associate a large byte string
with another data structure, it is recommended to use an array or
map followed immediately by an indefinite-length byte string. For example,
instead of the following map::
{
"key1": "value1",
"key2": "value2",
"long_value": "some very large value...",
}
Use a map followed by a byte string:
{
"key1": "value1",
"key2": "value2",
"value_follows": True,
}
<BEGIN INDEFINITE-LENGTH BYTE STRING>
"some very large value"
"..."
<END INDEFINITE-LENGTH BYTE STRING>