sapling/eden/scm/edenscm/node.py
Muir Manders 159fe07e6d node: remove Python 2 support
Reviewed By: quark-zju

Differential Revision: D42183497

fbshipit-source-id: 069fe3dd1a319dd428ed0ebc1e5a6ee8c0e228cc
2022-12-21 13:50:31 -08:00

52 lines
1.2 KiB
Python

# Portions Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
# node.py - basic nodeid manipulation for mercurial
#
# Copyright 2005, 2006 Olivia Mackall <olivia@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
import binascii
# This ugly style has a noticeable effect in manifest parsing
bhex = binascii.hexlify
bbin = binascii.unhexlify
def bin(node):
try:
return bbin(node)
except binascii.Error as e:
raise TypeError(e)
hex = bytes.hex
nullrev = -1
nullid = b"\0" * 20
nullhex = hex(nullid)
# Phony node value to stand-in for new files in some uses of
# manifests.
newnodeid = b"!" * 20
addednodeid = (b"0" * 15) + b"added"
modifiednodeid = (b"0" * 12) + b"modified"
wdirnodes = {newnodeid, addednodeid, modifiednodeid}
# pseudo identifiers for working directory
# (they are experimental, so don't add too many dependencies on them)
wdirrev = 0x7FFFFFFF
wdirid = b"\xff" * 20
wdirhex = hex(wdirid)
def short(node):
return hex(node[:6])