Commit Graph

3340 Commits

Author SHA1 Message Date
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
Adam Simpkins
11e1432ff8 update the EdenFS monitor to support self-restarts
Summary:
Update the EdenFS monitor to restart itself when it receives SIGHUP.  This
allows upgrading the monitor daemon to a new version of the software without
disrupting the current running EdenFS daemon.

Reviewed By: wez

Differential Revision: D19588698

fbshipit-source-id: f0303788cee0cc9bf4ce3b7342f10a595c3874b1
2020-01-31 13:22:27 -08:00
Adam Simpkins
b03d2b6c89 update the monitor to poll for successful EdenFS startup
Summary:
Update the SpawnedEdenInstance class to wait for EdenFS to become healthy
before signalling the Future returned by `start()`.

This code works by just polling the `getStatus()` call every few hundred
milliseconds, and waiting until it returns `ALIVE`.

Currently the code will poll forever, until EdenFS either becomes healthy or
exits.  In practice we will likely configure startup timeouts in systemd,
which means that they probably are not necessary in this code.

Reviewed By: wez

Differential Revision: D19588699

fbshipit-source-id: fef57ca23fcc14da908c2e4f7f715db33b7bf841
2020-01-31 13:22:27 -08:00
Adam Simpkins
4f7fd33e29 add a new process to monitor EdenFS
Summary:
Add a simple new wrapper daemon to manage the edenfs daemon.  This is intended
to provide a few different features:

- Perform log rotation for EdenFS's output and the output of any of its
  spawned children processes.
- Help schedule restarts of EdenFS when the system looks idle.
- Provide a single process for the system to manage across graceful EdenFS
  restarts, to make management slightly simpler.

This initial commit does not perform graceful restarts yet, but has the basic
daemon management and log rotation present.

Reviewed By: wez

Differential Revision: D19588700

fbshipit-source-id: bba41c9f7efeb4417753c1d48dd72cf6d191f0c3
2020-01-31 13:22:26 -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
Chad Austin
daaeb5012a replace some uses of memset
Summary: Easier to zero initialize structs with braces, which defines that even padding is zeroed.

Reviewed By: wez

Differential Revision: D19655675

fbshipit-source-id: 2fd12383324029646707e93008cf9ad34e9f1dce
2020-01-31 10:50:48 -08:00
Chad Austin
4e1cd5c49a return a valid inode number when looking up an inode fails
Summary:
When importing an object from the backing store failed, we would not
fail lookup requests (e.g. lstat) so that the file could still be
removed with `rm`. Unfortunately that data would get cached, even if
the error was transient. This diff returns a correct inode number for
failed requests and limits the amount of time these fake stat()
results are cached.

Reviewed By: wez

Differential Revision: D19655425

fbshipit-source-id: 1a44ace9217f1ab3f69a2c5a6edc89d0f9c4a941
2020-01-31 10:50:48 -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
Chad Austin
7c6efd32e7 rename LogEvent fields so names in code match names in the log
Summary:
Multiple times I've gotten mixed up by the different casing of the
LogEvent fields versus the names in the structured log. Change the
field names to match the log names.

Reviewed By: genevievehelsel

Differential Revision: D19585307

fbshipit-source-id: 3ccbb9ec5e18155367bc85e9db00bc8d556812c4
2020-01-31 10:42:26 -08:00