mercurial/helptext/internals/changegroups.txt
changeset 47077 119790e1c67c
parent 43632 2e017696181f
equal deleted inserted replaced
47076:08e26ef4ad35 47077:119790e1c67c
     1 Changegroups are representations of repository revlog data, specifically
     1 Changegroups are representations of repository revlog data, specifically
     2 the changelog data, root/flat manifest data, treemanifest data, and
     2 the changelog data, root/flat manifest data, treemanifest data, and
     3 filelogs.
     3 filelogs.
     4 
     4 
     5 There are 3 versions of changegroups: ``1``, ``2``, and ``3``. From a
     5 There are 4 versions of changegroups: ``1``, ``2``, ``3`` and ``4``. From a
     6 high-level, versions ``1`` and ``2`` are almost exactly the same, with the
     6 high-level, versions ``1`` and ``2`` are almost exactly the same, with the
     7 only difference being an additional item in the *delta header*. Version
     7 only difference being an additional item in the *delta header*. Version
     8 ``3`` adds support for storage flags in the *delta header* and optionally
     8 ``3`` adds support for storage flags in the *delta header* and optionally
     9 exchanging treemanifests (enabled by setting an option on the
     9 exchanging treemanifests (enabled by setting an option on the
    10 ``changegroup`` part in the bundle2).
    10 ``changegroup`` part in the bundle2). Version ``4`` adds support for exchanging
       
    11 sidedata (additional revision metadata not part of the digest).
    11 
    12 
    12 Changegroups when not exchanging treemanifests consist of 3 logical
    13 Changegroups when not exchanging treemanifests consist of 3 logical
    13 segments::
    14 segments::
    14 
    15 
    15    +---------------------------------+
    16    +---------------------------------+
    72 
    73 
    73 The *delta data* is a series of *delta*s that describe a diff from an existing
    74 The *delta data* is a series of *delta*s that describe a diff from an existing
    74 entry (either that the recipient already has, or previously specified in the
    75 entry (either that the recipient already has, or previously specified in the
    75 bundle/changegroup).
    76 bundle/changegroup).
    76 
    77 
    77 The *delta header* is different between versions ``1``, ``2``, and
    78 The *delta header* is different between versions ``1``, ``2``, ``3`` and ``4``
    78 ``3`` of the changegroup format.
    79 of the changegroup format.
    79 
    80 
    80 Version 1 (headerlen=80)::
    81 Version 1 (headerlen=80)::
    81 
    82 
    82    +------------------------------------------------------+
    83    +------------------------------------------------------+
    83    |            |             |             |             |
    84    |            |             |             |             |
   101    |            |             |             |            |            |           |
   102    |            |             |             |            |            |           |
   102    |    node    |   p1 node   |   p2 node   | base node  | link node  |   flags   |
   103    |    node    |   p1 node   |   p2 node   | base node  | link node  |   flags   |
   103    | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
   104    | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) |
   104    |            |             |             |            |            |           |
   105    |            |             |             |            |            |           |
   105    +------------------------------------------------------------------------------+
   106    +------------------------------------------------------------------------------+
       
   107 
       
   108 Version 4 (headerlen=103)::
       
   109 
       
   110    +------------------------------------------------------------------------------+----------+
       
   111    |            |             |             |            |            |           |          |
       
   112    |    node    |   p1 node   |   p2 node   | base node  | link node  |   flags   |  pflags  |
       
   113    | (20 bytes) |  (20 bytes) |  (20 bytes) | (20 bytes) | (20 bytes) | (2 bytes) | (1 byte) |
       
   114    |            |             |             |            |            |           |          |
       
   115    +------------------------------------------------------------------------------+----------+
   106 
   116 
   107 The *delta data* consists of ``chunklen - 4 - headerlen`` bytes, which contain a
   117 The *delta data* consists of ``chunklen - 4 - headerlen`` bytes, which contain a
   108 series of *delta*s, densely packed (no separators). These deltas describe a diff
   118 series of *delta*s, densely packed (no separators). These deltas describe a diff
   109 from an existing entry (either that the recipient already has, or previously
   119 from an existing entry (either that the recipient already has, or previously
   110 specified in the bundle/changegroup). The format is described more fully in
   120 specified in the bundle/changegroup). The format is described more fully in
   138    parents).
   148    parents).
   139 8192
   149 8192
   140    Externally stored. The revision fulltext contains ``key:value`` ``\n``
   150    Externally stored. The revision fulltext contains ``key:value`` ``\n``
   141    delimited metadata defining an object stored elsewhere. Used by the LFS
   151    delimited metadata defining an object stored elsewhere. Used by the LFS
   142    extension.
   152    extension.
       
   153 4096
       
   154    Contains copy information. This revision changes files in a way that could
       
   155    affect copy tracing. This does *not* affect changegroup handling, but is
       
   156    relevant for other parts of Mercurial.
   143 
   157 
   144 For historical reasons, the integer values are identical to revlog version 1
   158 For historical reasons, the integer values are identical to revlog version 1
   145 per-revision storage flags and correspond to bits being set in this 2-byte
   159 per-revision storage flags and correspond to bits being set in this 2-byte
   146 field. Bits were allocated starting from the most-significant bit, hence the
   160 field. Bits were allocated starting from the most-significant bit, hence the
   147 reverse ordering and allocation of these flags.
   161 reverse ordering and allocation of these flags.
       
   162 
       
   163 The *pflags* (protocol flags) field holds bitwise flags affecting the protocol
       
   164 itself. They are first in the header since they may affect the handling of the
       
   165 rest of the fields in a future version. They are defined as such:
       
   166 
       
   167 1 indicates whether to read a chunk of sidedata (of variable length) right
       
   168   after the revision flags.
       
   169 
   148 
   170 
   149 Changeset Segment
   171 Changeset Segment
   150 =================
   172 =================
   151 
   173 
   152 The *changeset segment* consists of a single *delta group* holding
   174 The *changeset segment* consists of a single *delta group* holding
   164 *filelogs segment*, depending on version and the request options).
   186 *filelogs segment*, depending on version and the request options).
   165 
   187 
   166 Treemanifests Segment
   188 Treemanifests Segment
   167 ---------------------
   189 ---------------------
   168 
   190 
   169 The *treemanifests segment* only exists in changegroup version ``3``, and
   191 The *treemanifests segment* only exists in changegroup version ``3`` and ``4``,
   170 only if the 'treemanifest' param is part of the bundle2 changegroup part
   192 and only if the 'treemanifest' param is part of the bundle2 changegroup part
   171 (it is not possible to use changegroup version 3 outside of bundle2).
   193 (it is not possible to use changegroup version 3 or 4 outside of bundle2).
   172 Aside from the filenames in the *treemanifests segment* containing a
   194 Aside from the filenames in the *treemanifests segment* containing a
   173 trailing ``/`` character, it behaves identically to the *filelogs segment*
   195 trailing ``/`` character, it behaves identically to the *filelogs segment*
   174 (see below). The final sub-segment is followed by an *empty chunk* (logically,
   196 (see below). The final sub-segment is followed by an *empty chunk* (logically,
   175 a sub-segment with filename size 0). This denotes the boundary to the
   197 a sub-segment with filename size 0). This denotes the boundary to the
   176 *filelogs segment*.
   198 *filelogs segment*.