Commit Graph

1299 Commits

Author SHA1 Message Date
Durham Goode
df37fef5b3 py3: fix test-basics.t
Summary: Simple fix to output bytes

Reviewed By: xavierd

Differential Revision: D20921348

fbshipit-source-id: befa8abab0a7943fd2d20614dcacf3ef25f1e9ba
2020-04-09 09:23:53 -07:00
Xavier Deguillard
9583563bf2 tests: fix test-fb-hgext-crdump.t in Python3
Summary: The .encode('hex') isn't available in Python3, codecs.encode needs to be used.

Reviewed By: DurhamG

Differential Revision: D20927989

fbshipit-source-id: cd0ecdbcbf0ab6391b37f44e7b38a3ffabf91340
2020-04-09 09:10:58 -07:00
Xavier Deguillard
19556ad7d7 tests: enable tests that are now passing in python3
Reviewed By: DurhamG

Differential Revision: D20927681

fbshipit-source-id: f94efe77ce2d4b1377f7f210493678858ba5eae1
2020-04-09 09:10:57 -07:00
Xavier Deguillard
935b80f837 templater: diff is returning bytes chunks
Summary:
Not sure if this is the proper solution, but the template engine refuse to work
with anything but utf8 strings, but the diff operation only work on bytes.
Let's convert the return of diff to utf-8.

Reviewed By: DurhamG

Differential Revision: D20927680

fbshipit-source-id: 25c2947cac417448ca3521c2d5478fa8eebef04f
2020-04-09 09:10:57 -07:00
Xavier Deguillard
6dadf6fdd9 node: use binascii.Error in Python3
Summary:
In Python3, the error returned from binascii.unhexlify changed, from a generic
TypeError to a binascii.Error. Therefore, wrap the binascii function and catch
the binascii.Error before raising a TypeError.

Reviewed By: DurhamG

Differential Revision: D20924129

fbshipit-source-id: 33f852ea97396af715ef73630e0dd1b4324eb707
2020-04-08 23:46:09 -07:00
Stefan Filip
25fd8b9034 py3: fix test-hint.py
Summary:
I can't say that I understand `mdiff.splitnewlines`. In my test it does not
behave the way it reads and I don't know why. The stripping that it's supposed
to do doesn't happen for some reason. It behaves like splitlines.
I believe that rcutil used '\n' for line termination because it was relying on
Python to do the conversion to system line end. I updated to use os.linesep
now that we encode the contents.

Reviewed By: quark-zju

Differential Revision: D20935377

fbshipit-source-id: 0958fdff03950ab0a4b2da02e4333b5438ac5c70
2020-04-08 22:00:35 -07:00
Stefan Filip
5afca4fadd py3: fix test-manifest.py
Summary:
Bytes and Str usages mostly. __iter__ seems to have been incorrectly
converted to python 3 previously.

Reviewed By: xavierd

Differential Revision: D20933166

fbshipit-source-id: 10e63e90bd83c70a51dd808e9b5073ab8d766e71
2020-04-08 19:14:15 -07:00
Xavier Deguillard
76ecec0e57 bisect: make it python3 compatible
Summary: We should read/write to it via as utf8.

Reviewed By: DurhamG

Differential Revision: D20923404

fbshipit-source-id: 86cdc329395d60c88637f24d3c7c5caedcc7111a
2020-04-08 19:08:51 -07:00
Jun Wu
0b5a4ae2c3 cpython-ext: infer errno from io::ErrorKind
Summary:
Sometimes the Rust io::Error is generated without an errno (ex. pipe
0.2 would generate BrokenPipe error without an errno). The Python
land uses errno to check error type (Python does not have io::ErrorKind).

Therefore attempt to translate ErrorKind to Python errno. Without this
exiting the rust pager early would crash like:

  StdioError: [Errno None] pipe reader has been dropped
  abort: pipe reader has been dropped

Reviewed By: markbt

Differential Revision: D20898559

fbshipit-source-id: ef863617e0e500d878ea0f9aeac06b4d87ffbcf2
2020-04-08 13:13:08 -07:00
Lukas Piatkowski
c7d12b648f mononoke/mercurial: make revlog crate OSS buildable
Reviewed By: krallin

Differential Revision: D20869309

fbshipit-source-id: bc234b6cfcb575a5dabdf154969db7577ebdb5c5
2020-04-08 09:49:11 -07:00
Mark Thomas
c02f38dfb7 mutation: public commits are never obsolete
Summary:
The computation of commit obsolescence is inconsistent.  If we compute the full
set of obsolete commits in `mutation.obsoletecache.obsoletenodes`, then we
correctly ignore public commits as they cannot be obsolete.

However, if we compute the obsolescence state for a single public commit with
`mutation.obsoletecache.isobsolete`, and that commit somehow has a visible
successor, then we will incorrectly consider the commit as obsolete.

Similarly, `allpredecessors` and `allsuccessors` should stop when they hit a
public commit.

Reviewed By: quark-zju

Differential Revision: D20892778

fbshipit-source-id: 223cb8b2bc9f2f08124df6ff51c2eb208bb8eb5f
2020-04-08 06:33:14 -07:00
Jun Wu
4d951d777b util: add more APIs for pytracing
Summary: This makes the tracing features easier to use.

Reviewed By: DurhamG

Differential Revision: D19797703

fbshipit-source-id: fb5cb17cd389575cf0134a708bcd9df3b90e9ab4
2020-04-07 21:35:31 -07:00
Xavier Deguillard
d5793b1796 colors: do not disable colors in the pager
Summary:
Somehow, enabling VT can fail when writing to the pager, but this doesn't
mean that the pager doesn't support VT mode, so let's just ignore the error
when the pager is active.

Reviewed By: DurhamG

Differential Revision: D20906374

fbshipit-source-id: 7cba52817bc8e4dc91d5d50e856ad8af7fc9542c
2020-04-07 19:36:55 -07:00
Jun Wu
e6fb421769 tests: add a hint about how to set up HGRCPATH for --keeptmp
Summary: Print out a command that can be copied and executed to make `--keeptmp` more handy.

Reviewed By: sfilipco

Differential Revision: D20829140

fbshipit-source-id: 7976e3f64fd423425ec29634a53a34f7b5e091d0
2020-04-07 19:21:06 -07:00
Jun Wu
5a69be9e70 commands: add debugvisibleheads
Summary:
Add a command to print visibleheads. This was part of my attempt to check if
visibleheads can accidentally include public commits and if there are a way
to remove it. I ended up thinking D20808884 might actualy solve the only case
that visibleheads include public heads.

I also tried to add strong verification so that the visibility layer never
writes public nodes. That's for non-narrow-heads use-cases. However, the
phasescache + repoview layer is kind of messy in a way that inside a
transaction there is only one "repo" that has the right in-memory, dirty
"phasescache" and other repos will load the (stale, wrong) phasescache from
disk. That means if we test phases in visibility before transaction flushes,
we won't be able to access the latest phases information correctly. So I
gave up this approach too.

Anyway, I wasn't able to add a new interesting test, but the utility built for
the test seems useful. Therefore this change.

Reviewed By: sfilipco

Differential Revision: D20829136

fbshipit-source-id: 5ebafefac820ebb4044db63b7892ffaa341c0573
2020-04-07 19:10:45 -07:00
Jun Wu
bd55a2e946 phrevset: improve error message if the commit hash is not found
Summary:
Make the error cleaner and more actionable. We don't autopull the commit
because the revset layer might be not ready for it (ex. it expects commit
graph to be immutable and might have done some calculations based on the
old graph already).

Reviewed By: sfilipco

Differential Revision: D20845159

fbshipit-source-id: c51f2f52c612ff14a88fb891c10d1faad1094635
2020-04-07 19:05:05 -07:00
Jun Wu
a06922ec0f phrevset: rename getdiff, finddiff to graphqlgetdiff, localgetdiff
Summary: This makes it easier to reason about.

Reviewed By: sfilipco

Differential Revision: D20845158

fbshipit-source-id: 4220c7790a2d3bb83380b65d3de469b42846b34d
2020-04-07 19:05:04 -07:00
Jun Wu
67bbd46027 phrevset: add a config to enforce querying Phabricator
Summary:
The old linear changelog search does not scale and does not work with segmented
changelog, which makes commit data lazy. The "forksearch" is also problematic as
it can produce non-deterministic results. Let's disable the linear search by
default with the intention to remove it if nobody complains.

Reviewed By: sfilipco

Differential Revision: D20845161

fbshipit-source-id: 6911035f146e15c88925217ee9940db59ea2d1c1
2020-04-07 19:05:04 -07:00
Jun Wu
42b1577340 context: provide what commit it is when we cannot load the manifest
Summary:
The manifest node is hard for debugging. Attach the commit as the context and
print it out.

Reviewed By: sfilipco

Differential Revision: D20829139

fbshipit-source-id: ff65d902f56bc79c2d5f2c3ec9cf79a620fd70fc
2020-04-07 19:05:03 -07:00
Jun Wu
35659be2a5 error: add a way to provide context to errors
Summary:
This allows providing context about errors, similar to Rust's "context"
features.

Reviewed By: sfilipco

Differential Revision: D20845160

fbshipit-source-id: 789a4c1b7356fd6eb4b1bcb71efd205d2d45e984
2020-04-07 19:05:03 -07:00
Xavier Deguillard
018e33237a revisionstore: upload local blobs
Summary:
On upload, read all the local blobs and upload them to the LFS server. This is
necessary to support `hg push` or `hg cloud sync` for local LFS blobs.

One of the change made here is to switch from having the batch method return an
Iterator to having them take a callback. This made it easier to write the gut
of the batch implementation in a more generic way.

A future change will also take care of moving local blobs to the shared store
after upload.

Reviewed By: DurhamG

Differential Revision: D20843136

fbshipit-source-id: 92d34a0971263829ff58e137e9905b527e18358d
2020-04-07 16:53:34 -07:00
Xavier Deguillard
0dca734464 revisionstore: add upload to RemoteDataStore
Summary: This method will be used to upload local LFS blobs to the LFS server.

Reviewed By: DurhamG

Differential Revision: D20843137

fbshipit-source-id: 33a331c42687c47442189ee329da33cb5ce4d376
2020-04-07 16:53:34 -07:00
Xavier Deguillard
80b222c01b revisionstore: use loose files for file backed LFS remote
Summary:
Loose files makes it easier to interact with a Mercurial server for tests, use
it instead of an IndexedLog.

Reviewed By: DurhamG

Differential Revision: D20786432

fbshipit-source-id: 61c1fc601d9a6ed157c5add9748e40840b081870
2020-04-07 16:53:34 -07:00
Jun Wu
6a09828a7f pager: add "internal:streampager" as an option to use the Rust pager
Reviewed By: DurhamG

Differential Revision: D20887175

fbshipit-source-id: 6b4cec2ce83578fe39bc3058d09cbb42b32a9d78
2020-04-07 15:57:07 -07:00
Jun Wu
a4a21b72d1 pager: add bindings to expose Rust's pager features to Python
Summary:
This exposes the Rust's pager to Python. Right now it's using the system
terminal.

Reviewed By: DurhamG

Differential Revision: D20887174

fbshipit-source-id: c72f31a58475e76f8097c515dd29f911d2ac4df1
2020-04-07 15:57:07 -07:00
Jun Wu
817f748113 debugindexedlogdump: output in a streaming way
Summary:
Do not convert the entire output to a string. This makes `debugindexedlog dump`
a good test case for native pager support - it takes a while to write the full
output for a large input.

Reviewed By: DurhamG

Differential Revision: D20885567

fbshipit-source-id: 35ed8f68dff1916f0833577c3cf2a52cbf2a658c
2020-04-07 15:57:06 -07:00
Jun Wu
52bb1ab77e clidispatch: add start_pager API for IO
Summary:
Implement the core API to start pager in native Rust. For now it is only
enabled for the entire command if `--pager=always` is set.

Reviewed By: DurhamG

Differential Revision: D20849644

fbshipit-source-id: 860b4e18d841da607864c3447d78dbac126f5f18
2020-04-07 15:57:06 -07:00
Jun Wu
9715911327 templatekw: fix predecessors with only mutation enabled
Summary: The template should use mutation instead of obsutil if mutation is enabled.

Reviewed By: markbt, simpkins

Differential Revision: D20901109

fbshipit-source-id: a2b587ddf2a03965886f753e54e075d5d9064f05
2020-04-07 15:11:30 -07:00
Stefan Filip
d1ba21803a version: warn users when they are running an old build
Summary:
Old is defined by being based on a commit that is more than 30 days old.
The build date is taken from the version string.
One observation is that if we fail to release in more than 30 days then all
users will start seeing this message without any way of turning it off. Doesn't
seem worth while to add a config for silencing it though.

Reviewed By: quark-zju

Differential Revision: D20825399

fbshipit-source-id: f97518031bbda5e2c49226f3df634c5b80651c5b
2020-04-07 14:25:38 -07:00
Mark Thomas
5499a6cbfd commitcloud: don't add deleted remotebookmarks to the set of new remote bookmarks
Summary:
When syncing, if the local copy of the remote bookmark is `None` then the
remote bookmark has been deleted, and shouldn't be added to the set of new
remote bookmarks.

Reviewed By: DurhamG

Differential Revision: D20855909

fbshipit-source-id: 84a7a78ec0ab179e4a14d946b37f496f3dbde03a
2020-04-07 09:33:05 -07:00
Thomas Orozco
c6aa2d3125 globalrevs: verify that convert_revision is a svnrev when falling back
Summary:
When falling back to convert_revision to get the svnrev for a commit to return
it as a globalrev, it seems like it would make sense to verify that the
convert_revision is indeed a svnrev (and not, say, a git commit hash from
hggit).

Reviewed By: farnz

Differential Revision: D20891268

fbshipit-source-id: 2451ad787fcce7b10b6a405f2855313ca51f5b3e
2020-04-07 06:47:26 -07:00
Jun Wu
5f8e89f1e2 tests: simplify test-commitcloud-sync-rb-enabling2.t
Summary:
Use modern utilities for this test. This makes the setup portion much shorter.

The test content changed a bit as the configuration is changed - both clients
have selectivepull enabled.

Reviewed By: sfilipco

Differential Revision: D20829137

fbshipit-source-id: d2f29d162172e149d7140925e7d3801707484df2
2020-04-06 14:29:57 -07:00
Jun Wu
59f7c9532d tests: add more utilities to tinit.sh
Summary:
This makes writing tests easier.

It was part of D20504732.

Reviewed By: sfilipco

Differential Revision: D20829138

fbshipit-source-id: e9309e099a13d0a509eff707ae229bf8b7a9c231
2020-04-06 14:29:57 -07:00
Jun Wu
ea0ffd3607 treemanifest: make post-pull prefetch non-fatal
Summary:
Similar to D19957251, failing to prefetch trees post-pull is not a fatal error.
This recently became an issue because with these conditions:

- We're migrating a repo from hg to Mononoke, and Mononoke has lagged
  bookmarks, esp. remote/master.
- We're still using Mercurial to serve infinitepush pulls (ex. scratch
  bookmarks). Mercurial will return bookmarks that are not synced to
  Mononoke yet.
- I made a recent change (D20531121) that moves selectivepull logic that
  changes `pull -r HASH` to `pull -r HASH -B master` to core. The CI
  tier didn't have selectivepull enabled that will pull bookmarks, but
  now they also pull bookmarks.
- The tree prefetch logic uses unpatched paths.default to fetch `master`,
   which can be an unknown commit for Mononoke.

Ideally, the final state is to rely on Mononoke for everything. There is
only `paths.default` which points to Mononoke. For now, as a temporary
fix let's just make post-pull tree prefetch non-fatal. Once this happens,
it will be logged to the cloud table with fatal=false.

Reviewed By: krallin

Differential Revision: D20873599

fbshipit-source-id: 291a2dc41c7c602f004ad8df71e19a48a98e9c5e
2020-04-06 14:04:51 -07:00
Jun Wu
a7c7d37443 sparse: print warnings for sparse profile typos
Summary:
This makes it easier to spot typos.

The config sparse.missingwarning affects everytime a sparse profile is used.
In this case we just want to check at "enableprofile" time. So avoid using
that config option.

Reviewed By: DurhamG

Differential Revision: D20846313

fbshipit-source-id: 79f80d5e01abfe1633f2597074e9acb5cda60fec
2020-04-06 13:57:48 -07:00
Xavier Deguillard
ffc487e2de color: do not try to enable VT mode for tests
Summary:
Tests are redirected, but we still want colors in them (to verify that ANSI
escape code works). Since VT mode will always fail, simply do not try to
enable it in this case.

Reviewed By: DurhamG

Differential Revision: D20875423

fbshipit-source-id: bd6b0046de9558d957e0df082d4392ad00e0b551
2020-04-06 13:07:52 -07:00
Xavier Deguillard
46d13ee650 ui: cache formatted
Summary:
Somehow the constant isatty and config reading shows up in my profile. Since
this is not intended to change, just cache it.

Reviewed By: DurhamG

Differential Revision: D20830511

fbshipit-source-id: de36c0a958f6a6046a05db0abf976994435b9e3c
2020-04-06 11:10:53 -07:00
Xavier Deguillard
1ece50fc62 tests: fix test-fb-hgext-remotefilelog-rust-lfs.t on Windows
Summary:
The IndexedLog code uses a lock file to lock a directory on Windows, make
sure we account for that.

Reviewed By: DurhamG

Differential Revision: D20818882

fbshipit-source-id: 7e9aa255354d36899ad57168311a4276d448dc07
2020-04-06 10:18:05 -07:00
Xavier Deguillard
ed68d04942 pyworker: no longer ignore windows file removal failures
Summary:
Now that we have a proper back-channel to retry failures in Python, the
failures will be retried at a later time, when the anti-virus would have
hopefully release any locks it has on the file.

Reviewed By: DurhamG

Differential Revision: D20847006

fbshipit-source-id: 4fad0e773f69ddff27a23bc86dbbd3ce47bb3b46
2020-04-06 09:49:52 -07:00
Xavier Deguillard
d0b63fcd01 color: only warn about VT mode when formatted
Summary: We don't want tests to show this warning.

Differential Revision: D20851847

fbshipit-source-id: bae87a980a2da4088aff6ed0b4a3a85971166817
2020-04-06 08:48:58 -07:00
Thomas Orozco
0565c7e244 hggit: add a external-sync command that does the bare minimum
Summary:
For our HgExternalSync jobs that pull from git, we don't really use most of the
bells and whistles of hggit. Notably, we don't care about bookmarks: we only
ever pull master, we never update to it, we only ever look at `-r tip`.

However, we do care about things that are actually much harder to fit in a
world where we try to pretend the remote git repository is actually a hg
repository we can pull from.

Notably, we'd like to enforce limits on how many commits we pull (and convert)
at a time, so that if we fall behind a little bit, we don't start falling even
more behind by having to convert bigger and bigger batches of commits. If we're
trying to pretend fetching from git and converting commits is actually a pull,
then that seems harder to pull off (we'd need to somehow rewind the remote head
we're pulling before importing it).

So, this adds a new external-sync command to hggit that basically the bare
minimum that we do need. It lets you specify a git remote and a head you care
about, and import up to N commits from it. That's it — no bookmarks are updated
or anything (but the git-mapfile is, of course). The only thing that changes is
your commits.

If you actually want to interact with your git repository on an ongoing basis
as if it were a remote hg repository, this is completely useless, but that
isn't what we actually do, so that should be OK.

As part of this, I've modified a few other parts of git_handler to remove
places where we called a `uri` `remote_name` (which is a bit confusing), and a
place where we were asking for a `remote_name` parameter that I don't have
here, but which we also didn't actually need (in `import_git_objects`).

Reviewed By: farnz

Differential Revision: D20836601

fbshipit-source-id: 96230e6e8269d0472404414948fd2f02aa98d79c
2020-04-06 07:35:36 -07:00
Mark Thomas
5456adefe7 infinitepush: don't create revive obsmarkers if evolution is not enabled
Summary:
Evolution crashes if you try to create obsmarkers in a repo where obsmarkers
are not enabled.  Instead, check before reviving commits with obsmarkers that
it is enabled.

Reviewed By: krallin

Differential Revision: D20868173

fbshipit-source-id: b3a08ef05ddc13e9b78df8ac7c1ca1ef808b7602
2020-04-06 06:43:35 -07:00
Xavier Deguillard
7bcf163d55 color: remove all the win32 terminal handling
Summary:
Let's mandate a 256 color terminal in Windows. We also update less to default
to using VT mode: https://github.com/gwsw/less/pull/29

With this, the colors appears to be working as expected on Windows!

Reviewed By: quark-zju

Differential Revision: D20826922

fbshipit-source-id: 5d2a149e2698b3ccc7bf6388b5cd97da20898eb7
2020-04-03 13:47:32 -07:00
Xavier Deguillard
08984182b9 setup: write the pyc before the py during packaging
Summary:
I'm not exactly sure why, but my guess is that by writing the py files first,
the pyc might be copied and not generated, causing Python to not read the pyc
at import time, leading to slow startup time.

Reviewed By: quark-zju

Differential Revision: D20829130

fbshipit-source-id: e838ff18b9fbf65d1a9437e0a8ef58d57803d2fa
2020-04-03 11:35:29 -07:00
Xavier Deguillard
01e921aa19 crecord: fix windows arrow keys
Summary:
For whatever reason, ncurses doesn't interpret the arrow keys properly... Use
whatever is returned from it instead.

Reviewed By: kulshrax

Differential Revision: D20821432

fbshipit-source-id: 019426a1333538a479fb3dd8d147fb9cb4ba6559
2020-04-03 08:26:26 -07:00
Jun Wu
4ae44e316a remotenames: move repo._accessedbookmarks to core repo._remotenames._accessedbookmarks
Summary:
Move the attribute so it won't cause an AttributeError when remotenames is not
enabled.

As we're here, also move it to repo._remotenames from repo. This makes the repo
object a bit clearner and avoids loading the accessed bookmarks if remotenames
are not accessed at all.

Reviewed By: singhsrb

Differential Revision: D20821070

fbshipit-source-id: b5a01016451ee202f778cadb2dd418400406fa6b
2020-04-02 19:25:33 -07:00
David Tolnay
1a86366f0e third-party/rust: Turn off async-trait/support_old_nightly
Summary:
This diff turns off the support_old_nightly feature of async-trait (https://github.com/dtolnay/async-trait/blob/0.1.24/Cargo.toml#L28-L32) everywhere in fbcode. I am getting ready to remove the feature upstream. It was an alternative implementation of async-trait that produces worse error messages but supports some older toolchains dating back to before stabilization of async/await that the default implementation does not support.

This diff includes updating async-trait from 0.1.24 to 0.1.29 to pull in fixes for some patterns that used to work in the support_old_nightly implementation but not the default implementation.

Differential Revision: D20805832

fbshipit-source-id: cd34ce55b419b5408f4f7efb4377c777209e4a6d
2020-04-02 17:01:24 -07:00
Thomas Orozco
56251513bf git-sl: remove Mercurial import
Summary:
This isn't actually a Mercurial extension, so we can't be importing Mercurial
imports here. I'm not sure this is actually being used because we apparently
have 2 copies of this (see D20793452, which is also how I came upon this), but
it's probably worth not breaking it.

Reviewed By: farnz

Differential Revision: D20794695

fbshipit-source-id: daaf0f5822567b55a787669073421fd1ce604e08
2020-04-02 12:32:34 -07:00
Durham Goode
9976df9010 watchman: keep using watchman even if there are state-enter/leave errors
Summary:
We've seen a number of recent cases where hg stops using watchman for
status because state-enter or state-leave fail because multiple enters or leaves
are called out of order. The root cause needs to be found, but in the mean time
we should not allow such errors to block of from using watchman entirely.

Let's eat these gracefully and just log that the issue happened.

Reviewed By: quark-zju

Differential Revision: D20807004

fbshipit-source-id: 517d9562febc226ce7db836435ca2ca9db1c68fb
2020-04-02 11:42:59 -07:00
Xavier Deguillard
a7e5557baa test: properly set ui.ssh
Summary:
On Windows, we have to do a bit of dance for Windows to stop complaining
about ui.ssh.

Reviewed By: DurhamG

Differential Revision: D20817712

fbshipit-source-id: acbda636fe114fd616dee89b2c4d1c9ff26470bf
2020-04-02 11:26:54 -07:00