Summary:
In configerator, extras might be non-utf8 and plain bytes. This causes 2
issues, the first one is when extracting the file list out of the change, the
other one is when dealing with the extras directly. For the first one, only
decode the file list, and for the second one, use the surrogateescape error
handling when decoding/encoding them.
Reviewed By: quark-zju
Differential Revision: D22260068
fbshipit-source-id: 19ef0248c69ea2b75bb91e59c3cdaed869110950
Summary:
From a simple `hg trace log -r .`, it appears that importing the module takes
16ms, which dominates the time it takes to load the treemanifest extension.
Since the module isn't necessary, don't import it.
Reviewed By: farnz
Differential Revision: D22048075
fbshipit-source-id: ccaf2d53eb006faa36d97df452b0db10f4983c23
Summary:
In a future diff we want to log information about configuration
mismatches. In order to do that, we need to be able to call ui.log before
extensions are setup. Let's move the ui.log sampling logic into core so it can
be called before extension setup.
Reviewed By: quark-zju
Differential Revision: D21313257
fbshipit-source-id: fe1c0f572720c17e7398f2a4fa7082ef8fb59536
Summary:
Now that we've upgraded mysql-connector-python, we can enable these
tests.
Reviewed By: quark-zju
Differential Revision: D21009185
fbshipit-source-id: e9ae62cadcc8d0a291381ab2cfb5c7bc04606d9e
Summary:
archive uses a formatter to produce it's metadat file. We need to use a
string io stream instead of bytes.
Reviewed By: quark-zju
Differential Revision: D19748163
fbshipit-source-id: fbd8c32066cfc4a234d9b51691717c7fce4c7c9a
Summary:
We don't have confidence that python 2 is only using bytes (vs unicode
or other byte-like objects). These asserts break users, so let's disable them
except for in tests. We should uncover issues here as we port to python 3.
Reviewed By: xavierd
Differential Revision: D19819699
fbshipit-source-id: 9e3a9c34e7661fac4db9ee2a79f65be3d5e48cb3
Summary:
Use `abc.ABC` from Python 3 stdlib directly. The definition matches
`pycompat3.py`:
class ABC(metaclass=ABCMeta):
pass
The following changes are reverted since they're no longer necessary:
D19732319 "[hg] py3: fix windows build"
D19703778 "[hg] py3: exclude mercurial/pycompat3.py from Python 2 builds"
D19703779 "[hg] py3: exclude pycompat3.py from Buck-based Python 2 builds"
Reviewed By: simpkins, singhsrb
Differential Revision: D19739075
fbshipit-source-id: 8c1e3727e8a88ff5f7232270d528d690523b1824
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: 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: There are no-ops. This makes type checkers' life slightly easier.
Reviewed By: farnz
Differential Revision: D19673051
fbshipit-source-id: 363eb8a4e799113b16529825d45645807cafe2fc
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: 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:
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:
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
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
Summary: Some strings had to stay as unicode
Reviewed By: quark-zju
Differential Revision: D19628661
fbshipit-source-id: 6ea191c60a4ef2ed98b2e2d3ab90c875e6eea248
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
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
Summary:
On Python 2 we want bytes.encode("utf-8") to be no-op, while on Python 3 we
want it to return a real `str`. This helper function does that.
Reviewed By: sfilipco
Differential Revision: D19613118
fbshipit-source-id: 1f0fc31bf8aee28cc20694da52b10b12dbdd9000
Summary:
See D17098991 for our encoding strategy.
This diff changes the pycompat module to prefer unicode on Python 3.
Reviewed By: farnz
Differential Revision: D19594828
fbshipit-source-id: 3e6db24a2ebaed69deb68908f19e9b462f62c350
Summary:
These call sites are hit during initialization. They all appear to be
small-ish dictionaries so the performance hit of having this iteration be
non-lazy in Python 2 should not matter much.
Reviewed By: farnz
Differential Revision: D19591565
fbshipit-source-id: 324844d64ba63f6e379aab270e453d44a02063e9
Summary:
We won't need it as we're going straight to dual-compatible code instead of
transforming it.
Reviewed By: quark-zju
Differential Revision: D19588132
fbshipit-source-id: 100f19b3e29874de9e8d48692c42cb2d5856bf5a
Summary:
sysplatform is defined as a byte string, and thus a byte string needs to be
provided.
Reviewed By: ikostia
Differential Revision: D18816931
fbshipit-source-id: c653f1319f160bc00d7a1c90b06ff3b4f4d035ad
Summary:
In Python3, unicode doesn't exist, instead of re-inventing the wheel, just use
unicode from the pycompat module.
Reviewed By: ikostia
Differential Revision: D18816929
fbshipit-source-id: d3ec9ae4f2190db64866568b1945b26e05b9c2a5
Summary:
Somehow, pyre isn't able to inline the value of ispy3 and propagate it properly
and thus complains about lots of code paths. Let's inline it everywhere.
Reviewed By: ikostia
Differential Revision: D18816333
fbshipit-source-id: 80f81cb91bef4c6831952f9469401d87040335e2
Summary:
The Mercurial codebase contains over 500 errors, let's ignore them for now, we
can go back to them later to fix them.
Besides the manual change to .pyre_configuration.local, the changes were
generated with:
pyre --output=json check | pyre-upgrade fixme
Reviewed By: singhsrb
Differential Revision: D18803908
fbshipit-source-id: 724db7bd864c0de47a97ef2092bdee9f2cda531f
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.