Commit Graph

691 Commits

Author SHA1 Message Date
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