Commit Graph

871 Commits

Author SHA1 Message Date
Xavier Deguillard
fd2c463b9a rebase: decode rebasestate before parsing it
Summary:
This file contains text data, let's decode it before doing anything else with
it.

Reviewed By: quark-zju

Differential Revision: D19675385

fbshipit-source-id: 8aae08c2400dd7d76c8678d5312bab060563e0ba
2020-01-31 18:12:14 -08:00
Xavier Deguillard
06fa75f637 tests: use vfs.writeutf8
Summary: This is the right method to write plain strings data to files.

Reviewed By: quark-zju

Differential Revision: D19675386

fbshipit-source-id: 1f939f79294cbc45f56944058649c384b674b880
2020-01-31 18:12:14 -08:00
Jun Wu
6462672163 pycompat: drop sysbytes, sysstr, strurl, bytesurl
Summary: There are no-ops.  This makes type checkers' life slightly easier.

Reviewed By: farnz

Differential Revision: D19673051

fbshipit-source-id: 363eb8a4e799113b16529825d45645807cafe2fc
2020-01-31 17:59:53 -08:00
Saurabh Singh
185119e3c0 test-extension: fix the test
Summary: This is broken after D19672686.

Reviewed By: quark-zju

Differential Revision: D19674321

fbshipit-source-id: 7f225b7090ce9168e10e02b25ee17ae2b98cd86a
2020-01-31 17:37:43 -08:00
Saurabh Singh
1891591abc unicode: consistently use 'utf-8' everywhere
Summary:
We generally use 'utf-8' but are using 'utf8' at some places. This
diff changes to using 'utf-8' consistently everywhere.

Reviewed By: farnz

Differential Revision: D19674111

fbshipit-source-id: 3be42859a180ded1c234b805259f086f9531ba18
2020-01-31 17:34:53 -08:00
Xavier Deguillard
57d59e5499 remotenames: write bytes to the file
Summary: The write method requires bytes, let's encode what we're writing into it.

Reviewed By: quark-zju

Differential Revision: D19674450

fbshipit-source-id: 9eaa3393d3d0e6324be39f94d7f31f2228b14412
2020-01-31 17:31:24 -08:00
Xavier Deguillard
7182c8c2ca hgdemandimport: use a set for the ignored modules
Summary:
A set gives us constant time test, while list requires a linear search. This
may speedup the importer slightly.

Reviewed By: quark-zju

Differential Revision: D19674449

fbshipit-source-id: 994a5303114d54b9cd40469b7cfe4b35e2515729
2020-01-31 17:31:23 -08:00
Xavier Deguillard
6f3af2ab10 tests: remove iteritems
Summary: The method doesn't exist in python3, let's simply replace it with items.

Reviewed By: quark-zju

Differential Revision: D19673674

fbshipit-source-id: b17eef7d820ae38db3fea1d457b0b8bb409f1b86
2020-01-31 17:31:23 -08:00
Xavier Deguillard
bf3292412a patch: add a missing b""
Summary:
The headers are bytes, therefore startswith needs to be called with a bytes
argument.

Reviewed By: quark-zju

Differential Revision: D19673675

fbshipit-source-id: 9a978ad42bf94a55c984f2ae35c566a59bfd6180
2020-01-31 17:31:23 -08:00
Adam Simpkins
bcad94171a py3: add pycompat.ABC
Summary:
Assigning to `__metaclass__` only works in Python 2.  In Python 3 this
attribute is ignored, and you instead need to specify `metaclass=` in your
class signature.

This adds a new `pycompat.ABC` base class to make it easier to define abstract
classes that are compatible with both Python 2 and 3.

Reviewed By: sfilipco

Differential Revision: D19672078

fbshipit-source-id: c56eb6c7266f962ef9c13c742e6ac0651b9c19c9
2020-01-31 17:05:54 -08:00
Adam Simpkins
3abc65f90d py3: add type annotations to ui.write()
Summary:
Add type annotations to `ui.write()` and the helper functions it calls.
I also removed unused `**opts` arguments on a few of the helper functions that
it calls.

Reviewed By: markbt

Differential Revision: D19657806

fbshipit-source-id: d020396a51d9fc3b07542c65541fca6067addb23
2020-01-31 17:05:54 -08:00
Zeyi (Rice) Fan
fa54b36b93 fix Windows tests
Summary: This fixes the Windows build failure we are seeing. Apparently Python 2 on Windows does not like unicode type in `os.environ`

Reviewed By: markbt

Differential Revision: D19672308

fbshipit-source-id: b45c1ccf47bdd46dc31d6c980d0e70dd2e084c8f
2020-01-31 16:53:12 -08:00
Saurabh Singh
2f3657f342 test-unbundlereplay: fix the test
Reviewed By: farnz

Differential Revision: D19673662

fbshipit-source-id: e2b05e9efb449ffa1af24c5b221eca1e97873b13
2020-01-31 16:47:43 -08:00
Jun Wu
5d3db79c23 pycompat: drop strkwargs / byteskwargs
Summary: There are no-ops.  This makes type checkers' life slightly easier.

Reviewed By: markbt

Differential Revision: D19673053

fbshipit-source-id: 04f26cd3ca0dbfe579ef939fc39be00035e70cee
2020-01-31 16:38:03 -08:00
Jun Wu
ae22d7d613 pycompat: drop fsencode / fsdecode
Summary:
There are basically no-op (see D19613693).
This makes type checkers' life slightly easier.

Reviewed By: farnz

Differential Revision: D19672686

fbshipit-source-id: 27ca44dd53ec9788fdbb8f31235eae88d1853415
2020-01-31 16:38:03 -08:00
Jun Wu
30f2b80d9f pycompat: drop iterbytestr
Summary: This makes type checkers' life easier.

Reviewed By: markbt

Differential Revision: D19672687

fbshipit-source-id: 335c560289e29ac7c08e36501e9841ddc51232be
2020-01-31 16:38:03 -08:00
Jun Wu
ad0c50a5cb py3: fix some type issues detected by pyre with some type stubs
Summary:
The issues were found by pyre with some type stubs generated via pytype:

  python36 -m pytype edenscm --no-report-errors -j 30

I didn't include the pytype generated stubs because most of them are `Any`.
I'm trying to see if we can get something cleaner.

Reviewed By: markbt

Differential Revision: D19672435

fbshipit-source-id: c57f2ad3a981ddd4a3a267ff1c00e7bdb71e65ca
2020-01-31 16:38:02 -08:00
Simon Farnsworth
9266779248 py3: tools to quickly remove the py2 only marking from tests
Summary:
Simple tools, based on D19664298, that use the JSON report to enable py2 only tests for py3 testing, and revert the changes to those tests that fail.

update-successes.py is just xavierd's original code

Use as needed to enable tests on py3 after debugging, A recommended workflow is in the test plan

Reviewed By: singhsrb

Differential Revision: D19670838

fbshipit-source-id: fc525941cb010c9038c1f73d89913420e0c79981
2020-01-31 16:35:39 -08:00
Xavier Deguillard
fe3fc9712f pyrevisionstore: copyfrom should be PyPathBuf, not PyBytes
Summary: This was missed while converting pyrevisionstore to PyPathBuf.

Reviewed By: markbt

Differential Revision: D19672441

fbshipit-source-id: 466a66f2e00c7f73c11a8989c22508560f423e0e
2020-01-31 16:19:25 -08:00
Mark Thomas
df702d9cb6 py3: encode communication with the worker
Reviewed By: quark-zju

Differential Revision: D19665152

fbshipit-source-id: d4cda1e48bdf0fe64047e12d3011c81b501df113
2020-01-31 15:57:38 -08:00
Mateusz Kwapich
d5a207cf18 py3: fix more diff tests
Summary: This diff enables more test while hopefully not breaking anything

Reviewed By: markbt

Differential Revision: D19671316

fbshipit-source-id: 76ecd22a094c0a40b9724a3070a01e5d294888f3
2020-01-31 15:40:54 -08:00
Xavier Deguillard
179aa8ac28 tests: make test-dispatch.py python3 compatible
Summary: Writing to a file opened in "b" mode needs byte strings.

Reviewed By: sfilipco

Differential Revision: D19668666

fbshipit-source-id: 9e8670fa080cc2a7fc611083a4ee2305d8262a3a
2020-01-31 15:31:03 -08:00
Mark Thomas
4604332170 py3: cmdutil.export should encode its output when writing to a file
Reviewed By: quark-zju

Differential Revision: D19666638

fbshipit-source-id: 66cc3a9f6efbb421b31e18fb199e6478702eb950
2020-01-31 15:27:31 -08:00
Mark Thomas
ec02a1dc49 py3: decode undolog redonode
Reviewed By: quark-zju

Differential Revision: D19666639

fbshipit-source-id: e9f5760802750c06f965be0f370b9ed185abb79f
2020-01-31 15:27:31 -08:00
Mark Thomas
f00c23e42e py3: fix encoding in test-visibility.t
Summary: The test itself needs to ensure it decodes the visibleheads file.

Reviewed By: quark-zju

Differential Revision: D19666640

fbshipit-source-id: 999ab3396b0afc7bd86db9ae1ba126730ee3f02d
2020-01-31 15:27:31 -08:00
Xavier Deguillard
299212da50 checkmessagehook: make it python3 compatible
Summary:
The commit message should already be a utf8 string. Make sure that when it is
read from a file, we decode it properly.

Reviewed By: sfilipco

Differential Revision: D19666371

fbshipit-source-id: ee24fe33b5aaf1ede54286979c9523cedd901b3a
2020-01-31 15:21:55 -08:00
Simon Farnsworth
ee586e769a fix test-unified-test.t on python 2
Summary: D19663298 changed the return code, making this test fail

Reviewed By: singhsrb

Differential Revision: D19669105

fbshipit-source-id: c105cd130dcae3889946180761b1f51f4daae527
2020-01-31 14:20:54 -08:00
Durham Goode
1e3ec1859e py3: enable some -t.py tests
Summary: These now pass.

Reviewed By: xavierd

Differential Revision: D19669905

fbshipit-source-id: b141ea6baefa6a6eb92a0c8d70c46214ea24446d
2020-01-31 13:55:11 -08:00
Xavier Deguillard
e83115ecee remotefilelog: fix hg_memcache_client protocol
Summary:
The pipe expects bytes, but the code was passing in strings. Since the protocol
is ascii only, we can encode/decode the str/bytes

Reviewed By: farnz

Differential Revision: D19666372

fbshipit-source-id: 095bf50b9e9529c4ea7d1a06ac01643bac47bca3
2020-01-31 13:51:43 -08:00
Durham Goode
aac5ebea17 py3: remove #require py2 from passing tests
Summary: These now pass

Reviewed By: xavierd

Differential Revision: D19669584

fbshipit-source-id: dd4d374c3b373367138408ae86563ae44849690c
2020-01-31 13:46:59 -08:00
Xavier Deguillard
182e362070 tests: enable some test on Python3
Summary: These are newly passing, let's enable them.

Reviewed By: quark-zju

Differential Revision: D19668516

fbshipit-source-id: d979631203e14ce6e2ec0ab0c45773ee4846ba71
2020-01-31 13:27:46 -08:00
Jun Wu
e124dfebc6 pyre: add stub for "bindings"
Summary:
Add a partial stub so pyre stops complaining about "bindings" being unknown.

Pyre's "search_path" was adjusted to read the new "pystubs" directory.

Reviewed By: DurhamG

Differential Revision: D19669131

fbshipit-source-id: a592ed411d1689058405689eb657e543b7172774
2020-01-31 13:18:54 -08:00
Durham Goode
e985d51e02 py3: update simplemerge conflict logic to use bytes
Summary: Patches are bytes, so the lines we add to them need to be bytes

Reviewed By: mitrandir77

Differential Revision: D19668850

fbshipit-source-id: cb521f71d927dbe1cbe3287be37123b609889846
2020-01-31 13:12:15 -08:00
Durham Goode
4f35ef07bf py3: remotenames use writeutf8 for cached distance
Reviewed By: xavierd

Differential Revision: D19668611

fbshipit-source-id: 82d10a29e257a5779ef41675ab60b74cf97adaa3
2020-01-31 13:12:14 -08:00
Durham Goode
2eaaaa65bc py3: fix encodings for magic strings
Summary:
Fixes a few encoding issues for changegroup/bundle2 related issues. In
particular makes magic string comparison use strings.

Reviewed By: xavierd

Differential Revision: D19668613

fbshipit-source-id: c1bc8ab76d13bb04a9c440b5d9d9babfe34c5c92
2020-01-31 13:12:14 -08:00
Durham Goode
ff7266e7f5 py3: fix plural templating
Summary:
It decides whether to render the actual values by using a
isinstance(...,bytes) which isn't correct in python 3. Let's change it to str.

Reviewed By: xavierd

Differential Revision: D19668612

fbshipit-source-id: cf093754707a0a0369cfc3aa74270dd81a6560b5
2020-01-31 13:12:14 -08:00
Durham Goode
fae3d05bdb py3: encode activebookmark before putting it on the wire
Summary: The activebookmark is a string, the wire wants bytes. Encode it!

Reviewed By: farnz

Differential Revision: D19665896

fbshipit-source-id: f5afc1c5b17d90bf3f0d0703cd752d66c6f38778
2020-01-31 13:12:13 -08:00
Durham Goode
a876c6a13b py3: fix pushkey encoding by removing local encoding
Summary:
Now that bundle2 has strings everywhere, pushkey needs to also handle
encoding correctly. Previously it used local encoding, which seems strange.
Let's drop the encoding entirely since we're only dealing with since we're only dealing with utf8 string and bytes.

Reviewed By: farnz

Differential Revision: D19665894

fbshipit-source-id: ed054ab25636ac52de646329f26681ae843b6de3
2020-01-31 13:12:13 -08:00
Mateusz Kwapich
ad3f789bf9 py3: supress the write return value
Summary:
`>>> open(file).write(data)` is a common patten for writing files across the
tests. In py3 such statement return the number of bytes written in py2 the
output is none. Let's make it None in py3 as well.

Reviewed By: xavierd

Differential Revision: D19666339

fbshipit-source-id: 5424287f85f34f3aef2d1596bb476d622464564a
2020-01-31 13:00:23 -08:00
Mateusz Kwapich
e2dc4e8014 diff: update for py3
Summary:
All diff functions are (bytes, bytes) -> bytes to preserver
the original file encoding.

Because of that I had to add ui.writebytes output function that accepts
bytes for terminal output.

Reviewed By: farnz

Differential Revision: D19656673

fbshipit-source-id: b9a1e4361e825fc8c2313e8402c2bbe00f490dd4
2020-01-31 13:00:23 -08:00
Xavier Deguillard
bf8fbe7d7f grep: make it run with python3
Summary:
The input/output of a subprocess is bytes, let's encode/decode when
writing/reading from it.

Reviewed By: farnz

Differential Revision: D19665636

fbshipit-source-id: 840f6b7a0edbedb7e7de5a65eacab9e1a7f78864
2020-01-31 12:47:04 -08:00
Xavier Deguillard
3bffbe2bf8 ui: remove a b from a regexp
Summary: I've seen this while running some tests, they now go slightly further.

Reviewed By: singhsrb

Differential Revision: D19666665

fbshipit-source-id: 35ad73f383de148f3d53c7f9de24b1a1e1c51f7e
2020-01-31 12:44:09 -08:00
Carolyn Busch
d84dc2c276 py3 cmdutil fix isinstance bytes
Summary:
The msg string isn't bytes in python 3. Hg revert works in both python 2&3
using 'str' instead.

Reviewed By: farnz

Differential Revision: D19664504

fbshipit-source-id: 5e16b637a5fb282eaa97390ef1f7e8912d0359f0
2020-01-31 11:39:13 -08:00
Durham Goode
3eca8e1086 py3: enforce bytes for bundle2 parts
Summary:
We enforced this at send time, but it was hard to debug where it was
coming from. Let's enforce it at part.setdata() time so the stack points out
exactly who the problem is.

Reviewed By: farnz

Differential Revision: D19665895

fbshipit-source-id: 5a6ca0263d52cac472e1ef2aca3ee702f38258e4
2020-01-31 11:29:29 -08:00
Stefan Filip
ae8a2613a6 py3/watchmanclient: use bser encoding
Summary:
The `bser-v1` encoding is not supported for Python 3 so we are forced to
update.

Reviewed By: quark-zju

Differential Revision: D19649948

fbshipit-source-id: 0ae1800942dd967eddcd58183f9899d36256598d
2020-01-31 11:14:47 -08:00
Durham Goode
984192ebef py3: fix hg pull
Summary:
D19657765+D19656773 made bundle2 use the standard urllib which turns
bytes into strings. This messes up bundle2 caps encoding and decoding. Caps
encoding/decoding is a nested mess of strings and bytes, so let's make it all
strings until the last minute it goes over the wire.

Reviewed By: quark-zju

Differential Revision: D19665131

fbshipit-source-id: a2fd6e309ed6da2b927d2f4ead97825a16bfcaac
2020-01-31 10:56:31 -08:00
Durham Goode
c572f1e344 py3: update test-argspans.py
Summary:
test-argspans is an awful test that includes it's own line numbers in
the test assertions. When the imports were changed in D19655148, these needed to
be updated.

Reviewed By: quark-zju

Differential Revision: D19664131

fbshipit-source-id: cdd03be2fbbc9d13ac3047f9565a1f68284e9cf0
2020-01-31 10:56:31 -08:00
Durham Goode
3df423a83b py3: fix histedit json parsing
Summary:
fbhistedit adds support for json histedit commands. Unfortunately
json.loads produces unicode strings, which then fail assertions in
pycompat.encodeutf8(...). Let's make sure it produces non-unicode on python2.

Reviewed By: singhsrb

Differential Revision: D19656390

fbshipit-source-id: 11b828319b20a153aa008f03d554087b88b7763c
2020-01-31 10:56:30 -08:00
Durham Goode
850c78d8c9 errors: drop quotes around OSError paths
Summary:
Python 3 has changed which errors are OSError vs IOError. We have
slightly different formatting which makes the test awkward to be py2 and 3
compatible. Let's make the formats the same.

Reviewed By: quark-zju

Differential Revision: D19663964

fbshipit-source-id: 892461049b61d648431f300bea0da2f6f1c70066
2020-01-31 10:56:30 -08:00
Xavier Deguillard
77e09b4e47 test-fb-hgext-extutil.py: fix some python3 warning
Summary:
This is reported while running with buck. assertEquals is renamed to
assertEqual

Reviewed By: quark-zju

Differential Revision: D19665159

fbshipit-source-id: cb7c25901005c6a97f2c703c4773ea01232943b1
2020-01-31 10:53:52 -08:00
Xavier Deguillard
e0e01cbc81 bundle2: backout D19656773
Summary: This broke a bunch of tests. Revert it and re-enable all the tests.

Reviewed By: DurhamG

Differential Revision: D19665042

fbshipit-source-id: c3c17e3ac7e2ea028be5b5836bc8349cdf56184e
2020-01-31 10:48:19 -08:00
Xavier Deguillard
467f4aef45 tests: mark python3 tests as passing
Summary:
Ran ./run-tests.py --json and used the following script:

  import json
  import subprocess

  with open("report.json", "r") as f:
      tests = json.load(f)
      for name, t in tests.items():
          if t["result"] == "success":
              print("%s successful" % name)
              subprocess.run("sed -i '/#require py2/d' %s" % name, shell=True)
              subprocess.run("sed -i '/require.*py2/d' %s" % name, shell=True)

Reviewed By: singhsrb

Differential Revision: D19664298

fbshipit-source-id: fa67c7c7abd110c9f0df9345daf09f2792aacd44
2020-01-31 10:13:45 -08:00
Xavier Deguillard
3545d26208 tests-rustthreading.py: the thread is renamed to _thread
Summary: The module no longer exist in Python3, it has been renamed.

Reviewed By: quark-zju

Differential Revision: D19663426

fbshipit-source-id: a805e7fa3d15335a0be4f6a8d8ae096328470728
2020-01-31 10:13:45 -08:00
Xavier Deguillard
9643c72d6e run-tests.py: exit 80 on skip
Summary: This allows unittestify to properly report skipped tests.

Reviewed By: quark-zju

Differential Revision: D19663298

fbshipit-source-id: a95d28731fbf324a6f772e9d0b1dd84f2d5968d6
2020-01-31 10:13:44 -08:00
Aida Getoeva
af1d91abf0 hg-py3: changegroup - types and encoding
Summary: Added types, added decodeutf8 where needed while packing and unpacking chunks.

Reviewed By: xavierd

Differential Revision: D19626372

fbshipit-source-id: f15cbde5fd7e01a79b8591f0174f266078852a12
2020-01-31 10:10:56 -08:00
Mark Thomas
4c322218db hggit: only test fetch_pack.refs if it exists
Summary:
Different versions of dulwich return different types for
`localclient.fetch_pack`.  If the returned type is a real dict, then we can't
test the inner `refs` attribute, so check if it is there before testing if it
is `None`.

Reviewed By: singhsrb

Differential Revision: D19657503

fbshipit-source-id: 63cce72fa87f615e7b33279726dcb19c2fdf5b9e
2020-01-31 09:44:27 -08:00
Simon Farnsworth
5232dcf9d1 py3: make .py tests continue to run on python 2
Summary:
Use sed to convert testutil.ddot requires to hghave.

ignore-conflict-markers

for test-simplemerge.py

Reviewed By: simpkins

Differential Revision: D19658355

fbshipit-source-id: afae73eb1e43ead79514dfaf9f911f51ac25972e
2020-01-31 00:18:22 -08:00
Simon Farnsworth
4e10dbb9f6 py3: Back out "[hg] py3: re-enable demandimport"
Summary:
This breaks test-alias.t, so it looks like demandimport no longer behaves properly.

Original commit changeset: d56814049181

Reviewed By: simpkins

Differential Revision: D19658109

fbshipit-source-id: 9fd4865bd00d2307afe0c99f1500b6e08fe3e785
2020-01-31 00:14:04 -08:00
Adam Simpkins
1a359987cd py3: update urllibcompat.quote() to operate on strings again
Summary:
D19652082 changed `urllibcompat.urlreq.quote()` to always return bytes.
This broke most of the code outside of the bundle2 module that was expecting
it to operate on strings.

This changes `quote()` to operate on strings again, since this is what the
Python 3 standard library does.  This updates `bundle2` to handle encoding and
decoding properly when parsing strings that go through `quote()` and
`unquote()`.

This also changes bundle2 to stop going through the `urllibcompat.urlreq`
wrapper class, since that wrapper class prevents type checking from being
performed on its members.

Reviewed By: quark-zju

Differential Revision: D19657765

fbshipit-source-id: 0611838213ec22221e0b8367e1f0d8a6dcfceb15
2020-01-30 23:22:02 -08:00
Adam Simpkins
faf9de663d fix filelog to work with Python 2 again
Summary:
D19656501 added a usage of the `b"%b"` format specifier, which only works in
Python 3.  Change the code to use `b"".join()` for now, which works in both
Python 2 and Python 3.

Reviewed By: farnz

Differential Revision: D19657472

fbshipit-source-id: 22d3123f4939fa984ffd17516e1cc48bad2bb2b7
2020-01-30 20:59:49 -08:00
Saurabh Singh
13a2e1f8ed memcommit: refactor code to be pyre friendly
Summary:
This diff allows us to remove the `type: ignore` specification on the
affected lines.

Reviewed By: farnz

Differential Revision: D19657442

fbshipit-source-id: 4626daf20c57fbb511b203e54f2575edc619f40f
2020-01-30 20:08:34 -08:00
Jun Wu
935cf597c6 py3: hggit: fix absolute import
Reviewed By: singhsrb

Differential Revision: D19657557

fbshipit-source-id: dc0ba4c11f4ad69dc7e5e811875fb78c4fb492b9
2020-01-30 20:05:01 -08:00
Adam Simpkins
fabce3a798 py3: fix typing for journalentry
Summary:
Fix the type annotation for `journalentry.serialize()`: It needs to come
immediately after the method declaration to be recognized, not after the
docstring.

Fixing this causes pyre to produce type errors for this method.  I have
changed `journalentry` to derive from `typing.NamedTuple` to fix this.  This
syntax is somewhat awkward with Python 2, but is much cleaner in Python 3.

Reviewed By: quark-zju

Differential Revision: D19656758

fbshipit-source-id: a97b8a092bff0bdc7e9dee0650c35ef383b32248
2020-01-30 19:57:05 -08:00
Mark Thomas
18ecb01b8a mutationstore: update tests so that user is now a string
Summary: D19649887 changed mutation entry users to be strings.  Update the tests accordingly.

Reviewed By: simpkins

Differential Revision: D19656792

fbshipit-source-id: fcff677099dc0200130bf30eadaaf66822c6139c
2020-01-30 19:54:45 -08:00
Zeyi (Rice) Fan
92f6f35e7a mark all tests requiring Python 2
Summary:
This diff marks **ALL** mercurial tests requiring Python 2 feature.

After you fixes some tests, simply remove the `py2` feature requirement and that tests will be continuously run after your diff is landed.

To bypass this feature requirement, run the tests command with `HGTEST_FORCE_PY2=1`. For example:

```
HGTEST_FORCE_PY2=1 buck test //eden/scm/tests:hg_run_tests
```

or

```
HGTEST_FORCE_PY2=1 python run-tests.py
```

----

Basically this diff are created with the following commands:

```
$ sed -i 's/import feature\(.*\)$/import feature\1\n\nfeature.require(["py2"])/' test-*-t.py
$ sed -i '1s/^/#require py2\n/' test-*.t
$ ls | grep -P "^test.*(?<\!-t)\.py$" > list && vim -p $(cat list)
# manually adding feature requires for these Python tests.
```

(Note: this ignores all push blocking failures!)

ignore-conflict-markers

Reviewed By: singhsrb

Differential Revision: D19655148

fbshipit-source-id: 985e3ccb4010cc559049f1d89f8909bc2d9b5e20
2020-01-30 18:49:21 -08:00
Zeyi (Rice) Fan
cdd601bfac change py3k feature to py2
Summary:
This is used in D19655148 to skip all the tests that are not passing in Python 3.

(Note: this ignores all push blocking failures!)

Reviewed By: farnz

Differential Revision: D19655164

fbshipit-source-id: 1a0d26926aa1b764077fa1e5bdddf853621a54f1
2020-01-30 18:49:20 -08:00
Xavier Deguillard
5c00ebfd06 bundle2: fix encoding issue
Summary: The urlreq.quote returns a byte string, let's use b string to manipulate it.

Reviewed By: farnz

Differential Revision: D19656773

fbshipit-source-id: 1cbcc0f19e9463d5eabec2f67f5b00329188777d
2020-01-30 18:45:36 -08:00
Xavier Deguillard
d169de8946 bookmarks: binaryencode should return a byte string
Reviewed By: quark-zju

Differential Revision: D19656320

fbshipit-source-id: 85b0015dd3a8c485bbc5fb6ba854dbb7273ddc11
2020-01-30 18:45:36 -08:00
Xavier Deguillard
1629a2e038 remotenames: encoding fixes
Summary: Reading/writing to files is done via bytes, not strings.

Reviewed By: quark-zju

Differential Revision: D19656321

fbshipit-source-id: 9a9b13b27fc9dd8db6fe757dcd53e4730179832d
2020-01-30 18:45:36 -08:00
Xavier Deguillard
d6d60bda6a clone: make the samplehgrcs strings
Summary: These aren't bytes, they are strings.

Reviewed By: quark-zju

Differential Revision: D19656112

fbshipit-source-id: fcd505e3b4e522154358c80305e39ebca5936395
2020-01-30 18:45:35 -08:00
Adam Simpkins
a4722f9515 py3: fix reading of commitcloud backedupheads files
Summary:
Process the backupstate file as UTF-8.  Previously it was being read as raw
bytes, causing the code to think it was an unknown version.

These files contain the version specifier (pure-ASCII), the remote path
(unicode), followed by a list of hexadecimal node IDs (pure-ASCII).  Therefore
reading the whole file as UTF-8 should be fine.

Reviewed By: farnz

Differential Revision: D19655547

fbshipit-source-id: 6ca536d445cbf81b19122916f1b70b8895304bdb
2020-01-30 18:29:51 -08:00
Adam Simpkins
2370602802 py3: re-enable demandimport
Summary:
D19539064 disabled demandimport when using Python 3 as a precaution while we
were initially working on Python 3 support.  However, it appears to work
correctly and does not seem to cause obvious problems when enabled.

This re-enables demand import by default.  It can be explicitly disabled at
runtime by specifying `HGDEMANDIMPORT=disable` in the environment.

Reviewed By: xavierd, farnz

Differential Revision: D19655548

fbshipit-source-id: d56814049181da2d68abd09ac7ca772b04e06618
2020-01-30 18:29:50 -08:00
Adam Simpkins
ebf7df9c50 fix the relpath() template to work in hg status
Summary:
When used in an `hg status` command the `relpath()` template function would
throw an unhandled `KeyError` when it tried to access `ctx` in the template
mapping.  This field is only present in `hg log` templates, and is not present
in `hg status` templates.

This updates the `relpath()` template function to look for `repo` in the
template mapping instead.  I also updated the `hg status` code to pass in the
`repo` value now.  The `hg log` code already passes in this field.

Reviewed By: quark-zju

Differential Revision: D19568463

fbshipit-source-id: 3e1c1d6571c73e4b24bfce22ea28f57679d39846
2020-01-30 18:26:36 -08:00
Xavier Deguillard
781d0e04ad test-check-code.t: make it run on python3
Summary:
The sources are opened in byte mode, therefore the regexp needs to be a byte
one.

Reviewed By: singhsrb

Differential Revision: D19655928

fbshipit-source-id: 79b54cc5016dc47aee4fe6cf053f28bf04ba630c
2020-01-30 18:12:30 -08:00
Xavier Deguillard
7c48ba6119 rebase: fix encoding issues
Summary:
Bunch of read/writes to files were using plain strings, use byte strings
instead.

Reviewed By: quark-zju

Differential Revision: D19655101

fbshipit-source-id: 0cb70cbc51630d2c83752846774ff1a1c5ec9f41
2020-01-30 18:12:29 -08:00
Xavier Deguillard
607b2db333 obsutil: decode marker metadata
Summary: These are strings, let's decode them.

Reviewed By: quark-zju

Differential Revision: D19655102

fbshipit-source-id: 18ca5556c76603a53bcb20b58fa8787e2fab70fb
2020-01-30 18:12:29 -08:00
Xavier Deguillard
4eb639c665 amend: write to the obsinhibit with bytes
Summary: This file contains bytes representation of nodes, let's add the b prefix.

Reviewed By: quark-zju

Differential Revision: D19655100

fbshipit-source-id: 2dc163038b17b0d3bce384d9b04f13b1449705fc
2020-01-30 18:12:28 -08:00
Xavier Deguillard
1ddfa14e5a tests: fix encoding issue in test-commit-multiple.t
Summary: The file is opened in binary mode, we need to write bytes into it.

Reviewed By: quark-zju

Differential Revision: D19655103

fbshipit-source-id: a2d059adff72db6c65e2933b3c64804325e51a71
2020-01-30 18:12:28 -08:00
Jun Wu
94c6853e8d edenscm: add a main module
Summary:
Make it possible to run edenscm via a "python package".

This makes it possible to run monkeytype [1] via debugpyhon:

    ./hg3 debugpython -- -m monkeytype run edenscm help log --pager=off

[1]: https://github.com/Instagram/MonkeyType

Reviewed By: farnz

Differential Revision: D19655850

fbshipit-source-id: 358f9dcf976141f798af2d57fb6392f2bca6a396
2020-01-30 18:09:14 -08:00
Mateusz Kwapich
040e01d65c filelog: file contents shouldn't be strings
Summary: on file copies instead of contents we were commiting b'contents'

Reviewed By: markbt

Differential Revision: D19656501

fbshipit-source-id: e1cb0bdac79da851494318ce31396a2aca6c5754
2020-01-30 18:05:39 -08:00
Durham Goode
8c211e5224 py3: fix stdout/stderr in dott tests
Summary:
dott tests rig up a custom stdout/stderr. In Python 3 we expect them to
be strings, so we need to use an appropriate io object.

Unfortunatly upstream already created a pycompat.stringio object which uses
bytes for both python 3 and 2, so I had to use a new name for now.

Reviewed By: quark-zju

Differential Revision: D19653469

fbshipit-source-id: a529df5a2ab179c105fa441c4503ed6606e77543
2020-01-30 18:00:34 -08:00
Simon Farnsworth
a579ce59f9 py3: add types to bundle2.py and make wireprotocol exclusively bytes
Reviewed By: xavierd

Differential Revision: D19652082

fbshipit-source-id: b6670845bbd06dc55439ad5223d47bda2ae014b1
2020-01-30 17:56:58 -08:00
Mark Thomas
8e673a1de0 py3: implement util.dirs in Rust
Summary:
The C implementation of util.dirs doesn't work with Python 3.  Instead of trying to port it, write an implementation in Rust that works in both Python 2 and Python 3.

The old implementation had a hack for flat dirstate to omit certain entries.  Remove this hack as we now only use flat dirstate in tests and small repos.  This simplifies the code in the fastpath case.

Reviewed By: quark-zju

Differential Revision: D19634699

fbshipit-source-id: cbb6562bc9a0209b13f67db3dfa5250800a9fcbe
2020-01-30 17:33:36 -08:00
Mark Thomas
914607cac7 cpython-ext: add PyPath for references to paths
Summary: `PyPath` is to `PyPathBuf` as `Path` is to `PathBuf` and `str` is to `String`.

Reviewed By: quark-zju

Differential Revision: D19647995

fbshipit-source-id: 841a5f6fea295bc72b00da028ae256ca38578504
2020-01-30 17:33:35 -08:00
Zeyi (Rice) Fan
a634526801 some fix for run-tests
Summary:
Fix some common errors when run `run-tests` in Python 3.

shlib would be using `str` for stdin/stdout instead of bytes as most of the code in Python 2 operates with that assumption. Getting it to `bytes` will take some work.

Reviewed By: DurhamG, quark-zju

Differential Revision: D19649475

fbshipit-source-id: 1f0190fce4df9a530246774fd17cdfc2d7974a65
2020-01-30 17:24:32 -08:00
Zeyi (Rice) Fan
92e9ae6eea convert print statements in tests
Summary: These are Python 2 style print statements not surfaced during the tests. Mostly because they are used in `hg dbsh` or invoked with Mercurial's Python interrupter. So I did a ripgrep to find these statements and convert them into functions.

Reviewed By: farnz

Differential Revision: D19612968

fbshipit-source-id: 1b07e9c789ab834be692ba00fd58c575bc4a17bf
2020-01-30 17:24:32 -08:00
Arun Kulshreshtha
dd34889d43 py3: make patchrmdir work with Python 3
Summary: With this change `hg rm` works even with extensions enabled. Since this is a Cython extension, I did not bother adding type annotations since IIUC Pyre cannot type check Cython files.

Reviewed By: quark-zju

Differential Revision: D19652178

fbshipit-source-id: 2e03a0f241f80732bdae3f472a1e0576684b1911
2020-01-30 17:22:30 -08:00
Saurabh Singh
45d5467eec memcommit: add type hints
Summary: This diff just adds the type hints for `memcommit` extension.

Reviewed By: quark-zju

Differential Revision: D19651074

fbshipit-source-id: 834a5980cded92641e4d368ce00d01a3dcaec330
2020-01-30 16:49:50 -08:00
Xavier Deguillard
5ecc59749e treemanifest: hashing requires bytes
Summary: We need to encode the key to be able to hash it.

Reviewed By: genevievehelsel

Differential Revision: D19651373

fbshipit-source-id: 214a3d127eb71a1c9cbf4ed1fec4f5a58f7f5195
2020-01-30 16:29:17 -08:00
Xavier Deguillard
6b328f5f7d remotefilelog: the filelog data is bytes
Reviewed By: DurhamG

Differential Revision: D19651372

fbshipit-source-id: 13bf86235b95ad84beb9fe45e7abc06baec67a47
2020-01-30 16:29:16 -08:00
Xavier Deguillard
4b2b0c6630 remotenames: fix python3 warning
Summary:
Importing directly from collection is deprecated, we should import from
collections.abc in Python3.

Reviewed By: DurhamG

Differential Revision: D19650852

fbshipit-source-id: b2e470e5fde3fe915944ae68a4274e47ed91071a
2020-01-30 16:29:16 -08:00
Xavier Deguillard
8c08a97290 fsmonitor: fix test_symlinks_t
Summary:
A previous change requires the default value to be a tuple with 4 values,
fsmonitor was only passing 1.

Reviewed By: kulshrax

Differential Revision: D19652000

fbshipit-source-id: c9ae04109c61173a1df27ce653622dc4db653977
2020-01-30 16:20:13 -08:00
Carolyn Busch
fca8aafffc py3 chgserver bytes <-> unicode
Summary:
Server reads & writes bytes. Convert between bytes and unicode where
neccessary in chgserver. Add some type annotations.

Reviewed By: xavierd

Differential Revision: D19645028

fbshipit-source-id: 1ad4bec25c398422112ee0ed1780ee9d704e6622
2020-01-30 15:44:42 -08:00
Durham Goode
419858ad5c py3: fix journal writing
Summary:
Writing to the file should happen in bytes, so let's make the
journalentry serializer/deserializer convert from strings to bytes for us.

Reviewed By: xavierd

Differential Revision: D19650468

fbshipit-source-id: 3c13aff032ace1a15611c2370fc7d6ed44a6df34
2020-01-30 15:22:25 -08:00
Durham Goode
c1672ad848 py3: fix treemanifest fetching
Summary:
bundle2 parameter values are bytes, so when we compare the treemanifest
category with the bundle2 part category we need to encode the bundle2 part one.

Also fix wirepack to read utf8 paths.

Reviewed By: xavierd

Differential Revision: D19650197

fbshipit-source-id: 67da3bd8244f7953ec608019844988b20ad1929f
2020-01-30 15:22:25 -08:00
Durham Goode
b567c16b60 py3: make mutation markers 'user' utf8
Summary: Username as utf8, so let's make mutationmarker treat them as such.

Reviewed By: xavierd

Differential Revision: D19649887

fbshipit-source-id: 3f8b2db434a57ee8ee3017de8d925c19a2002b20
2020-01-30 15:22:24 -08:00
Xavier Deguillard
c1652cad03 drawdag: the commit data should be bytes
Summary:
The commit context requires commit data to be bytes, but drawdag was using str
for it, breaking tests.

Reviewed By: DurhamG

Differential Revision: D19650219

fbshipit-source-id: 1409ce9a277c1c410ede8109989e07595378ff3e
2020-01-30 14:55:55 -08:00
Xavier Deguillard
cb64df7197 tests: @command expects str command names
Summary: This change all the tests to use strings as the command names.

Reviewed By: simpkins

Differential Revision: D19649479

fbshipit-source-id: 4b2cb9b3af73a7508ef359ee3c407d04a39c7893
2020-01-30 14:55:55 -08:00
Xavier Deguillard
96f5dc6652 localrepo: wwread returns bytes
Summary:
This is directly used in fctx.data() which expects bytes to be returned, encode
the return value of vfs.symlink.

Reviewed By: quark-zju

Differential Revision: D19647846

fbshipit-source-id: 966a5e79db6843c4bc6b802aeb90364e983cd834
2020-01-30 14:55:55 -08:00
Xavier Deguillard
b863a561a4 pytreestate: use PyPath where necessary
Summary:
A previous diff missed these PyPath. As a bonus, replace most of the PyObject
into proper Rust types.

Reviewed By: quark-zju

Differential Revision: D19646139

fbshipit-source-id: a3b55e5a802d8bbef86e9a9431f605bb4e284b32
2020-01-30 14:55:54 -08:00
Durham Goode
ca48fc2665 py3: fix resolving unknown binary nodes in changectx
Summary:
changectx takes an arbitrary identifier and tries to resolve it. If it
takes a binary node and the node is not known, the fallback looksup don't accept
bytes and throw an exception. Let's stop early and raise the RepoLookupError.

Reviewed By: quark-zju

Differential Revision: D19643834

fbshipit-source-id: cfee39e0487f908ebd4ff628b847e53dec13c66e
2020-01-30 14:39:41 -08:00
Durham Goode
cfdf7814f4 py3: fix pipe reads in sshpeer
Summary:
In Python 3, subprocess creates FileIO type pipes, which do one syscall
and are not guaranteed to return 'size' bytes. In Python 2 they're 'file' types
which are guaranteed to return 'size' bytes (via multiple syscalls).

So let's handle that case.

Reviewed By: quark-zju, xavierd

Differential Revision: D19648035

fbshipit-source-id: 7d04a67acc569a55d3a855fc8521f1b8261f4636
2020-01-30 13:55:21 -08:00
Durham Goode
22b2f5becc py3: fix encoding of remotenames at write time
Summary:
remotenames are stored as unicode in memory and bytes on disk. We need
to convert before we write in this case.

Reviewed By: quark-zju

Differential Revision: D19648032

fbshipit-source-id: 4b96cf05eefd66ca031436d9979b94da8e28b8dd
2020-01-30 13:55:20 -08:00
Durham Goode
5311ab2fbb py3: fix encoding of pushkeys
Summary: Let's decode pushkeys into utf8.

Reviewed By: quark-zju

Differential Revision: D19648033

fbshipit-source-id: 9deeeecd53e065df9b344f8edd0183dc7c1511c5
2020-01-30 13:55:20 -08:00
Stefan Filip
843f8a7f50 py3/cython: set the language_level to 3str
Summary:
Follow up to the previous diff setting language_level to 3str for
`edenscmnative/clindex.pyx`. Consistent behavior for all files.

Reviewed By: quark-zju

Differential Revision: D19634907

fbshipit-source-id: 779d6090b5660e109a37f9740299fb9623d8f34d
2020-01-30 12:52:06 -08:00
Mark Thomas
13b7a759a2 cpython-ext: add PyNone, a marker struct for functions that can only return None
Summary: Add `PyNone`.  This is a marker struct that indicates that a python function can only return `PyNone`.

Reviewed By: xavierd

Differential Revision: D19644338

fbshipit-source-id: f846b146237ebf7de996177494934fec662cde0f
2020-01-30 12:28:38 -08:00
Carolyn Busch
6b24e9a69e py3: commandserver write and read bytes
Summary: Make the command server write and read bytes. Add type annotations.

Reviewed By: quark-zju

Differential Revision: D19642862

fbshipit-source-id: 2dfcd8f0c2e6124cc6afe1e85c0f5275e7fe5b1f
2020-01-30 11:12:10 -08:00
Mark Thomas
6b8042662a cpython_ext: rename PyPath to PyPathBuf
Summary:
`PyPath` is the type that owns the data.  Rename it to `PyPathBuf` for analogy
with `PathBuf` and `RepoPathBuf`, and to allow us to introduce a reference type
named `PyPath`.

Reviewed By: xavierd

Differential Revision: D19643797

fbshipit-source-id: 56d80fea5677f7223e967b0723039d1763b26f68
2020-01-30 11:06:24 -08:00
Durham Goode
f170b964be py3: fix known wireproto command
Summary:
It was iterating over what it thought was a string, but in python3 it's
a byte string, which results in iterating over integers. So known always claimed
the server knew every commit.

Reviewed By: quark-zju

Differential Revision: D19644837

fbshipit-source-id: 4e84a33b4d3e436006f93a5d8e1bdabf12e7d120
2020-01-30 10:59:01 -08:00
Xavier Deguillard
f83e1d76b0 pypathmatcher: use PyPath when calling into Python
Summary: The Python code expect paths to be unicode in Python3, not bytes.

Reviewed By: markbt

Differential Revision: D19643701

fbshipit-source-id: fa98da2daccccf70ac047a69b2e2359270f7e3d0
2020-01-30 10:55:34 -08:00
Stefan Filip
45fa522e1c py3/fsmonitor: use next(iter) instead of iter.next()
Summary: iter.next() is gone in Python 3. next(iter) is the Python2 compatible version.

Reviewed By: quark-zju

Differential Revision: D19630455

fbshipit-source-id: e5d4f0a6cc0c6b0489916ca6d177a6831bd7d277
2020-01-30 10:28:02 -08:00
Adam Simpkins
dbaac4f0e7 py3: fix some Python 3 compatibility issues in sshpeer
Summary:
Fix `threadedstderr` to stop directly deriving from `threading.Thread`.
Deriving directly from `threading.Thread` is somewhat tricky.  Classes that
derive from `Thread` are only allowed to implement `__init__()` and `run()`.
This class also defined `close()`, which violates the `Thread` docs.  Changing
this to no longer derive from `Thread` fixes exceptions being thrown when
trying to read from the SSH stderr pipe in this thread.

This also updates `_writessherror()` to decode the stderr data before writing
it to the `ui` object.

Reviewed By: quark-zju

Differential Revision: D19634265

fbshipit-source-id: bddd120c7995f49d3bbebbb171384d5b15b779e9
2020-01-30 10:22:30 -08:00
Durham Goode
3ed7b6e3f2 py3: fix journal to work with utf8
Summary: Various fixes to make it stop crashing

Reviewed By: quark-zju

Differential Revision: D19643879

fbshipit-source-id: 9dd0bcef5369b769a8c968ea86de0e8aaf640650
2020-01-30 09:58:26 -08:00
Durham Goode
9aa1e8d7a3 py3: fix sparse utf8 logging
Summary:
Sparse logs the profile to scuba, but our logging data must be utf8.
Let's encode it first. We probably want to make this "replace" instead of
"strict" for the conversion once D19634265  lands.

Reviewed By: quark-zju

Differential Revision: D19643832

fbshipit-source-id: 550c67f194171ccdbd244bc79edfa1b999467824
2020-01-30 09:58:26 -08:00
Durham Goode
e3992926b7 py3: utf8 fixes for pull and wireproto
Summary: Moves pull closer to working by appropriately encoding and decoding.

Reviewed By: quark-zju

Differential Revision: D19643833

fbshipit-source-id: d311fb897d15594f2cb644b15038866ce506e011
2020-01-30 09:58:26 -08:00
Durham Goode
484a088417 py3: support caching in python3
Summary:
Revlog did a type check against str. In python 3 it accepts bytes
instead, so we need to support that.

Reviewed By: xavierd

Differential Revision: D19634882

fbshipit-source-id: 04ae908b4bfe8ed5de7a6d41cbe748dcb34b2540
2020-01-30 09:12:30 -08:00
Durham Goode
8b942a7166 remotenames: fix broken changelog contains check
Summary:
cl.__contains__ does a "0 < rev <= len(repo)" check, so passing nodes
will always fail. In python 3 this causes a type error, so let's fix this.

Reviewed By: quark-zju

Differential Revision: D19634880

fbshipit-source-id: 011ab2f0c07a16fa45734d360ac952273c4fefc2
2020-01-30 09:12:30 -08:00
Genevieve Helsel
247f686447 izip_longest to zip_longest
Summary:
izip_longest depreciated in python3 in favor of zip_longest, use zip_longest from future

source: https://python-future.org/compatible_idioms.html#itertools-filterfalse-zip-longest

Reviewed By: xavierd

Differential Revision: D19632101

fbshipit-source-id: 2eb3c125d2beaf66045dad304b900fe7928f2066
2020-01-30 08:50:41 -08:00
Xavier Deguillard
a14897afc8 clindex: remove one b
Summary: In `hg sl`, this raises an exception.

Reviewed By: singhsrb

Differential Revision: D19635386

fbshipit-source-id: 28482941bd61b5526993d6d16b2886c7edbe763f
2020-01-30 08:31:23 -08:00
Jun Wu
097503d073 py3: treestate: use IntoAnyhowResult
Summary: This preserves the Python errors across language boundaries.

Reviewed By: xavierd

Differential Revision: D19635355

fbshipit-source-id: 14ab8af38362182ca43951d4c560fa405687bf6e
2020-01-30 08:27:34 -08:00
Jun Wu
002d32e878 py3: treestate: use PyPath
Summary: Use PyPath for input/output and Python callbacks.

Reviewed By: xavierd

Differential Revision: D19635356

fbshipit-source-id: c2d8898ef903fda436277997a842bc837bb1bf2f
2020-01-30 08:27:33 -08:00
Jun Wu
c5dd6829c7 cpython-ext: add more utilities for PyPath
Summary:
Make the type easier to use. Namely, the treestate bindings want PyPath <->
bytes since treestate internally uses bytes.

Reviewed By: xavierd

Differential Revision: D19635357

fbshipit-source-id: 37d1889b5da1d7f3869bb7820de0219b87b71a8b
2020-01-30 08:27:33 -08:00
Jun Wu
cd04a56178 repo: avoid metalog when migrating files from sharedvfs to storevfs
Summary: Otherwise it can trigger metalog ProgrammingErrors.

Reviewed By: markbt

Differential Revision: D19624779

fbshipit-source-id: ba56a9aefa28d56a38ea8d966115647975613c91
2020-01-30 07:25:31 -08:00
Mateusz Kwapich
e4ee93b38b py: fixes for cloud sync
Summary: "hg cloud sync" succeeds when there's nothing to do

Reviewed By: quark-zju

Differential Revision: D19630431

fbshipit-source-id: e2c9859c7660e6283e6d319c634f1cd9053f8b3f
2020-01-29 18:25:41 -08:00
Mateusz Kwapich
892dcb3189 py3: make "hg cloud sl" work in py3
Summary: Some strings had to stay as unicode

Reviewed By: quark-zju

Differential Revision: D19628661

fbshipit-source-id: 6ea191c60a4ef2ed98b2e2d3ab90c875e6eea248
2020-01-29 18:25:41 -08:00
Adam Simpkins
b9790d38d6 py3: explicitly set the language_level to 3str
Summary:
This causes the code to always treat unprefixed string literals as the `str`:
i.e., bytes in Python 2 and Unicode in Python 3.  Without this setting our
unprefixed string literals were always being treated as unicode.

Reviewed By: lisroach

Differential Revision: D19634266

fbshipit-source-id: 770d7d03a96aa92a4e183819d34c72281c6c794b
2020-01-29 17:46:30 -08:00
Zeyi (Rice) Fan
b58fe35549 make run-tests.py py3 compatible
Summary: This diff makes `run-test.py` compatible with Python 3, so we can run this tests both in Python 3 and 2.

Differential Revision: D19611680

fbshipit-source-id: 97571cca7e1310e482ac8c03af73eb345ab825c1
2020-01-29 17:07:33 -08:00
Zeyi (Rice) Fan
e214ad8df9 testing utilities py3 compatibility
Summary:
We temporarily pin these test tools to run with Python 2 so the tests can pass no matter if it is run with 3 or 2.

This diff also makes the fake biggrep client to be Python 3 compatible.

Reviewed By: farnz

Differential Revision: D19611681

fbshipit-source-id: 0c980165934899902b152e27a0a444d6a6c9eb2f
2020-01-29 17:07:32 -08:00
Zeyi (Rice) Fan
05d306bfc3 make test-extension.t py3 compatible
Summary: because of the test `type(b"") != type("")` we actually have different behavior in Python 3 and Python 2. So we remove this test temporarily and we can add it back later.

Reviewed By: sfilipco

Differential Revision: D19611682

fbshipit-source-id: 7bca979f8ef871672ac9666286c8d5e54747e8b3
2020-01-29 17:07:32 -08:00
Zeyi (Rice) Fan
f0e50448b4 make the rest of the tests py3 compatible
Summary: This diff converts the rest of our tests to be compatible with Python 3. There are still a few tests are not fully compatible with Python 3 yet and I'll address these individually as they require major modifications.

Reviewed By: markbt

Differential Revision: D19608299

fbshipit-source-id: 3779dd0d4641ce8470598fa4909306317cf777d8
2020-01-29 17:07:32 -08:00
Stefan Filip
56c0adbc46 py3/match: convert filter result to list
Summary:
In Python3 the result of filter is a class that does not have len
implemented. In Python2 the result of filter is a list.

Reviewed By: quark-zju

Differential Revision: D19629139

fbshipit-source-id: a7a1d9d831d72b2aab8b7a920bf82295c4673603
2020-01-29 17:03:05 -08:00
Stefan Filip
49e90ce242 py3/pypathmatcher: return Str instead of Bytes
Summary:
Globs and patterns generally speaking. They should be typed as Str in
Python3 following how paths are typed.

Reviewed By: quark-zju

Differential Revision: D19628654

fbshipit-source-id: eeaede72f41258d6fe0f3cde26c434fe0b908b8b
2020-01-29 17:03:04 -08:00
Stefan Filip
f80b7bd6c4 py3/sparse: decode sparse profile as utf-8
Summary: File contents are read as bytes but content should be interpreted as utf-8.

Reviewed By: quark-zju

Differential Revision: D19628315

fbshipit-source-id: 523a201ddf57a2aabcd135156e71034c52b59adb
2020-01-29 17:03:04 -08:00
Stefan Filip
ac4aaab5a2 py3/util: treat authentication url as str
Summary: Python3 socke address is str.

Reviewed By: quark-zju

Differential Revision: D19628130

fbshipit-source-id: d6ce93d28588a9ab8829f5b95db30ecee040a160
2020-01-29 17:03:04 -08:00
Mateusz Kwapich
3cfb8a6a7c py3: node: get rid of extra encoding
Summary:
The extra call to encode makes everything a big slower, fortunately python
standard library provides functions that do the right thing.

Reviewed By: xavierd

Differential Revision: D19634034

fbshipit-source-id: 6bb0de26300c41667824422c016e8d4f0aee70d3
2020-01-29 16:48:41 -08:00
Xavier Deguillard
467b3095c1 eden_dirstate_map: encode the path
Summary: This enables `hg add` on EdenFS

Reviewed By: quark-zju

Differential Revision: D19631538

fbshipit-source-id: 1621ab77fef977c9364052bc522df18729face48
2020-01-29 16:45:46 -08:00
Durham Goode
13b96565e5 py3: convert parts of undo.py to specify utf-8
Summary: This makes hg pull make more progress.

Reviewed By: mitrandir77

Differential Revision: D19630124

fbshipit-source-id: 6e8d6bd441353ffbf87076addd2774d5e09dd24a
2020-01-29 16:41:54 -08:00
Jun Wu
c642e72b3e test-rebase-moved: fix up the test
Summary: I think my editor eat the spaces incorrectly. Fix it.

Reviewed By: xavierd

Differential Revision: D19630482

fbshipit-source-id: 3a8b94cdb269b045f678e07d0f21975effbaf7f9
2020-01-29 16:25:02 -08:00
Durham Goode
654ed5e4b1 remotenames: prefer picking default paths
Summary:
S194477 was caused by a config change adding a custom path to
repositories, where the path had the same url as default. This caused all the
remotebookmarks to be associated with the new path instead of default.

This is subtle and undesirable. Let's make it so that the default path takes
precedence.

I also deleted a hggit test because it was causing the entire test to be skipped
when dulwich wasn't available.

Reviewed By: quark-zju

Differential Revision: D19627711

fbshipit-source-id: 55b3ce94f18a26ccb9471c8e96a584d3087dbb82
2020-01-29 15:31:16 -08:00
Simon Farnsworth
c87bac85e1 py3: streamclone: make wireprotocol bytes
Summary: The wireprotocol for streaming clones should be explicitly bytes, encoding filenames as UTF-8 when needed. Make it so

Reviewed By: quark-zju, xavierd

Differential Revision: D19616097

fbshipit-source-id: 3513c801035c8d7ba950777aa119e1d1480013a5
2020-01-29 15:20:56 -08:00
Xavier Deguillard
73d424dd90 pyedenapi: use PyPath and String instead of PyBytes
Summary: This allows edenapi to be able to fetch trees on Python3.

Reviewed By: quark-zju

Differential Revision: D19629411

fbshipit-source-id: f6abd585d8d672854f7219ef8e3ab86d2f659118
2020-01-29 14:51:43 -08:00
Jun Wu
07a1c0a776 py3: connectionpool: fix some Python 3 issues
Summary: `im_self` is gone. Use `__self__` instead.

Reviewed By: xavierd

Differential Revision: D19630121

fbshipit-source-id: aa1af51e89cdffcfc63f3c18eeaf04d35425160e
2020-01-29 14:27:12 -08:00
Jun Wu
552c1dfabd py3: sshpeer: fix some encoding issues
Reviewed By: mitrandir77

Differential Revision: D19630030

fbshipit-source-id: b700187aeb412ac85e81532a525601454c45c426
2020-01-29 14:27:12 -08:00
Jun Wu
b01245ecc1 py3: commitcloud: fix some encoding issues
Reviewed By: mitrandir77, xavierd

Differential Revision: D19630028

fbshipit-source-id: 825bffa5c591f442ddecac4b9b8485dfe273b667
2020-01-29 14:27:12 -08:00
Jun Wu
50f80dff96 py3: clienttelemetry: fix some encoding issues
Reviewed By: xavierd

Differential Revision: D19630029

fbshipit-source-id: e9a9060a1e0cc2745dcb8588a083e8752384cf9f
2020-01-29 14:27:11 -08:00
Jun Wu
77a51f0e3b merge: allow specifying a customized rename script
Summary:
Provide an option to run an external script that calculates the rename
destination. This is especially helpful for cases where development happened in
another branch and *directory* and want to merge changes back.

For example, we recently had an experimental `scm3` branch that copies files
from `scm` to `scm3` to try out changes:

  o master <-- rebase destination
  |
  o (changes in scm/)
  :
  | o (changes that need to backport to scm/) <-- rebase source
  | |
  | o (changes in scm3/ that got implemented differently in scm/)
  | :
  | o (copy scm/ to scm3/ for experiments)
  |/
  o

This allows `--config experimental.rename-cmd='sed "s#scm3/#scm/#"'` to be
used for the above case.

While working on this feature, I noticed a bug that if the "copy" information
is recorded, rebase might lose changes. I added a test to track that bug.

Reviewed By: mitrandir77

Differential Revision: D19609868

fbshipit-source-id: 94462889d3ce9214b48fac793852d16aeacecc77
2020-01-29 14:27:11 -08:00
Jun Wu
0ba90481ab pycompat: add basestring, drop dep on "past"
Summary:
This removes the dependency of `future` (used by `import past`) which is not
available in our Windows tests.

Reviewed By: farnz

Differential Revision: D19626387

fbshipit-source-id: 2b13f08a9dafe77d1e7f6fc1a3cc48b3581681ca
2020-01-29 13:46:04 -08:00
Jun Wu
c18818de39 py3: pyindexes: use str for hex prefix matching
Summary: The hex prefix should be in str, not bytes.

Reviewed By: mitrandir77

Differential Revision: D19627762

fbshipit-source-id: dc9b054198dc61614518fec9bba69f789326ff8b
2020-01-29 13:43:09 -08:00
Jun Wu
282aaf155d py3: remotenames: fix compatibility issues
Reviewed By: mitrandir77

Differential Revision: D19627763

fbshipit-source-id: 3e1396a0686de81e3ed97ea5d3fb14c695bb3b8d
2020-01-29 13:43:09 -08:00
Xavier Deguillard
f2733fb294 pyrevisionstore: use PyPath for key name
Summary:
The names are really RepoPath, and thus let's use PyPath as a way to pass these
in.

Reviewed By: quark-zju, sfilipco

Differential Revision: D19625372

fbshipit-source-id: 4802030b91e6a065d3cb1905c770cad8a86da510
2020-01-29 13:32:46 -08:00
Xavier Deguillard
7c0c6feea1 commitcloud: fix max(None, None) in Python3
Summary:
In Python2, max allows None to be passed in, not in Python3, let's mimic the
Python2 behavior.

Reviewed By: sfilipco

Differential Revision: D19626654

fbshipit-source-id: f4fcaaa0516d898bc747d21735d2c30a4a9b41f4
2020-01-29 13:32:46 -08:00
Mateusz Kwapich
30c0e6482c proper bytes handling for remotefilelog
Summary:
I've inspected how the data flows from struct.unpack through the remotefilelog
and annotated few functions.

In one place I've used encodeutf8 function

Reviewed By: quark-zju

Differential Revision: D19626711

fbshipit-source-id: 77499c567b0cddab17d21b4f11b06f58bf3fcaef
2020-01-29 12:59:44 -08:00
Mateusz Kwapich
c1335eac46 add types module
Summary: Let's have a module that defines types ussed commonly in HG

Reviewed By: quark-zju

Differential Revision: D19625872

fbshipit-source-id: 817535d87acee6cb5647bc8ad25df21a95bec09c
2020-01-29 12:59:44 -08:00
Mateusz Kwapich
13aee5fa2a make all config function params strings
Summary: We want unicode configs.

Reviewed By: quark-zju

Differential Revision: D19612400

fbshipit-source-id: ec9f863c3203be7c956dcd97c735d74a11adce35
2020-01-29 12:09:37 -08:00
Stefan Filip
2dacfad0fc py3/make: rename hg3 to local3 and clean up fix
Summary:
Fixing up cleanup for hg3.
Seems to have a positive impact on regenerating the artifact after doing a rebase.

Reviewed By: quark-zju

Differential Revision: D19626379

fbshipit-source-id: 11caf0826ecb47440bcc532bfb7495771dc9159c
2020-01-29 11:56:38 -08:00
Xavier Deguillard
a80bcd779b phabstatus: make PeekaheadRevsetIter an Iterator
Summary:
Python2 and Python3 have different method names for an iterator, let's inherit
from Iterator so Python (both version) tells us what needs to be implemented.

Reviewed By: mitrandir77

Differential Revision: D19624294

fbshipit-source-id: b9c3d5ae796216b4bcd330c8be6f061e369e2614
2020-01-29 11:07:10 -08:00
Xavier Deguillard
20459835bb clindex: use str as input to vfs
Reviewed By: farnz

Differential Revision: D19624129

fbshipit-source-id: cbee989334d5cf114ef7b74c9143a992cee70370
2020-01-29 11:07:09 -08:00
Xavier Deguillard
776f0fabac pyedenapi: use String for the client constructor
Summary:
Both the repo name and the url come from the config, and thus Unicode values
are passed in in Python3. The String type handles the Python2/Python3
difference, so let's use it instead of PyBytes.

Reviewed By: DurhamG

Differential Revision: D19623202

fbshipit-source-id: 72c72f8338fbb6a2f3e88395f3587a5b59389711
2020-01-29 11:07:09 -08:00
Stefan Filip
11b85a8a33 py3/remotenames: convert to str after reading data
Summary: In Python3, nodes and bookmarks are str.

Reviewed By: DurhamG

Differential Revision: D19624130

fbshipit-source-id: edbb115c7e6fa1232c92ce76e8ee5aa46b3f23db
2020-01-29 11:00:26 -08:00
Genevieve Helsel
7c8128744c remove unsued urllib import
Summary: as title, removes unused import that had python 2/3 compat issues.

Reviewed By: sfilipco

Differential Revision: D19588354

fbshipit-source-id: 05d185d0b1a8fdd1bdb7eef0557362e95d85beb4
2020-01-29 10:45:57 -08:00
Jun Wu
4e7edef4b7 py3: use edenscmdeps3.zip for Python 3 deps
Summary:
Python 2 pyc files are incompatible with Python 3.  Use a different zip file.

This also makes it possible for Python 2 and 3 setup.py build to co-exist
(discovered by markbt).

Reviewed By: markbt

Differential Revision: D19617513

fbshipit-source-id: 47b2a01e905b0cb1ec68e7a7eec40868f09a2167
2020-01-29 10:40:16 -08:00
Durham Goode
38756127f2 hgevents: disable events during status
Summary:
There are times when status updates the dirstate to mark files as
clean or to resolve lookup files. In doing so it takes the wlock, which triggers
a state-enter event which causes external watchers to then run hg status, which
can then trigger another wlock event from status. This causes an infinite loop.

It's not clear why status is taking the wlock every time. It should be a
one-time thing. So more investigation is needed. For now though, we can prevent
this from happening by disabling hgevent signals while status has the wlock.

Reviewed By: quark-zju

Differential Revision: D19602370

fbshipit-source-id: 609316de1441d40be4f81236b8d00ce7dc30a130
2020-01-29 10:30:22 -08:00
Durham Goode
a4453150d0 py3: migrate unittestify to python3
Summary: Fixes some minor issues with unittestify to make it work in python 3.

Reviewed By: quark-zju

Differential Revision: D19613469

fbshipit-source-id: 00ae212d606fbef298eb5467e225341512db1290
2020-01-29 10:11:25 -08:00
Durham Goode
0913d16fb1 py3: support python3 for the builtin interpretter
Summary:
The builtin interpreter currently only responds to "python" as the
input arg. Let's also support python3.

Reviewed By: farnz

Differential Revision: D19613372

fbshipit-source-id: 5d2eed85c2d9546808c1661f12681b03f1edc40f
2020-01-29 10:11:24 -08:00
Jun Wu
8699e769e8 py3: minirst: fix some encoding issues
Summary: This makes `hg3 help` work.

Reviewed By: xavierd

Differential Revision: D19617512

fbshipit-source-id: 6f7621cff36e8f711fb5c7c21c805a1f82f80dfd
2020-01-29 09:00:19 -08:00
Xavier Deguillard
9db47445cd remotefilelog: switch some wireprotocol to use bytes
Summary:
String literals are unicode in Python3, which is not the intention for
over-the-wire streams. I've also added type-checking to get help from pyre to
do the right thing.

Reviewed By: quark-zju

Differential Revision: D19614060

fbshipit-source-id: 33f2b603012481159593426dbb3c18b1614b19f6
2020-01-29 08:50:03 -08:00
Jun Wu
7d8003f36e py3: manifest: drop pure lazymanifest
Summary:
The pure implementation has many encoding issues. Since our code does not build
in the pure Python mode, just drop the pure lazymanifest implementation for
simplicity.

Reviewed By: farnz

Differential Revision: D19613691

fbshipit-source-id: f3f95717bc77a75d4aa7b597a33f8eec745df134
2020-01-29 07:45:23 -08:00
Jun Wu
df746ae467 py3: wireproto: fix some encoding issue
Reviewed By: markbt

Differential Revision: D19615830

fbshipit-source-id: c16efaba5fca65898b24192910b2afd81f77a0b9
2020-01-29 07:45:23 -08:00
Jun Wu
fa999c515f py3: visibility: fix some encoding issue
Reviewed By: farnz

Differential Revision: D19615841

fbshipit-source-id: a88a2f9328dcef77a603d67f29435c6da4956d60
2020-01-29 07:45:23 -08:00
Jun Wu
c048b191ba py3: config: fix a minor encoding issue
Reviewed By: markbt

Differential Revision: D19615812

fbshipit-source-id: 997f4c4111dfecd1c157cd428b5044efb49883f8
2020-01-29 07:45:22 -08:00
Jun Wu
4da8312956 py3: transaction: fix some encoding issues
Summary: Use bytes to write files.

Reviewed By: markbt

Differential Revision: D19615839

fbshipit-source-id: 7881a7078fcfde154ba4b6e58c706064fd8e26b9
2020-01-29 07:45:22 -08:00
Jun Wu
dc01df5bb4 py3: templater: fix some encoding issues
Summary: The template language is in unicode.

Reviewed By: markbt

Differential Revision: D19615823

fbshipit-source-id: 30c6b295b4e4c999480c46aba8b4e8ffed5a4d64
2020-01-29 07:45:21 -08:00
Jun Wu
98a90ec4a0 py3: store: fix some encoding issues
Reviewed By: markbt

Differential Revision: D19615828

fbshipit-source-id: 8adf9b8d5fda818efd7d02d1ce05cb47c56a26da
2020-01-29 07:45:21 -08:00
Jun Wu
4b64b6ce9e py3: scmutil: fix some encoding issues
Reviewed By: farnz

Differential Revision: D19615819

fbshipit-source-id: e0137e15d14cf7fd84fdd015fe1c63dc35195459
2020-01-29 07:45:21 -08:00
Jun Wu
cc6dee9815 py3: revsetlang: fix some encoding issues
Summary: Use unicode in revset expressions.

Reviewed By: farnz

Differential Revision: D19615816

fbshipit-source-id: fc0251ca7108cf3baacd9ec154bc2760657754e0
2020-01-29 07:45:20 -08:00
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