Mercurial > hg
annotate hgext/remotefilelog/debugcommands.py @ 49725:f632b9e1e047
path: pass `path` to `peer` in `remote(...)` revset
We directly use the `path` object to build the `peer` object.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 02 Dec 2022 05:11:53 +0100 |
parents | 642e31cb55f0 |
children | 460e80488cf0 |
rev | line source |
---|---|
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 # debugcommands.py - debug logic for remotefilelog |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 # |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 # Copyright 2013 Facebook, Inc. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 # |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 import os |
40507
e2a1584e9e3f
remotefilelog: rip out lz4 support
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
9 import zlib |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
11 from mercurial.node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
12 bin, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
13 hex, |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
14 sha1nodeconstants, |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
15 short, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
16 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 from mercurial.i18n import _ |
43085
eef9a2d67051
py3: manually import pycompat.open into files that need it
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43080
diff
changeset
|
18 from mercurial.pycompat import open |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 from mercurial import ( |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 error, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 filelog, |
42943
5fadf6103790
remotefilelog: replace repack lock to solve race condition
Boris Feld <boris.feld@octobus.net>
parents:
41807
diff
changeset
|
22 lock as lockmod, |
41807
941685500125
remotefilelog: fix format str, blobsize isn't always a #, can be "(missing)"
Kyle Lippincott <spectral@google.com>
parents:
41365
diff
changeset
|
23 pycompat, |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 revlog, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 ) |
44062
2d49482d0dd4
hgext: replace references to hashlib.sha1 with hashutil.sha1
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
26 from mercurial.utils import hashutil |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 from . import ( |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 constants, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 datapack, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 fileserverclient, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 historypack, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 repack, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
33 shallowutil, |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 ) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
36 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 def debugremotefilelog(ui, path, **opts): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
38 decompress = opts.get('decompress') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 size, firstnode, mapping = parsefileblob(path, decompress) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
42 ui.status(_(b"size: %d bytes\n") % size) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
43 ui.status(_(b"path: %s \n") % path) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
44 ui.status(_(b"key: %s \n") % (short(firstnode))) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
45 ui.status(_(b"\n")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
46 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
47 _(b"%12s => %12s %13s %13s %12s\n") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
48 % (b"node", b"p1", b"p2", b"linknode", b"copyfrom") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
49 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 queue = [firstnode] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 while queue: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 node = queue.pop(0) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 p1, p2, linknode, copyfrom = mapping[node] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
55 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
56 _(b"%s => %s %s %s %s\n") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
57 % (short(node), short(p1), short(p2), short(linknode), copyfrom) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
58 ) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
59 if p1 != sha1nodeconstants.nullid: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 queue.append(p1) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
61 if p2 != sha1nodeconstants.nullid: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 queue.append(p2) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
64 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 def buildtemprevlog(repo, file): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
66 # get filename key |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
67 filekey = hex(hashutil.sha1(file).digest()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
68 filedir = os.path.join(repo.path, b'store/data', filekey) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 # sort all entries based on linkrev |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
71 fctxs = [] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
72 for filenode in os.listdir(filedir): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
73 if b'_old' not in filenode: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 fctxs.append(repo.filectx(file, fileid=bin(filenode))) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
75 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
76 fctxs = sorted(fctxs, key=lambda x: x.linkrev()) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
77 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 # add to revlog |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 temppath = repo.sjoin(b'data/temprevlog.i') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 if os.path.exists(temppath): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 os.remove(temppath) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
82 r = filelog.filelog(repo.svfs, b'temprevlog') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48935
diff
changeset
|
84 class faket: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 def add(self, a, b, c): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 pass |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
87 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
88 t = faket() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
89 for fctx in fctxs: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
90 if fctx.node() not in repo: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 continue |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
92 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
93 p = fctx.filelog().parents(fctx.filenode()) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
94 meta = {} |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
95 if fctx.renamed(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
96 meta[b'copy'] = fctx.renamed()[0] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
97 meta[b'copyrev'] = hex(fctx.renamed()[1]) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
98 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
99 r.add(fctx.data(), meta, t, fctx.linkrev(), p[0], p[1]) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
100 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
101 return r |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
102 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
103 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
104 def debugindex(orig, ui, repo, file_=None, **opts): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
105 """dump the contents of an index file""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
106 if ( |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
107 opts.get('changelog') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
108 or opts.get('manifest') |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
109 or opts.get('dir') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
110 or not shallowutil.isenabled(repo) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
111 or not repo.shallowmatch(file_) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
112 ): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
113 return orig(ui, repo, file_, **opts) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
114 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
115 r = buildtemprevlog(repo, file_) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
116 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
117 # debugindex like normal |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
118 format = opts.get(b'format', 0) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
119 if format not in (0, 1): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
120 raise error.Abort(_(b"unknown format %d") % format) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
121 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 generaldelta = r.version & revlog.FLAG_GENERALDELTA |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 if generaldelta: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
124 basehdr = b' delta' |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
126 basehdr = b' base' |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
128 if format == 0: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
129 ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
130 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
131 b" rev offset length " + basehdr + b" linkrev" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
132 b" nodeid p1 p2\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
133 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
134 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
135 elif format == 1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
136 ui.write( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
137 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
138 b" rev flag offset length" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
139 b" size " + basehdr + b" link p1 p2" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
140 b" nodeid\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
141 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
142 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 for i in r: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 node = r.node(i) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 if generaldelta: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 base = r.deltaparent(i) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
148 else: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 base = r.chainbase(i) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 if format == 0: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 try: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 pp = r.parents(node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 except Exception: |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
154 pp = [repo.nullid, repo.nullid] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
155 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
156 b"% 6d % 9d % 7d % 6d % 7d %s %s %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
157 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
158 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
159 r.start(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
160 r.length(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
161 base, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
162 r.linkrev(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
163 short(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
164 short(pp[0]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
165 short(pp[1]), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
166 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
167 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 elif format == 1: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 pr = r.parentrevs(i) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
170 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
171 b"% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
172 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
173 i, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
174 r.flags(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
175 r.start(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
176 r.length(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
177 r.rawsize(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
178 base, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
179 r.linkrev(i), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
180 pr[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
181 pr[1], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
182 short(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
183 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
184 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
185 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 def debugindexdot(orig, ui, repo, file_): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
188 """dump an index DAG as a graphviz dot file""" |
40514
6f0b6905ef6f
shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40510
diff
changeset
|
189 if not shallowutil.isenabled(repo): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 return orig(ui, repo, file_) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
192 r = buildtemprevlog(repo, os.path.basename(file_)[:-2]) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
193 |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
194 ui.writenoi18n(b"digraph G {\n") |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
195 for i in r: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 node = r.node(i) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
197 pp = r.parents(node) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
198 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i)) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
199 if pp[1] != repo.nullid: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
200 ui.write(b"\t%d -> %d\n" % (r.rev(pp[1]), i)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
201 ui.write(b"}\n") |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
203 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 def verifyremotefilelog(ui, path, **opts): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
205 decompress = opts.get('decompress') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 for root, dirs, files in os.walk(path): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 for file in files: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
209 if file == b"repos": |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 continue |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 filepath = os.path.join(root, file) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 size, firstnode, mapping = parsefileblob(filepath, decompress) |
48935
2cce2fa5bcf7
py3: replace pycompat.itervalues(x) with x.values()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
213 for p1, p2, linknode, copyfrom in mapping.values(): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
214 if linknode == sha1nodeconstants.nullid: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 actualpath = os.path.relpath(root, path) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
216 key = fileserverclient.getcachekey( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
217 b"reponame", actualpath, file |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
218 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
219 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 b"%s %s\n" % (key, os.path.relpath(filepath, path)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
221 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
222 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
223 |
40507
e2a1584e9e3f
remotefilelog: rip out lz4 support
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
224 def _decompressblob(raw): |
e2a1584e9e3f
remotefilelog: rip out lz4 support
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
225 return zlib.decompress(raw) |
e2a1584e9e3f
remotefilelog: rip out lz4 support
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
226 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
227 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
228 def parsefileblob(path, decompress): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
229 f = open(path, b"rb") |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 try: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 raw = f.read() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
232 finally: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 f.close() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 if decompress: |
40507
e2a1584e9e3f
remotefilelog: rip out lz4 support
Augie Fackler <augie@google.com>
parents:
40495
diff
changeset
|
236 raw = _decompressblob(raw) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 offset, size, flags = shallowutil.parsesizeflags(raw) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 start = offset + size |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
240 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
241 firstnode = None |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 mapping = {} |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
244 while start < len(raw): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
245 divider = raw.index(b'\0', start + 80) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
246 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
247 currentnode = raw[start : (start + 20)] |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
248 if not firstnode: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
249 firstnode = currentnode |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
250 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
251 p1 = raw[(start + 20) : (start + 40)] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
252 p2 = raw[(start + 40) : (start + 60)] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
253 linknode = raw[(start + 60) : (start + 80)] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
254 copyfrom = raw[(start + 80) : divider] |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
255 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
256 mapping[currentnode] = (p1, p2, linknode, copyfrom) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
257 start = divider + 1 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
258 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
259 return size, firstnode, mapping |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
260 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
261 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
262 def debugdatapack(ui, *paths, **opts): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 for path in paths: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
264 if b'.data' in path: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
265 path = path[: path.index(b'.data')] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
266 ui.write(b"%s:\n" % path) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
267 dpack = datapack.datapack(path) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
268 node = opts.get('node') |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
269 if node: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
270 deltachain = dpack.getdeltachain(b'', bin(node)) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
271 dumpdeltachain(ui, deltachain, **opts) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
272 return |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
273 |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43104
diff
changeset
|
274 if opts.get('long'): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
275 hashformatter = hex |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
276 hashlen = 42 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
277 else: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
278 hashformatter = short |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
279 hashlen = 14 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
280 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
281 lastfilename = None |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
282 totaldeltasize = 0 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
283 totalblobsize = 0 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
284 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
285 def printtotals(): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
286 if lastfilename is not None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
287 ui.write(b"\n") |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
288 if not totaldeltasize or not totalblobsize: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
289 return |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
290 difference = totalblobsize - totaldeltasize |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
291 deltastr = b"%0.1f%% %s" % ( |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
292 (100.0 * abs(difference) / totalblobsize), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
293 (b"smaller" if difference > 0 else b"bigger"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
294 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
295 |
43080
86e4daa2d54c
cleanup: mark some ui.(status|note|warn|write) calls as not needing i18n
Augie Fackler <augie@google.com>
parents:
43077
diff
changeset
|
296 ui.writenoi18n( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
297 b"Total:%s%s %s (%s)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
298 % ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
299 b"".ljust(2 * hashlen - len(b"Total:")), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
300 (b'%d' % totaldeltasize).ljust(12), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
301 (b'%d' % totalblobsize).ljust(9), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
302 deltastr, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
303 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
304 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
305 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
306 bases = {} |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
307 nodes = set() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
308 failures = 0 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
309 for filename, node, deltabase, deltalen in dpack.iterentries(): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
310 bases[node] = deltabase |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
311 if node in nodes: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
312 ui.write((b"Bad entry: %s appears twice\n" % short(node))) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
313 failures += 1 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
314 nodes.add(node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
315 if filename != lastfilename: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
316 printtotals() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
317 name = b'(empty name)' if filename == b'' else filename |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
318 ui.write(b"%s:\n" % name) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
319 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
320 b"%s%s%s%s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
321 % ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
322 b"Node".ljust(hashlen), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
323 b"Delta Base".ljust(hashlen), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
324 b"Delta Length".ljust(14), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
325 b"Blob Size".ljust(9), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
326 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
327 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
328 lastfilename = filename |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
329 totalblobsize = 0 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
330 totaldeltasize = 0 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
331 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
332 # Metadata could be missing, in which case it will be an empty dict. |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
333 meta = dpack.getmeta(filename, node) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
334 if constants.METAKEYSIZE in meta: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
335 blobsize = meta[constants.METAKEYSIZE] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
336 totaldeltasize += deltalen |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
337 totalblobsize += blobsize |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
338 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
339 blobsize = b"(missing)" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
340 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
341 b"%s %s %s%s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
342 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
343 hashformatter(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
344 hashformatter(deltabase), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
345 (b'%d' % deltalen).ljust(14), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
346 pycompat.bytestr(blobsize), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
347 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
348 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
349 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
350 if filename is not None: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
351 printtotals() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
352 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
353 failures += _sanitycheck(ui, set(nodes), bases) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
354 if failures > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
355 ui.warn((b"%d failures\n" % failures)) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
356 return 1 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
357 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
358 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
359 def _sanitycheck(ui, nodes, bases): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
360 """ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
361 Does some basic sanity checking on a packfiles with ``nodes`` ``bases`` (a |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
362 mapping of node->base): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
363 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
364 - Each deltabase must itself be a node elsewhere in the pack |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
365 - There must be no cycles |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
366 """ |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
367 failures = 0 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
368 for node in nodes: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
369 seen = set() |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
370 current = node |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
371 deltabase = bases[current] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
372 |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
373 while deltabase != sha1nodeconstants.nullid: |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
374 if deltabase not in nodes: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
375 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
376 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
377 b"Bad entry: %s has an unknown deltabase (%s)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
378 % (short(node), short(deltabase)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
379 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
380 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
381 failures += 1 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
382 break |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
383 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
384 if deltabase in seen: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
385 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
386 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
387 b"Bad entry: %s has a cycle (at %s)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
388 % (short(node), short(deltabase)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
389 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
390 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
391 failures += 1 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
392 break |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
393 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
394 current = deltabase |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
395 seen.add(current) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
396 deltabase = bases[current] |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
397 # Since ``node`` begins a valid chain, reset/memoize its base to nullid |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
398 # so we don't traverse it again. |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46113
diff
changeset
|
399 bases[node] = sha1nodeconstants.nullid |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
400 return failures |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
401 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
402 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
403 def dumpdeltachain(ui, deltachain, **opts): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
404 hashformatter = hex |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
405 hashlen = 40 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
406 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
407 lastfilename = None |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
408 for filename, node, filename, deltabasenode, delta in deltachain: |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
409 if filename != lastfilename: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
410 ui.write(b"\n%s\n" % filename) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
411 lastfilename = filename |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
412 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 b"%s %s %s %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
414 % ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 b"Node".ljust(hashlen), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 b"Delta Base".ljust(hashlen), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 b"Delta SHA1".ljust(hashlen), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 b"Delta Length".ljust(6), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
419 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
420 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
421 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
422 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
423 b"%s %s %s %d\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
424 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
425 hashformatter(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
426 hashformatter(deltabasenode), |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
44062
diff
changeset
|
427 hex(hashutil.sha1(delta).digest()), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
428 len(delta), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
429 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
430 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
431 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
432 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
433 def debughistorypack(ui, path): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
434 if b'.hist' in path: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
435 path = path[: path.index(b'.hist')] |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
436 hpack = historypack.historypack(path) |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
437 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
438 lastfilename = None |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
439 for entry in hpack.iterentries(): |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
440 filename, node, p1node, p2node, linknode, copyfrom = entry |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
441 if filename != lastfilename: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
442 ui.write(b"\n%s\n" % filename) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
443 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
444 b"%s%s%s%s%s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
445 % ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
446 b"Node".ljust(14), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
447 b"P1 Node".ljust(14), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
448 b"P2 Node".ljust(14), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
449 b"Link Node".ljust(14), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
450 b"Copy From", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
451 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
452 ) |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
453 lastfilename = filename |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
454 ui.write( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
455 b"%s %s %s %s %s\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
456 % ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
457 short(node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
458 short(p1node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
459 short(p2node), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
460 short(linknode), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
461 copyfrom, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
462 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
463 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
464 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
465 |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
466 def debugwaitonrepack(repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
467 with lockmod.lock(repack.repacklockvfs(repo), b"repacklock", timeout=-1): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
468 return |
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
469 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
470 |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
471 def debugwaitonprefetch(repo): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
472 with repo._lock( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
473 repo.svfs, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
474 b"prefetchlock", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
475 True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
476 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
477 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
478 _(b'prefetching in %s') % repo.origroot, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42943
diff
changeset
|
479 ): |
40495
3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
480 pass |