sapling/eden/scm/edenscm/hgext/remotefilelog/constants.py
Durham Goode f5a2347fbb py3: fix Mononoke Python 3 test failures
Summary:
Fixes a few issues with Mononoke tests in Python 3.

1. We need to use different APIs to account for the unicode vs bytes difference
for path hash encoding.
2. We need to set the language environment for tests that create utf8 file
paths.
3. We need the redaction message and marker to be bytes.  Oddly this test still
fails with jq CLI errors, but it makes it past the original error.

Reviewed By: quark-zju

Differential Revision: D23582976

fbshipit-source-id: 44959903aedc5dc9c492ec09a17b9c8e3bdf9457
2020-09-09 18:31:04 -07:00

47 lines
1.4 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
import struct
from edenscm.mercurial.i18n import _
REQUIREMENT = "remotefilelog"
FILENAMESTRUCT = "!H"
FILENAMESIZE = struct.calcsize(FILENAMESTRUCT)
NODESIZE = 20
PACKREQUESTCOUNTSTRUCT = "!I"
NODECOUNTSTRUCT = "!I"
NODECOUNTSIZE = struct.calcsize(NODECOUNTSTRUCT)
PATHCOUNTSTRUCT = "!I"
PATHCOUNTSIZE = struct.calcsize(PATHCOUNTSTRUCT)
FILEPACK_CATEGORY = ""
TREEPACK_CATEGORY = "manifests"
ALL_CATEGORIES = [FILEPACK_CATEGORY, TREEPACK_CATEGORY]
# revision metadata keys. must be a single character.
METAKEYFLAG = "f" # revlog flag
METAKEYSIZE = "s" # full rawtext size
# Tombstone string returned as content for redacted files
REDACTED_CONTENT = b"PoUOK1GkdH6Xtx5j9WKYew3dZXspyfkahcNkhV6MJ4rhyNICTvX0nxmbCImFoT0oHAF9ivWGaC6ByswQZUgf1nlyxcDcahHknJS15Vl9Lvc4NokYhMg0mV1rapq1a4bhNoUI9EWTBiAkYmkadkO3YQXV0TAjyhUQWxxLVskjOwiiFPdL1l1pdYYCLTE3CpgOoxQV3EPVxGUPh1FGfk7F9Myv22qN1sUPSNN4h3IFfm2NNPRFgWPDsqAcaQ7BUSKa\n"
# Message shown to the user when file is redacted
REDACTED_MESSAGE = b"This version of the file is redacted and you are not allowed to access it. Update or rebase to a newer commit.\n"
def getunits(category):
if category == FILEPACK_CATEGORY:
return _("files")
if category == TREEPACK_CATEGORY:
return _("trees")