Mercurial > hg
diff hgext/fastannotate/context.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 | 2d49482d0dd4 |
children | 6000f5b25c9b |
line wrap: on
line diff
--- a/hgext/fastannotate/context.py Sun Dec 13 18:29:22 2020 -0800 +++ b/hgext/fastannotate/context.py Tue Dec 01 21:54:46 2020 +0100 @@ -17,12 +17,16 @@ open, setattr, ) +from mercurial.node import ( + bin, + hex, + short, +) from mercurial import ( error, linelog as linelogmod, lock as lockmod, mdiff, - node, pycompat, scmutil, util, @@ -150,7 +154,7 @@ diffoptstr = stringutil.pprint( sorted((k, getattr(diffopts, k)) for k in mdiff.diffopts.defaults) ) - return node.hex(hashutil.sha1(diffoptstr).digest())[:6] + return hex(hashutil.sha1(diffoptstr).digest())[:6] _defaultdiffopthash = hashdiffopts(mdiff.defaultopts) @@ -308,7 +312,7 @@ # command could give us a revision number even if the user passes a # commit hash. if isinstance(rev, int): - rev = node.hex(self.repo.changelog.node(rev)) + rev = hex(self.repo.changelog.node(rev)) # fast path: if rev is in the main branch already directly, revfctx = self.canannotatedirectly(rev) @@ -493,7 +497,7 @@ result = True f = None if not isinstance(rev, int) and rev is not None: - hsh = {20: bytes, 40: node.bin}.get(len(rev), lambda x: None)(rev) + hsh = {20: bytes, 40: bin}.get(len(rev), lambda x: None)(rev) if hsh is not None and (hsh, self.path) in self.revmap: f = hsh if f is None: @@ -598,7 +602,7 @@ self.ui.debug( b'fastannotate: reading %s line #%d ' b'to resolve lines %r\n' - % (node.short(hsh), linenum, idxs) + % (short(hsh), linenum, idxs) ) fctx = self._resolvefctx(hsh, revmap.rev2path(rev)) lines = mdiff.splitnewlines(fctx.data()) @@ -610,8 +614,7 @@ # run the annotate and the lines should match to the file content self.ui.debug( - b'fastannotate: annotate %s to resolve lines\n' - % node.short(hsh) + b'fastannotate: annotate %s to resolve lines\n' % short(hsh) ) linelog.annotate(rev) fctx = self._resolvefctx(hsh, revmap.rev2path(rev)) @@ -640,12 +643,10 @@ hsh = f.node() llrev = self.revmap.hsh2rev(hsh) if not llrev: - raise faerror.CorruptedFileError( - b'%s is not in revmap' % node.hex(hsh) - ) + raise faerror.CorruptedFileError(b'%s is not in revmap' % hex(hsh)) if (self.revmap.rev2flag(llrev) & revmapmod.sidebranchflag) != 0: raise faerror.CorruptedFileError( - b'%s is not in revmap mainbranch' % node.hex(hsh) + b'%s is not in revmap mainbranch' % hex(hsh) ) self.linelog.annotate(llrev) result = [