mirror of
https://github.com/facebook/sapling.git
synced 2024-12-26 22:47:26 +03:00
py3: fix remotefilelog repack tests
Reviewed By: quark-zju Differential Revision: D19751790 fbshipit-source-id: a898a8c37929a73ee2654d2907e9ea5bb2e3fd8a
This commit is contained in:
parent
3a5728b32f
commit
41cc67d011
@ -8,17 +8,7 @@ from __future__ import absolute_import
|
||||
|
||||
import struct
|
||||
from collections import defaultdict
|
||||
from typing import (
|
||||
IO,
|
||||
Dict,
|
||||
Generator,
|
||||
Iterable,
|
||||
List,
|
||||
Optional,
|
||||
Sequence,
|
||||
Tuple,
|
||||
cast,
|
||||
)
|
||||
from typing import IO, Dict, Generator, Iterable, List, Optional, Sequence, Tuple, cast
|
||||
|
||||
from edenscm.mercurial import perftrace, progress, pycompat
|
||||
from edenscm.mercurial.i18n import _
|
||||
@ -32,7 +22,7 @@ from .shallowutil import buildpackmeta, parsepackmeta, readexactly, readpath, re
|
||||
|
||||
|
||||
def sendpackpart(filename, history, data, version=1):
|
||||
# type: (str, Sequence[Tuple[bytes, bytes, bytes, bytes, Optional[bytes]]], Sequence[Tuple[bytes, bytes, bytes, int]], int) -> Iterable[bytes]
|
||||
# type: (str, Sequence[Tuple[bytes, bytes, bytes, bytes, Optional[str]]], Sequence[Tuple[bytes, bytes, bytes, int]], int) -> Iterable[bytes]
|
||||
"""A wirepack is formatted as follows:
|
||||
|
||||
wirepack = <filename len: 2 byte unsigned int><filename>
|
||||
@ -58,7 +48,7 @@ def sendpackpart(filename, history, data, version=1):
|
||||
historylen = struct.pack("!I", len(history))
|
||||
rawhistory = b""
|
||||
for entry in history:
|
||||
copyfrom = entry[4] or b""
|
||||
copyfrom = pycompat.encodeutf8(entry[4] or "")
|
||||
copyfromlen = len(copyfrom)
|
||||
tup = entry[:-1] + (copyfromlen,)
|
||||
rawhistory += struct.pack("!20s20s20s20sH", *tup)
|
||||
@ -132,7 +122,7 @@ def readhistory(fh):
|
||||
for i in range(count):
|
||||
entry = readunpack(fh, "!20s20s20s20sH")
|
||||
if entry[4] != 0:
|
||||
copyfrom = readexactly(fh, entry[4])
|
||||
copyfrom = pycompat.decodeutf8(readexactly(fh, entry[4]))
|
||||
else:
|
||||
copyfrom = ""
|
||||
entry = entry[:4] + (copyfrom,)
|
||||
|
@ -2763,7 +2763,12 @@ class nodeinfoserializer(object):
|
||||
"invalid nodeinfo serialization: %s %s %s %s %s"
|
||||
% (hex(p1), hex(p2), hex(linknode), str(copyfromlen), raw[NODEINFOLEN:])
|
||||
)
|
||||
return p1, p2, linknode, raw[NODEINFOLEN : NODEINFOLEN + copyfromlen]
|
||||
return (
|
||||
p1,
|
||||
p2,
|
||||
linknode,
|
||||
pycompat.decodeutf8(raw[NODEINFOLEN : NODEINFOLEN + copyfromlen]),
|
||||
)
|
||||
|
||||
|
||||
class cachestoreserializer(object):
|
||||
|
@ -387,6 +387,10 @@ py_class!(class treemanifest |py| {
|
||||
}
|
||||
|
||||
def iteritems(&self) -> PyResult<PyObject> {
|
||||
self.items(py)
|
||||
}
|
||||
|
||||
def items(&self) -> PyResult<PyObject> {
|
||||
let mut result = Vec::new();
|
||||
let tree = self.underlying(py).borrow();
|
||||
for entry in tree.files(&AlwaysMatcher::new()) {
|
||||
|
@ -8,9 +8,6 @@ from __future__ import absolute_import
|
||||
from testutil.dott import feature, sh, testtmp # noqa: F401
|
||||
|
||||
|
||||
feature.require(["py2"])
|
||||
|
||||
|
||||
sh % ". $TESTDIR/library.sh"
|
||||
|
||||
sh % "hginit master"
|
||||
|
@ -1,4 +1,3 @@
|
||||
#require py2
|
||||
#chg-compatible
|
||||
|
||||
$ disable treemanifest
|
||||
|
@ -1,4 +1,3 @@
|
||||
#require py2
|
||||
#chg-compatible
|
||||
|
||||
$ . "$TESTDIR/library.sh"
|
||||
|
@ -1,4 +1,3 @@
|
||||
#require py2
|
||||
#chg-compatible
|
||||
|
||||
$ disable treemanifest
|
||||
|
@ -1,4 +1,3 @@
|
||||
#require py2
|
||||
#chg-compatible
|
||||
|
||||
$ enable amend
|
||||
|
@ -49,7 +49,7 @@ def hgcloneshallow(orig, dest, *args):
|
||||
*args
|
||||
)
|
||||
open(os.path.join(dest, ".hg/hgrc"), "ab").write(
|
||||
r"""
|
||||
b"""
|
||||
[remotefilelog]
|
||||
reponame=master
|
||||
[phases]
|
||||
|
Loading…
Reference in New Issue
Block a user