Mercurial > hg
annotate mercurial/revlogutils/debug.py @ 50896:b2b8c25f9462
hgwebmod: use sysstr to check for attribute presence
We do not need bytes here.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 30 Aug 2023 13:28:09 +0200 |
parents | 47b44d80d836 |
children | d718eddf01d9 |
rev | line source |
---|---|
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 # revlogutils/debug.py - utility used for revlog debuging |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 # |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 # Copyright 2005-2007 Olivia Mackall <olivia@selenic.com> |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 # Copyright 2022 Octobus <contact@octobus.net> |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 # |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
9 import collections |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
10 import string |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
11 |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 from .. import ( |
49676
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
13 mdiff, |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 node as nodemod, |
49676
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
15 revlogutils, |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
16 util, |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 ) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
19 from . import ( |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
20 constants, |
49676
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
21 deltas as deltautil, |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
22 ) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
23 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
24 INDEX_ENTRY_DEBUG_COLUMN = [] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
25 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
26 NODE_SIZE = object() |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
27 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
28 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
29 class _column_base: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
30 """constains the definition of a revlog column |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
31 |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
32 name: the column header, |
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
33 value_func: the function called to get a value, |
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
34 size: the width of the column, |
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
35 verbose_only: only include the column in verbose mode. |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
36 """ |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
37 |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
38 def __init__(self, name, value_func, size=None, verbose=False): |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
39 self.name = name |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
40 self.value_func = value_func |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
41 if size is not NODE_SIZE: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
42 if size is None: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
43 size = 8 # arbitrary default |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
44 size = max(len(name), size) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
45 self._size = size |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
46 self.verbose_only = verbose |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
47 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
48 def get_size(self, node_size): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
49 if self._size is NODE_SIZE: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
50 return node_size |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
51 else: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
52 return self._size |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
53 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
54 |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
55 def debug_column(name, size=None, verbose=False): |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
56 """decorated function is registered as a column |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
57 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
58 name: the name of the column, |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
59 size: the expected size of the column. |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
60 """ |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
61 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
62 def register(func): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
63 entry = _column_base( |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
64 name=name, |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
65 value_func=func, |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
66 size=size, |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
67 verbose=verbose, |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
68 ) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
69 INDEX_ENTRY_DEBUG_COLUMN.append(entry) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
70 return entry |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
71 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
72 return register |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
73 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
74 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
75 @debug_column(b"rev", size=6) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
76 def _rev(index, rev, entry, hexfn): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
77 return b"%d" % rev |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
78 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
79 |
49266
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
diff
changeset
|
80 @debug_column(b"rank", size=6, verbose=True) |
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
diff
changeset
|
81 def rank(index, rev, entry, hexfn): |
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
diff
changeset
|
82 return b"%d" % entry[constants.ENTRY_RANK] |
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
diff
changeset
|
83 |
da3e37ecacde
debugindex: add a `rank` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49265
diff
changeset
|
84 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
85 @debug_column(b"linkrev", size=6) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
86 def _linkrev(index, rev, entry, hexfn): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
87 return b"%d" % entry[constants.ENTRY_LINK_REV] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
88 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
89 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
90 @debug_column(b"nodeid", size=NODE_SIZE) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
91 def _nodeid(index, rev, entry, hexfn): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
92 return hexfn(entry[constants.ENTRY_NODE_ID]) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
93 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
94 |
49255
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
diff
changeset
|
95 @debug_column(b"p1-rev", size=6, verbose=True) |
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
diff
changeset
|
96 def _p1_rev(index, rev, entry, hexfn): |
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
diff
changeset
|
97 return b"%d" % entry[constants.ENTRY_PARENT_1] |
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
diff
changeset
|
98 |
251650844331
debugindex: add a `p1-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49254
diff
changeset
|
99 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
100 @debug_column(b"p1-nodeid", size=NODE_SIZE) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
101 def _p1_node(index, rev, entry, hexfn): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
102 parent = entry[constants.ENTRY_PARENT_1] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
103 p_entry = index[parent] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
104 return hexfn(p_entry[constants.ENTRY_NODE_ID]) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
105 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
106 |
49256
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
diff
changeset
|
107 @debug_column(b"p2-rev", size=6, verbose=True) |
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
diff
changeset
|
108 def _p2_rev(index, rev, entry, hexfn): |
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
diff
changeset
|
109 return b"%d" % entry[constants.ENTRY_PARENT_2] |
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
diff
changeset
|
110 |
d910ca4e995b
debugindex: add a `p2-rev` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49255
diff
changeset
|
111 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
112 @debug_column(b"p2-nodeid", size=NODE_SIZE) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
113 def _p2_node(index, rev, entry, hexfn): |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
114 parent = entry[constants.ENTRY_PARENT_2] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
115 p_entry = index[parent] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
116 return hexfn(p_entry[constants.ENTRY_NODE_ID]) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
117 |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
118 |
49257
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
diff
changeset
|
119 @debug_column(b"full-size", size=20, verbose=True) |
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
diff
changeset
|
120 def full_size(index, rev, entry, hexfn): |
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
diff
changeset
|
121 return b"%d" % entry[constants.ENTRY_DATA_UNCOMPRESSED_LENGTH] |
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
diff
changeset
|
122 |
b0238fc496af
debugindex: add a `full-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49256
diff
changeset
|
123 |
49258
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
diff
changeset
|
124 @debug_column(b"delta-base", size=6, verbose=True) |
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
diff
changeset
|
125 def delta_base(index, rev, entry, hexfn): |
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
diff
changeset
|
126 return b"%d" % entry[constants.ENTRY_DELTA_BASE] |
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
diff
changeset
|
127 |
f6ef18be36e1
debugindex: add a `delta-base` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49257
diff
changeset
|
128 |
49259
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
129 @debug_column(b"flags", size=2, verbose=True) |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
130 def flags(index, rev, entry, hexfn): |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
131 field = entry[constants.ENTRY_DATA_OFFSET] |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
132 field &= 0xFFFF |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
133 return b"%d" % field |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
134 |
fbb2477298a6
debugindex: add a `flags` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49258
diff
changeset
|
135 |
49260
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
diff
changeset
|
136 @debug_column(b"comp-mode", size=4, verbose=True) |
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
diff
changeset
|
137 def compression_mode(index, rev, entry, hexfn): |
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
diff
changeset
|
138 return b"%d" % entry[constants.ENTRY_DATA_COMPRESSION_MODE] |
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
diff
changeset
|
139 |
7a18f6fc7e0c
debugindex: add a `comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49259
diff
changeset
|
140 |
49261
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
141 @debug_column(b"data-offset", size=20, verbose=True) |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
142 def data_offset(index, rev, entry, hexfn): |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
143 field = entry[constants.ENTRY_DATA_OFFSET] |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
144 field >>= 16 |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
145 return b"%d" % field |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
146 |
7ba8adced391
debugindex: add a `data-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49260
diff
changeset
|
147 |
49262
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
diff
changeset
|
148 @debug_column(b"chunk-size", size=10, verbose=True) |
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
diff
changeset
|
149 def data_chunk_size(index, rev, entry, hexfn): |
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
diff
changeset
|
150 return b"%d" % entry[constants.ENTRY_DATA_COMPRESSED_LENGTH] |
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
diff
changeset
|
151 |
4c145006b24a
debugindex: add a `chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49261
diff
changeset
|
152 |
49263
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
153 @debug_column(b"sd-comp-mode", size=7, verbose=True) |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
154 def sidedata_compression_mode(index, rev, entry, hexfn): |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
155 compression = entry[constants.ENTRY_SIDEDATA_COMPRESSION_MODE] |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
156 if compression == constants.COMP_MODE_PLAIN: |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
157 return b"plain" |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
158 elif compression == constants.COMP_MODE_DEFAULT: |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
159 return b"default" |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
160 elif compression == constants.COMP_MODE_INLINE: |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
161 return b"inline" |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
162 else: |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
163 return b"%d" % compression |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
164 |
27583efef74d
debugindex: add a `sd-comp-mode` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49262
diff
changeset
|
165 |
49264
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
diff
changeset
|
166 @debug_column(b"sidedata-offset", size=20, verbose=True) |
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
diff
changeset
|
167 def sidedata_offset(index, rev, entry, hexfn): |
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
diff
changeset
|
168 return b"%d" % entry[constants.ENTRY_SIDEDATA_OFFSET] |
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
diff
changeset
|
169 |
e3a267a93711
debugindex: add a `sidedata-offset` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49263
diff
changeset
|
170 |
49265
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
diff
changeset
|
171 @debug_column(b"sd-chunk-size", size=10, verbose=True) |
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
diff
changeset
|
172 def sidedata_chunk_size(index, rev, entry, hexfn): |
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
diff
changeset
|
173 return b"%d" % entry[constants.ENTRY_SIDEDATA_COMPRESSED_LENGTH] |
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
diff
changeset
|
174 |
30d2beab8163
debugindex: add a `sd-chunk-size` column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49264
diff
changeset
|
175 |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
176 def debug_index( |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
177 ui, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
178 repo, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
179 formatter, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
180 revlog, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
181 full_node, |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
182 ): |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
183 """display index data for a revlog""" |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
184 if full_node: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
185 hexfn = nodemod.hex |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
186 else: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
187 hexfn = nodemod.short |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
188 |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
189 idlen = 12 |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
190 for i in revlog: |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
191 idlen = len(hexfn(revlog.node(i))) |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
192 break |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
193 |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
194 fm = formatter |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
195 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
196 header_pieces = [] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
197 for column in INDEX_ENTRY_DEBUG_COLUMN: |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
198 if column.verbose_only and not ui.verbose: |
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
199 continue |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
200 size = column.get_size(idlen) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
201 name = column.name |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
202 header_pieces.append(name.rjust(size)) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
203 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
204 fm.plain(b' '.join(header_pieces) + b'\n') |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
205 |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
206 index = revlog.index |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
207 |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
208 for rev in revlog: |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
209 fm.startitem() |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
210 entry = index[rev] |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
211 first = True |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
212 for column in INDEX_ENTRY_DEBUG_COLUMN: |
49254
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
213 if column.verbose_only and not ui.verbose: |
69983adfed06
debugindex: introduce a concept of "verbose-only" column
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49253
diff
changeset
|
214 continue |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
215 if not first: |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
216 fm.plain(b' ') |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
217 first = False |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
218 |
49253
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
219 size = column.get_size(idlen) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
220 value = column.value_func(index, rev, entry, hexfn) |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
221 display = b"%%%ds" % size |
a321304269cf
debugindex: move to a flexible column
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49252
diff
changeset
|
222 fm.write(column.name, display, value) |
49250
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
223 fm.plain(b'\n') |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
224 |
61cf3d39fd9e
debugindex: move the logic into its own module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
225 fm.end() |
49659
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
226 |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
227 |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
228 def dump(ui, revlog): |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
229 """perform the work for `hg debugrevlog --dump""" |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
230 # XXX seems redundant with debug index ? |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
231 r = revlog |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
232 numrevs = len(r) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
233 ui.write( |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
234 ( |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
235 b"# rev p1rev p2rev start end deltastart base p1 p2" |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
236 b" rawsize totalsize compression heads chainlen\n" |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
237 ) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
238 ) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
239 ts = 0 |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
240 heads = set() |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
241 |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
242 for rev in range(numrevs): |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
243 dbase = r.deltaparent(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
244 if dbase == -1: |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
245 dbase = rev |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
246 cbase = r.chainbase(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
247 clen = r.chainlen(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
248 p1, p2 = r.parentrevs(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
249 rs = r.rawsize(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
250 ts = ts + rs |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
251 heads -= set(r.parentrevs(rev)) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
252 heads.add(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
253 try: |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
254 compression = ts / r.end(rev) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
255 except ZeroDivisionError: |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
256 compression = 0 |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
257 ui.write( |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
258 b"%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d " |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
259 b"%11d %5d %8d\n" |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
260 % ( |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
261 rev, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
262 p1, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
263 p2, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
264 r.start(rev), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
265 r.end(rev), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
266 r.start(dbase), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
267 r.start(cbase), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
268 r.start(p1), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
269 r.start(p2), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
270 rs, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
271 ts, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
272 compression, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
273 len(heads), |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
274 clen, |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
275 ) |
7c0a383849a8
debug-revlog: move the --dump code in `revlogutils` module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49266
diff
changeset
|
276 ) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
277 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
278 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
279 def debug_revlog(ui, revlog): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
280 """code for `hg debugrevlog`""" |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
281 r = revlog |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
282 format = r._format_version |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
283 v = r._format_flags |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
284 flags = [] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
285 gdelta = False |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
286 if v & constants.FLAG_INLINE_DATA: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
287 flags.append(b'inline') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
288 if v & constants.FLAG_GENERALDELTA: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
289 gdelta = True |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
290 flags.append(b'generaldelta') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
291 if not flags: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
292 flags = [b'(none)'] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
293 |
49662
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
294 ### the total size of stored content if incompressed. |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
295 full_text_total_size = 0 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
296 ### tracks merge vs single parent |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
297 nummerges = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
298 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
299 ### tracks ways the "delta" are build |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
300 # nodelta |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
301 numempty = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
302 numemptytext = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
303 numemptydelta = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
304 # full file content |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
305 numfull = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
306 # intermediate snapshot against a prior snapshot |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
307 numsemi = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
308 # snapshot count per depth |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
309 numsnapdepth = collections.defaultdict(lambda: 0) |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
310 # number of snapshots with a non-ancestor delta |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
311 numsnapdepth_nad = collections.defaultdict(lambda: 0) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
312 # delta against previous revision |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
313 numprev = 0 |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
314 # delta against prev, where prev is a non-ancestor |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
315 numprev_nad = 0 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
316 # delta against first or second parent (not prev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
317 nump1 = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
318 nump2 = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
319 # delta against neither prev nor parents |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
320 numother = 0 |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
321 # delta against other that is a non-ancestor |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
322 numother_nad = 0 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
323 # delta against prev that are also first or second parent |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
324 # (details of `numprev`) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
325 nump1prev = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
326 nump2prev = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
327 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
328 # data about delta chain of each revs |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
329 chainlengths = [] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
330 chainbases = [] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
331 chainspans = [] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
332 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
333 # data about each revision |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
334 datasize = [None, 0, 0] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
335 fullsize = [None, 0, 0] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
336 semisize = [None, 0, 0] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
337 # snapshot count per depth |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
338 snapsizedepth = collections.defaultdict(lambda: [None, 0, 0]) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
339 deltasize = [None, 0, 0] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
340 chunktypecounts = {} |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
341 chunktypesizes = {} |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
342 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
343 def addsize(size, l): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
344 if l[0] is None or size < l[0]: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
345 l[0] = size |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
346 if size > l[1]: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
347 l[1] = size |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
348 l[2] += size |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
349 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
350 numrevs = len(r) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
351 for rev in range(numrevs): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
352 p1, p2 = r.parentrevs(rev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
353 delta = r.deltaparent(rev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
354 if format > 0: |
49662
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
355 s = r.rawsize(rev) |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
356 full_text_total_size += s |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
357 addsize(s, datasize) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
358 if p2 != nodemod.nullrev: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
359 nummerges += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
360 size = r.length(rev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
361 if delta == nodemod.nullrev: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
362 chainlengths.append(0) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
363 chainbases.append(r.start(rev)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
364 chainspans.append(size) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
365 if size == 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
366 numempty += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
367 numemptytext += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
368 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
369 numfull += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
370 numsnapdepth[0] += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
371 addsize(size, fullsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
372 addsize(size, snapsizedepth[0]) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
373 else: |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
374 nad = ( |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
375 delta != p1 and delta != p2 and not r.isancestorrev(delta, rev) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
376 ) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
377 chainlengths.append(chainlengths[delta] + 1) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
378 baseaddr = chainbases[delta] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
379 revaddr = r.start(rev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
380 chainbases.append(baseaddr) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
381 chainspans.append((revaddr - baseaddr) + size) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
382 if size == 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
383 numempty += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
384 numemptydelta += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
385 elif r.issnapshot(rev): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
386 addsize(size, semisize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
387 numsemi += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
388 depth = r.snapshotdepth(rev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
389 numsnapdepth[depth] += 1 |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
390 if nad: |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
391 numsnapdepth_nad[depth] += 1 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
392 addsize(size, snapsizedepth[depth]) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
393 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
394 addsize(size, deltasize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
395 if delta == rev - 1: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
396 numprev += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
397 if delta == p1: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
398 nump1prev += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
399 elif delta == p2: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
400 nump2prev += 1 |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
401 elif nad: |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
402 numprev_nad += 1 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
403 elif delta == p1: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
404 nump1 += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
405 elif delta == p2: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
406 nump2 += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
407 elif delta != nodemod.nullrev: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
408 numother += 1 |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
409 numother_nad += 1 |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
410 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
411 # Obtain data on the raw chunks in the revlog. |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
412 if util.safehasattr(r, '_getsegmentforrevs'): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
413 segment = r._getsegmentforrevs(rev, rev)[1] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
414 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
415 segment = r._revlog._getsegmentforrevs(rev, rev)[1] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
416 if segment: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
417 chunktype = bytes(segment[0:1]) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
418 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
419 chunktype = b'empty' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
420 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
421 if chunktype not in chunktypecounts: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
422 chunktypecounts[chunktype] = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
423 chunktypesizes[chunktype] = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
424 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
425 chunktypecounts[chunktype] += 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
426 chunktypesizes[chunktype] += size |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
427 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
428 # Adjust size min value for empty cases |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
429 for size in (datasize, fullsize, semisize, deltasize): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
430 if size[0] is None: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
431 size[0] = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
432 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
433 numdeltas = numrevs - numfull - numempty - numsemi |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
434 numoprev = numprev - nump1prev - nump2prev - numprev_nad |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
435 num_other_ancestors = numother - numother_nad |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
436 totalrawsize = datasize[2] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
437 datasize[2] /= numrevs |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
438 fulltotal = fullsize[2] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
439 if numfull == 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
440 fullsize[2] = 0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
441 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
442 fullsize[2] /= numfull |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
443 semitotal = semisize[2] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
444 snaptotal = {} |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
445 if numsemi > 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
446 semisize[2] /= numsemi |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
447 for depth in snapsizedepth: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
448 snaptotal[depth] = snapsizedepth[depth][2] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
449 snapsizedepth[depth][2] /= numsnapdepth[depth] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
450 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
451 deltatotal = deltasize[2] |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
452 if numdeltas > 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
453 deltasize[2] /= numdeltas |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
454 totalsize = fulltotal + semitotal + deltatotal |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
455 avgchainlen = sum(chainlengths) / numrevs |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
456 maxchainlen = max(chainlengths) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
457 maxchainspan = max(chainspans) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
458 compratio = 1 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
459 if totalsize: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
460 compratio = totalrawsize / totalsize |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
461 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
462 basedfmtstr = b'%%%dd\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
463 basepcfmtstr = b'%%%dd %s(%%5.2f%%%%)\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
464 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
465 def dfmtstr(max): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
466 return basedfmtstr % len(str(max)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
467 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
468 def pcfmtstr(max, padding=0): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
469 return basepcfmtstr % (len(str(max)), b' ' * padding) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
470 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
471 def pcfmt(value, total): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
472 if total: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
473 return (value, 100 * float(value) / total) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
474 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
475 return value, 100.0 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
476 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
477 ui.writenoi18n(b'format : %d\n' % format) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
478 ui.writenoi18n(b'flags : %s\n' % b', '.join(flags)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
479 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
480 ui.write(b'\n') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
481 fmt = pcfmtstr(totalsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
482 fmt2 = dfmtstr(totalsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
483 ui.writenoi18n(b'revisions : ' + fmt2 % numrevs) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
484 ui.writenoi18n(b' merges : ' + fmt % pcfmt(nummerges, numrevs)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
485 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
486 b' normal : ' + fmt % pcfmt(numrevs - nummerges, numrevs) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
487 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
488 ui.writenoi18n(b'revisions : ' + fmt2 % numrevs) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
489 ui.writenoi18n(b' empty : ' + fmt % pcfmt(numempty, numrevs)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
490 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
491 b' text : ' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
492 + fmt % pcfmt(numemptytext, numemptytext + numemptydelta) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
493 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
494 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
495 b' delta : ' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
496 + fmt % pcfmt(numemptydelta, numemptytext + numemptydelta) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
497 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
498 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
499 b' snapshot : ' + fmt % pcfmt(numfull + numsemi, numrevs) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
500 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
501 for depth in sorted(numsnapdepth): |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
502 base = b' lvl-%-3d : ' % depth |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
503 count = fmt % pcfmt(numsnapdepth[depth], numrevs) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
504 pieces = [base, count] |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
505 if numsnapdepth_nad[depth]: |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
506 pieces[-1] = count = count[:-1] # drop the final '\n' |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
507 more = b' non-ancestor-bases: ' |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
508 anc_count = fmt |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
509 anc_count %= pcfmt(numsnapdepth_nad[depth], numsnapdepth[depth]) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
510 pieces.append(more) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
511 pieces.append(anc_count) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
512 ui.write(b''.join(pieces)) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
513 ui.writenoi18n(b' deltas : ' + fmt % pcfmt(numdeltas, numrevs)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
514 ui.writenoi18n(b'revision size : ' + fmt2 % totalsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
515 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
516 b' snapshot : ' + fmt % pcfmt(fulltotal + semitotal, totalsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
517 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
518 for depth in sorted(numsnapdepth): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
519 ui.write( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
520 (b' lvl-%-3d : ' % depth) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
521 + fmt % pcfmt(snaptotal[depth], totalsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
522 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
523 ui.writenoi18n(b' deltas : ' + fmt % pcfmt(deltatotal, totalsize)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
524 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
525 letters = string.ascii_letters.encode('ascii') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
526 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
527 def fmtchunktype(chunktype): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
528 if chunktype == b'empty': |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
529 return b' %s : ' % chunktype |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
530 elif chunktype in letters: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
531 return b' 0x%s (%s) : ' % (nodemod.hex(chunktype), chunktype) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
532 else: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
533 return b' 0x%s : ' % nodemod.hex(chunktype) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
534 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
535 ui.write(b'\n') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
536 ui.writenoi18n(b'chunks : ' + fmt2 % numrevs) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
537 for chunktype in sorted(chunktypecounts): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
538 ui.write(fmtchunktype(chunktype)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
539 ui.write(fmt % pcfmt(chunktypecounts[chunktype], numrevs)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
540 ui.writenoi18n(b'chunks size : ' + fmt2 % totalsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
541 for chunktype in sorted(chunktypecounts): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
542 ui.write(fmtchunktype(chunktype)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
543 ui.write(fmt % pcfmt(chunktypesizes[chunktype], totalsize)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
544 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
545 ui.write(b'\n') |
49662
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
546 b_total = b"%d" % full_text_total_size |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
547 p_total = [] |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
548 while len(b_total) > 3: |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
549 p_total.append(b_total[-3:]) |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
550 b_total = b_total[:-3] |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
551 p_total.append(b_total) |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
552 p_total.reverse() |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
553 b_total = b' '.join(p_total) |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
554 |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
555 ui.write(b'\n') |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
556 ui.writenoi18n(b'total-stored-content: %s bytes\n' % b_total) |
7aea9babac5d
debugrevlog: display total stored information
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49661
diff
changeset
|
557 ui.write(b'\n') |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
558 fmt = dfmtstr(max(avgchainlen, maxchainlen, maxchainspan, compratio)) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
559 ui.writenoi18n(b'avg chain length : ' + fmt % avgchainlen) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
560 ui.writenoi18n(b'max chain length : ' + fmt % maxchainlen) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
561 ui.writenoi18n(b'max chain reach : ' + fmt % maxchainspan) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
562 ui.writenoi18n(b'compression ratio : ' + fmt % compratio) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
563 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
564 if format > 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
565 ui.write(b'\n') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
566 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
567 b'uncompressed data size (min/max/avg) : %d / %d / %d\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
568 % tuple(datasize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
569 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
570 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
571 b'full revision size (min/max/avg) : %d / %d / %d\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
572 % tuple(fullsize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
573 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
574 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
575 b'inter-snapshot size (min/max/avg) : %d / %d / %d\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
576 % tuple(semisize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
577 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
578 for depth in sorted(snapsizedepth): |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
579 if depth == 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
580 continue |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
581 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
582 b' level-%-3d (min/max/avg) : %d / %d / %d\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
583 % ((depth,) + tuple(snapsizedepth[depth])) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
584 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
585 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
586 b'delta size (min/max/avg) : %d / %d / %d\n' |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
587 % tuple(deltasize) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
588 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
589 |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
590 if numdeltas > 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
591 ui.write(b'\n') |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
592 fmt = pcfmtstr(numdeltas) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
593 fmt2 = pcfmtstr(numdeltas, 4) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
594 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
595 b'deltas against prev : ' + fmt % pcfmt(numprev, numdeltas) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
596 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
597 if numprev > 0: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
598 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
599 b' where prev = p1 : ' + fmt2 % pcfmt(nump1prev, numprev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
600 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
601 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
602 b' where prev = p2 : ' + fmt2 % pcfmt(nump2prev, numprev) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
603 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
604 ui.writenoi18n( |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
605 b' other-ancestor : ' + fmt2 % pcfmt(numoprev, numprev) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
606 ) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
607 ui.writenoi18n( |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
608 b' unrelated : ' + fmt2 % pcfmt(numoprev, numprev) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
609 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
610 if gdelta: |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
611 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
612 b'deltas against p1 : ' + fmt % pcfmt(nump1, numdeltas) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
613 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
614 ui.writenoi18n( |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
615 b'deltas against p2 : ' + fmt % pcfmt(nump2, numdeltas) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
616 ) |
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
617 ui.writenoi18n( |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
618 b'deltas against ancs : ' |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
619 + fmt % pcfmt(num_other_ancestors, numdeltas) |
49660
bd3b6f363fb9
debug-revlog: move the code in revlogutils module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49659
diff
changeset
|
620 ) |
49661
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
621 ui.writenoi18n( |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
622 b'deltas against other : ' |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
623 + fmt % pcfmt(numother_nad, numdeltas) |
511106bcb16c
debug-revlog: details about non-ancestors delta-bases
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49660
diff
changeset
|
624 ) |
49676
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
625 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
626 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
627 def debug_delta_find(ui, revlog, rev, base_rev=nodemod.nullrev): |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
628 """display the search process for a delta""" |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
629 deltacomputer = deltautil.deltacomputer( |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
630 revlog, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
631 write_debug=ui.write, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
632 debug_search=not ui.quiet, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
633 ) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
634 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
635 node = revlog.node(rev) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
636 p1r, p2r = revlog.parentrevs(rev) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
637 p1 = revlog.node(p1r) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
638 p2 = revlog.node(p2r) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
639 full_text = revlog.revision(rev) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
640 btext = [full_text] |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
641 textlen = len(btext[0]) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
642 cachedelta = None |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
643 flags = revlog.flags(rev) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
644 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
645 if base_rev != nodemod.nullrev: |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
646 base_text = revlog.revision(base_rev) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
647 delta = mdiff.textdiff(base_text, full_text) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
648 |
49677
05db41701ece
find-delta: pass the cache-delta usage policy alongside the cache-delta
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49676
diff
changeset
|
649 cachedelta = (base_rev, delta, constants.DELTA_BASE_REUSE_TRY) |
49676
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
650 btext = [None] |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
651 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
652 revinfo = revlogutils.revisioninfo( |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
653 node, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
654 p1, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
655 p2, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
656 btext, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
657 textlen, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
658 cachedelta, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
659 flags, |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
660 ) |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
661 |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
662 fh = revlog._datafp() |
4302db0f54c8
find-delta: move most of the debug-find-delta code in the debug module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49662
diff
changeset
|
663 deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev) |
49819
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
664 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
665 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
666 def debug_revlog_stats( |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
667 repo, fm, changelog: bool, manifest: bool, filelogs: bool |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
668 ): |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
669 """Format revlog statistics for debugging purposes |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
670 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
671 fm: the output formatter. |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
672 """ |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
673 fm.plain(b'rev-count data-size inl type target \n') |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
674 |
50681
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
675 revlog_entries = [e for e in repo.store.walk() if e.is_revlog] |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
676 revlog_entries.sort(key=lambda e: (e.revlog_type, e.target_id)) |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
677 |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
678 for entry in revlog_entries: |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
679 if not changelog and entry.is_changelog: |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
680 continue |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
681 elif not manifest and entry.is_manifestlog: |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
682 continue |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
683 elif not filelogs and entry.is_filelog: |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
684 continue |
47b44d80d836
debug-revlog-stats: make it use the new store entry API
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49819
diff
changeset
|
685 rlog = entry.get_revlog_instance(repo).get_revlog() |
49819
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
686 fm.startitem() |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
687 nb_rev = len(rlog) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
688 inline = rlog._inline |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
689 data_size = rlog._get_data_offset(nb_rev - 1) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
690 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
691 target = rlog.target |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
692 revlog_type = b'unknown' |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
693 revlog_target = b'' |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
694 if target[0] == constants.KIND_CHANGELOG: |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
695 revlog_type = b'changelog' |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
696 elif target[0] == constants.KIND_MANIFESTLOG: |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
697 revlog_type = b'manifest' |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
698 revlog_target = target[1] |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
699 elif target[0] == constants.KIND_FILELOG: |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
700 revlog_type = b'file' |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
701 revlog_target = target[1] |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
702 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
703 fm.write(b'revlog.rev-count', b'%9d', nb_rev) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
704 fm.write(b'revlog.data-size', b'%12d', data_size) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
705 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
706 fm.write(b'revlog.inline', b' %-3s', b'yes' if inline else b'no') |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
707 fm.write(b'revlog.type', b' %-9s', revlog_type) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
708 fm.write(b'revlog.target', b' %s', revlog_target) |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
709 |
b1e4c74beb6f
debug: add debug-revlog-stats command
Franck Bret <franck.bret@octobus.net>
parents:
49677
diff
changeset
|
710 fm.plain(b'\n') |