tests/test-debugcommands.t
author Mads Kiilerich <madski@unity3d.com>
Sun, 12 Jan 2014 23:28:21 +0100
changeset 20244 47d0843647d1
parent 17188 76e55914c303
child 20283 2b96073f3138
permissions -rw-r--r--
util: introduce util.debugstacktrace for showing a stack trace without crashing This is often very handy when hacking/debugging. Calling util.debugstacktrace('hey') from a place in hg will give something like: hey at: ./hg:38 in <module> /home/user/hgsrc/mercurial/dispatch.py:28 in run /home/user/hgsrc/mercurial/dispatch.py:65 in dispatch /home/user/hgsrc/mercurial/dispatch.py:88 in _runcatch /home/user/hgsrc/mercurial/dispatch.py:740 in _dispatch /home/user/hgsrc/mercurial/dispatch.py:514 in runcommand /home/user/hgsrc/mercurial/dispatch.py:830 in _runcommand /home/user/hgsrc/mercurial/dispatch.py:801 in checkargs /home/user/hgsrc/mercurial/dispatch.py:737 in <lambda> /home/user/hgsrc/mercurial/util.py:472 in check ...

  $ hg init debugrevlog
  $ cd debugrevlog
  $ echo a > a
  $ hg ci -Am adda
  adding a
  $ hg debugrevlog -m
  format : 1
  flags  : inline
  
  revisions     :  1
      merges    :  0 ( 0.00%)
      normal    :  1 (100.00%)
  revisions     :  1
      full      :  1 (100.00%)
      deltas    :  0 ( 0.00%)
  revision size : 44
      full      : 44 (100.00%)
      deltas    :  0 ( 0.00%)
  
  avg chain length  : 0
  compression ratio : 0
  
  uncompressed data size (min/max/avg) : 43 / 43 / 43
  full revision size (min/max/avg)     : 44 / 44 / 44
  delta size (min/max/avg)             : 0 / 0 / 0


Test internal debugstacktrace command

  $ cat > debugstacktrace.py << EOF
  > from mercurial.util import debugstacktrace, dst, sys
  > def f():
  >     dst('hello world')
  > def g():
  >     f()
  >     debugstacktrace(skip=-5, f=sys.stdout)
  > g()
  > EOF
  $ python debugstacktrace.py
  hello world at:
   debugstacktrace.py:7 in <module>
   debugstacktrace.py:5 in g
   debugstacktrace.py:3 in f
  stacktrace at:
   debugstacktrace.py:7 *in <module> (glob)
   debugstacktrace.py:6 *in g (glob)
   */util.py:* in debugstacktrace (glob)