sapling/eden/scm/tests/test-word-merge.t
Jun Wu ccf5b813b6 merge: add a word merge feature
Summary:
This helps solving certain conflicts efficiently. For example, rebasing
D32800583 (66a7c13139) V3 caused a lot of conflicts like:

    <<<<<<< dest:   cf04306ad6ac - quark: [hg] edenapi: use "reponame" associated...
                .allow_threads(|| block_unless_interrupted(api.files_attrs(repo, spec.0))
    =======
                .allow_threads(|| block_unless_interrupted(inner.files_attrs(spec.0)))
    >>>>>>> source: e4fbe1289312 - quark: [hg] edenapi: drop reponame from edenap...

These conflicts are "obvious" to resolve using word-level diff and merge.

Run ordinary line-based merge algorithm, for each conflicted region, try
word-based merge algorithm. If it works, then pick the result. Otherwise
still show line-based conflicts.

The word merge feature is off by default so it won't affect existing behaviors.

Reviewed By: mitrandir77

Differential Revision: D10456947

fbshipit-source-id: 30f942ed2b26b2efba1d37a078e5b57ee3a56dcc
2021-12-17 09:12:42 -08:00

79 lines
1.9 KiB
Perl

#chg-compatible
$ configure modern
$ enable rebase
$ setconfig merge.word-merge=1
Successful word merge:
$ newrepo
$ drawdag <<'EOS'
> B C # C/A=That is a word.\n
> |/ # B/A=This IS a sentence.\n
> A # A/A=This is a sentence.\n
> EOS
$ hg rebase -r $C -d $B -q
$ hg cat -r tip A
That IS a word.
Unsuccessful. Still show conflicts at line boundary:
$ newrepo
$ drawdag <<'EOS'
> B C # C/A=Those are one kind of sentences.\n
> |/ # B/A=That is one sentence.\n
> A # A/A=This is a sentence.\n
> EOS
$ hg rebase -r $C -d $B -q
warning: 1 conflicts while merging A! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ cat A
<<<<<<< dest: 952e28cce513 - test: B
That is one sentence.
=======
Those are one kind of sentences.
>>>>>>> source: 5f8b40280adf - test: C
Partially successful at the second conflict region.
$ newrepo
$ drawdag <<'EOS'
> B C # C/A=Bar.\n\nThis is a second line.\n
> |/ # B/A=Foo.\n\nThat is the second line.\n
> A # A/A=First line.\n\nThis is the second line.\n
> EOS
$ hg rebase -r $C -d $B -q
warning: 1 conflicts while merging A! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ cat A
<<<<<<< dest: f32bfbad7819 - test: B
Foo.
=======
Bar.
>>>>>>> source: 141643ae4b3c - test: C
That is a second line.
Conflicted case. Example is from a sparse related test.
$ newrepo
$ drawdag <<'EOS'
> B C # C/A=[include]\n*.py\n*.txt\n
> |/ # B/A=[include]\n*.html\n
> A # A/A=[include]\n*.py\n
> EOS
$ hg rebase -r $C -d $B -q
warning: 1 conflicts while merging A! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
[1]
$ cat A
[include]
<<<<<<< dest: fbfdba3e838e - test: B
*.html
=======
*.py
*.txt
>>>>>>> source: f4337c9b9462 - test: C