comparison mercurial/obsolete.py @ 46113:59fa3890d40a

node: import symbols explicitly There is no point in lazy importing mercurial.node, it is used all over the place anyway. So consistently import the used symbols directly. Fix one file using symbols indirectly via mercurial.revlog. Differential Revision: https://phab.mercurial-scm.org/D9480
author Joerg Sonnenberger <joerg@bec.de>
date Tue, 01 Dec 2020 21:54:46 +0100
parents 89a2afe31e82
children 6266d19556ad
comparison
equal deleted inserted replaced
46112:d6afa9c149c3 46113:59fa3890d40a
72 import errno 72 import errno
73 import struct 73 import struct
74 74
75 from .i18n import _ 75 from .i18n import _
76 from .pycompat import getattr 76 from .pycompat import getattr
77 from .node import (
78 bin,
79 hex,
80 nullid,
81 )
77 from . import ( 82 from . import (
78 encoding, 83 encoding,
79 error, 84 error,
80 node,
81 obsutil, 85 obsutil,
82 phases, 86 phases,
83 policy, 87 policy,
84 pycompat, 88 pycompat,
85 util, 89 util,
233 parents = (metadata.pop(b'p1', None),) 237 parents = (metadata.pop(b'p1', None),)
234 elif b'p0' in metadata: 238 elif b'p0' in metadata:
235 parents = () 239 parents = ()
236 if parents is not None: 240 if parents is not None:
237 try: 241 try:
238 parents = tuple(node.bin(p) for p in parents) 242 parents = tuple(bin(p) for p in parents)
239 # if parent content is not a nodeid, drop the data 243 # if parent content is not a nodeid, drop the data
240 for p in parents: 244 for p in parents:
241 if len(p) != 20: 245 if len(p) != 20:
242 parents = None 246 parents = None
243 break 247 break
260 if parents is not None: 264 if parents is not None:
261 if not parents: 265 if not parents:
262 # mark that we explicitly recorded no parents 266 # mark that we explicitly recorded no parents
263 metadata[b'p0'] = b'' 267 metadata[b'p0'] = b''
264 for i, p in enumerate(parents, 1): 268 for i, p in enumerate(parents, 1):
265 metadata[b'p%i' % i] = node.hex(p) 269 metadata[b'p%i' % i] = hex(p)
266 metadata = _fm0encodemeta(metadata) 270 metadata = _fm0encodemeta(metadata)
267 numsuc = len(sucs) 271 numsuc = len(sucs)
268 format = _fm0fixed + (_fm0node * numsuc) 272 format = _fm0fixed + (_fm0node * numsuc)
269 data = [numsuc, len(metadata), flags, pre] 273 data = [numsuc, len(metadata), flags, pre]
270 data.extend(sucs) 274 data.extend(sucs)
527 531
528 Exist as a separated function to allow the evolve extension for a more 532 Exist as a separated function to allow the evolve extension for a more
529 subtle handling. 533 subtle handling.
530 """ 534 """
531 for mark in markers: 535 for mark in markers:
532 if node.nullid in mark[1]: 536 if nullid in mark[1]:
533 raise error.Abort( 537 raise error.Abort(
534 _( 538 _(
535 b'bad obsolescence marker detected: ' 539 b'bad obsolescence marker detected: '
536 b'invalid successors nullid' 540 b'invalid successors nullid'
537 ) 541 )
637 for succ in succs: 641 for succ in succs:
638 if len(succ) != 20: 642 if len(succ) != 20:
639 raise ValueError(succ) 643 raise ValueError(succ)
640 if prec in succs: 644 if prec in succs:
641 raise ValueError( 645 raise ValueError(
642 'in-marker cycle with %s' % pycompat.sysstr(node.hex(prec)) 646 'in-marker cycle with %s' % pycompat.sysstr(hex(prec))
643 ) 647 )
644 648
645 metadata = tuple(sorted(pycompat.iteritems(metadata))) 649 metadata = tuple(sorted(pycompat.iteritems(metadata)))
646 for k, v in metadata: 650 for k, v in metadata:
647 try: 651 try:
1029 for p in relation[0] + relation[1]: 1033 for p in relation[0] + relation[1]:
1030 folddigest.update(b'%d' % p.rev()) 1034 folddigest.update(b'%d' % p.rev())
1031 folddigest.update(p.node()) 1035 folddigest.update(p.node())
1032 # Since fold only has to compete against fold for the same successors, it 1036 # Since fold only has to compete against fold for the same successors, it
1033 # seems fine to use a small ID. Smaller ID save space. 1037 # seems fine to use a small ID. Smaller ID save space.
1034 return node.hex(folddigest.digest())[:8] 1038 return hex(folddigest.digest())[:8]
1035 1039
1036 1040
1037 def createmarkers( 1041 def createmarkers(
1038 repo, relations, flag=0, date=None, metadata=None, operation=None 1042 repo, relations, flag=0, date=None, metadata=None, operation=None
1039 ): 1043 ):