Commit Graph

3156 Commits

Author SHA1 Message Date
Jun Wu
1e9cec215e py3: profiling: fix some encoding issues
Summary: Write bytes to files.

Reviewed By: farnz

Differential Revision: D19615833

fbshipit-source-id: 0f5a0df493715fad5723b98f4b4246fc1dec53be
2020-01-29 07:45:20 -08:00
Jun Wu
9cafa05c43 py3: phases: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615840

fbshipit-source-id: ad9694e736b24254172f732f988230b987597e0e
2020-01-29 07:45:19 -08:00
Jun Wu
573b64085c py3: peer: fix a minor encoding issues
Summary: The "function name" is unicode in Python 3. Put unicode as the dict keys.

Reviewed By: farnz

Differential Revision: D19615814

fbshipit-source-id: 3508f59d11e4f8ab6345c80c6bdfaff150a63d76
2020-01-29 07:45:19 -08:00
Jun Wu
47d36736ae py3: obsolete: fix some encoding issues
Summary: Use bytes to write files.

Reviewed By: farnz

Differential Revision: D19615831

fbshipit-source-id: 0868b9272f3570547326f63e34b9b6a489788464
2020-01-29 07:45:19 -08:00
Jun Wu
330306cfde py3: blackbox: fix some encoding issues
Summary: Use bytes to write files.

Reviewed By: farnz

Differential Revision: D19615824

fbshipit-source-id: fa7b87dea80960dcc7b6586b3d50baef6228db3a
2020-01-29 07:45:18 -08:00
Jun Wu
bfa9485f90 py3: merge: fix some encoding issues
Summary: This affects mergestate and updatestate.

Reviewed By: farnz

Differential Revision: D19615836

fbshipit-source-id: bc549c71a5ba5ba9d2069deb1e77cb580f210ba2
2020-01-29 07:45:18 -08:00
Jun Wu
751d53d4e6 py3: localrepo: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615825

fbshipit-source-id: 1801652ed93ac9218a66af7f23f5bce9eab3ab10
2020-01-29 07:45:17 -08:00
Jun Wu
456a0ad5e1 py3: json: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615829

fbshipit-source-id: 3d251b8febedbdfbefe5b1e59ea026de54503663
2020-01-29 07:45:17 -08:00
Jun Wu
29711c1cf0 py3: hg: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615834

fbshipit-source-id: 8c8aaaf6bca688476662f29375b8c5484ff0765a
2020-01-29 07:45:17 -08:00
Jun Wu
3dea327fba py3: eden_dirstate: use unicode paths on Python 3
Reviewed By: farnz

Differential Revision: D19615837

fbshipit-source-id: 97e514fbc5ab3b077fd9b6c56cd8b5d7b6bc7856
2020-01-29 07:45:16 -08:00
Jun Wu
60733ef7b2 py3: dirstate: fix some encoding issues
Summary: Some assertions were added to make sure paths are unicode.

Reviewed By: farnz

Differential Revision: D19615813

fbshipit-source-id: 7d2135c0ac424fc46edd9d660b072a2a95be7f82
2020-01-29 07:45:16 -08:00
Jun Wu
a3d23bb8d7 py3: context: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615827

fbshipit-source-id: 79cfab528eeb00048b00be75fa776737b49a53d7
2020-01-29 07:45:15 -08:00
Jun Wu
0ad9daf67f py3: config: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615815

fbshipit-source-id: 2ae650dc321c776b50f49070b1c8f18dd5a2149f
2020-01-29 07:45:15 -08:00
Jun Wu
b084775bd8 py3: changegroup: fix some encoding issues
Summary:
Changegroup should be using bytes mostly except when it tries to access
files via `repo.file(path)`. The `path` should be unicode on Python 3.
Make it happen. Some assertions are added to help capture issues.

Reviewed By: farnz

Differential Revision: D19615835

fbshipit-source-id: b35d13152ecb835092c7870e88383f484dc5f868
2020-01-29 07:45:15 -08:00
Jun Wu
ef1dd7f142 py3: bundle2: use some bytes
Summary:
The bundle2 layer uses bytes since it's part of the wireprotocol.
Some assertions were added to help detecting issues.

Reviewed By: farnz

Differential Revision: D19615832

fbshipit-source-id: 73ea657b501c7539b17862165c7a5781884013a2
2020-01-29 07:45:14 -08:00
Jun Wu
19c31c1690 py3: remotefilelog: add some type assertions
Summary: This helps detecting type errors at runtime.

Reviewed By: farnz

Differential Revision: D19615821

fbshipit-source-id: 0f45e1271aff50c29858c823366a0a54c89a3903
2020-01-29 07:45:14 -08:00
Jun Wu
e2b48e1122 py3: manifest: use bytes
Summary: The layer interacting with raw manifest text should use bytes.

Reviewed By: farnz

Differential Revision: D19613694

fbshipit-source-id: c5a12235eb50acd90e409c1059a3f9f11665f9f3
2020-01-29 07:45:14 -08:00
Jun Wu
fe28d31b8f py3: lock: drop an unnecessary encoding conversion
Summary: Use native unicode hostname without converting it to bytes.

Reviewed By: farnz

Differential Revision: D19613692

fbshipit-source-id: 0bd7e37890b96566143fb0501c3fa310270844d3
2020-01-29 07:45:13 -08:00
Jun Wu
3add434b57 py3: changelog: use bytes in low-level interfaces
Summary:
Like revlog, the changelog layer should use bytes for parsing its raw content.
`str` is still used for users, messages, etc.

Reviewed By: markbt

Differential Revision: D19613695

fbshipit-source-id: 4f6758f9fca0788bc89ad5c14d9103f66d19b7f2
2020-01-29 07:45:13 -08:00
Jun Wu
63ea4b2ab0 py3: bookmarks: fix encoding
Summary:
Bookmarks use unicode by default. Only need to use bytes when interacting with
vfs.

Reviewed By: farnz

Differential Revision: D19613689

fbshipit-source-id: bbe80e552cf17a023e5905f849a273b4b4299dc5
2020-01-29 07:45:13 -08:00
Jun Wu
47f4f75aba py3: diff: fix patchtext encoding
Summary: The patchtext is about a binary patch. It should use bytes.

Reviewed By: farnz

Differential Revision: D19613688

fbshipit-source-id: 20bddeb17f520f625396b23b5dcead7c7bbd3ede
2020-01-29 07:45:12 -08:00
Jun Wu
4ef1f31745 py3: util: fix some encoding issues
Summary:
Make sure file content and wireproto buffers are using bytes.
Added a utf8 helper function.

Reviewed By: farnz

Differential Revision: D19613686

fbshipit-source-id: 5d67ce48246dc8c3cc47041f461e454c46bc67f9
2020-01-29 07:45:12 -08:00
Jun Wu
32eec0fc37 py3: lock: fix encoding
Reviewed By: farnz

Differential Revision: D19613690

fbshipit-source-id: 617220ac09df7ccbbd1a3bee627b1a796199a33a
2020-01-29 07:45:12 -08:00
Jun Wu
2a28611d8a py3: pycompat: make fsencode/fsdecode do nothing
Summary:
We want to assume almost all paths are unicode and drop support for non-unicode
paths. `os.fsencode` returns bytes that breaks the assumption.

Change fsencode and fsdecode to do nothing so path types remain unicode.

Most use-cases are related to `__file__`, which is already unicode on Python 3.
`posix._checklink` uses it. But it seems making it no-op is okay.

Reviewed By: farnz

Differential Revision: D19613693

fbshipit-source-id: 587dbeef68b23beeaf6bc8861c71ea27b3c512d7
2020-01-29 07:45:11 -08:00
Jun Wu
0e6add4877 py3: repair: fix encoding for SHA1 calculation
Reviewed By: farnz

Differential Revision: D19613687

fbshipit-source-id: e8dbbcc8c1151dd2defe63b1c67df0a3dc598c90
2020-01-29 07:45:11 -08:00
Jun Wu
21b2a06c6f py3: vfs: add helper functions to get utf-8 content directly
Summary: Those will simplify some use-cases.

Reviewed By: farnz

Differential Revision: D19613121

fbshipit-source-id: 85ac4fa0c86afb84e0c9fb78950d3da2c93aa967
2020-01-29 07:45:10 -08:00
Jun Wu
535b35f427 py3: treestate: fix encoding
Summary: The raw blobs are in bytes, while paths and other things are in native string.

Reviewed By: markbt

Differential Revision: D19613122

fbshipit-source-id: e865168b5bc839e85ef843d771d8a6044e35a03a
2020-01-29 07:45:10 -08:00
Jun Wu
a986833f9e py3: ui.edit: fix encoding
Summary:
The commit message should be in native string. The raw file content is bytes.
Add translation for that.

Reviewed By: xavierd

Differential Revision: D19613117

fbshipit-source-id: 1b4145f0de75e48df3416cd7c52c09df1e6c4a07
2020-01-29 07:45:10 -08:00
Jun Wu
96309864ff py3: remotefilelog: use bytes
Summary: Like filelog, the remotefilelog layer should use bytes.

Reviewed By: xavierd

Differential Revision: D19613119

fbshipit-source-id: c8221ac21dc255ad0a837b2bb30fa9966df95390
2020-01-29 07:45:09 -08:00
Jun Wu
0c6dc8d8c9 py3: filelog: use bytes
Summary: Like revlog, the filelog layer should use bytes.

Reviewed By: sfilipco

Differential Revision: D19613116

fbshipit-source-id: 6b07d05a6960c2d1c8b4ebe3001632fd8024c5af
2020-01-29 07:45:09 -08:00
Jun Wu
df36f5c459 py3: revlog: use bytes
Summary: The revlog layer should use bytes.

Reviewed By: sfilipco

Differential Revision: D19613120

fbshipit-source-id: 09f0028cbf810b52694643c79c91997d434cdaf5
2020-01-29 07:45:08 -08:00
Jun Wu
cb289128dc py3: pycompat: add helpers for encode("utf-8")
Summary:
On Python 2 we want bytes.encode("utf-8") to be no-op, while on Python 3 we
want it to return a real `str`. This helper function does that.

Reviewed By: sfilipco

Differential Revision: D19613118

fbshipit-source-id: 1f0fc31bf8aee28cc20694da52b10b12dbdd9000
2020-01-29 07:45:08 -08:00
Jun Wu
9b4d48bcea py3: lz4revlog: fix encoding issues
Summary: The lz4revlog extension needs binary types.

Reviewed By: sfilipco

Differential Revision: D19612879

fbshipit-source-id: c66d3953883d9b06fc9867511843c36d44fe2245
2020-01-29 07:45:08 -08:00
Mark Thomas
1e63f205f4 rust-cpython: allow compilation for both py2 and py3
Summary:
Set up the `cpython-ext` and `hgcommands` libraries so that they can compile
against py2 and py3 versions of rust-cpython.  Make py2 the default so
that cargo test still works.

Reviewed By: singhsrb

Differential Revision: D19615656

fbshipit-source-id: 3403e7077deb3c0a9dfe0e3b7d4f4ad1da73bba3
2020-01-28 20:17:20 -08:00
Genevieve Helsel
ce2bf270b3 fix_map
Summary: Python 3 map call doesn't return list, so wrap in list.

Reviewed By: mitrandir77, xavierd

Differential Revision: D19588352

fbshipit-source-id: 8556f4783f9bedb8a74ec0e99ff226ff96f387a9
2020-01-28 18:24:56 -08:00
Stefan Filip
cdc1efc872 py3: open stdout log file in text mode
Summary: In both py2 and py3 stdout is text mode.

Reviewed By: simpkins

Differential Revision: D19613397

fbshipit-source-id: fe01363836cb5956c7e6d83a0f81488649c262a9
2020-01-28 17:17:45 -08:00
Xavier Deguillard
40d31b3060 traceprof: remove some b
Summary:
The config functions takes Str (ie: bytes in Python2, Unicode in Python3), the
b is uncessary.

Reviewed By: sfilipco

Differential Revision: D19611274

fbshipit-source-id: 0807bd6aed1b5bd0baa0b78d3dfcbb9c46aeff35
2020-01-28 17:07:36 -08:00
Xavier Deguillard
b1e73324ea clindex: remove some b
Summary: All of these should just plain strings.

Reviewed By: sfilipco

Differential Revision: D19611275

fbshipit-source-id: 1d16c10df6f67cee9dadd7480c40950c0abae926
2020-01-28 17:07:36 -08:00
Zeyi (Rice) Fan
09d7bb259c make part of the tests Python 3 compatible
Summary:
Most of these tests use `file` instead of `open` for opening files, which is removed in Python 3. And when we open files in byte mode, Python disallows writing `str` into such files, so we add `b` prefix to write actual bytes instead.

There are some other minor problems like reading from `sys.stdin` gives you `str` while expecting `bytes`. The solution is to use `sys.stdin.buffer` instead. However, Python 2 does not have `sys.stdin.buffer` so we have to do a version check to provide compatibility.

Reviewed By: quark-zju

Differential Revision: D19606357

fbshipit-source-id: e9177134294f03af8b581230a57902c3435b319a
2020-01-28 16:42:11 -08:00
Adam Simpkins
c6b023ce2a py3: remove an incorrect encode() call in python 3
Summary:
We want all config values to always be `str` types, so remove this explicit
`encode()` call that was trying to convert the value to `bytes`.

Reviewed By: sfilipco

Differential Revision: D19610590

fbshipit-source-id: a72f0755cdb12cae13fb9d58f529433d508d46e9
2020-01-28 16:33:38 -08:00
Mark Thomas
ffa61b0945 hggit: allow empty repos when dulwich returns empty FetchPackResult
Summary:
For empty repos, some versions of dulwich return a non-`None` `FetchPackResult`
where `bool(result)` throws an exception.   Handle this by explicitly checking
for `result.refs` being `None`, too.

Reviewed By: sfilipco

Differential Revision: D19611221

fbshipit-source-id: 094e3ec667a484a150eb75596684a120528159e9
2020-01-28 16:27:29 -08:00
Mark Thomas
82715fd2ea py3: iter{keys,values,items} -> pycompat.iter{keys,values,items}
Reviewed By: quark-zju

Differential Revision: D19608323

fbshipit-source-id: dd186ef16d6422a56af41fcaa850d9838ae9a240
2020-01-28 16:27:28 -08:00
Genevieve Helsel
ec51946a13 add pyre ignore for dbm
Summary: this pyre-ignore got lost in translation and caused pyre eden to fail

Reviewed By: sfilipco, mitrandir77, xavierd

Differential Revision: D19610997

fbshipit-source-id: b21faa36ee6b45585a774402d081bb7a3b8731b4
2020-01-28 16:16:40 -08:00
Adam Simpkins
ad957e7803 py3: update Rust hgcommands code to pass argv to python as Str
Summary:
Update the Rust hgcommands code to pass the command line arguments into the
Python logic as `Str` types, so that this will be Unicode `str` objects when
using Python 3.

Reviewed By: xavierd

Differential Revision: D19596739

fbshipit-source-id: 7cdfd44a1c4ce8b0f86d20b634d9b27eab822b2d
2020-01-28 15:58:37 -08:00
Adam Simpkins
2165181562 py3: ensure all command names are str
Summary:
Several of the debug commands explicitly defined their command names as bytes.
Remove the leading `b` prefix so that all command names are uniformly `str`
data types.

Reviewed By: DurhamG, sfilipco

Differential Revision: D19596738

fbshipit-source-id: 3851a32c38009968dfa338877b9ae03015dfca61
2020-01-28 15:56:20 -08:00
Genevieve Helsel
de029e9be7 unicode to pycompat.unicode
Summary: Use pycompat unicode instead of python 2 built in unicode to check type.

Reviewed By: mitrandir77

Differential Revision: D19589969

fbshipit-source-id: 3e3cf2c5cb6fd90cca9c8f803e7bd45f262f96e5
2020-01-28 15:45:17 -08:00
Xavier Deguillard
8697be6910 minirst: use string regexp
Summary: The input of minirst will be unicode, therefore, remove the b prefix.

Reviewed By: sfilipco

Differential Revision: D19610028

fbshipit-source-id: d3b1ebfeb1ba5a30afe250ce5713857dd9ebc359
2020-01-28 15:40:56 -08:00
Xavier Deguillard
ff536a2c24 remotenames: use Mapping instead of DictMixin
Summary: The later is deprecated since python 2.6, and the former works in python3

Reviewed By: simpkins

Differential Revision: D19608560

fbshipit-source-id: c9e45bbc51f0e20416c2640dfc25e4cac4934152
2020-01-28 15:40:56 -08:00
Mateusz Kwapich
7f606baac5 store: remove extra b's
Summary: The fallback filename handling can be utf8 under py3

Reviewed By: sfilipco

Differential Revision: D19610624

fbshipit-source-id: a86ed958edca70597ff5a7c67cbc746c1e325518
2020-01-28 15:37:09 -08:00
Xavier Deguillard
08f8dbab46 pycliparser: use Str instead of Bytes
Reviewed By: quark-zju

Differential Revision: D19607631

fbshipit-source-id: 472b660c9dcd2d044567ce091bf7fa0fdf157121
2020-01-28 15:02:21 -08:00