Commit Graph

773 Commits

Author SHA1 Message Date
Michael Devine
0dceab8e95 New custom immutable revision object to track commit conversions: conversionrevision
Summary:
The Mercurial convert extension passes around parameters to indicate a commit that needs to be converted from source to sink. For existing converters like Git, this is a simple 1:1 conversion: a commit in the source gets mapped to a commit in the sink, and so they use the source commit hash (sometimes called rev or version in the API) to represent the commit to be converted.

Our converter is much more complicated. Source commits get converted multiple times to account for different ways of mounting it into the destination file system and commit history. The commits are also coming from multiple source Git projects. This means that we need multiple pieces of data to represent a single commit conversion action.

Thus far, we've been trying to meet part of this need by using concatenated strings of (variant, commithash). This logic is breaking down as we add more fields. This commit adds a new immutable object called "conversionrevision" that represents the (variant, source commit hash, source project name, destination path) that is the unique identifier for the individual commit conversions we need to perform. This commit also includes logic for serializing and deserializing these objects as strings (useful because the converter seems to require commit IDs to be strings) and unit tests for all of the new logic.

Reviewed By: tchebb

Differential Revision: D19606867

fbshipit-source-id: 77815ca858f841d452874e95dfa3b351bafde306
2020-02-05 10:20:19 -08:00
Saurabh Singh
cbf6db3c58 py3: mark tests failing for Python 3 as requiring Python 2
Reviewed By: xavierd

Differential Revision: D19744346

fbshipit-source-id: b9defccfb396218b2d2fc4d4a2aee438468dcc60
2020-02-05 09:41:55 -08:00
Durham Goode
d0e41ff822 py3: fix test-remotenames-basic.t on Windows
Summary:
When I removed an hggit test case from this test last week, it caused
it to stop being skipped and therefore runs on Windows. The filterpwd magic
doesn't work there, and it's unnecessary, so let's just drop it.

Reviewed By: singhsrb, xavierd

Differential Revision: D19744329

fbshipit-source-id: 21f5c67d4fa7a61f14bbacd78756e5397fd6c819
2020-02-05 09:32:36 -08:00
Saurabh Singh
de006ecee1 test-rebase-inmemory-mergedriver: make the test output more stable
Summary:
Write output using `ui` object instead of using `print` to improve
robustness.

Reviewed By: xavierd

Differential Revision: D19743159

fbshipit-source-id: d0e8d581c65a79784b9843d691c4802ec37d5933
2020-02-05 08:50:54 -08:00
Jun Wu
1bcfec407d py3: remove pycompat3
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
2020-02-04 22:15:16 -08:00
Saurabh Singh
8f5ec4b183 test-status-inprocess: make the test output more stable
Summary:
Write output using `ui` object instead of using `print` to improve
robustness.

Reviewed By: quark-zju

Differential Revision: D19738486

fbshipit-source-id: 4da80ce7efef44e9c5694ed71a55b7d64629166c
2020-02-04 20:36:42 -08:00
Saurabh Singh
5c37bfd373 nointerrupt: make output more stable
Summary:
Printing via `ui` object instead of directly to the `stderr` makes the
output more consistent.

Reviewed By: quark-zju

Differential Revision: D19738355

fbshipit-source-id: 384bf2de11f2ae7b5264ec5d94b041502c4ef7fb
2020-02-04 20:36:42 -08:00
Jun Wu
7316c4cc22 cpython-ext: add a way to wrap Rust Write object into a Python object
Summary:
The library already has a way to wrap a Python object into a Rust object that
exposes the Rust Read/Write interface. This is the reverse direction for
the Write interface.

The initial intention is to expose Rust stdout as described in D19702533.
However, I found Python's `sys.stdout.buffer` also enforces utf-8 encoding
on Windows (unless PYTHONLEGACYWINDOWSSTDIO is set). So Python's
stdout actually behaves similarly with Rust's stdout on Windows and is okay
to use. That said, it's still useful to have this abstraction, for streampager [1]
integration.

[1]: https://github.com/markbt/streampager/

Reviewed By: sfilipco

Differential Revision: D19716127

fbshipit-source-id: ba39898122561d9a49b7080ee95d7c940540eb40
2020-02-04 18:41:13 -08:00
David Tolnay
d358c71e6d Update to Rust 1.41.0
Reviewed By: jsgf

Differential Revision: D19656956

fbshipit-source-id: ef791638021ae55375ca35ca191cf1b8a3cc5d7f
2020-02-04 18:03:03 -08:00
Durham Goode
d3227d34c2 py3: remove forced decoding of environment variable
Summary:
On python 2, os.environ is expected to be bytes, so let's remove the
forced decoding. This broke run-tests.py on Windows.

Reviewed By: singhsrb

Differential Revision: D19737218

fbshipit-source-id: d4782eea279275f57cc91bc412a2d74857002cc1
2020-02-04 17:31:45 -08:00
David Tolnay
34a520536a Update rustfmt and reformat fbsource
Summary:
```
$ tools/third-party/rustfmt/rustfmt --version
rustfmt 1.4.11-nightly (1838235 2019-12-03)
```

Reviewed By: zertosh

Differential Revision: D19704678

fbshipit-source-id: fe8707e964495e76746edcb8b68e34fc1411f52a
2020-02-04 17:14:27 -08:00
Durham Goode
fd47fd9202 py3: fix windows build
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
2020-02-04 15:40:35 -08:00
Carolyn Busch
d49c251d13 py3 iteritems -> pycompat.iteritems
Summary: More replacements of dict.iteritems with pycompat.iteritems(dict) for py3 compatibility.

Reviewed By: singhsrb

Differential Revision: D19704211

fbshipit-source-id: 544cb292c0241a293fc4ab83c3d9472dcf4328b6
2020-02-04 15:29:39 -08:00
Saurabh Singh
3d78cca814 util: remove redundant 'timed' function
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
2020-02-04 12:33:40 -08:00
Durham Goode
16efd0a0e0 py3: fix osx tests
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
2020-02-04 12:19:13 -08:00
Adam Simpkins
0e1437c823 py3: add some additional type annotations on functions writing file data
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
2020-02-03 21:36:56 -08:00
Adam Simpkins
0657c35391 py3: add more vfs-related type annotations
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
2020-02-03 21:36:56 -08:00
Jun Wu
9602130aab py3: chg: fix compatibility
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
2020-02-03 18:26:57 -08:00
Jun Wu
3e0b781197 py3: only use binary stdin/stdout/stderr
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
2020-02-03 18:26:57 -08:00
Durham Goode
16d4739981 fsmonitor: catch watchman issue and fallback
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
2020-02-03 18:04:25 -08:00
Jun Wu
2777fea957 py3: localrepo: manually fixup some type annotations
Summary: This might help pyre check more things.

Reviewed By: farnz

Differential Revision: D19678144

fbshipit-source-id: a04207ccb04ce76796e9a0a7326a8d527d17cff1
2020-02-03 17:07:36 -08:00
Jun Wu
165a8d4f8d py3: add stub for localrepository
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
2020-02-03 17:07:36 -08:00
Aida Getoeva
38fca29eaf hg-py3: fix restack-multidest/t and fold
Reviewed By: xavierd

Differential Revision: D19700265

fbshipit-source-id: 557cec8388d5c7759d24e1b995f971e72f925a30
2020-02-03 17:05:35 -08:00
Aida Getoeva
acc0425925 hg-py3: make amend-next/prev work
Reviewed By: xavierd

Differential Revision: D19700028

fbshipit-source-id: 9aaab361058a2dfa34f4d0c9218c71c1654aaa8a
2020-02-03 17:05:34 -08:00
Wez Furlong
30d0a77d53 eden: add helper command for working with apfs
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
2020-02-03 16:59:17 -08:00
Adam Simpkins
b6ce7a08a6 py3: make vfs.join() consistent across subclasses; add type hints
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
2020-02-03 15:27:52 -08:00
Adam Simpkins
bb9599d1ba py3: exclude mercurial/pycompat3.py from Python 2 builds
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
2020-02-03 15:13:09 -08:00
Sam Uong
974db0c7cd hgext: add hg equivalent for 'git stash clear'
Reviewed By: farnz

Differential Revision: D19669269

fbshipit-source-id: 2d33aae66b1733b9085adb829b38a07afd80fdd8
2020-02-03 12:59:46 -08:00
Aida Getoeva
201a17ca37 hg-py3: make amend-to work
Reviewed By: quark-zju

Differential Revision: D19673900

fbshipit-source-id: cfdc985716aec23335eeddef517855be65505576
2020-02-03 10:04:38 -08:00
Jun Wu
a8f232e0ab py3: drawdag: fix some types
Summary: This fixed using drawdag to create merge commits.

Reviewed By: xavierd

Differential Revision: D19697893

fbshipit-source-id: fac4278a54d2cf2eb2b9d8154a13edd29e1a510a
2020-02-03 09:54:12 -08:00
Simon Farnsworth
ad40d8567f py3: fix up matchers to exclusively use unicode
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
2020-02-03 08:00:11 -08:00
Jun Wu
18a20f5301 context: add some type annotations
Summary: This gives type checker some hints. Pyre can now look into more areas.

Reviewed By: markbt

Differential Revision: D19676085

fbshipit-source-id: db05b4238051953eb7f8af44da220825ec589c3c
2020-02-03 07:35:32 -08:00
Jun Wu
4e272b6fad revlog: add some type annotations
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
2020-02-03 07:35:32 -08:00
Jun Wu
348ce20341 py3: add type annotations to i18n
Summary: This allows type checkers to understand the i18n._ calls.

Reviewed By: markbt

Differential Revision: D19673677

fbshipit-source-id: be2cc72f70e56925007485c786f0d72b5cd40a1a
2020-02-03 07:35:31 -08:00
Durham Goode
14ec2d4b34 py3: enable more tests
Summary: These now pass

Reviewed By: farnz

Differential Revision: D19678869

fbshipit-source-id: 68601ff6a6d33b13947210eecfecd999aa2ddb1a
2020-02-01 10:39:39 -08:00
Adam Simpkins
df74c3e8fa py3: start adding type hints in mercurial/vfs.py
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
2020-02-01 10:32:51 -08:00
Adam Simpkins
3c8739e179 py3: add type hints for util.atomictempfile
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
2020-02-01 10:32:51 -08:00
Simon Farnsworth
eb5e4fb57e py3: fix share command
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
2020-01-31 22:13:04 -08:00
Mark Thomas
a6b159822f py3: fix escaping test-unified-test.t
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
2020-01-31 22:00:59 -08:00
Mark Thomas
b36cdab6f9 py3: use new-style class for fd wrapper
Reviewed By: farnz

Differential Revision: D19672991

fbshipit-source-id: 06ce264f17b395c336c5bd936534e346d0b08a68
2020-01-31 21:28:47 -08:00
Adam Simpkins
7a61371a9d py3: move checkwinfilename() to a separate file and add type hints
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
2020-01-31 20:18:21 -08:00
Durham Goode
3430fdd32f py3: treat sshserver wireprotocol commands and arguments as strings
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
2020-01-31 18:39:42 -08:00
Durham Goode
10d673add5 py3: handle utf8 paths properly in remotefilelog
Summary: remotefilelog streaming clones need to handle paths as utf8 strings.

Reviewed By: quark-zju

Differential Revision: D19675219

fbshipit-source-id: dadf54fc67ecb6fbb23c1aeffd0c058ff5804bf5
2020-01-31 18:39:41 -08:00
Durham Goode
d37a246d60 py3: use bytes for stdin for hg serve
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
2020-01-31 18:39:41 -08:00
Durham Goode
d8fbaa7553 py3: fix sshserver to respond with bytes in most places
Summary: This moves streaming clones a bit further along.

Reviewed By: quark-zju

Differential Revision: D19672546

fbshipit-source-id: 054dd639a8067dce34a5bf667996cc5d30301190
2020-01-31 18:39:41 -08:00
Durham Goode
4e8759a594 py3: various fixes to batch and wireproto encoding
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
2020-01-31 18:39:40 -08:00
Durham Goode
3ce72efbc5 py3: misc fixes around streaming clones
Summary: A couple random stops that need correct encoding.

Reviewed By: quark-zju

Differential Revision: D19672547

fbshipit-source-id: edb0490f70cbf89885fe5fb0a1a8a2472d33e18d
2020-01-31 18:39:40 -08:00
Carolyn Busch
ba8ac287b8 py3 sshserver-test
Summary: Translate between bytes and unicode in sshserver to make test-sshserver pass.

Reviewed By: farnz

Differential Revision: D19672378

fbshipit-source-id: 7e1c0bc2d6fc03fac6ebcf54764862e3ed743f7e
2020-01-31 18:39:40 -08:00
Xavier Deguillard
ae089886fd setdiscovery: use the nodemap __contains__
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
2020-01-31 18:34:01 -08:00
Aida Getoeva
ad097305f5 hg-py3: make metaedit command work
Reviewed By: quark-zju

Differential Revision: D19666536

fbshipit-source-id: e8d02dd6ff6ab73efd94002b83319cbfe506c21f
2020-01-31 18:29:01 -08:00