Commit Graph

52068 Commits

Author SHA1 Message Date
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
svcscm
1a618dbed4 Updating submodules
Summary:
GitHub commits:

116b79c0cf
44fd32d79b
c9a5e48762

Reviewed By: wittgenst

fbshipit-source-id: f44312ed39974f9e380845938845c852a609c741
2020-01-30 16:45:40 -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
svcscm
a0c7be96f3 Updating submodules
Summary:
GitHub commits:

73638a8795
7a83deaa83
969d173d11

Reviewed By: wittgenst

fbshipit-source-id: 399ed7a972876727a6bfd1409667c735c406fef5
2020-01-30 15:41:52 -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
svcscm
ef089fa255 Updating submodules
Summary:
GitHub commits:

199e5f16a2
3f2622e669

Reviewed By: wittgenst

fbshipit-source-id: 17f5024fa3b463538644bb56626bcdbd489a408c
2020-01-30 13:05:40 -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
svcscm
2a1d781f1f Updating submodules
Summary:
GitHub commits:

b1cb5e37f0
0b9ddbb4dc
90c71aa5d9
71db4e4023
2056a44d0d

Reviewed By: wittgenst

fbshipit-source-id: 77120ea8a69d2254b178bb0e86852f05950859aa
2020-01-30 12:10:06 -08:00