comparison hgext/remotefilelog/debugcommands.py @ 47012:d55b71393907

node: replace nullid and friends with nodeconstants class The introduction of 256bit hashes require changes to nullid and other constant magic values. Start pushing them down from repository and revlog where sensible. Differential Revision: https://phab.mercurial-scm.org/D9465
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 29 Mar 2021 01:52:06 +0200
parents 59fa3890d40a
children 6000f5b25c9b
comparison
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
10 import zlib 10 import zlib
11 11
12 from mercurial.node import ( 12 from mercurial.node import (
13 bin, 13 bin,
14 hex, 14 hex,
15 nullid, 15 sha1nodeconstants,
16 short, 16 short,
17 ) 17 )
18 from mercurial.i18n import _ 18 from mercurial.i18n import _
19 from mercurial.pycompat import open 19 from mercurial.pycompat import open
20 from mercurial import ( 20 from mercurial import (
55 p1, p2, linknode, copyfrom = mapping[node] 55 p1, p2, linknode, copyfrom = mapping[node]
56 ui.status( 56 ui.status(
57 _(b"%s => %s %s %s %s\n") 57 _(b"%s => %s %s %s %s\n")
58 % (short(node), short(p1), short(p2), short(linknode), copyfrom) 58 % (short(node), short(p1), short(p2), short(linknode), copyfrom)
59 ) 59 )
60 if p1 != nullid: 60 if p1 != sha1nodeconstants.nullid:
61 queue.append(p1) 61 queue.append(p1)
62 if p2 != nullid: 62 if p2 != sha1nodeconstants.nullid:
63 queue.append(p2) 63 queue.append(p2)
64 64
65 65
66 def buildtemprevlog(repo, file): 66 def buildtemprevlog(repo, file):
67 # get filename key 67 # get filename key
150 base = r.chainbase(i) 150 base = r.chainbase(i)
151 if format == 0: 151 if format == 0:
152 try: 152 try:
153 pp = r.parents(node) 153 pp = r.parents(node)
154 except Exception: 154 except Exception:
155 pp = [nullid, nullid] 155 pp = [repo.nullid, repo.nullid]
156 ui.write( 156 ui.write(
157 b"% 6d % 9d % 7d % 6d % 7d %s %s %s\n" 157 b"% 6d % 9d % 7d % 6d % 7d %s %s %s\n"
158 % ( 158 % (
159 i, 159 i,
160 r.start(i), 160 r.start(i),
195 ui.writenoi18n(b"digraph G {\n") 195 ui.writenoi18n(b"digraph G {\n")
196 for i in r: 196 for i in r:
197 node = r.node(i) 197 node = r.node(i)
198 pp = r.parents(node) 198 pp = r.parents(node)
199 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i)) 199 ui.write(b"\t%d -> %d\n" % (r.rev(pp[0]), i))
200 if pp[1] != nullid: 200 if pp[1] != repo.nullid:
201 ui.write(b"\t%d -> %d\n" % (r.rev(pp[1]), i)) 201 ui.write(b"\t%d -> %d\n" % (r.rev(pp[1]), i))
202 ui.write(b"}\n") 202 ui.write(b"}\n")
203 203
204 204
205 def verifyremotefilelog(ui, path, **opts): 205 def verifyremotefilelog(ui, path, **opts):
210 if file == b"repos": 210 if file == b"repos":
211 continue 211 continue
212 filepath = os.path.join(root, file) 212 filepath = os.path.join(root, file)
213 size, firstnode, mapping = parsefileblob(filepath, decompress) 213 size, firstnode, mapping = parsefileblob(filepath, decompress)
214 for p1, p2, linknode, copyfrom in pycompat.itervalues(mapping): 214 for p1, p2, linknode, copyfrom in pycompat.itervalues(mapping):
215 if linknode == nullid: 215 if linknode == sha1nodeconstants.nullid:
216 actualpath = os.path.relpath(root, path) 216 actualpath = os.path.relpath(root, path)
217 key = fileserverclient.getcachekey( 217 key = fileserverclient.getcachekey(
218 b"reponame", actualpath, file 218 b"reponame", actualpath, file
219 ) 219 )
220 ui.status( 220 ui.status(
369 for node in nodes: 369 for node in nodes:
370 seen = set() 370 seen = set()
371 current = node 371 current = node
372 deltabase = bases[current] 372 deltabase = bases[current]
373 373
374 while deltabase != nullid: 374 while deltabase != sha1nodeconstants.nullid:
375 if deltabase not in nodes: 375 if deltabase not in nodes:
376 ui.warn( 376 ui.warn(
377 ( 377 (
378 b"Bad entry: %s has an unknown deltabase (%s)\n" 378 b"Bad entry: %s has an unknown deltabase (%s)\n"
379 % (short(node), short(deltabase)) 379 % (short(node), short(deltabase))
395 current = deltabase 395 current = deltabase
396 seen.add(current) 396 seen.add(current)
397 deltabase = bases[current] 397 deltabase = bases[current]
398 # Since ``node`` begins a valid chain, reset/memoize its base to nullid 398 # Since ``node`` begins a valid chain, reset/memoize its base to nullid
399 # so we don't traverse it again. 399 # so we don't traverse it again.
400 bases[node] = nullid 400 bases[node] = sha1nodeconstants.nullid
401 return failures 401 return failures
402 402
403 403
404 def dumpdeltachain(ui, deltachain, **opts): 404 def dumpdeltachain(ui, deltachain, **opts):
405 hashformatter = hex 405 hashformatter = hex