tests/test-progress.t
author Brodie Rao <brodie@bitheap.org>
Mon, 19 Sep 2011 15:58:03 -0700
changeset 15141 16dc9a32ca04
parent 14838 5d261fd00446
child 15372 695ac6aca77f
permissions -rw-r--r--
mdiff: speed up showfunc for large diffs This addresses the following issues with showfunc: - Silly usage of regular expressions. - Doing str.rstrip() needlessly in an inner loop. - Doing catastrophic backtracking when trying to find a function line. Finding function text is now at worst O(n lines in the old file), and at best close to O(n hunks). Given a diff like this[1]: src/main/antlr3/uk/ac/cam/ch/wwmm/pregenerated/ChemicalChunker.g | 4 +- src/main/java/uk/ac/cam/ch/wwmm/pregenerated/ChemicalChunkerLexer.java | 2 +- src/main/java/uk/ac/cam/ch/wwmm/pregenerated/ChemicalChunkerParser.java | 29189 +++++---- 3 files changed, 14741 insertions(+), 14454 deletions(-) [1]: https://bitbucket.org/wwmm/chemicaltagger/changeset/d2bfbaecd4fc/raw Without this change, hg log --stat --config diff.showfunc=1 takes an absurdly long time to complete: CallCount Recursive Total(ms) Inline(ms) module:lineno(function) 32813 0 80.3546 40.6086 mercurial.mdiff:160(yieldhunk) +65062746 0 25.7227 25.7227 +<method 'match' of '_sre.SRE_Pattern' objects> +65062746 0 14.0221 14.0221 +<method 'rstrip' of 'str' objects> +1809 0 0.0009 0.0009 +mercurial.mdiff:148(contextend) +1809 0 0.0003 0.0003 +<len> 65062746 0 25.7227 25.7227 <method 'match' of '_sre.SRE_Pattern' objects> 65062763 0 14.0221 14.0221 <method 'rstrip' of 'str' objects> 543 0 0.1631 0.1631 <zlib.decompress> 3 0 0.0505 0.0505 <mercurial.bdiff.blocks> 31007 0 80.4564 0.0477 mercurial.mdiff:147(_unidiff) +32813 0 80.3546 40.6086 +mercurial.mdiff:160(yieldhunk) +3 0 0.0505 0.0505 +<mercurial.bdiff.blocks> +3618 0 0.0022 0.0022 +mercurial.mdiff:154(contextstart) +5427 0 0.0013 0.0013 +<len> +3 0 0.0001 0.0000 +re:188(compile) 1 0 80.8381 0.0322 mercurial.patch:1777(diffstatdata) +107499 0 0.0235 0.0235 +<method 'startswith' of 'str' objects> +31014 0 80.7820 0.0071 +mercurial.util:1284(iterlines) +3 0 0.0000 0.0000 +<method 'search' of '_sre.SRE_Pattern' objects> +4 0 0.0000 0.0000 +mercurial.patch:1783(addresult) +3 0 0.0000 0.0000 +<method 'group' of '_sre.SRE_Match' objects> 6 0 0.0444 0.0283 mercurial.mdiff:12(splitnewlines) +6 0 0.0160 0.0160 +<method 'split' of 'str' objects> 32 0 0.0246 0.0246 <method 'update' of '_hashlib.HASH' objects> 11 0 0.0236 0.0236 <method 'read' of 'file' objects> Time: real 80.880 secs (user 80.200+0.000 sys 0.380+0.000) With this change, it's almost as fast as not using showfunc at all: CallCount Recursive Total(ms) Inline(ms) module:lineno(function) 543 0 0.1699 0.1699 <zlib.decompress> 3 0 0.0501 0.0501 <mercurial.bdiff.blocks> 32813 0 0.0415 0.0348 mercurial.mdiff:161(yieldhunk) +70837 0 0.0058 0.0058 +<method 'isalnum' of 'str' objects> +1809 0 0.0006 0.0006 +mercurial.mdiff:148(contextend) +1809 0 0.0002 0.0002 +<len> 1 0 0.4879 0.0310 mercurial.patch:1777(diffstatdata) +107499 0 0.0230 0.0230 +<method 'startswith' of 'str' objects> +31014 0 0.4335 0.0065 +mercurial.util:1284(iterlines) +3 0 0.0000 0.0000 +<method 'search' of '_sre.SRE_Pattern' objects> +4 0 0.0000 0.0000 +mercurial.patch:1783(addresult) +1 0 0.0004 0.0000 +re:188(compile) 32 0 0.0293 0.0293 <method 'update' of '_hashlib.HASH' objects> 6 0 0.0427 0.0279 mercurial.mdiff:12(splitnewlines) +6 0 0.0147 0.0147 +<method 'split' of 'str' objects> 31007 0 0.1169 0.0235 mercurial.mdiff:147(_unidiff) +3 0 0.0501 0.0501 +<mercurial.bdiff.blocks> +32813 0 0.0415 0.0348 +mercurial.mdiff:161(yieldhunk) +3618 0 0.0012 0.0012 +mercurial.mdiff:154(contextstart) +5427 0 0.0006 0.0006 +<len> 107597 0 0.0230 0.0230 <method 'startswith' of 'str' objects> 16 0 0.0213 0.0213 <mercurial.mpatch.patches> 194 0 0.0149 0.0149 <method 'split' of 'str' objects> Time: real 0.530 secs (user 0.450+0.000 sys 0.070+0.000)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     1
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     2
  $ cat > loop.py <<EOF
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     3
  > from mercurial import commands
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     4
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     5
  > def loop(ui, loops, **opts):
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     6
  >     loops = int(loops)
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     7
  >     total = None
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     8
  >     if loops >= 0:
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
     9
  >         total = loops
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    10
  >     if opts.get('total', None):
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    11
  >         total = int(opts.get('total'))
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    12
  >     nested = False
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    13
  >     if opts.get('nested', None):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    14
  >         nested = True
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    15
  >     loops = abs(loops)
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    16
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    17
  >     for i in range(loops):
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    18
  >         ui.progress('loop', i, 'loop.%d' % i, 'loopnum', total)
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    19
  >         if opts.get('parallel'):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    20
  >             ui.progress('other', i, 'other.%d' % i, 'othernum', total)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    21
  >         if nested:
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    22
  >             for j in range(2):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    23
  >                 ui.progress('nested', j, 'nested.%d' % j, 'nestnum', 2)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    24
  >             ui.progress('nested', None, 'nested.done', 'nestnum', 2)
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    25
  >     ui.progress('loop', None, 'loop.done', 'loopnum', total)
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    26
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    27
  > commands.norepo += " loop"
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    28
  > 
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    29
  > cmdtable = {
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    30
  >     "loop": (loop, [('', 'total', '', 'override for total'),
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    31
  >                     ('', 'nested', False, 'show nested results'),
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    32
  >                     ('', 'parallel', False, 'show parallel sets of results'),
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    33
  >                    ],
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    34
  >              'hg loop LOOPS'),
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    35
  > }
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    36
  > EOF
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    37
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    38
  $ echo "[extensions]" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    39
  $ echo "progress=" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    40
  $ echo "loop=`pwd`/loop.py" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    41
  $ echo "[progress]" >> $HGRCPATH
13149
735dd8e8a208 progress using tests: disable time estimates to avoid flakiness
Augie Fackler <durin42@gmail.com>
parents: 13145
diff changeset
    42
  $ echo  "format = topic bar number" >> $HGRCPATH
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    43
  $ echo "assume-tty=1" >> $HGRCPATH
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    44
  $ echo "width=60" >> $HGRCPATH
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    45
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    46
test default params, display nothing because of delay
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    47
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
    48
  $ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    49
  
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    50
  $ echo "delay=0" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    51
  $ echo "refresh=0" >> $HGRCPATH
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    52
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    53
test with delay=0, refresh=0
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    54
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
    55
  $ hg -y loop 3 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    56
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    57
  loop [                                                ] 0/3
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    58
  loop [===============>                                ] 1/3
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    59
  loop [===============================>                ] 2/3
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
    60
                                                              \r (esc)
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    61
14838
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    62
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    63
test nested short-lived topics (which shouldn't display with nestdelay):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    64
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    65
  $ hg -y loop 3 --nested 2>&1 | \
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    66
  > python $TESTDIR/filtercr.py
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    67
  
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    68
  loop [                                                ] 0/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    69
  loop [===============>                                ] 1/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    70
  loop [===============================>                ] 2/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    71
                                                              \r (esc)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    72
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    73
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    74
  $ hg --config progress.changedelay=0 -y loop 3 --nested 2>&1 | \
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    75
  > python $TESTDIR/filtercr.py
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    76
  
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    77
  loop [                                                ] 0/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    78
  nested [                                              ] 0/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    79
  nested [======================>                       ] 1/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    80
  loop [===============>                                ] 1/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    81
  nested [                                              ] 0/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    82
  nested [======================>                       ] 1/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    83
  loop [===============================>                ] 2/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    84
  nested [                                              ] 0/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    85
  nested [======================>                       ] 1/2
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    86
                                                              \r (esc)
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    87
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    88
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    89
test two topics being printed in parallel (as when we're doing a local
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    90
--pull clone, where you get the unbundle and bundle progress at the
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    91
same time):
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    92
  $ hg loop 3 --parallel 2>&1 | python $TESTDIR/filtercr.py
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    93
  
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    94
  loop [                                                ] 0/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    95
  loop [===============>                                ] 1/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    96
  loop [===============================>                ] 2/3
5d261fd00446 progress: add a changedelay to prevent parallel topics from flapping (issue2698)
Augie Fackler <durin42@gmail.com>
parents: 13236
diff changeset
    97
                                                              \r (esc)
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
    98
test refresh is taken in account
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    99
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   100
  $ hg -y --config progress.refresh=100 loop 3 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   101
  
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   102
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   103
test format options 1
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   104
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   105
  $ hg -y --config 'progress.format=number topic item+2' loop 2 2>&1 \
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   106
  > | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   107
  
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   108
  0/2 loop lo
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   109
  1/2 loop lo
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   110
                                                              \r (esc)
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   111
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   112
test format options 2
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   113
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   114
  $ hg -y --config 'progress.format=number item-3 bar' loop 2 2>&1 \
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   115
  > | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   116
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   117
  0/2 p.0 [                                                 ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   118
  1/2 p.1 [=======================>                         ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   119
                                                              \r (esc)
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   120
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   121
test format options and indeterminate progress
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   122
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   123
  $ hg -y --config 'progress.format=number item bar' loop -- -2 2>&1 \
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   124
  > | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   125
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   126
  0 loop.0               [ <=>                              ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   127
  1 loop.1               [  <=>                             ]
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   128
                                                              \r (esc)
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   129
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   130
make sure things don't fall over if count > total
10465
5d7e84e7ac6d Add test for progress extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
   131
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   132
  $ hg -y loop --total 4 6 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   133
  
13142
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   134
  loop [                                                ] 0/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   135
  loop [===========>                                    ] 1/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   136
  loop [=======================>                        ] 2/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   137
  loop [===================================>            ] 3/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   138
  loop [===============================================>] 4/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   139
  loop [ <=>                                            ] 5/4
e9827c85c50b progress: test setting progress.width
Martin Geisler <mg@aragost.com>
parents: 13141
diff changeset
   140
                                                              \r (esc)
10891
83af68e38be3 progress: fall back to indeterminate progress if position is >= total
Augie Fackler <durin42@gmail.com>
parents: 10788
diff changeset
   141
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   142
test immediate progress completion
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   143
13141
6cfe17c19ba2 tests: add filtercr.py helper for progress tests
Martin Geisler <mg@aragost.com>
parents: 12942
diff changeset
   144
  $ hg -y loop 0 2>&1 | $TESTDIR/filtercr.py
12479
2f9ef3657730 tests: unify test-progress
Matt Mackall <mpm@selenic.com>
parents: 10891
diff changeset
   145
  
13145
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   146
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   147
test delay time estimates
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   148
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   149
  $ cat > mocktime.py <<EOF
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   150
  > import os
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   151
  > import time
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   152
  > 
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   153
  > class mocktime(object):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   154
  >     def __init__(self, increment):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   155
  >         self.time = 0
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   156
  >         self.increment = increment
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   157
  >     def __call__(self):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   158
  >         self.time += self.increment
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   159
  >         return self.time
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   160
  > 
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   161
  > def uisetup(ui):
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   162
  >     time.time = mocktime(int(os.environ.get('MOCKTIME', '11')))
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   163
  > EOF
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   164
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   165
  $ echo "[extensions]" > $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   166
  $ echo "mocktime=`pwd`/mocktime.py" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   167
  $ echo "progress=" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   168
  $ echo "loop=`pwd`/loop.py" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   169
  $ echo "[progress]" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   170
  $ echo "assume-tty=1" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   171
  $ echo "delay=25" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   172
  $ echo "width=60" >> $HGRCPATH
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   173
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   174
  $ hg -y loop 8 2>&1 | python $TESTDIR/filtercr.py
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   175
  
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   176
  loop [=========>                                ] 2/8 1m07s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   177
  loop [===============>                            ] 3/8 56s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   178
  loop [=====================>                      ] 4/8 45s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   179
  loop [==========================>                 ] 5/8 34s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   180
  loop [================================>           ] 6/8 23s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   181
  loop [=====================================>      ] 7/8 12s
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   182
                                                              \r (esc)
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   183
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   184
  $ MOCKTIME=10000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   185
  
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   186
  loop [                                                ] 0/4
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   187
  loop [=========>                                ] 1/4 8h21m
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   188
  loop [====================>                     ] 2/4 5h34m
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   189
  loop [==============================>           ] 3/4 2h47m
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   190
                                                              \r (esc)
ce4cd176634e test-progress: test completion estimates and progress bar delay
Augie Fackler <durin42@gmail.com>
parents: 13142
diff changeset
   191
13236
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   192
  $ MOCKTIME=1000000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   193
  
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   194
  loop [                                                ] 0/4
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   195
  loop [=========>                                ] 1/4 5w00d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   196
  loop [====================>                     ] 2/4 3w03d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   197
  loop [=============================>           ] 3/4 11d14h
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   198
                                                              \r (esc)
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   199
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   200
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   201
  $ MOCKTIME=14000000 hg -y loop 4 2>&1 | python $TESTDIR/filtercr.py
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   202
  
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   203
  loop [                                                ] 0/4
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   204
  loop [=========>                                ] 1/4 1y18w
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   205
  loop [===================>                     ] 2/4 46w03d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   206
  loop [=============================>           ] 3/4 23w02d
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   207
                                                              \r (esc)
3f299f5d9a29 progress: handle days, weeks and years
timeless <timeless@gmail.com>
parents: 13154
diff changeset
   208
13154
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   209
Time estimates should not fail when there's no end point:
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   210
  $ hg -y loop -- -4 2>&1 | python $TESTDIR/filtercr.py
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   211
  
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   212
  loop [ <=>                                              ] 2
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   213
  loop [  <=>                                             ] 3
e11c14f14491 progress: don't compute estimate without a total
Augie Fackler <durin42@gmail.com>
parents: 13149
diff changeset
   214
                                                              \r (esc)