dirstate-tree: Avoid BTreeMap double-lookup when inserting a dirstate entry
The child nodes of a given node in the tree-shaped dirstate are kept in a
`BTreeMap` where keys are file names as strings. Finding or inserting a value
in the map takes `O(log(n))` string comparisons, which adds up when constructing
the tree.
The `entry` API allows finding a "spot" in the map that may or may not be
occupied and then access that value or insert a new one without doing map
lookup again. However the current API is limited in that calling `entry`
requires an owned key (and so a memory allocation), even if it ends up not
being used in the case where the map already has a value with an equal key.
This is still a win, with 4% better end-to-end time for `hg status` measured
here with hyperfine:
```
Benchmark #1: ../hg2/hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1
Time (mean ± σ): 1.337 s ± 0.018 s [User: 892.9 ms, System: 437.5 ms]
Range (min … max): 1.316 s … 1.373 s 10 runs
Benchmark #2: ./hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1
Time (mean ± σ): 1.291 s ± 0.008 s [User: 853.4 ms, System: 431.1 ms]
Range (min … max): 1.283 s … 1.309 s 10 runs
Summary
'./hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1' ran
1.04 ± 0.02 times faster than '../hg2/hg status -R $REPO --config=experimental.dirstate-tree.in-memory=1'
```
* ./hg is this revision
* ../hg2/hg is its parent
* $REPO is an old snapshot of mozilla-central
Differential Revision: https://phab.mercurial-scm.org/D10550
Testing recorded "modified" files for merge commit
==================================================
This file shows what hg says are "modified" files for a merge commit
(hg log -T {files}), somewhat exhaustively.
This test file shows merges that involves files contents changing
For merges taht involves executable bit changing, check test-merge-combination-exec-bytes.t
For testing of multiple corner case, check test-merge-combination-misc.t
Case with multiple or zero merge ancestors, copies/renames, and identical file contents
with different filelog revisions are not currently covered.
$ . $TESTDIR/testlib/merge-combination-util.sh
All the merges of various file contents.
$ range () {
> max=0
> for i in $@; do
> if [ $i = - ]; then continue; fi
> if [ $i -gt $max ]; then max=$i; fi
> done
> $TESTDIR/seq.py `expr $max + 1`
> }
$ isgood () { true; }
$ createfile () {
> if [ -f a ] && [ "`cat a`" = $1 ]
> then touch $file
> else echo $v > a
> fi
> }
$ genmerges
1111 : agree on ""
1112 : agree on "a"
111- : agree on "a"
1121 : agree on "a"
1122 : agree on ""
1123 : agree on "a"
112- : agree on "a"
11-1 : hg said "", expected "a"
11-2 : agree on "a"
11-- : agree on ""
1211 : agree on "a"
1212 : agree on ""
1213 : agree on "a"
121- : agree on "a"
1221 : agree on "a"
1222 : agree on ""
1223 : agree on "a"
122- : agree on "a"
1231 C: agree on "a"
1232 C: agree on "a"
1233 C: agree on "a"
1234 C: agree on "a"
123- C: agree on "a"
12-1 C: agree on "a"
12-2 C: hg said "", expected "a"
12-3 C: agree on "a"
12-- C: agree on "a"
1-11 : hg said "", expected "a"
1-12 : agree on "a"
1-1- : agree on ""
1-21 C: agree on "a"
1-22 C: hg said "", expected "a"
1-23 C: agree on "a"
1-2- C: agree on "a"
1--1 : agree on "a"
1--2 : agree on "a"
1--- : agree on ""
-111 : agree on ""
-112 : agree on "a"
-11- : agree on "a"
-121 C: agree on "a"
-122 C: agree on "a"
-123 C: agree on "a"
-12- C: agree on "a"
-1-1 : agree on ""
-1-2 : agree on "a"
-1-- : agree on "a"
--11 : agree on ""
--12 : agree on "a"
--1- : agree on "a"
---1 : agree on "a"
---- : agree on ""