perf: define formatter locally for Mercurial earlier than 2.2
Before this patch, using ui.formatter() prevents perf.py from
measuring performance with Mercurial earlier than 2.2 (or
ae5f92e154d3), because ui.formatter() isn't available in such
Mercurial, even though there are some code paths for Mercurial earlier
than 2.2 in perf.py.
For example, setting "_prereadsize" attribute in perfindex() and
perfnodelookup() is effective only with hg earlier than 1.8 (or
61c9bc3da402).
This patch defines formatter class locally, and use it instead of the
value returned by ui.formatter(), if perf.py is used with Mercurial
earlier than 2.2.
In this case, we don't need to think about -T/--template option for
formatter, because previous patch made -T/--template disabled for
perf.py with Mercurial earlier than 3.2 (or
7a7eed5176a4).
$ hg init base
$ cd base
$ echo 'alpha' > alpha
$ hg ci -A -m 'add alpha'
adding alpha
$ cd ..
$ hg clone base work
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd work
$ echo 'beta' > beta
$ hg ci -A -m 'add beta'
adding beta
$ cd ..
$ cd base
$ echo 'gamma' > gamma
$ hg ci -A -m 'add gamma'
adding gamma
$ cd ..
$ cd work
$ hg pull -q
$ hg merge
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
Update --clean to revision 1 to simulate a failed merge:
$ rm alpha beta gamma
$ hg update --clean 1
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd ..