Commit Graph

80 Commits

Author SHA1 Message Date
Xavier Deguillard
dc6cbcdfe6 remotefilelog: do not preload packs
Summary:
Preloading all the pack files on initialization ties the lifetime of the
packfiles to the repo. For normal operations, this is fine, as packfiles are
mostly read. During a repack however, we need to be able to remove them, and
while having an open file handle allows deletion on unix OSes, it prevents it
on Windows.

The Rust repack now succeeds on Windows.

Reviewed By: DurhamG

Differential Revision: D14013786

fbshipit-source-id: 99279d4af67a0dfe8679159e9409186f56a09296
2019-02-14 10:34:52 -08:00
Mateusz Kwapich
4f58ae8678 config: stop lying about the config locations
Summary:
Since september (D9840431) rcutil.rccomponents is no longer source of truth
about which config files we load. In fact we use it only in the
`hg config --debug`. This leads to situations where the debug command mentions
loading a specific config file and then ignores it completely which is very
confusing.

Let's remove it.

Reviewed By: suitingtseng

Differential Revision: D14083220

fbshipit-source-id: 362fd9bf574e24639f99a1203206184da42d1e24
2019-02-14 09:31:58 -08:00
Johan Schuijt-Li
09d54f3cf4 remotenames: treat query strings and fragments as parameters
Summary:
When using query strings or fragments in an URL we should treat repository paths
as the same repo. This allows servers to use query strings for metadata, without
treating the urls as different servers. By introducing normalization in our grouping,
we will consider the normalized result to be the qualifier for what is the same repo,
rather then the full absolute path - which includes query strings and fragments.

Reviewed By: DurhamG

Differential Revision: D14051479

fbshipit-source-id: c82fe041467f6bd6af210688c0be873e2da93781
2019-02-14 03:21:53 -08:00
Arun Kulshreshtha
a4a155c025 edenapi: add configitem call for edenapi.url
Summary: We were reading the  `edenapi.url` config item without explicitly setting it up with the `configitem()` function. Not sure what negative impact this would have, but it's probably a good idea to have the explicit call in place.

Reviewed By: quark-zju

Differential Revision: D14075080

fbshipit-source-id: bb4e25de273341768f850f1d5aab6ac21e7f2fc5
2019-02-13 17:41:54 -08:00
Arun Kulshreshtha
c68b388bed edenapi: remove try around import
Summary: Now that the `edenapi` module in bindings is always available for all platforms, we no longer need a try block around the import.

Reviewed By: quark-zju

Differential Revision: D14075082

fbshipit-source-id: e3f45e67ef4572e58f85875af12390ea5d697d43
2019-02-13 17:41:54 -08:00
Arun Kulshreshtha
575e570a28 bindings: move pyedenapi into bindings crate
Summary: Move the edenapi Python bindings into the common `bindings` crate.

Reviewed By: quark-zju

Differential Revision: D13963179

fbshipit-source-id: 76dead82af992615a9e452ee6fbb9f66639c822c
2019-02-13 16:07:00 -08:00
Arun Kulshreshtha
127ca1a990 edenapi: use rustls instead of openssl
Summary:
Switch from using OpenSSL (via `native-tls`) to [Rustls](https://github.com/ctz/rustls), a pure-Rust TLS implementation based on the `ring` crypto crate.

Unlike `native-tls`, Rustls supports ALPN, which means it can be used along with Hyper to perform HTTP/2 requests over TLS. (OpenSSL also supports ALPN, but older versions of Windows' `schannel` library do not, and as such `native-tls` doesn't support ALPN either regardless of platform.)

Rustls also builds on Windows without any special configuration, sidestepping the issues we've been having with OpenSSL in the Windows build.

Reviewed By: quark-zju

Differential Revision: D14070084

fbshipit-source-id: 25268c58a88177f4708370696d326b4c0bdc89a0
2019-02-13 16:07:00 -08:00
Arun Kulshreshtha
1d00a343e4 bindings: add init module
Summary:
Add a new `init` module to the `bindings` crate. This is intended as a place to put global Rust initialization code for Mercurial's Rust extensions. Ordinarily, such code would go at the start of `main()`, but since `hg` doesn't have a Rust main, putting initialization here at least guarantees that it will happen before any of the Rust extension code runs.

Right now, the only thing initialized in the new module is `env_logger`.

Reviewed By: quark-zju

Differential Revision: D14072560

fbshipit-source-id: 0f2770d0a3a6e9c6b7fe68eb62007cc091adad59
2019-02-13 16:07:00 -08:00
Liubov Dmitrieva
380f425385 infinitepush: fix issue with discovery
Summary:
if server already have everything, the function should return True

otherwise we treat it as fail to backup in pushbackupbundlestacks function

failed to push stack bundle rooted at ...

Reviewed By: quark-zju

Differential Revision: D14048141

fbshipit-source-id: 288291db2f31b0d284c97fecbd61049a58c045de
2019-02-13 08:20:17 -08:00
Jun Wu
9d21b98c57 convert: drop monotone support
Summary:
Monotone repos are rare these days. Drop support for it.
This also solves an issue that test-convert-mtn.t uses named branches.

Differential Revision: D14059836

fbshipit-source-id: 1e9d4fe6fdc295393ff67c5e068b230b9ed0c0af
2019-02-12 21:45:13 -08:00
Jun Wu
4cd0b5c098 transplant: remove the extension
Summary:
The (disabled by default) `transplant` command is similar to `graft` or
`rebase`. It makes sense to removeit.

This diff removes the extension.

Reviewed By: singhsrb

Differential Revision: D14000099

fbshipit-source-id: a03e4925cefa4236bd9d62cfe9d33d140707bd7c
2019-02-12 21:45:11 -08:00
Jun Wu
8fd207a853 revset: stop supporting origin() and destination()
Summary: They will be replaced by successors and predecessors.

Reviewed By: singhsrb

Differential Revision: D14000097

fbshipit-source-id: 07f0c97edd7eb16ad665c00886c00212d516ae72
2019-02-12 21:45:11 -08:00
Jun Wu
87b87d5490 rebase: remove --keepbranches flag
Summary: Branches are going away. Remove related features.

Differential Revision: D13993824

fbshipit-source-id: 8afb01912df016bda08be5bc22ac52be7f5168eb
2019-02-12 21:45:10 -08:00
Jun Wu
fbccd19ed7 patchbomb: remove the extension
Summary:
`test-patchbomb.t` uses named branches and does not look simple to fix.
We don't use email patches internally, and it's not hard to write scripts
around `hg export`. Therefore drop the extension and its tests.

Reviewed By: singhsrb

Differential Revision: D13978577

fbshipit-source-id: 19867ae68c19c996bfce064eb2234705939db9ea
2019-02-12 21:45:10 -08:00
Jun Wu
64c43d2eab import: remove the --import-branch flag
Summary: Branches are going away.

Reviewed By: singhsrb

Differential Revision: D13978568

fbshipit-source-id: b9b4f3d2755757c0d3780bbb10c4579bf8d15fef
2019-02-12 19:54:31 -08:00
Jun Wu
04f6795519 remotenames: remove logic about named branches
Summary: Named branches are going away. Remove the logic around it.

Reviewed By: phillco

Differential Revision: D13978575

fbshipit-source-id: d6e28d7cadffa612f74a2afc12800829d6113dfa
2019-02-12 19:54:30 -08:00
Xavier Deguillard
e241404290 remotefilelog: always refresh before runonpacks
Summary:
The refresh function is intended to load on-disk packfiles that aren't yet
present in the cache, but it had several issues that resulted in unexpected
behavior. Mainly, the new files would be added in the wrong order in the cache,
and runonpacks would not update the last used packs.

Differential Revision: D14013785

fbshipit-source-id: da4151b859441f0ba51863f3907852922c255f82
2019-02-12 11:21:34 -08:00
Xavier Deguillard
f5d7209d39 remotefilelog: move rustrepack
Summary:
Previously, the logic for chosing between the rust repack, and the python one
was deeply integrated with the python repack. This resulted in work being
performed unnecessarily.

The drawbacks of this method is that in the case of fallback to Python, the
repacklock will be dropped and re-obtained, as well as the prerepack hook will
be ran twice. Since the python code will soon be entirely replaced this is
probably not important.

Differential Revision: D14013790

fbshipit-source-id: 7c754db3fb984cc9e6b7df1a4e32b72fa4a1531b
2019-02-12 11:21:34 -08:00
Xavier Deguillard
f134a4fe92 remotefilelog: refactor incremental/full repack
Summary: Most of the code is identical between these 2 functions, so let's merge them.

Differential Revision: D14013787

fbshipit-source-id: f0469e05fcf723db02d9f4c28097e61f958284a5
2019-02-12 11:21:34 -08:00
Jun Wu
946fa43efd fsmonitor: update watchman clock if too many files are returned
Summary:
This should auto recover from a state where watchman returns too many files,
which makes "hg status" slow.

The default config value 200 is not chosen very scientifically, but it should
cover the 6s status case where there are 90k changed files reported.

Differential Revision: D14036494

fbshipit-source-id: 368f53e99e2e54343a6ac9145cbb86e4ac65e4ac
2019-02-12 11:16:12 -08:00
Jun Wu
98bb16cace hgsql: fix hggit sync
Summary: Teach mysql connector to deal with bytearray.

Reviewed By: DurhamG, StanislavGlebik

Differential Revision: D14025816

fbshipit-source-id: 738d9ef37b985afad5fe62815be134a4a5913b9a
2019-02-11 13:47:12 -08:00
Aida Getoeva
3aee83d26a prefetch: replaced store path with the cache path
Summary:
To connect to the memcache client it used a path from a loose files data store (`remotefilelogcontentstore._path`), which is a path to the hg cache, but pack files store doesn't have the same field.
I replaced the path with cache path from shallowutil.

Reviewed By: singhsrb, liubov-dmitrieva

Differential Revision: D14020122

fbshipit-source-id: 29bc8a01fc42d43eddc6ae67cf4e41fc552e117c
2019-02-11 09:38:43 -08:00
Jun Wu
f656af6866 encoding: alias cp65001 to utf-8 on Windows
Summary:
This back ports Yuya's patch from upstream:

  changeset:   443029011990c75c533ec0454fd0f5c1060d4690
  branch:      stable
  user:        Yuya Nishihara <yuya@tcha.org>
  date:        Sun, 01 Jul 2018 06:36:53 -0800

      encoding: alias cp65001 to utf-8 on Windows

      As far as I can tell, cp65001 is the Windows name for UTF-8. I don't know
      how different it is from the UTF-8, but Python 3 appears to have introduced
      new codec for cp65001, so the alias is enabled only for Python 2.

      https://bugs.python.org/issue13216

      This patch is untested, but hopefully fixes the following issue.

      https://bitbucket.org/tortoisehg/thg/issues/5127/

More context:
Windows 10 Build 17035 (November 2017) introduced a
"Use Unicode UTF-8 for worldwide language support" checkbox, which makes the
"A" flavored APIs use UTF-8 instead of some non-UTF-8 local encoding. With
that checkbox ticked, hg would crash in cmd.exe complaining
"LookupError: unknown encoding: cp65001"

{F150484107}

Reviewed By: phillco

Differential Revision: D14017361

fbshipit-source-id: a648b2a9bc341d796532c6fd2730c083402b3736
2019-02-11 09:16:02 -08:00
Xavier Deguillard
0ce06567ab remotefilelog: properly declare CacheConnectionError
Summary:
The super python builtin expects a type as an argument, while a string was
passed, this was causing trouble for some users.

Reviewed By: DurhamG

Differential Revision: D14012716

fbshipit-source-id: 6714eb20745428818721ec3df85588a7b4c7ebb7
2019-02-08 17:16:00 -08:00
Jun Wu
b74ee0564d chg: make it incompatible with upstream chg server
Summary:
It would be massy if there are 2 chg servers running: one for fb hg, one for
upstream hg, and they share a same socket path.

Change socket path and the commandserver name so fb-hg chg can only talk to
fb-hg chg servers.

Reviewed By: markbt

Differential Revision: D13869319

fbshipit-source-id: f9d42af9bdfc542207f23c536b478fd5ef8d02a0
2019-02-08 16:12:53 -08:00
Liubov Dmitrieva
ca7f631006 lazy connection open for memcache has an issue with SIGPIPE
Summary: My earlier diff broke master, this is the fix.

Reviewed By: markbt

Differential Revision: D14005894

fbshipit-source-id: 6ce43913fb501791592512f2f12cd67ef27f0457
2019-02-08 09:44:06 -08:00
Liubov Dmitrieva
261da2a786 fix remotenames for infinitepush
Summary:
Currently if default path and infinitepush both point to the remote path
from the repo, the activepath function returns 'infinitepush' rather than
'default' because of the logic I have fixed.

It makes your smartlog looks like.

```
o  037dddb5  62 minutes ago  infinitepush/fbobjc/stable remote/fbobjc/stable
.
o  66e0e00c  Today at 05:58  infinitepush/fbandroid/stable
remote/fbandroid/stable
.
@  28c3b5b0  Today at 05:40  mlesyk  D14003881  T27597699
.  [fbar][prod_role] fix region detection part
.
o  407504d6  Today at 04:58  infinitepush/fbsource/stable
remote/fbsource/stable
```

When you pull it updates infinitepush/master, etc instead of remote/master,
etc.

This only happens if they both point to the same url.

This is not desirable for infinitepush.

I also introduced infinitepush-other that we will use for the secondary commit cloud backend.

It would have the same issue if it matches the url of the default path.

Reviewed By: markbt

Differential Revision: D14005639

fbshipit-source-id: f3ea8098e1c418e2efd43b5430bb4252f6ad6b2c
2019-02-08 09:24:20 -08:00
Wez Furlong
35e2b7c6ff hg: fix lfs and journal extension postshare wrapping
Summary:
this fixes `hg-new-workdir` by matching the function signature
and propagating the arguments.

Reviewed By: singhsrb

Differential Revision: D13992348

fbshipit-source-id: 582025affe2e0511f239e82bc880b2fecea84ac7
2019-02-07 18:58:40 -08:00
Jun Wu
c2ef481658 logexchange: delete the experimental component
Summary:
logexchange was a subset of remotenames, added by:

  changeset:   5a62910948d2d4bac5defe305d0ddb22f0fda549  D1547
  user:        Pulkit Goyal <7895pulkit@gmail.com>
  date:        Wed, 04 Oct 2017 10:32:02 -0800
  summary:     remotenames: move function to pull remotenames from the remoterepo to core

Since we use the full remotenames instead, remove logexchange and its test,
which depends on named branch.

Differential Revision: D13954458

fbshipit-source-id: d565c131100ef90f3cf69e9051643ac8e5846f0d
2019-02-07 18:17:18 -08:00
Durham Goode
20f9ac38f6 remotefilelog: handle corrupt loose files more gracefully
Summary:
If the history portion of a loose file was corrupt, users would often
get errors like "ValueError: substring not found" when trying to split on the
null separators. Let's catch that and handle it where appropriate. For cache
stores, we move it out of the way and return a KeyError, so the union store will
move on to try to fetch it from the server again. For local stores, we return a
ValueError and surface it to the user since their local data may be corrupt.

Reviewed By: quark-zju

Differential Revision: D13976499

fbshipit-source-id: 39e63f19fc752ca0179fbc5b0908a28d46de3a3a
2019-02-07 13:40:42 -08:00
Durham Goode
2def6874f5 remotefilelog: default file blobs to version 1
Summary:
We're seeing cache corruption issues due to mixing and matching loose
file versions. Let's just default to 1.

Reviewed By: quark-zju

Differential Revision: D13980892

fbshipit-source-id: 1e8cc9a53b8b92e05dc08b202505bb8f453a3074
2019-02-07 11:08:01 -08:00
Liubov Dmitrieva
da5a666d2f use simplecache store on the server side to store remotefilelog cache
Summary:
simplecache can be configured with memcache backend

this will potentially save us a lot of disk space and allow us to have a shared cache between hg hosts.

getting rid of the caches on disks will save 966GB of disk space per machine.
P60876105

Reviewed By: quark-zju

Differential Revision: D13950137

fbshipit-source-id: 015e971f1bfed334edb4fe2381c2c6336b84b161
2019-02-07 05:15:11 -08:00
Liubov Dmitrieva
638959056d simplecache - reuse the connection to memcache
Summary:
reuse the connection for other requests
I made it global

Reviewed By: quark-zju

Differential Revision: D13964705

fbshipit-source-id: ed759e36f15b91a838dc2c20b58384ae54ad5d48
2019-02-07 04:59:48 -08:00
Liubov Dmitrieva
13abfafb8d treemanifest: use simplecache as a cache store
Summary:
simplecache extension support both memcache and local disk as a cache store.

we are going to use memcache on hg servers

getting rid of the caches on disks will save 966GB of disk space per machine.

P60876105

this will also allow hg machines to share the same cached data

Reviewed By: DurhamG

Differential Revision: D13927163

fbshipit-source-id: 3155c61da4a82dd7a790a8ccf8dbc701fe3957e1
2019-02-07 04:59:48 -08:00
Aida Getoeva
baa9bab088 set ui.slash=True if HGPLAIN=1
Summary:
`hg status` should show slashes in filepaths standard for the diff format. Now it shows windows' backslash.

More details:
https://fb.workplace.com/groups/scm/permalink/1933867456662865/

Reviewed By: quark-zju

Differential Revision: D13944478

fbshipit-source-id: d34d2c6bc0b9966e1806e36668c21e8abfc83a02
2019-02-07 04:32:27 -08:00
Adam Simpkins
8d35b90969 fix a crash in remotefilelog prefetch
Summary:
It looks like D13924759 accidentally replace `prog.value` with `prog` in one
location, which is causing crashes of the form:

  TypeError: unsupported operand type(s) for +=: 'nullbar' and 'int'

Reviewed By: quark-zju

Differential Revision: D13984835

fbshipit-source-id: cbf1a52d8048b623beac6048224767f0abb7f5c0
2019-02-06 22:03:19 -08:00
Jun Wu
dbc9a9f3e6 fscap: mark "fuse.ntfs" (ntfs-3g) as not supporting symlinks
Summary: See D13964546 for context.

Reviewed By: DurhamG, ikostia

Differential Revision: D13982878

fbshipit-source-id: abce6f3c005b916cfb2e7a34276b99f9fcaa44b5
2019-02-06 18:34:30 -08:00
Jun Wu
89882201b0 posix: detect fuse.ntfs on Linux
Summary:
On linux, ask /proc/self/mountinfo for the block device information, and then
ask udev for the filesystem type. It works for block devices, and is what
util-linux tools like findmnt, lsblk do.

This detects ntfs-3g mounts of block devices as `fuse.ntfs`.

Reviewed By: DurhamG

Differential Revision: D13982877

fbshipit-source-id: eacea6a949b54d9a6483f2c55c437718eb89c243
2019-02-06 18:34:30 -08:00
Jun Wu
efba35645a osutil: detect fuse on Linux
Summary:
The constant is not exposed in linux/magic.h, perhaps because fuse is an
optional feature. It's unlikely to be changed. Define it so fuse fstype
can be detected.

Reviewed By: DurhamG

Differential Revision: D13969640

fbshipit-source-id: 5084bdacf193261a187a74546a82995f2dd2d7c6
2019-02-06 18:34:30 -08:00
Durham Goode
af61927d32 remotefilelog: add documentation for remotefilelog.getfilesstep
Summary:
This is breaking the tests. It has existed for years, so not sure why
the recent reformatting broke it now.

Reviewed By: quark-zju

Differential Revision: D13976462

fbshipit-source-id: 08f3a9f08ec54449b4554017ea9806f3ee51afcb
2019-02-06 13:02:59 -08:00
Aida Getoeva
562b9d1884 prefetch: remove check misses after fetching from server
Summary: We don't really need to check misses here as neither of request fucnctions return misses after fetching from the server. They raise exception if there are any misses.

Differential Revision: D13908252

fbshipit-source-id: 80b6e4fb79b419b5e6d3b343b3bd46d3f8dc7d3c
2019-02-06 10:43:15 -08:00
Aida Getoeva
996ac6da37 prefetch: add requestpacks
Summary: Implemented logic for fetching data from the scmmemcache and the server in pack files format. By default `prefetch` will still use loose files, unless the `remotefilelog.fetchpacks` config flag will be set to true.

Differential Revision: D13905733

fbshipit-source-id: cc559f5bc600067199a91efe6cf44b1bde6bf69b
2019-02-06 10:43:15 -08:00
Aida Getoeva
d853db727d prefetch: add get/set for pack files and remove hitcount
Summary: New get/set protocols for pack files. Also removed hitcount from `receive` method, because it is not used.

Differential Revision: D13924759

fbshipit-source-id: 1382b6f2bc865a19125f3ccd17a779cd16f08b50
2019-02-06 10:43:15 -08:00
Aida Getoeva
2b23a376f6 prefetch: get packs' paths after fetching from server
Summary: To add the data fetched from the server to the scmmemcache, we need to know pasths to the packfiles created.

Differential Revision: D13905734

fbshipit-source-id: 7c470b560e32e63e7df4f960be92bc9b6da9de3d
2019-02-06 10:43:15 -08:00
Aida Getoeva
3ea6881ea7 prefetch: move "fetch from server" code to the requestloose
Summary: Moved fetching loose files from the server to the separate function

Reviewed By: DurhamG

Differential Revision: D13855807

fbshipit-source-id: 39821644abcdc7375ba1b9ef9519fd2083eb0a71
2019-02-06 10:43:15 -08:00
Aida Getoeva
e218de341c prefetch: add set and get request
Summary: Move scmmemcache set/get commands protocol to the cache wrapper to isolate it from the main logic

Reviewed By: DurhamG

Differential Revision: D13855809

fbshipit-source-id: 95b70f7f9d10d97beff107f9f6e5e4f5a8a307c1
2019-02-06 10:43:14 -08:00
Aida Getoeva
79a1bd7770 prefetch: return set of misses instead of list
Summary: List of missed files is converted to a set many times. So changing the type to a set.

Differential Revision: D13924760

fbshipit-source-id: 65fe52ff6113724d8f7f7a8d5b3c1501f245eedc
2019-02-06 10:43:14 -08:00
Aida Getoeva
494608cf81 prefetch: add receive
Summary: Move scmmemcache receive logic to the cache wrapper to isolate it from the main prefetch logic

Reviewed By: DurhamG

Differential Revision: D13855808

fbshipit-source-id: d0da84857797e3e155507fcf284b39a146677e54
2019-02-06 10:43:14 -08:00
Durham Goode
163704f80a disablesymlinks: add extension to disable symlinks
Summary:
In some cases we are mounting ntfs in a linux host using ntfs.3g and we
want to prevent it from writing symlinks that can't be read from Windows.

Some background, ntfs.3g supports symlinks, but it produces IntxLNK which cause
problems when mounted into a real Windows machine. We don't support symlinks on
Windows anyway, so we want to just disable this. Unfortunately it's difficult to
detect if we're on a ntfs.3g fuse mount, so instead we're just going to have the
machine set up the repo with this extension enabled.

Differential Revision: D13964546

fbshipit-source-id: 7545538e51be4c986a50161165d7cc2e64280555
2019-02-06 08:41:34 -08:00
Arun Kulshreshtha
8aaab173c0 bindings: convert to Rust 2018
Summary: Convert crate to Rust 2018.

Reviewed By: quark-zju

Differential Revision: D13963023

fbshipit-source-id: f81a1ecd505d3bdc70c41f5272f861fdd737a8fc
2019-02-05 21:22:48 -08:00