tests/test-dispatch.py
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 09 Oct 2016 01:03:20 +0900
changeset 30150 c0410814002f
parent 28405 1d9d29d4813a
child 36374 f0c94af0d70d
permissions -rw-r--r--
perf: make perftags clear tags cache correctly Before this patch, "hg perftags" command doesn't measure performance of "repo.tags()" correctly, because it doesn't clear tags cache correctly. 9dca7653b525 replaced repo._tags with repo._tagscache, but didn't change the code path to clear tags cache in perftags() at that time. BTW, full history of "tags cache" is: - d7df759d0e97 (or 0.6) introduced repo.tagscache as the first "tags cache" - 5614a628d173 (or 1.4) replaced repo.tagscache with repo._tags - 9dca7653b525 (or 2.0) replaced repo._tags with repo._tagscache - 98c867ac1330 (or 2.5) made repo._tagscache filteredpropertycache To make perftags clear tags cache correctly, and to increase "historical portability" of perftags, this patch examines existence of attributes in repo object, and guess appropriate procedure to clear tags cache. To avoid examining existence of attributes at each repetition, this patch makes repocleartagscachefunc() return the function, which actually clears tags cache. mozilla-central repo (85 tags on 308365 revs) with each Mercurial version between before and after this patch. ==== ========= ========= ver before after ==== ========= ========= 1.9 0.476062 0.466464 ------- *1 ------- 2.0 0.346309 0.458327 2.1 0.343106 0.454489 ------- *2 ------- 2.2 0.069790 0.071263 2.3 0.067829 0.069340 2.4 0.068075 0.069573 ------- *3 ------- 2.5 0.021896 0.022406 2.6 0.021900 0.022374 2.7 0.021883 0.022379 2.8 0.021949 0.022327 2.9 0.021877 0.022330 3.0 0.021860 0.022314 3.1 0.021869 0.022669 3.2 0.021831 0.022668 3.3 0.021809 0.022691 3.4 0.021861 0.022916 3.5 0.019335 0.020749 3.6 0.019319 0.020866 3.7 0.018781 0.020251 ------- *4 ------- 3.8 0.068262 0.072558 3.9 0.069682 0.073773 ==== ========= ========= (*1) repo._tags was replaced with repo._tagscache at this point "repo._tags = None" in perftags "before" this patch doesn't clear tags cache for Mercurial 2.0 or later. This causes significant gap of "before" between 1.9 and 2.0 . (*2) I'm not sure about significant gap at this point, but release note of 2.2 described "a number of significant performance improvements for large repositories" (*3) filtered changelog was cached in repoview as repoview.changelog at this point (by 4d92e2d75cff) This avoids calculation of filtered changelog at each repetition of t(). (*4) calculation of filtered changelog was included into wall time at this point (by 332926212ef8), again See below for detail about this significant gap: https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-April/083410.html
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28405
1d9d29d4813a tests: test-dispatch use print_function
timeless <timeless@mozdev.org>
parents: 28404
diff changeset
     1
from __future__ import absolute_import, print_function
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     2
import os
28404
06245740b408 tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents: 14438
diff changeset
     3
from mercurial import (
06245740b408 tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents: 14438
diff changeset
     4
    dispatch,
06245740b408 tests: test-dispatch use absolute_import
timeless <timeless@mozdev.org>
parents: 14438
diff changeset
     5
)
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     6
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
     7
def testdispatch(cmd):
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
     8
    """Simple wrapper around dispatch.dispatch()
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
     9
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    10
    Prints command and result value, but does not handle quoting.
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    11
    """
28405
1d9d29d4813a tests: test-dispatch use print_function
timeless <timeless@mozdev.org>
parents: 28404
diff changeset
    12
    print("running: %s" % (cmd,))
14438
08bfec2ef031 dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents: 9031
diff changeset
    13
    req = dispatch.request(cmd.split())
08bfec2ef031 dispatch: wrap dispatch related information in a request class
Idan Kamara <idankk86@gmail.com>
parents: 9031
diff changeset
    14
    result = dispatch.dispatch(req)
28405
1d9d29d4813a tests: test-dispatch use print_function
timeless <timeless@mozdev.org>
parents: 28404
diff changeset
    15
    print("result: %r" % (result,))
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    16
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
    17
testdispatch("init test1")
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    18
os.chdir('test1')
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    19
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    20
# create file 'foo', add and commit
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 5178
diff changeset
    21
f = open('foo', 'wb')
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    22
f.write('foo\n')
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    23
f.close()
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
    24
testdispatch("add foo")
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
    25
testdispatch("commit -m commit1 -d 2000-01-01 foo")
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    26
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    27
# append to file 'foo' and commit
9031
3b76321aa0de compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents: 5178
diff changeset
    28
f = open('foo', 'ab')
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    29
f.write('bar\n')
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    30
f.close()
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
    31
testdispatch("commit -m commit2 -d 2000-01-02 foo")
5095
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    32
f3f033def181 Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
    33
# check 88803a69b24 (fancyopts modified command table)
5178
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
    34
testdispatch("log -r 0")
18a9fbb5cd78 dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents: 5095
diff changeset
    35
testdispatch("log -r tip")