tests/test-issue2137.t
author Kyle Lippincott <spectral@google.com>
Wed, 02 Dec 2020 12:33:51 -0800
changeset 46018 8b0a3ff5ed12
parent 36564 c4ccc73f9d49
permissions -rw-r--r--
statprof: separate functions and "line", assume 4 digit line numbers Previously, the profile output looked like this (I've removed many lines that are mostly inconsequential): ``` | 100.0% 0.02s hg: <module> line 43: dispatch.run() | 100.0% 0.02s dispatch.py: run line 115: status = dispatch(req) | 100.0% 0.02s dispatch.py: _runcatchfunc line 432: return _dispatch(req) \ 50.0% 0.01s dispatch.py: _dispatch line 1228: return runcommand( | 50.0% 0.01s dispatch.py: runcommand line 883: ret = _runcommand(ui, optio... | 50.0% 0.01s dispatch.py: _runcommand line 1240: return cmdfunc() | 50.0% 0.01s localrepo.py: __getitem__ line 1670: quick_access = self._quick_... | 50.0% 0.01s localrepo.py: _quick_access_changeidline 1650: return self._quick_access_c... | 50.0% 0.01s localrepo.py: __get__ line 179: return getattr(unfi, self.n... | 50.0% 0.01s util.py: __get__ line 1747: result = self.func(obj) | 50.0% 0.01s localrepo.py: _quick_access_changeid_wcline 1611: cl = self.unfiltered().chan... | 50.0% 0.01s localrepo.py: __get__ line 110: return super(_basefilecache... | 50.0% 0.01s util.py: __getattribute__line 245: self.__spec__.loader.exec_m... | 50.0% 0.01s <frozen importlib._bootstrap_external>: exec_moduleline 783: | 50.0% 0.01s <frozen importlib._bootstrap>: _call_with_frames_removedline 219: | 50.0% 0.01s changelog.py: <module> line 376: class changelog(revlog.revl... | 50.0% 0.01s util.py: __getattribute__line 245: self.__spec__.loader.exec_m... | 50.0% 0.01s <frozen importlib._bootstrap_external>: exec_moduleline 779: | 50.0% 0.01s <frozen importlib._bootstrap_external>: get_codeline 868: | 50.0% 0.01s <frozen importlib._bootstrap_external>: path_statsline 1012: | 50.0% 0.01s <frozen importlib._bootstrap_external>: _path_statline 87: ``` This has a few problems, though I'm only addressing some of them. 1. If the stuff before "line ###" is long, there's no separation between the function name and the "line" string. 2. If the stuff before "line ###" is really long, there's excessive separation between the "line" string and the line number. 3. We frequently have 4-digit line numbers, the code on the right wasn't dynamically indented and ended up quite messy looking. To solve these problems, I've added a ", " prefix before "line" iff it would otherwise not have any separation such as spaces. I've added a 'max' so that we never use a negative width (which is the cause of problem #2 above), and I've added a default assumption of 4 digit line numbers (but again using a 'max' so this shouldn't cause problems if we go beyond that. With these changes, it now looks like this: ``` | 100.0% 0.02s hg: <module> line 43: dispatch.run() | 100.0% 0.02s dispatch.py: run line 115: status = dispatch(req) | 100.0% 0.02s dispatch.py: _runcatchfunc line 432: return _dispatch(req) \ 50.0% 0.01s dispatch.py: _dispatch line 1228: return runcommand( | 50.0% 0.01s dispatch.py: runcommand line 883: ret = _runcommand(ui, optio... | 50.0% 0.01s dispatch.py: _runcommand line 1240: return cmdfunc() | 50.0% 0.01s localrepo.py: __getitem__ line 1670: quick_access = self._quick_... | 50.0% 0.01s localrepo.py: _quick_access_changeid, line 1650: return self._quick_access_c... | 50.0% 0.01s localrepo.py: __get__ line 179: return getattr(unfi, self.n... | 50.0% 0.01s util.py: __get__ line 1747: result = self.func(obj) | 50.0% 0.01s localrepo.py: _quick_access_changeid_wc, line 1611: cl = self.unfiltered().chan... | 50.0% 0.01s localrepo.py: __get__ line 110: return super(_basefilecache... | 50.0% 0.01s util.py: __getattribute__, line 245: self.__spec__.loader.exec_m... | 50.0% 0.01s <frozen importlib._bootstrap_external>: exec_module, line 783: | 50.0% 0.01s <frozen importlib._bootstrap>: _call_with_frames_removed, line 219: | 50.0% 0.01s changelog.py: <module> line 376: class changelog(revlog.revl... | 50.0% 0.01s util.py: __getattribute__, line 245: self.__spec__.loader.exec_m... | 50.0% 0.01s <frozen importlib._bootstrap_external>: exec_module, line 779: | 50.0% 0.01s <frozen importlib._bootstrap_external>: get_code, line 868: | 50.0% 0.01s <frozen importlib._bootstrap_external>: path_stats, line 1012: | 50.0% 0.01s <frozen importlib._bootstrap_external>: _path_stat, line 87: ``` Differential Revision: https://phab.mercurial-scm.org/D9511
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26420
2fc86d92c4a9 urls: bulk-change BTS urls to new location
Matt Mackall <mpm@selenic.com>
parents: 17802
diff changeset
     1
https://bz.mercurial-scm.org/2137
10914
b7ca37b90762 revlog: fix lazyparser.__iter__() to return all revisions (issue2137)
Greg Ward <greg-hg@gerg.ca>
parents:
diff changeset
     2
12204
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
     3
Setup:
10914
b7ca37b90762 revlog: fix lazyparser.__iter__() to return all revisions (issue2137)
Greg Ward <greg-hg@gerg.ca>
parents:
diff changeset
     4
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12204
diff changeset
     5
create a little extension that has 3 side-effects:
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12204
diff changeset
     6
1) ensure changelog data is not inlined
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12204
diff changeset
     7
2) make revlog to use lazyparser
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12204
diff changeset
     8
3) test that repo.lookup() works
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12204
diff changeset
     9
1 and 2 are preconditions for the bug; 3 is the bug.
10914
b7ca37b90762 revlog: fix lazyparser.__iter__() to return all revisions (issue2137)
Greg Ward <greg-hg@gerg.ca>
parents:
diff changeset
    10
12204
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    11
  $ cat > commitwrapper.py <<EOF
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    12
  > from mercurial import extensions, node, revlog
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    13
  > 
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    14
  > def reposetup(ui, repo):
17802
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    15
  >     class wraprepo(repo.__class__):
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    16
  >         def commit(self, *args, **kwargs):
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    17
  >             result = super(wraprepo, self).commit(*args, **kwargs)
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    18
  >             tip1 = node.short(repo.changelog.tip())
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    19
  >             tip2 = node.short(repo.lookup(tip1))
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    20
  >             assert tip1 == tip2
36564
c4ccc73f9d49 tests: add missing b prefix in test python in test-issue2137.t
Augie Fackler <augie@google.com>
parents: 26420
diff changeset
    21
  >             ui.write(b'new tip: %s\n' % tip1)
17802
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    22
  >             return result
a421459b83c0 test: use proper subclassing in `test-issue2137.t`.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16913
diff changeset
    23
  >     repo.__class__ = wraprepo
12204
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    24
  > 
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    25
  > def extsetup(ui):
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    26
  >     revlog._maxinline = 8             # split out 00changelog.d early
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    27
  >     revlog._prereadsize = 8           # use revlog.lazyparser
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    28
  > EOF
10914
b7ca37b90762 revlog: fix lazyparser.__iter__() to return all revisions (issue2137)
Greg Ward <greg-hg@gerg.ca>
parents:
diff changeset
    29
12204
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    30
  $ cat >> $HGRCPATH <<EOF
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    31
  > [extensions]
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    32
  > commitwrapper = `pwd`/commitwrapper.py
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    33
  > EOF
10914
b7ca37b90762 revlog: fix lazyparser.__iter__() to return all revisions (issue2137)
Greg Ward <greg-hg@gerg.ca>
parents:
diff changeset
    34
12204
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    35
  $ hg init repo1
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    36
  $ cd repo1
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    37
  $ echo a > a
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    38
  $ hg commit -A -m'add a with a long commit message to make the changelog a bit bigger'
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    39
  adding a
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    40
  new tip: 553596fad57b
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    41
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    42
Test that new changesets are visible to repo.lookup():
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    43
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    44
  $ echo a >> a
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    45
  $ hg commit -m'one more commit to demonstrate the bug'
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    46
  new tip: 799ae3599e0e
10914
b7ca37b90762 revlog: fix lazyparser.__iter__() to return all revisions (issue2137)
Greg Ward <greg-hg@gerg.ca>
parents:
diff changeset
    47
12204
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    48
  $ hg tip
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    49
  changeset:   1:799ae3599e0e
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    50
  tag:         tip
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    51
  user:        test
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    52
  date:        Thu Jan 01 00:00:00 1970 +0000
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    53
  summary:     one more commit to demonstrate the bug
c55d69c5fb77 tests: unify test-issue1438 and test-issue2137
Adrian Buehlmann <adrian@cadifra.com>
parents: 11072
diff changeset
    54
  
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 12328
diff changeset
    55
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 12328
diff changeset
    56
  $ cd ..