mercurial/helptext/evolution.txt
author Martin von Zweigbergk <martinvonz@google.com>
Tue, 18 Jan 2022 13:05:21 -0800
changeset 48981 f3aafd785e65
parent 47017 da4e6d7a8fdd
permissions -rw-r--r--
filemerge: add support for partial conflict resolution by external tool A common class of merge conflicts is in imports/#includes/etc. It's relatively easy to write a tool that can resolve these conflicts, perhaps by naively just unioning the statements and leaving any cleanup to other tools to do later [1]. Such specialized tools cannot generally resolve all conflicts in a file, of course. Let's therefore call them "partial merge tools". Note that the internal simplemerge algorithm is such a partial merge tool - one that only resolves trivial "conflicts" where one side is unchanged or both sides change in the same way. One can also imagine having smarter language-aware partial tools that merge the AST. It may be useful for such tools to interactively let the user resolve any conflicts it can't resolve itself. However, having the option of implementing it as a partial merge tool means that the developer doesn't *need* to create a UI for it. Instead, the user can resolve any remaining conflicts with their regular merge tool (e.g. `:merge3` or `meld). We don't currently have a way to let the user define such partial merge tools. That's what this patch addresses. It lets the user configure partial merge tools to run. Each tool can be configured to run only on files matching certain patterns (e.g. "*.py"). The tool takes three inputs (local, base, other) and resolves conflicts by updating these in place. For example, let's say the inputs are these: base: ``` import sys def main(): print('Hello') ``` local: ``` import os import sys def main(): print('Hi') ``` other: ``` import re import sys def main(): print('Howdy') ``` A partial merge tool could now resolve the conflicting imports by replacing the import statements in *all* files by the following snippet, while leaving the remainder of the files unchanged. ``` import os import re import sys ``` As a result, simplemerge and any regular merge tool that runs after the partial merge tool(s) will consider the imports to be non-conflicting and will only present the conflict in `main()` to the user. Differential Revision: https://phab.mercurial-scm.org/D12356
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47017
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     1
Obsolescence markers make it possible to mark changesets that have been
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     2
deleted or superseded in a new version of the changeset.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     3
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     4
Unlike the previous way of handling such changes, by stripping the old
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     5
changesets from the repository, obsolescence markers can be propagated
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     6
between repositories. This allows for a safe and simple way of exchanging
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     7
mutable history and altering it after the fact. Changeset phases are
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     8
respected, such that only draft and secret changesets can be altered (see
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
     9
:hg:`help phases` for details).
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    10
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    11
Obsolescence is tracked using "obsolescence markers", a piece of metadata
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    12
tracking which changesets have been made obsolete, potential successors for
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    13
a given changeset, the moment the changeset was marked as obsolete, and the
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    14
user who performed the rewriting operation. The markers are stored
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    15
separately from standard changeset data can be exchanged without any of the
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    16
precursor changesets, preventing unnecessary exchange of obsolescence data.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    17
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    18
The complete set of obsolescence markers describes a history of changeset
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    19
modifications that is orthogonal to the repository history of file
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    20
modifications. This changeset history allows for detection and automatic
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    21
resolution of edge cases arising from multiple users rewriting the same part
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    22
of history concurrently.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    23
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    24
Current feature status
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    25
======================
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    26
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    27
This feature is still in development.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    28
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    29
Instability
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    30
===========
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    31
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    32
Rewriting changesets might introduce instability.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    33
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    34
There are two main kinds of instability: orphaning and diverging.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    35
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    36
Orphans are changesets left behind when their ancestors are rewritten.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    37
Divergence has two variants:
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    38
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    39
* Content-divergence occurs when independent rewrites of the same changesets
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    40
  lead to different results.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    41
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    42
* Phase-divergence occurs when the old (obsolete) version of a changeset
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    43
  becomes public.
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    44
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    45
It is possible to prevent local creation of orphans by using the following config::
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    46
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    47
    [experimental]
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    48
    evolution.createmarkers = true
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    49
    evolution.exchange = true
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    50
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    51
You can also enable that option explicitly::
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    52
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    53
    [experimental]
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    54
    evolution.createmarkers = true
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    55
    evolution.exchange = true
da4e6d7a8fdd help: add topic about evolution, based on text from evolve extension
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
    56
    evolution.allowunstable = true