Mercurial > public > mercurial-scm > hg-stable
diff hgext/journal.py @ 46114: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 | 9f70512ae2cf |
children | d55b71393907 |
line wrap: on
line diff
--- a/hgext/journal.py Sun Dec 13 18:29:22 2020 -0800 +++ b/hgext/journal.py Tue Dec 01 21:54:46 2020 +0100 @@ -19,6 +19,11 @@ import weakref from mercurial.i18n import _ +from mercurial.node import ( + bin, + hex, + nullid, +) from mercurial import ( bookmarks, @@ -31,7 +36,6 @@ localrepo, lock, logcmdutil, - node, pycompat, registrar, util, @@ -113,8 +117,8 @@ new = list(new) if util.safehasattr(dirstate, 'journalstorage'): # only record two hashes if there was a merge - oldhashes = old[:1] if old[1] == node.nullid else old - newhashes = new[:1] if new[1] == node.nullid else new + oldhashes = old[:1] if old[1] == nullid else old + newhashes = new[:1] if new[1] == nullid else new dirstate.journalstorage.record( wdirparenttype, b'.', oldhashes, newhashes ) @@ -127,7 +131,7 @@ if util.safehasattr(repo, 'journal'): oldmarks = bookmarks.bmstore(repo) for mark, value in pycompat.iteritems(store): - oldvalue = oldmarks.get(mark, node.nullid) + oldvalue = oldmarks.get(mark, nullid) if value != oldvalue: repo.journal.record(bookmarktype, mark, oldvalue, value) return orig(store, fp) @@ -248,8 +252,8 @@ ) = line.split(b'\n') timestamp, tz = time.split() timestamp, tz = float(timestamp), int(tz) - oldhashes = tuple(node.bin(hash) for hash in oldhashes.split(b',')) - newhashes = tuple(node.bin(hash) for hash in newhashes.split(b',')) + oldhashes = tuple(bin(hash) for hash in oldhashes.split(b',')) + newhashes = tuple(bin(hash) for hash in newhashes.split(b',')) return cls( (timestamp, tz), user, @@ -263,8 +267,8 @@ def __bytes__(self): """bytes representation for storage""" time = b' '.join(map(pycompat.bytestr, self.timestamp)) - oldhashes = b','.join([node.hex(hash) for hash in self.oldhashes]) - newhashes = b','.join([node.hex(hash) for hash in self.newhashes]) + oldhashes = b','.join([hex(hash) for hash in self.oldhashes]) + newhashes = b','.join([hex(hash) for hash in self.newhashes]) return b'\n'.join( ( time,