Mercurial > hg
view tests/test-hgk.t @ 28487:98d98a645e9d
changelog: add class to represent parsed changelog revisions
Currently, changelog entries are parsed into their respective
components at read time. Many operations are only interested
in a subset of fields of a changelog entry. The parsing and
storing of all the fields adds avoidable overhead.
This patch introduces the "changelogrevision" class. It takes
changelog raw text and exposes the parsed results as attributes.
The code for parsing changelog entries has been moved into its
construction function. changelog.read() has been modified to use
the new class internally while maintaining its existing API.
Future patches will make revision parsing lazy.
We implement the construction function of the new class with
__new__ instead of __init__ so we can use a named tuple to
represent the empty revision. This saves overhead and complexity
of coercing later versions of this class to represent an empty
instance.
While we are here, we add a method on changelog to obtain an
instance of the new type.
The overhead of constructing the new class regresses performance
of revsets accessing this data:
author(mpm)
0.896565
0.929984
desc(bug)
0.887169
0.935642 105%
date(2015)
0.878797
0.908094
extra(rebase_source)
0.865446
0.922624 106%
author(mpm) or author(greg)
1.801832
1.902112 105%
author(mpm) or desc(bug)
1.812438
1.860977
date(2015) or branch(default)
0.968276
1.005824
author(mpm) or desc(bug) or date(2015) or extra(rebase_source)
3.656193
3.743381
Once lazy parsing is implemented, these revsets will all be faster
than before. There is no performance change on revsets that do not
access this data. There /could/ be a performance regression on
operations that perform several changelog reads. However, I can't
think of anything outside of revsets and `hg log` (basically the
same as a revset) that would be impacted.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Mar 2016 14:28:02 -0800 |
parents | 5fb1fc2e1281 |
children |
line wrap: on
line source
Minimal hgk check $ echo "[extensions]" >> $HGRCPATH $ echo "hgk=" >> $HGRCPATH $ hg init repo $ cd repo $ echo a > a $ hg ci -Am adda adding a $ hg debug-cat-file commit 0 tree a0c8bcbbb45c parent 000000000000 author test 0 0 revision 0 branch default phase draft adda $ echo b > b $ hg ci -Am addb adding b $ hg log -T '{node}\n' 102a90ea7b4a3361e4082ed620918c261189a36a 07f4944404050f47db2e5c5071e0e84e7a27bba9 $ hg debug-diff-tree 07f494440405 102a90ea7b4a :000000 100664 000000000000 1e88685f5dde N b b $ hg debug-diff-tree 07f494440405 102a90ea7b4a --patch diff --git a/b b/b new file mode 100644 --- /dev/null +++ b/b @@ -0,0 +1,1 @@ +b Ensure that diff-tree output isn't affected by diffopts $ hg --config diff.noprefix=True debug-diff-tree 07f494440405 102a90ea7b4a :000000 100664 000000000000 1e88685f5dde N b b $ hg --config diff.noprefix=True debug-diff-tree --patch 07f494440405 102a90ea7b4a diff --git a/b b/b new file mode 100644 --- /dev/null +++ b/b @@ -0,0 +1,1 @@ +b $ cd ..