py3: fix commitcloud lock output

Summary:
The use of json meant the progress step was coming out as unicode when
it should be str. Use the mercurial.json functions to solve this for python 2
and 3.

Reviewed By: xavierd

Differential Revision: D19777255

fbshipit-source-id: 15c8e45425fc8742b6e118249104fc1fb2f3345d
This commit is contained in:
Durham Goode 2020-02-06 13:21:31 -08:00 committed by Facebook Github Bot
parent d39eea991b
commit 309a3a0592

View File

@ -7,10 +7,16 @@ from __future__ import absolute_import
import contextlib
import errno
import json
import subprocess
from edenscm.mercurial import error, lock as lockmod, node as nodemod, pycompat, util
from edenscm.mercurial import (
error,
json,
lock as lockmod,
node as nodemod,
pycompat,
util,
)
from edenscm.mercurial.i18n import _
@ -32,7 +38,7 @@ progressfilename = "commitcloudsyncprogress"
def progress(repo, step, **kwargs):
with repo.sharedvfs.open(progressfilename, "w", atomictemp=True) as f:
with repo.sharedvfs.open(progressfilename, "wb", atomictemp=True) as f:
data = {"step": str(step), "data": kwargs}
f.write(pycompat.encodeutf8(json.dumps(data)))
@ -61,7 +67,7 @@ def progresscomplete(repo):
def _getprogressstep(repo):
try:
data = json.load(repo.sharedvfs.open(progressfilename))
data = json.loads(repo.sharedvfs.open(progressfilename).read())
except IOError as e:
if e.errno != errno.ENOENT:
raise