Mercurial > hg
view tests/test-encoding.t @ 39018:e793e11e1462
changegroup: introduce requests to define delta generation
Currently, we iterate through each revision we will be producing
a delta for then call into 1 of 2 functions for generating that
delta. Deltas are emitted as we iterate.
A problem with this model is that revision generation is tightly
coupled to the changegroup code. And the storage layer needs to
expose APIs like deltaparent() so changegroup delta generation
can produce a delta with that knowledge.
Another problem is that in this model, deltas can only be produced
sequentially after the previous delta was produced and emitted.
Some storage backends might be capable of producing deltas in
parallel (e.g. if the changegroup deltas are cached somewhere).
This commit aims to solve these problems by turning delta generation
into a 2 phase implementation where the first phase determines
info about all the deltas that need to be generated and the 2nd
phase resolves those deltas.
We introduce a "revisiondeltarequest" object that holds data about
a to-be-generated delta. We perform a full pass over all revisions
whose delta is to be generated and generate a "revisiondeltarequest"
for each. Then we iterate over the "revisiondeltarequest" instances
and derive a "revisiondelta" for each.
This patch was quite large. In order to avoid even more churn, aspects
of the implementation are less than ideal. e.g. we're recording
revision numbers instead of nodes in a few places and we don't
yet have a formal API for resolving an iterable of revisiondeltarequest
instances. Things will be improved in subsequent commits.
Unfortunately, this commit reduces performance substantially. For
`hg perfchangegroupchangelog` on my hg repo:
! wall 1.512607 comb 1.510000 user 1.490000 sys 0.020000 (best of 7)
! wall 2.150863 comb 2.150000 user 2.150000 sys 0.000000 (best of 5)
And for `hg bundle -t none-v2 -a` for the mozilla-unified repo:
178.32user 4.22system 3:02.59elapsed
190.97user 4.17system 3:15.19elapsed
Some of this was attributed to changelog slowdown. `hg
perfchangegroupchangelog` on mozilla-unified:
! wall 21.688715 comb 21.690000 user 21.570000 sys 0.120000 (best of 3)
! wall 25.683659 comb 25.680000 user 25.540000 sys 0.140000 (best of 3)
Profiling seems to reveal that the changelog slowdown is due to reading
changelog revisions multiple times. First in the linknode callback
to resolve the set of files changed. Second in the delta generation.
Before, we likely had hit the last revision cache in the revlog when
doing delta generation since we performed that immediately after
performing the linknode callback.
I'm not exactly sure where the other ~8s are being spent. It might be
from overhead of constructing a few million revisiondeltarequest
objects. I'm OK with the regression for now because it is in service
of a larger cause (storage abstraction). I'll try to profile later
and claw back the performance.
Differential Revision: https://phab.mercurial-scm.org/D4215
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 09 Aug 2018 09:28:26 -0700 |
parents | 035af48b2903 |
children | 89630d0b3e23 |
line wrap: on
line source
Test character encoding $ hg init t $ cd t we need a repo with some legacy latin-1 changesets $ hg unbundle "$TESTDIR/bundles/legacy-encoding.hg" adding changesets adding manifests adding file changes added 2 changesets with 2 changes to 1 files new changesets 1e78a93102a3:0e5b7e3f9c4a (run 'hg update' to get a working copy) $ hg co 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ $PYTHON << EOF > f = open('latin-1', 'wb'); f.write(b"latin-1 e' encoded: \xe9"); f.close() > f = open('utf-8', 'wb'); f.write(b"utf-8 e' encoded: \xc3\xa9"); f.close() > f = open('latin-1-tag', 'wb'); f.write(b"\xe9"); f.close() > EOF should fail with encoding error $ echo "plain old ascii" > a $ hg st M a ? latin-1 ? latin-1-tag ? utf-8 $ HGENCODING=ascii hg ci -l latin-1 transaction abort! rollback completed abort: decoding near ' encoded: \xe9': 'ascii' codec can't decode byte 0xe9 in position 20: ordinal not in range(128)! (esc) [255] these should work $ echo "latin-1" > a $ HGENCODING=latin-1 hg ci -l latin-1 $ echo "utf-8" > a $ HGENCODING=utf-8 hg ci -l utf-8 $ HGENCODING=latin-1 hg tag `cat latin-1-tag` $ HGENCODING=latin-1 hg branch `cat latin-1-tag` marked working directory as branch \xe9 (esc) (branches are permanent and global, did you want a bookmark?) $ HGENCODING=latin-1 hg ci -m 'latin1 branch' $ hg -q rollback $ HGENCODING=latin-1 hg branch \xe9 (esc) $ HGENCODING=latin-1 hg ci -m 'latin1 branch' $ rm .hg/branch hg log (ascii) $ hg --encoding ascii log changeset: 5:a52c0692f24a branch: ? tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin1 branch changeset: 4:94db611b4196 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: Added tag ? for changeset ca661e7520de changeset: 3:ca661e7520de tag: ? user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: utf-8 e' encoded: ? changeset: 2:650c6f3d55dd user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin-1 e' encoded: ? changeset: 1:0e5b7e3f9c4a user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: koi8-r: ????? = u'\u0440\u0442\u0443\u0442\u044c' changeset: 0:1e78a93102a3 user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: latin-1 e': ? = u'\xe9' hg log (latin-1) $ hg --encoding latin-1 log changeset: 5:a52c0692f24a branch: \xe9 (esc) tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin1 branch changeset: 4:94db611b4196 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: Added tag \xe9 for changeset ca661e7520de (esc) changeset: 3:ca661e7520de tag: \xe9 (esc) user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: utf-8 e' encoded: \xe9 (esc) changeset: 2:650c6f3d55dd user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin-1 e' encoded: \xe9 (esc) changeset: 1:0e5b7e3f9c4a user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: koi8-r: \xd2\xd4\xd5\xd4\xd8 = u'\\u0440\\u0442\\u0443\\u0442\\u044c' (esc) changeset: 0:1e78a93102a3 user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: latin-1 e': \xe9 = u'\\xe9' (esc) hg log (utf-8) $ hg --encoding utf-8 log changeset: 5:a52c0692f24a branch: \xc3\xa9 (esc) tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin1 branch changeset: 4:94db611b4196 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: Added tag \xc3\xa9 for changeset ca661e7520de (esc) changeset: 3:ca661e7520de tag: \xc3\xa9 (esc) user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: utf-8 e' encoded: \xc3\xa9 (esc) changeset: 2:650c6f3d55dd user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin-1 e' encoded: \xc3\xa9 (esc) changeset: 1:0e5b7e3f9c4a user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: koi8-r: \xc3\x92\xc3\x94\xc3\x95\xc3\x94\xc3\x98 = u'\\u0440\\u0442\\u0443\\u0442\\u044c' (esc) changeset: 0:1e78a93102a3 user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: latin-1 e': \xc3\xa9 = u'\\xe9' (esc) hg tags (ascii) $ HGENCODING=ascii hg tags tip 5:a52c0692f24a ? 3:ca661e7520de hg tags (latin-1) $ HGENCODING=latin-1 hg tags tip 5:a52c0692f24a \xe9 3:ca661e7520de (esc) hg tags (utf-8) $ HGENCODING=utf-8 hg tags tip 5:a52c0692f24a \xc3\xa9 3:ca661e7520de (esc) hg tags (JSON) $ hg tags -Tjson [ { "node": "a52c0692f24ad921c0a31e1736e7635a8b23b670", "rev": 5, "tag": "tip", "type": "" }, { "node": "ca661e7520dec3f5438a63590c350bebadb04989", "rev": 3, "tag": "\xc3\xa9", (esc) "type": "" } ] hg branches (ascii) $ HGENCODING=ascii hg branches ? 5:a52c0692f24a default 4:94db611b4196 (inactive) hg branches (latin-1) $ HGENCODING=latin-1 hg branches \xe9 5:a52c0692f24a (esc) default 4:94db611b4196 (inactive) hg branches (utf-8) $ HGENCODING=utf-8 hg branches \xc3\xa9 5:a52c0692f24a (esc) default 4:94db611b4196 (inactive) $ echo '[ui]' >> .hg/hgrc $ echo 'fallbackencoding = koi8-r' >> .hg/hgrc hg log (utf-8) $ HGENCODING=utf-8 hg log changeset: 5:a52c0692f24a branch: \xc3\xa9 (esc) tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin1 branch changeset: 4:94db611b4196 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: Added tag \xc3\xa9 for changeset ca661e7520de (esc) changeset: 3:ca661e7520de tag: \xc3\xa9 (esc) user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: utf-8 e' encoded: \xc3\xa9 (esc) changeset: 2:650c6f3d55dd user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: latin-1 e' encoded: \xc3\xa9 (esc) changeset: 1:0e5b7e3f9c4a user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: koi8-r: \xd1\x80\xd1\x82\xd1\x83\xd1\x82\xd1\x8c = u'\\u0440\\u0442\\u0443\\u0442\\u044c' (esc) changeset: 0:1e78a93102a3 user: test date: Mon Jan 12 13:46:40 1970 +0000 summary: latin-1 e': \xd0\x98 = u'\\xe9' (esc) hg log (dolphin) $ HGENCODING=dolphin hg log abort: unknown encoding: dolphin (please check your locale settings) [255] $ HGENCODING=ascii hg branch `cat latin-1-tag` abort: decoding near '\xe9': 'ascii' codec can't decode byte 0xe9 in position 0: ordinal not in range(128)! (esc) [255] $ cp latin-1-tag .hg/branch $ HGENCODING=latin-1 hg ci -m 'auto-promote legacy name' Test roundtrip encoding of lookup tables when not using UTF-8 (issue2763) $ HGENCODING=latin-1 hg up `cat latin-1-tag` 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ cd .. Test roundtrip encoding/decoding of utf8b for generated data #if hypothesis >>> from hypothesishelpers import * >>> from mercurial import encoding >>> roundtrips(st.binary(), encoding.fromutf8b, encoding.toutf8b) Round trip OK #endif