tests/test-empty.t
author Martin von Zweigbergk <martinvonz@google.com>
Tue, 18 Jan 2022 13:05:21 -0800
changeset 48981 f3aafd785e65
parent 48669 7ee07e1a25c0
child 49825 2f2682f40ea0
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:
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     1
Create an empty repo:
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     2
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     3
  $ hg init a
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     4
  $ cd a
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     5
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     6
Try some commands:
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     7
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     8
  $ hg log
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
     9
  $ hg grep wah
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 11743
diff changeset
    10
  [1]
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    11
  $ hg manifest
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    12
  $ hg verify
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    13
  checking changesets
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    14
  checking manifests
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    15
  crosschecking files in changesets and manifests
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    16
  checking files
39489
f1186c292d03 verify: make output less confusing (issue5924)
Meirambek Omyrzak <meirambek77@gmail.com>
parents: 19929
diff changeset
    17
  checked 0 changesets with 0 changes to 0 files
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    18
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    19
Check the basic files created:
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    20
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    21
  $ ls .hg
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    22
  00changelog.i
40793
64cdfcc73706 cache: create `cache` directory at init time
Boris Feld <boris.feld@octobus.net>
parents: 39489
diff changeset
    23
  cache
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    24
  requires
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    25
  store
40794
d5622dfe4ba3 cache: create `wcache` directory at init time
Boris Feld <boris.feld@octobus.net>
parents: 40793
diff changeset
    26
  wcache
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    27
48669
7ee07e1a25c0 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47447
diff changeset
    28
Should be empty (except for the "basic" requires):
1338
2b77ea66fe70 Add empty repo test
mpm@selenic.com
parents:
diff changeset
    29
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    30
  $ ls .hg/store
48669
7ee07e1a25c0 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47447
diff changeset
    31
  requires
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    32
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    33
Poke at a clone:
6944
7e5f3480c45b fix regression on empty repo cloning introduced by 0642d9d7ec80
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1338
diff changeset
    34
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    35
  $ cd ..
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    36
  $ hg clone a b
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    37
  updating to branch default
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    38
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    39
  $ cd b
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    40
  $ hg verify
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    41
  checking changesets
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    42
  checking manifests
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    43
  crosschecking files in changesets and manifests
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    44
  checking files
39489
f1186c292d03 verify: make output less confusing (issue5924)
Meirambek Omyrzak <meirambek77@gmail.com>
parents: 19929
diff changeset
    45
  checked 0 changesets with 0 changes to 0 files
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    46
  $ ls .hg
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    47
  00changelog.i
46314
95a615dd77bf clone: make sure we warm the cache after a clone
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 40794
diff changeset
    48
  cache
47447
377d8fc20e34 clone: reuse the stream clone logic for local clone
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47442
diff changeset
    49
  dirstate
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    50
  hgrc
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    51
  requires
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    52
  store
47442
d1c1fd7ac46d clone: use "official" API to create local clone destination
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 46314
diff changeset
    53
  wcache
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    54
48669
7ee07e1a25c0 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47447
diff changeset
    55
Should be empty (except for the "basic" requires):
11743
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    56
fc12420efcf4 tests: unify test-empty
Matt Mackall <mpm@selenic.com>
parents: 6944
diff changeset
    57
  $ ls .hg/store
48669
7ee07e1a25c0 share-safe: enable by default (BC)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47447
diff changeset
    58
  requires
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 12316
diff changeset
    59
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 12316
diff changeset
    60
  $ cd ..