Summary:
We added pycompat3.py which only parses in Python 3. We need to
exclude it from the Windows build as well.
Unfortunately, the Windows build users PyZipFile.writepy which writes an entire
directory. Let's copy in the implementation from Python 3 which allows us to
filter out certain files.
Reviewed By: xavierd
Differential Revision: D19732319
fbshipit-source-id: 4cebb434d052c51d9ae0dccdec5eadd1f412f9e5
Summary: More replacements of dict.iteritems with pycompat.iteritems(dict) for py3 compatibility.
Reviewed By: singhsrb
Differential Revision: D19704211
fbshipit-source-id: 544cb292c0241a293fc4ab83c3d9472dcf4328b6
Summary:
`timed` has been replaced by the `timefunction` in util.
I have also removed the existing usages because they seemed relevant only
during the development.
Reviewed By: quark-zju
Differential Revision: D19727919
fbshipit-source-id: 58c466f02ac2a5bf7096948b17b49ceb26fc1fd9
Summary:
The path normalization OSX logic was using unicode, and when it
switched to use pycompat in D19613690 it stopped using unicode, which broke it.
Let's roll it back.
Reviewed By: singhsrb
Differential Revision: D19726322
fbshipit-source-id: fa7bfacdf41dfedbcfef2fdb5ccb826196101e61
Summary:
Add a few additional type annotations on some functions.
This did require some minor code restructuring in `filestore.setfile()` to
work around pyre's unwillingness to unwrap `Optional` member variables.
Reviewed By: quark-zju
Differential Revision: D19715243
fbshipit-source-id: 8078329c1e4a50ad0aa6c765d42a89b5ed58e7bf
Summary:
Add more type annotations to vfs.py and some of the platform-specific
functions that it calls.
This did catch a couple of cases where string/bytes conversion were not being
done properly in Python 3.
Reviewed By: quark-zju
Differential Revision: D19678717
fbshipit-source-id: b3979cc5e0668ddbb93372dee25ef02ea1867d6f
Summary:
Fix various type issues when running chg under Python 3.
Enable chg in setup3.py build.
This should make tests run faster. For example, test-rebase-detach.t
now completes in 8 seconds, down from 29 seconds.
Reviewed By: xavierd
Differential Revision: D19702535
fbshipit-source-id: 8928b1b920b9b52fd03dc86f996da18f2405f146
Summary:
Drop stdoutbytes/stdinbytes. They make things unnecessarily complicated
(especially for chg / Rust dispatch entry point).
The new idea is IO are using bytes. Text are written in utf-8 (Python 3) or
local encoding (Python 2). To make stdout behave reasonably on systems not
using utf-8 locale (ex. Windows), we might add a Rust binding to Rust's stdout,
which does the right thing:
- When writing to stdout console, expect text to be utf-8 encoded and do proper decoding.
- Wehn writing to stdout file, write the raw bytes without translation.
Note Python's `sys.stdout.buffer` does not do translation when writing to stdout console
like Rust's stdout.
For now, my main motivation of this change is to fix chg on Python 3.
Reviewed By: xavierd
Differential Revision: D19702533
fbshipit-source-id: 74704c83e1b200ff66fb3a2d23d97ff21c7239c8
Summary:
My earlier refactor moved a watchmanclient.getcurrentclock() call out
of a "try/except Exception" block. This meant any watchman errors broke the hg
status entirely, instead of falling back to the old status path.
Let's add the logic around this watchman path.
Reviewed By: sfilipco
Differential Revision: D19709391
fbshipit-source-id: bfb0221ba405a926babddaf73c8e70924e4d9b25
Summary:
The "repo" type is a bit hard to type since it might be wrapped by extensions,
and the decorators like "unfilteredmethod" are too hard for type checkers.
Provide a stub for it so typecheck can work. The stub was generated by `pytype`,
I made a small change to `close` to make pyre happy.
Reviewed By: DurhamG
Differential Revision: D19677410
fbshipit-source-id: 71afb3fe78a75ee269c8005d18eee3a807b50df6
Summary:
This commit enables mounting and unmounting using the
new helper, and fixes up the behavior of `eden redirect list`
and `eden gc` so that they have reasonable behavior when APFS
is in the mix.
The semantics of the `TARGET` field in the redirect list output
become a bit hazy when using APFS volumes; it's a bit less important
because the data isn't effectively moved to a different part of
the filesystem namespace: we're just mounting a different filesystem
over the top and it can only be accessed through its mountpoint.
Reviewed By: chadaustin
Differential Revision: D19403162
fbshipit-source-id: 136a7b02f605cde0a74016608179924be801eda9
Summary:
We've had a small proportion of our users run into problems
with hdiutil and diskimages-helper, where those components get into
an unhappy state and effectively block operating on the redirections.
This diff introduces a new utility that is intended to replace the
use of disk image files with APFS volumes that we mount in the
appropriate places.
The intention is that we will teach `eden redirect` to use this tool
when available, rather than disk images.
macOS's security model is weird: it is perfectly valid for a non-privileged
user to create and delete APFS volumes in the APFS storage container,
but root privs are required to mount it into the VFS.
The intent is that we deploy this utility setuid root to minimize
the fan out--this way we won't need to teach the priv helper about
this kind of redirection.
There are a couple of subcommands demonstrated in the test plan.
Reviewed By: chadaustin
Differential Revision: D19323850
fbshipit-source-id: 35556f841e49e5c4b77679b756af9093222f4500
Summary:
To avoid accidents when people run `eden rm` with a subdirectory of
the mount, require that it be given the checkout root (or a symlink to
it).
Reviewed By: genevievehelsel
Differential Revision: D19549912
fbshipit-source-id: ae0a43e9164f73f5ad9c2f40f1b7226a1e85a567
Summary:
Add type hints for `vfs.join()`. Not all subclasses supported joining
multiple arguments, so fix them all to actually implement the full API.
Reviewed By: farnz
Differential Revision: D19678712
fbshipit-source-id: f7f77eee416cd5edda756a8423cbe3630e195d4a
Summary:
Update setup.py to exclude `edenscm/mercurial/pycompat3.py` when building
for Python 2.
Reviewed By: quark-zju
Differential Revision: D19703778
fbshipit-source-id: 269f1d4e746eb5112a9e577f43c040f2946b07d1
Summary:
There were some unsafe uses of folly::collect, especially in
the diff code. Switch to collectSafe.
Reviewed By: simpkins
Differential Revision: D19529784
fbshipit-source-id: e0ac920a2d2b44767a453f2c41a9166e72246ab6
Summary:
folly::collect's Future is completed immediately when any of its input
future is completed with an exception. This makes forking off subtasks
and then joining with folly::collect dangerous when closures don't
hold pointers or references to parameters, including `this`. Introduce
a collectSafe function, which has the same signature as folly::collect
but unconditionally waits until all futures are completed.
Reviewed By: simpkins
Differential Revision: D19529772
fbshipit-source-id: b3b493fcbb0d9058d2d6e5c8a064dfdae3a43e57
Summary: Matchers were mixing str and bytes - use decodeutf8 on the place using bytes, and enable all the tests that now pass.
Reviewed By: quark-zju
Differential Revision: D19679076
fbshipit-source-id: 2b90cfbf690b2365a1302efd9db72347a295c977
Summary: This gives type checker some hints. Pyre can now look into more areas.
Reviewed By: markbt
Differential Revision: D19676085
fbshipit-source-id: db05b4238051953eb7f8af44da220825ec589c3c
Summary:
This gives type checker some hints. Pyre was able to find some issues,
which are fixed.
Reviewed By: markbt
Differential Revision: D19674436
fbshipit-source-id: 44d6df6037f27e2edeff4d343a9fdec5e51420b3
Summary: This allows type checkers to understand the i18n._ calls.
Reviewed By: markbt
Differential Revision: D19673677
fbshipit-source-id: be2cc72f70e56925007485c786f0d72b5cd40a1a
Summary:
Begin adding type hints to many of the vfs methods.
These type hints indicate that the vfs objects are always opened in binary
mode. While it is possible to open a vfs in text mode if you explicitly
specify the argument `text=True`, this is very rare. If we run into cases
in the future that do need type hints to indicate TextIO mode I think it would
be better to split those out into completely separate functions, rather than
having functions that sometimes return bytes and sometimes return str based on
the arguments used.
Reviewed By: markbt
Differential Revision: D19673538
fbshipit-source-id: 8683223f28964d4b43fe131d4f16f8877dcbe777
Summary:
Make `atomictempfile` derive from `typing.BinaryIO` so that the type checker
understands it can be used like a file.
This required defining all `BinaryIO` methods on this class. This does result
in a fair amount of additional boilerplate code, but seems like the easiest
approach for now.
Reviewed By: markbt
Differential Revision: D19673539
fbshipit-source-id: b5775ca79b3af456b45e4ef5480711d7095e7949
Summary: The share command was reaching into the filesystem directly - use the right utility functions instead
Reviewed By: quark-zju
Differential Revision: D19672980
fbshipit-source-id: a14323fd5419c3ea00d9c009b9a77f63862a7b2a
Summary:
Python 3 is more strict about bad escape characters. As far as I can tell,
this was always wrong, and when corrected, works both in Python 2 and Python 3.
Reviewed By: quark-zju
Differential Revision: D19673184
fbshipit-source-id: b8b358327db8ce2e51761f8f98784bdd4b396423
Summary:
This moves `checkwinfilename()` from util.py to a new winutil.py module.
This allows the windows.py module to import winutil.py and re-expose
`checkwinfilename()` as `checkosfliename()`. This makes pyre happier, since
all platform modules now contain a `checkosfilename` method.
This also adds type hints to `checkwinfilename()`, and updates several parts
of the code that were still incorrectly assuming the input was bytes in
Python 3. However, note that I haven't done much testing of this on Windows.
Reviewed By: quark-zju
Differential Revision: D19672077
fbshipit-source-id: d78ed5b344a2e24c2a361b56465dedc516171d28
Summary:
While the payload of wire commands are bytes, we should treat the
command and args as utf8.
Reviewed By: quark-zju
Differential Revision: D19675217
fbshipit-source-id: df64c842e0c099d77dec1313aa0639e46e539194
Summary: hg serve works strictly with bytes, so let's expose it for stdin.
Reviewed By: quark-zju
Differential Revision: D19672836
fbshipit-source-id: 6abc5385daea81c584a89f19a568e42e4afad48a
Summary: This moves streaming clones a bit further along.
Reviewed By: quark-zju
Differential Revision: D19672546
fbshipit-source-id: 054dd639a8067dce34a5bf667996cc5d30301190
Summary:
We should generally be returning bytes on the wire. This fixes up a
number of places to do so, helping move streaming clone closer.
It also turns out that unescapearg is used in multiple situations. Usually it's
used for strings, but for batches the actual payloads are also delimited by this
and they are bytes. So let's have a function for each case.
Reviewed By: quark-zju
Differential Revision: D19672545
fbshipit-source-id: 6386ae2f39660b042af1382a1d696903fa1de9ad
Summary: A couple random stops that need correct encoding.
Reviewed By: quark-zju
Differential Revision: D19672547
fbshipit-source-id: edb0490f70cbf89885fe5fb0a1a8a2472d33e18d
Summary: Translate between bytes and unicode in sshserver to make test-sshserver pass.
Reviewed By: farnz
Differential Revision: D19672378
fbshipit-source-id: 7e1c0bc2d6fc03fac6ebcf54764862e3ed743f7e
Summary:
The changelog __contains__ expects rev numbers, not nodes, the nodemap should
be used instead.
Reviewed By: quark-zju
Differential Revision: D19674451
fbshipit-source-id: 8f0ddf3b9cebeea10f2fd639999f8c6c67a0e35d
Summary: These four tests pass on master. Let's enable them so that CI keeps us honest
Reviewed By: markbt
Differential Revision: D19672282
fbshipit-source-id: 2d45c3f9840c7323b7bfae8bbd89c4b7ec95f49d
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
Summary: This is the right method to write plain strings data to files.
Reviewed By: quark-zju
Differential Revision: D19675386
fbshipit-source-id: 1f939f79294cbc45f56944058649c384b674b880
Summary: There are no-ops. This makes type checkers' life slightly easier.
Reviewed By: farnz
Differential Revision: D19673051
fbshipit-source-id: 363eb8a4e799113b16529825d45645807cafe2fc
Summary: This is broken after D19672686.
Reviewed By: quark-zju
Differential Revision: D19674321
fbshipit-source-id: 7f225b7090ce9168e10e02b25ee17ae2b98cd86a
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
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
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
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
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
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
Summary: There are no-ops. This makes type checkers' life slightly easier.
Reviewed By: markbt
Differential Revision: D19673053
fbshipit-source-id: 04f26cd3ca0dbfe579ef939fc39be00035e70cee
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
Summary: This makes type checkers' life easier.
Reviewed By: markbt
Differential Revision: D19672687
fbshipit-source-id: 335c560289e29ac7c08e36501e9841ddc51232be
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
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
Summary: This was missed while converting pyrevisionstore to PyPathBuf.
Reviewed By: markbt
Differential Revision: D19672441
fbshipit-source-id: 466a66f2e00c7f73c11a8989c22508560f423e0e
Summary: This diff enables more test while hopefully not breaking anything
Reviewed By: markbt
Differential Revision: D19671316
fbshipit-source-id: 76ecd22a094c0a40b9724a3070a01e5d294888f3
Summary: Writing to a file opened in "b" mode needs byte strings.
Reviewed By: sfilipco
Differential Revision: D19668666
fbshipit-source-id: 9e8670fa080cc2a7fc611083a4ee2305d8262a3a
Summary: The test itself needs to ensure it decodes the visibleheads file.
Reviewed By: quark-zju
Differential Revision: D19666640
fbshipit-source-id: 999ab3396b0afc7bd86db9ae1ba126730ee3f02d
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
Summary: D19663298 changed the return code, making this test fail
Reviewed By: singhsrb
Differential Revision: D19669105
fbshipit-source-id: c105cd130dcae3889946180761b1f51f4daae527
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
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
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
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
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
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
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
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
Summary: The activebookmark is a string, the wire wants bytes. Encode it!
Reviewed By: farnz
Differential Revision: D19665896
fbshipit-source-id: f5afc1c5b17d90bf3f0d0703cd752d66c6f38778
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
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
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
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
Summary: I've seen this while running some tests, they now go slightly further.
Reviewed By: singhsrb
Differential Revision: D19666665
fbshipit-source-id: 35ad73f383de148f3d53c7f9de24b1a1e1c51f7e
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
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
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
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
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
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
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
Summary:
This is reported while running with buck. assertEquals is renamed to
assertEqual
Reviewed By: quark-zju
Differential Revision: D19665159
fbshipit-source-id: cb7c25901005c6a97f2c703c4773ea01232943b1