contrib/debugshell.py
author Pierre-Yves David <pierre-yves.david@fb.com>
Fri, 16 May 2014 13:18:57 -0700
changeset 21424 d13b4ecdb680
parent 21243 8b5c039f2b4f
child 27721 e4b512bb6386
permissions -rw-r--r--
test: split test-largefile.t in multiple file The `test-largefiles.t` unified test is significantly longer (about 30%) than any other tests in the mercurial test suite. As a result, its is alway the last test my test runner is waiting for at the end of a run. In practice, this means that `test-largefile.t` is wasting half a minute of my life every times I'm running the mercurial test suites. This probably mean more a few cumulated day by now. I've finally decided to split it up in multiple smaller tests to bring it back in reasonable length. This changeset extracts independent test cases in two files. One dedicated to wire protocole testing, and another one dedicated to all other tests that could be independently extracted. No test case were haltered in the making of this changeset. Various timing available below. All timing have been done on a with 90 jobs on a 64 cores machine. Similar result are shown on firefly (20 jobs on 12 core). General timing of the whole run -------------------------------- We see a 25% real time improvement for no significant cpu time impact. Before split: real 2m1.149s user 58m4.662s sys 11m28.563s After split: real 1m31.977s user 57m45.993s sys 11m33.634s Last test to finish (using run-test.py --time) ---------------------------------------------- test-largefile.t is now finishing at the same time than other slow tests. Before split: Time Test 119.280 test-largefiles.t 93.995 test-mq.t 89.897 test-subrepo.t 86.920 test-glog.t 85.508 test-rename-merge2.t 83.594 test-revset.t 79.824 test-keyword.t 78.077 test-mq-header-date.t After split: Time Test 90.414 test-mq.t 88.594 test-largefiles.t 85.363 test-subrepo.t 81.059 test-glog.t 78.927 test-rename-merge2.t 78.021 test-revset.t 77.777 test-command-template.t Timing of largefile test themself ----------------------------------- Running only tests prefixed with "test-largefiles". No significant change in cumulated time. Before: Time Test 58.673 test-largefiles.t 2.931 test-largefiles-cache.t 0.583 test-largefiles-small-disk.t After: Time Test 31.754 test-largefiles.t 17.460 test-largefiles-misc.t 8.888 test-largefiles-wireproto.t 2.864 test-largefiles-cache.t 0.580 test-largefiles-small-disk.t
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11633
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
     1
# debugshell extension
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
     2
"""a python shell with repo, changelog & manifest objects"""
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
     3
19773
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
     4
import sys
11633
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
     5
import mercurial
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
     6
import code
21243
8b5c039f2b4f debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 19794
diff changeset
     7
from mercurial import cmdutil
8b5c039f2b4f debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 19794
diff changeset
     8
8b5c039f2b4f debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 19794
diff changeset
     9
cmdtable = {}
8b5c039f2b4f debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 19794
diff changeset
    10
command = cmdutil.command(cmdtable)
11633
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    11
19771
3bc675361206 debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents: 11633
diff changeset
    12
def pdb(ui, repo, msg, **opts):
11633
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    13
    objects = {
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    14
        'mercurial': mercurial,
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    15
        'repo': repo,
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    16
        'cl': repo.changelog,
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    17
        'mf': repo.manifest,
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    18
    }
19771
3bc675361206 debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents: 11633
diff changeset
    19
3bc675361206 debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents: 11633
diff changeset
    20
    code.interact(msg, local=objects)
3bc675361206 debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents: 11633
diff changeset
    21
19772
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    22
def ipdb(ui, repo, msg, **opts):
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    23
    import IPython
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    24
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    25
    cl = repo.changelog
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    26
    mf = repo.manifest
19794
cccc44304b2c debugshell: appease pyflakes
Matt Mackall <mpm@selenic.com>
parents: 19773
diff changeset
    27
    cl, mf # use variables to appease pyflakes
19772
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    28
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    29
    IPython.embed()
6ccec36a1fd9 debugshell: add function to embed ipython
Sean Farley <sean.michael.farley@gmail.com>
parents: 19771
diff changeset
    30
21243
8b5c039f2b4f debugshell: declare command using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents: 19794
diff changeset
    31
@command('debugshell|dbsh', [])
19771
3bc675361206 debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents: 11633
diff changeset
    32
def debugshell(ui, repo, **opts):
11633
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    33
    bannermsg = "loaded repo : %s\n" \
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    34
                "using source: %s" % (repo.root,
6b7b99867ada contrib: add debugshell extension
Vishakh H <vsh426@gmail.com>
parents:
diff changeset
    35
                                      mercurial.__path__[0])
19771
3bc675361206 debugshell: abstract out pdb code.interact
Sean Farley <sean.michael.farley@gmail.com>
parents: 11633
diff changeset
    36
19773
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    37
    pdbmap = {
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    38
        'pdb'  : 'code',
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    39
        'ipdb' : 'IPython'
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    40
    }
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    41
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    42
    debugger = ui.config("ui", "debugger")
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    43
    if not debugger:
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    44
        debugger = 'pdb'
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    45
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    46
    # if IPython doesn't exist, fallback to code.interact
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    47
    try:
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    48
        __import__(pdbmap[debugger])
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    49
    except ImportError:
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    50
        ui.warn("%s debugger specified but %s module was not found\n"
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    51
                % (debugger, pdbmap[debugger]))
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    52
        debugger = 'pdb'
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    53
51799a965446 debugshell: check ui.debugger for which debugger to use
Sean Farley <sean.michael.farley@gmail.com>
parents: 19772
diff changeset
    54
    getattr(sys.modules[__name__], debugger)(ui, repo, bannermsg, **opts)