Commit Graph

1299 Commits

Author SHA1 Message Date
Xavier Deguillard
499a67a417 tests: add a test using the Rust workers
Summary: Basic test to validate that updating files works as expected.

Reviewed By: DurhamG

Differential Revision: D20450123

fbshipit-source-id: 3ce09e1f72fe00052b86eec07668f3aa45824725
2020-03-17 16:01:48 -07:00
Wez Furlong
0b27e18628 hg: don't depend on python2 for sshaskpass.py
Summary:
python2 doesn't exist on centos 8, and rather than guess
at which interpreter to use, run using the built in interpreter
from our rust binary which is accessible via `sys.executable`
under the `debugpython` subcommand.

Reviewed By: quark-zju

Differential Revision: D20379035

fbshipit-source-id: 57863427241ef01e5c0e8debbb5baf056fd41d65
2020-03-17 15:52:13 -07:00
Adam Simpkins
3723a1a0b1 fix invalid buffering setting in some tests
Summary:
Update a test that was attempting to call `os.fdopen()` in binary mode with
line buffering.  Line buffering is only valid on files opened in text mode.
Python 3.8 now emits a warning about this invalid call, which causes the test
to fail.  Switch the test to use unbuffered mode.

Reviewed By: pixelb

Differential Revision: D20484844

fbshipit-source-id: 3bedfa3f0fb7926ad3ab3b6ea85716d0e1b603c3
2020-03-17 11:07:50 -07:00
Adam Simpkins
9428d1cf40 delete the custom GzipFileWithTime class
Summary:
Remove the custom `GzipFileWithTime` class from `mercurial/archival.py`
This code was added in 2007.  Presumably back then Python's standard
`gzip.GzipFile` class did not support the `mtime` argument.  However, this
argument is present in Python 2.7+, and we don't care about older versions.

The custom `GzipFileWithTime` class breaks in Python 3.8 since Python 3.8
added an extra `compresslevel` argument to the internal `_write_gzip_header()`
method.

Reviewed By: pixelb

Differential Revision: D20484845

fbshipit-source-id: 4e381799d8537c97cd1993273c8efd02743531df
2020-03-17 11:07:49 -07:00
Durham Goode
ceca615943 workingcopy: enable rust walker by default in tests
Summary: Let's enable it for tests. We'll slow roll it in production.

Reviewed By: quark-zju

Differential Revision: D19543790

fbshipit-source-id: be7d18dd8ffe51615a27c39ebf4247ec405b4097
2020-03-17 10:39:15 -07:00
Durham Goode
da9aa40c43 unicode: skip binary filenames coming from Eden
Summary:
Mercurial can't handle these. Let's skip them instead of throwing an
exception.

Reviewed By: quark-zju

Differential Revision: D20016007

fbshipit-source-id: dbf37b9e315d29bcfa1e12f51bc96ed543ff6d84
2020-03-17 09:14:35 -07:00
Mark Thomas
5666399fcf mutationstore: switch mutation entry timestamp from f64 to i64
Summary:
The mutation store stores entries with a floating-point timestamp.  This
pattern was copied from obsmarkers.

However, Mercurial uses integer timestamps in the commit metadata (the
parser supports floats for historical reasons, but only stores integer
timestamps).   Mononoke also uses integer timestamps in its `DateTime`
type.

To keep things simple, switch to using integer timestamps for mutation
entries.  Existing entries with floating point timestamps are truncated.

Add a new entry format version that encodes the timestamp as an integer.
For now, continue to generate the old version so that old clients can
read entries created by new clients.

Reviewed By: quark-zju

Differential Revision: D20444366

fbshipit-source-id: 4d6d9851aacb314abea19b87c9d0130c47fdf512
2020-03-17 04:18:44 -07:00
Mark Thomas
ac80212e8f mutationstore: remove mutation entry origins
Summary:
Tracking the origin of mutation entries did not prove useful, and just creates
an un-necessary overhead.  Remove the tracking and repurpose the field as a
version field.

Reviewed By: quark-zju

Differential Revision: D20444365

fbshipit-source-id: 65ff11ee8cfe77d5e67a83d03a510541d58ef69b
2020-03-17 04:18:44 -07:00
Durham Goode
cb2e471763 treestate: make treestate a hard requirement
Summary:
We want to delete all the non-treestate dirstate implementations. Let's
start throwing an exception if treestate is not enabled. We temporarily have a
bypass in case we break an important usecase in the process.

This also sets the standard new repo to be created in treestate mode, but adding
treestate to newreporequirements.

This was landed once as D19204621 but was backed out because eden backing repos
were using the odl formats and hadn't been upgraded. We fixed that, and now the
data shows ~10 people still using repos in this condition
(https://fburl.com/scuba/dev_command_timers/zxb5hsg2). Some of them are broken
repos, some are ancient eden repos and a simple eden rm and eden clone should
fix them, some are simply old non-eden repos that no one has run commands in in a while.

Reviewed By: xavierd

Differential Revision: D20472234

fbshipit-source-id: 509b4f22b6ac4741b205ef69decfb26e56aebaf8
2020-03-16 18:39:52 -07:00
Chad Austin
b2a8809a8b fix hg revert on conflicted file during conflict resolution
Summary: Fix a ValueError when reverting conflicted files during conflict resolution.

Reviewed By: simpkins

Differential Revision: D20254088

fbshipit-source-id: 0c121e8b4b7a3d97ce138a824a44e0d258019d0d
2020-03-16 18:35:20 -07:00
Xavier Deguillard
deffd9a477 minibytes: address clippy warnings
Summary: Using ptr.add is shorter and preferred to ptr.offset.

Reviewed By: quark-zju

Differential Revision: D20452752

fbshipit-source-id: 1dc2fdbc392267d2d690673c10dcc161ecd00dfa
2020-03-16 14:58:22 -07:00
Xavier Deguillard
67c8cf22a3 hgtime: address clippy warnings
Summary:
These warnings are fairly trivial, as it recommends using single quote (char)
for single characters search instead of a double quote (str).

Reviewed By: quark-zju

Differential Revision: D20452408

fbshipit-source-id: b2951e133e57633a8e766536e22969fa9ac0ecee
2020-03-16 14:58:22 -07:00
Xavier Deguillard
bb30c40375 types: address clippy warnings
Summary:
Clippy had 3 sources of warnings in this crate:
 - from_str method not in impl FromStr. We still have 2 of them in path.rs, but
   this is documented as not supported by the FromStr trait due to returning a
   reference. Maybe we can find a different name?
 - Use of mem::transmute while casts are sufficient. I find the cast to be
   ugly, but they are simply safer as the compiler can do some type checking on
   them.
 - Unecessary lifetime parameters

Reviewed By: quark-zju

Differential Revision: D20452257

fbshipit-source-id: 94abd8d8cd76ff7af5e0bbfc97c1e106cdd142b0
2020-03-16 14:58:21 -07:00
Xavier Deguillard
82d3c7f544 configparser: address clippy warnings
Summary:
Clippy complains about 3 things:
 - Using raw pointers in a public function that is not declared as unsafe. This
   happens for C exported ones, this feels like a warning, so I haven't changed
   it.
 - Using .map(...).unwrap_or(<default value constructed>). The recommendation
   is to use .unwrap_or_default().
 - Single match instead of if let, the latter makes code much shorter.

Reviewed By: quark-zju

Differential Revision: D20452751

fbshipit-source-id: 8eeff7581c119c651ca41d8117f1f70f15774833
2020-03-16 14:53:45 -07:00
Stefan Filip
1fb5acf242 dag: use IdDagStore in IdDag with type parameter
Summary: Make IdDag storage generic by depending on IdDagStore.

Reviewed By: quark-zju

Differential Revision: D20471712

fbshipit-source-id: 3a2668f301758a3c880db35c9f0db6887ef1dd38
2020-03-16 14:41:41 -07:00
Stefan Filip
236292c0fd dag: add the GetLock trait
Summary: Used to generalize `get_lock` functionality.

Reviewed By: quark-zju

Differential Revision: D20471710

fbshipit-source-id: e44d5b22ecacdb653170ef83914354f521f82dfc
2020-03-16 14:41:40 -07:00
Stefan Filip
66436b4a3c dag: add the IdDagStore trait
Summary: Abstract the storage functionality required by IdDag.

Reviewed By: quark-zju

Differential Revision: D20449122

fbshipit-source-id: fc3c7d7b88d74f7a93670d310be2e680f35e8ce7
2020-03-16 14:41:40 -07:00
Stefan Filip
1239628ef8 dag: move IdDag storage details to the iddagstore module
Summary:
Right now the module has one implementation IndexedLogStore. The name could
be more specific in the context of the crate.

The goal will be to add a trait for storage requirements of IdDag and
make IndexedLogStorage one implementation of that trait.

Reviewed By: quark-zju

Differential Revision: D20446042

fbshipit-source-id: 7576e1cc4ad757c1a2c00322936cc884838ff710
2020-03-16 14:41:40 -07:00
Jun Wu
1f64b4ec50 nameset: fix LazySet iteration
Summary:
The `next` method forgot to increase the iteration index, causing infinite
iteration.

Reviewed By: ikostia

Differential Revision: D20473206

fbshipit-source-id: 82a95de1b1c12ac4e9e4d328a0adba7145d7b24c
2020-03-16 13:00:35 -07:00
Xavier Deguillard
181981452d build: have make local run on Centos8
Summary:
On Centos8, `python` no longer exist, instead `python2` or `python3` must be
used.

The onetime-setup.py will have to be re-worked a bit too for Centos8
differences.

Reviewed By: quark-zju

Differential Revision: D20284986

fbshipit-source-id: bb1d9c8b211f1e50ce379fcb6bd92d677323935b
2020-03-16 12:54:01 -07:00
Jun Wu
1734cfe169 metalog: allow overridding root using HGFORCEMETALOGROOT
Summary:
Together with `debugmetalogroots`, this allows some kind of "time travel" to
investigate repo states in the past.

Reviewed By: sfilipco

Differential Revision: D20449409

fbshipit-source-id: ed5c134f9e9ee235b24f45c1aa35867a55a71fe5
2020-03-16 10:21:48 -07:00
Jun Wu
d7fd7c15d6 metalog: add debugmetalogroots
Summary: The command lists all metalog roots. It's useful for debugging purpose.

Reviewed By: sfilipco

Differential Revision: D20449408

fbshipit-source-id: 206573b20c7740b6e536bf5d97276175c684959a
2020-03-16 10:21:47 -07:00
Jun Wu
3bf265bcd2 bookmarks: sort bookmarks before writing
Summary:
This makes the content of `bookmarks` stable.
It will make the metalog root IDs stable in tests.

Reviewed By: sfilipco

Differential Revision: D20449410

fbshipit-source-id: 969be63ab231f5865ec62e99398b5318d4257093
2020-03-16 10:21:47 -07:00
Jun Wu
8115053c00 indexedlog: implement xxd-like fmt::Debug for Log
Summary: This makes `hg debugindexedlog dump` more useful.

Reviewed By: sfilipco

Differential Revision: D20448863

fbshipit-source-id: c5cc24449ae00ee329ce02bf0adf947ff57e72ed
2020-03-16 10:21:46 -07:00
Durham Goode
a13fcd4910 workingcopy: support returning directories from the walker
Summary:
Purge needs to be able to see what directories the walker traversed, so
it can delete them if they are empty. Instead of having the walker call
match.traversedir (which it seems like a bizarre pattern to use the matcher as a
holder for a non-matching related function), let's have the walker return an
enum and have an option to return directories.

At the python layer we then translate this into match.traversedir calls, but we
can clean that up later.

Reviewed By: quark-zju

Differential Revision: D19543795

fbshipit-source-id: cc51c86c91799d3df2c65d25a7b6cfe810206d0a
2020-03-16 10:15:26 -07:00
Durham Goode
fc7739fa26 workingcopy: rename walker results
Summary:
In preparation for supporting returning directories from the walker (to
support purge), let's rename the result structure to be more generic.

Reviewed By: kulshrax

Differential Revision: D19543791

fbshipit-source-id: 9b71452c879cf397ae92533a4ef4727140ac7369
2020-03-16 10:15:26 -07:00
Durham Goode
01285a9d4a workingcopy: handle file normalization for rust walker
Summary:
On case insensitive systems we need to normalize file case. I've made a
rust case normalizer, but it requires some more tweaks. In the mean time, let's
handle this at the matching and output stages of the rust walk.

This is probably the pattern we want to follow later anyway, so the walk is
completely decoupled from normalization.

Reviewed By: kulshrax

Differential Revision: D19543797

fbshipit-source-id: 2ef8bdcecb2611a08680441fc030c64c2f4097d1
2020-03-16 10:15:25 -07:00
Durham Goode
27d1ebe9ba workingcopy: support ignore files from rust walker
Summary:
Previously it didn't handle ignoring ignored files. Let's support this
via simple matcher composition.

Reviewed By: kulshrax

Differential Revision: D19543792

fbshipit-source-id: 0c807f3c1ffc10894f13373cbe9deb2b824f1ac9
2020-03-16 10:15:25 -07:00
Durham Goode
05e09b2b89 workingcopy: report invalid file types from rust walker
Summary:
The mercurial tests print errors when they encounter 'fifo' files.
Let's handle that case.

Differential Revision: D19543796

fbshipit-source-id: f87d4b9c3f0ad8b8d8ebe2e6d18e325fc93d0ae9
2020-03-16 10:15:25 -07:00
Durham Goode
1b892e1d50 tests: don't test \1 character in hgsql tests
Summary:
\1 is not a valid character in our new RepoPath's, so let's remove it
from the tests.

Reviewed By: quark-zju

Differential Revision: D19543793

fbshipit-source-id: 383a4b3f5c54b47180fe667f234a43eda22f91b6
2020-03-16 10:15:24 -07:00
Xavier Deguillard
0fa09ddc5d gen_version.py: run it with python3
Summary: On Centos8, python no longer exist.

Reviewed By: quark-zju

Differential Revision: D20452244

fbshipit-source-id: 07dd0256c1dc227eb9259954951184d282f5c272
2020-03-13 20:08:34 -07:00
Xavier Deguillard
fc51908dba pyworker: empty flags are valid
Summary: Empty flags can be sent by Mercurial, do not error out in that case.

Reviewed By: quark-zju

Differential Revision: D20450124

fbshipit-source-id: c85af42be2afb95b09057583f6fec3a2a13d478a
2020-03-13 19:41:48 -07:00
Xavier Deguillard
a07c1b6e77 remotefilelog: pass the right config object to Rust
Summary: Fallout from D20432938.

Reviewed By: quark-zju

Differential Revision: D20449456

fbshipit-source-id: a7c3d7f6b9b2fec57b83e5ae3e789c722a45ca39
2020-03-13 19:41:48 -07:00
Xavier Deguillard
185478d122 pyworker: stabilize quickcheck tests
Summary:
In some rare cases, quickcheck may give us 2 identical paths with different
Key, Mercurial will never do that, therefore reject this.

Reviewed By: quark-zju

Differential Revision: D20451344

fbshipit-source-id: 800b31f1aeea38322052baedb918c4f45a1ec95d
2020-03-13 19:37:09 -07:00
Xavier Deguillard
fd8d92f1f5 revisionstore: allow indexing LFS pointers via sha256
Summary:
While the sha256 of a blob gives access to its content, it doesn't allow
accessing its metadata, by adding a sha256 index, we can easily get the
metadata of a blob via its content hash.

Reviewed By: quark-zju

Differential Revision: D20445624

fbshipit-source-id: 42c04bd69d3c7380706c6237c5b4f4061c016cca
2020-03-13 19:03:29 -07:00
Xavier Deguillard
d9cca63444 types: add a into_inner method to Sha256
Reviewed By: quark-zju

Differential Revision: D20445623

fbshipit-source-id: d9cba7ddd16a8e89c76cd5e988ab0fb79383d0c2
2020-03-13 19:03:29 -07:00
Xavier Deguillard
60be0ac94d types: fix typo when displaying Sha256
Reviewed By: quark-zju

Differential Revision: D20445622

fbshipit-source-id: dc9a8a165ca55fdece90a5eb3a87cd3c28f444cb
2020-03-13 19:03:29 -07:00
Xavier Deguillard
6ee3a8f42f revisionstore: add metadata to FakeHgIdRemoteStore
Summary: This is necessary to properly test LFS stores.

Reviewed By: quark-zju

Differential Revision: D20445625

fbshipit-source-id: 530ddf87249e8d721957806f2d8edef3262f303c
2020-03-13 19:03:28 -07:00
Xavier Deguillard
5002d01e0a revisionstore: allow indexedlogutil users to lookup in different indices
Summary:
The OpenOptions allow for multiple indices to be added, but lookup had no way
to querying these multiple indices.

Reviewed By: quark-zju

Differential Revision: D20445627

fbshipit-source-id: 0cb754ba17b452d892b7bcb56d502d5753ef963a
2020-03-13 19:03:28 -07:00
Xavier Deguillard
01fb3c0a77 revisionstore: add a new StoreKey type
Summary:
This type can either be a Mercurial type key, or a content hash based key. Both
the prefetch and get_missing now can handle these properly. This is essential
for stores where data can either be fetched in both ways or when the data is
split in 2. For LFS for instance, it is possible to have the LFS pointer (via
getpackv2), but not the actual blob. In which case get_missing will simply
return the content hash version of the StoreKey, to signify what it actually
has missing.

Reviewed By: quark-zju

Differential Revision: D20445631

fbshipit-source-id: 06282f70214966cc96e805e9891f220b438c91a7
2020-03-13 19:03:28 -07:00
Xavier Deguillard
d900874401 revisionstore: rename HistoryStore to HgIdHistoryStore
Summary:
Similarly to the DataStore trait, this makes it easier to understand that they
deal with a Mercurial type Key.

Reviewed By: quark-zju

Differential Revision: D20445621

fbshipit-source-id: a1143d5f5d6a2c8686d517a6ea3c25b07c0df072
2020-03-13 19:03:27 -07:00
Xavier Deguillard
2e4742cefc revisionstore: rename DataStore traits to HgIdDataStore
Summary: This makes it clear that these traits are dealing with Mercurial Key.

Reviewed By: quark-zju

Differential Revision: D20445626

fbshipit-source-id: d5acbf442e9407b973e95e40af69b5a61bff0a4d
2020-03-13 19:03:27 -07:00
Xavier Deguillard
eaf2f2e9f0 tinit: fix a typo in newserver
Summary: treemanifest was misspelled.

Reviewed By: quark-zju

Differential Revision: D20449488

fbshipit-source-id: 91a3e6533d177083af5c46c09ad09b1a51d8ece5
2020-03-13 17:36:50 -07:00
Jun Wu
cf04fe3e1f thrift-types: recompile Thrift sources
Summary: The thrift compiler and sources are changed.

Reviewed By: xavierd

Differential Revision: D20445164

fbshipit-source-id: f20f16ae02a922042f366a9a80a3642577f60e57
2020-03-13 14:25:23 -07:00
Durham Goode
ae5fc6afde hggit: don't write flat map when using indexedlog
Summary:
The flat git map file can be huge and writing to it can hang for many
seconds or minutes on loaded systems since it calls fsync. Since we actually
rely on the indexedlog map file instead of the flat map, let's just stop writing
the flat map when indexedlog is enabled. This was previously done to enable
falling back, but we've had no issues and never needed to fallback.

Reviewed By: quark-zju

Differential Revision: D20443392

fbshipit-source-id: a3e7dbdb2b37e2e99df774f540b05d06414fb279
2020-03-13 12:11:18 -07:00
Jun Wu
f6f5649b46 test-configparser: migrate to Python unit test
Summary:
This makes the test compatible with Python 2, 3 and Windows.
It also looks easier to read.

Reviewed By: xavierd

Differential Revision: D20444919

fbshipit-source-id: c897e9abc8a5d6d98ff1fc526e2484720fb73bb1
2020-03-13 12:01:00 -07:00
Jun Wu
7a7f98f1b2 configparser: migrate from Bytes to Text
Summary:
Since configparser enforces utf-8 config files (because pest wants Rust strings),
let's migrate from Bytes to Text to remove extra encoding conversions.

Previously this was blocked by the lack of ref-counted text (since the "source"
of each config location is the entire config file). Now minibytes provides Text
so we can use it.

This unfortunately requires dependent code to be updated. The pyconfigparser
interface is in theory wrong - it shouldn't return utf-8 bytes but
local-encoded bytes. I think it's cleaner to make pyconfigparser unaware of
HGENCODING, so I changed pyconfigparser to use unicode, and add compatibility
layer in uiconfig.py.

This also fixes non-ascii encoding issues on user name (especially on Windows).
The hgrc config file should be in utf-8 and the config parser returns explicit
unicode types, and Python code round-trip them with local encodings.

Reviewed By: markbt

Differential Revision: D20432938

fbshipit-source-id: b1359429b8f1c133ab2d6b2deea6048377dfeca1
2020-03-13 10:51:41 -07:00
Jun Wu
715bc5d451 configparser: migrate from bytes to minibytes
Summary:
This makes it easier to further migrate to `Text` interface.
Dependent crate (`auth`) is updated.

Reviewed By: markbt

Differential Revision: D20432941

fbshipit-source-id: 1dc29d52c9b17ce14676ef0555470c6d36a09c2b
2020-03-13 10:51:41 -07:00
Jun Wu
c4ec99ded4 minibytes: implement Text
Summary:
Text is a reference-counted shared String.
It's similar to Bytes but works for utf-8 strings.

The motivation is to replace configparser's use of Bytes to Text.

Reviewed By: markbt

Differential Revision: D20432940

fbshipit-source-id: ef990255d269e60d433c6520819f60ccdcbe488f
2020-03-13 10:51:41 -07:00
Jun Wu
7895e70dcf minibytes: make Bytes abstract
Summary: This makes it possible to implement "Text". See the next diff.

Reviewed By: markbt

Differential Revision: D20432943

fbshipit-source-id: 94b3810ab205c260d33f57bd637e4accc3ee871d
2020-03-13 10:51:40 -07:00
Jun Wu
e9b14b3608 minibytes: implement From<&'static {str,[u8]}>
Summary:
This makes the API easier to use.

Practically this makes it easier for configparser to migrate to minibytes.

Reviewed By: markbt

Differential Revision: D20432942

fbshipit-source-id: ad08eb118d2216054dc24c86b0b129ae82b9d17c
2020-03-13 10:51:40 -07:00
Mark Thomas
98860e0615 rage: use smaller data sizes for debugnetwork tests
Summary:
For users on slow connections, hg debugnetwork may not complete within 20s.
Reduce the amount of data we use for the download and upload tests, so that we
have a better chance for the tests completing within the 20s limit.

Reviewed By: farnz

Differential Revision: D20439271

fbshipit-source-id: b3cb0d7e96673c8052022c7606cca80db1788370
2020-03-13 05:10:13 -07:00
Michael Devine
ce0c0be4b1 Add configuration setting to repo converter for branch whitelist
Summary: At current, there are some specific AOSP branches that are causing problems for the importer. It would be helpful to be able to run convert jobs that only run on a subset of branches for testing. This commit adds a configuration setting for a whitelist that allows us to specify which repo branches we want to convert, and we only convert those branches.

Reviewed By: tchebb

Differential Revision: D18534728

fbshipit-source-id: bf59605d9c6026e26914c4a7cbe9493bdee77ee5
2020-03-12 15:01:31 -07:00
Jun Wu
07e043045c transaction: ensure metalog message is valid utf8
Summary:
The metalog message is just for display purpose so it does not have to be
byte-to-byte accurate.  This solves potential crashes on Python 2 Windows.

    File "c:\Tools\hg\python27.zip\edenscm\mercurial\transaction.py", line 587, in _writemetalog
      " ".join(map(util.shellquote, pycompat.sysargv[1:])), int(util.timer())
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 1: invalid utf-8

The logic will become more "correct" when we migrate to Python 3.

Reported by: markbt

Reviewed By: markbt

Differential Revision: D20422747

fbshipit-source-id: 41123d132a1e545db77d7321099da611668174f4
2020-03-12 14:26:07 -07:00
Jun Wu
0d225e1288 checkmessagehook: drop incorrect utf-8 check
Summary:
hg makes sure commit messages are utf-8. So there is no need to check it.
The check logic is also incorrect if the local encoding is not utf-8:
`ctx.description()` returns local-encoding-encoded bytes, which should not
be treated as utf-8 bytes.

Reviewed By: markbt

Differential Revision: D20424241

fbshipit-source-id: 05480e37335c3f2c7971c28c2e23c115dfc6fba7
2020-03-12 13:52:03 -07:00
Jun Wu
e5ef3a81b2 changelog: do not treat draft remove heads as unconditionally visible
Summary: This makes it possible to hide draft branches using `hg hide`.

Reviewed By: markbt

Differential Revision: D20403505

fbshipit-source-id: d316e02c24ce636fdc6593f95a5d974b1ba0fc85
2020-03-12 13:02:44 -07:00
Mark Thomas
d37a1fe4ff commitcloud: write cloud sync state within the transaction
Summary:
During cloud sync, the `_applycloudchanges` step will pull all the new commits
from commit cloud, and then record that it has updated to the new workspace
version in the cloud sync state.

If the transaction subsequently fails and gets rolled back, we will roll back
the pull (so the new commits vanish) but we will not roll back the recording of
having updated to the new cloud workspace version.

On the *next* cloud sync, commit cloud will think the user has deliberately
hidden all of those missing commits, and remove them from the cloud workspace.

Write the cloud sync state within the transaction, so if the transaction is
rolled back, we also roll back the recording of the new workspace version.

Reviewed By: quark-zju

Differential Revision: D20420240

fbshipit-source-id: f3d201f299e491cbff47fc6b703a4e1af4015b18
2020-03-12 12:58:17 -07:00
Mark Thomas
d4cfd6f918 commitcloud: store cloud sync status in the store vfs
Summary:
Commit cloud sync works at the store granularity, so the status should be
stored in the store vfs.  Move it there.

Improve the output of `hg cloud status` by logging more information about the workspace.

Reviewed By: quark-zju

Differential Revision: D20419223

fbshipit-source-id: 4f0d6b9aab55d2bbeaf89b489606f0bc25400de5
2020-03-12 12:58:17 -07:00
Jun Wu
6908bc874c pytracing: support basic filtering in treespans
Summary:
Expose the "TreeSpans" type from tracing-collector so filtering can be done on
them.

Reviewed By: DurhamG

Differential Revision: D19797707

fbshipit-source-id: 56b63c8fb79865666ce923612dbd5a9cc512dce6
2020-03-12 12:19:39 -07:00
Jun Wu
ad8190713b cpython-ext: serialize Rust str into Python str type
Summary:
Previously Rust str was serialized into bytes. To be Python 3 friendly, let's
serialize it into `str`.

Reviewed By: markbt

Differential Revision: D19797706

fbshipit-source-id: 388eb044dc7e25cdc438f0c3d6fa5a5740f22e3d
2020-03-12 12:19:38 -07:00
Jun Wu
3376363721 tracing-collector: add is_event to TreeSpan
Summary: Expose the is_event property via public APIs.

Reviewed By: DurhamG

Differential Revision: D19797705

fbshipit-source-id: f441825e98208964f7b3d6815a177b464430cbb7
2020-03-12 12:19:38 -07:00
Jun Wu
32d3077147 windows: use getfstype from bindings.fs
Summary: A left over of D20313385.

Reviewed By: xavierd

Differential Revision: D20423035

fbshipit-source-id: 0dc5aae3660725ada8e1b311bb82e6429b001289
2020-03-12 10:16:15 -07:00
Arun Kulshreshtha
5c023bb37d treemanifest: add BFS fetching over SSH
Summary:
This diff adds client-side support for the new `designatednodes` mode of the `gettreepack` wireproto command (implemented in D20307442), which allows fetching an exact set of specified tree nodes. This enables the performance benefits of BFS tree fetching over SSH (whereas this sort of fetching was previously only possible over HTTPS via EdenAPI).

To allow us to smoothly control the rollout of this feature, it is gated behind the `treemanifest.ondemandfetch` config option. In theory, this should not be needed since the client will check that the server supports `designatednodes` before attempting to do on-demand fetching, but if users report issues it's nice to have a killswitch.

Reviewed By: quark-zju

Differential Revision: D20382825

fbshipit-source-id: f9aef3fdae08ae84a9720deead3549fe2fba0b9b
2020-03-12 09:59:47 -07:00
Thomas Orozco
472362fd6c treemanifest: comma-terminate directories list in gettreepack
Summary:
We cannot differentiate an empty list from a list containing the empty path only. This fixes that.

See D20309700 earlier in this stack for the server-side bits.

Reviewed By: quark-zju

Differential Revision: D20309699

fbshipit-source-id: 02efc747c3c5e2774f949ba0a6370169b55f3cf3
2020-03-12 06:35:34 -07:00
Stanislau Hlebik
ba871d3bdc xdiff: allow rendering diff for large files
Summary:
The goal of the stack is to support "rendering" diffs for large files in scs
server. Note that rendering is in quotes - we are fine with just showing a
placeholder like "Binary file ... differs". This is still better than the
current behaviour which just return an error.

In order to do that I suggest to tweak xdiff library to accept FileContentType
which can be either Normal(...) meaning that we have file content available, or
Omitted, which usually means the file is large and we don't even want to fetch it, and we
just want xdiff to generate a placeholder.

Reviewed By: markbt, krallin

Differential Revision: D20389226

fbshipit-source-id: 0b776d4f143e2ac657d664aa9911f6de8ccfea37
2020-03-12 04:27:23 -07:00
Kostia Balytskyi
30e39de418 edenscm: add a separate path type for infinitepush writes
Summary:
In order to support gradual rollout of infinitepush for other backends (e.g. Mononoke), we need the ability to route read vs write requests separately. To achieve this, we need a separate path type: `infinitepush-write` (kind of like `default-push`, the naming inconsistency is a little unfortunate, as I don't want to use `infinitepush-push`).

The desired behavior of the new path type is as follows:
- takes precedence over `infinitepush` path when the user does `hg push -r . --to scratch/bla`
- replaces `infinitepush` path when the user does `hg push infinitepush -r . --to scratch/bla`
- absence of this path means draft pushes will go to `infinitepush` path
- draft pulls always go to `infinitepush` path, and *there's no fallback to `infinitepush-write`*
- commit cloud always talks to `infinitepush-write`, if it is present (meaning that commit cloud pulls do go to `infinitepush-write` path
  - this is done, as commitcloud uses infinitepush paths to also check whether something is backed up
  - and also, commitcloud may need to pull very soon after something has been pushed

Reviewed By: quark-zju

Differential Revision: D20368158

fbshipit-source-id: 59db174cebbf2b48765dff37bc93aad176c2d7c1
2020-03-12 03:22:12 -07:00
Jun Wu
5fd51a48d2 changelog: extract some logic to methods
Summary: Those functions are reused in in a future diff.

Reviewed By: sfilipco

Differential Revision: D20367838

fbshipit-source-id: 944babf8c02f0560f8ac8ca5d7c4263432032715
2020-03-11 20:37:30 -07:00
Jun Wu
ffacd3a857 pydag: add new APIs
Summary: Expose the newly added APIs to Python.

Reviewed By: sfilipco

Differential Revision: D20367839

fbshipit-source-id: 856365513e0ff2010a8776c64ce6198d02953dc8
2020-03-11 20:37:30 -07:00
Jun Wu
194b38385a nameset: add a way to convert between NameSet and SpanSet
Summary:
This will be used in the Python world for legacy reasons. It shouldn't be used
in new Rust node.

To use it, the name `LegacyCodeNeedIdAccess` has to be used so we can do a code
search to find all users of it.

Reviewed By: sfilipco

Differential Revision: D20367834

fbshipit-source-id: 9b93a29f1461ce24bba6f31a2bbb1f327e216c6d
2020-03-11 20:37:30 -07:00
Jun Wu
eef56d9c5b namedag: add a sort API
Summary: This will be useful to actually sort commits.

Reviewed By: sfilipco

Differential Revision: D20367835

fbshipit-source-id: 43bc7835277af3a14ef323ce34247e0c03878dc8
2020-03-11 20:37:29 -07:00
Jun Wu
2ecc0bb757 namedag: move "all" concept to DagSet
Summary:
The old "AllSet" implementation is not very practical - it does not support
iteration. Practically, the "all()" set comes from the DAG. Change the "all"
concept to a hint similar to "is_topo_sorted", and update the fast path
(intersection) accordingly.

Reviewed By: sfilipco

Differential Revision: D20367837

fbshipit-source-id: fdbf370897c93058bfcab0571c1f6fa4b99b0f6b
2020-03-11 20:37:29 -07:00
Jun Wu
ef1696b4db namedag: rename arc_map to snapshot_map
Summary: The word "snapshot" more accurately describes its purpose.

Reviewed By: sfilipco

Differential Revision: D20367836

fbshipit-source-id: c91a0bd402fa1718b5d805beedc0e062824c53d3
2020-03-11 20:37:29 -07:00
Adam Simpkins
03873d9870 suppress exceptions that occur in sparse telemetry tracking
Summary:
The `sparse` extension's dirstate tracking code attempts to read dirstate data
after the command has executed.  For commands that didn't require accessing
the dirstate, this can end up reading it for the first time, and can this fail
in some circumstances.  Ignore all errors that occur when trying to compute
this telemetry, so they don't break the main command functionality.

In particular, we see reproducible scenarios where `hg` crashes due to this
error when invoked by watchman to compute the list of files changed between
two commits.  Watchman currently always invokes Mercurial with `HG_PENDING`
enabled, and this can cause dirstate loading to fail when there is pending
data.

Reviewed By: quark-zju

Differential Revision: D20402221

fbshipit-source-id: 782d9b6eff26d50ef20f080c0cbcbc852e425146
2020-03-11 18:34:09 -07:00
Jun Wu
a7dedfdfd6 fsinfo: remove old getfstype implementation
Summary: Remove the old Python, C implementation of getfstype.

Reviewed By: xavierd

Differential Revision: D20313385

fbshipit-source-id: 475c73343aae2fa2f5ad898c7b0879bfa2c80e93
2020-03-11 17:35:41 -07:00
Jun Wu
c5c75c9f59 fsinfo: autocorrect "" to "."
Summary:
Without this:

  In [3]: util.getfstype('')
  IOError: [Errno 2] No such file or directory (os error 2)

And there is a code path hitting this:

  File "edenscm/mercurial/util.py", line 1483, in checknlink
    fstype = getfstype(os.path.dirname(testfile))
		# testfile = '.'
	  # os.path.dirname(".") = ""

The old implementation works fine for an empty path:

	In [2]: m.util.getfstype('')
  Out[2]: 'eden'

So let's make the new Rust implementation consistent.

Reviewed By: xavierd

Differential Revision: D20313387

fbshipit-source-id: 258c424a3e8a796d983e20b0d4656e8e3f413706
2020-03-11 17:35:40 -07:00
Jun Wu
ea59a506f1 fsinfo: expose fstype via bindings.fs.fstype
Summary: Expose the Rust fstype implementation so we can remove C and Python code.

Reviewed By: xavierd

Differential Revision: D20313390

fbshipit-source-id: 931b4f6bc8c4b81f30bfea06d055fae3c677eedd
2020-03-11 17:35:40 -07:00
Jun Wu
61bebcaacc fsinfo: try harder to get fuse fs type
Summary: Similar to D13982877. Try to get names like "fuse.ntfs".

Reviewed By: farnz

Differential Revision: D20313392

fbshipit-source-id: 8363d3d92843e6afb53a0003950be083034bd841
2020-03-11 17:35:39 -07:00
Jun Wu
13374f9d74 fsinfo: drop most type parameters
Summary:
Only keep type parameters at the top-level function.
This reduces the binary size and speeds up rustc.

Reviewed By: xavierd

Differential Revision: D20313388

fbshipit-source-id: 29d77731ff462fee1f1bb9f234601e3430198ae7
2020-03-11 17:35:39 -07:00
Jun Wu
c83006002c fsinfo: return unknown on unsupported platforms
Summary: This makes the code a bit more portable.

Reviewed By: xavierd

Differential Revision: D20313389

fbshipit-source-id: 080538939fa4d2d72e5905f23ad9be987d952748
2020-03-11 17:35:38 -07:00
Jun Wu
9cdc818915 fsinfo: drop "repo" from method names
Summary:
Rename the main method to "fstype". The API has no relation with repo.
So let's rename it.

Reviewed By: xavierd

Differential Revision: D20313386

fbshipit-source-id: 80dd1231ccccfe945150b117b151bce773f0dfeb
2020-03-11 17:35:38 -07:00
Jun Wu
951c8ab082 fsinfo: backport from telemetry
Summary: The fsinfo crate provides the "filesystem type" information.

Reviewed By: xavierd

Differential Revision: D20313391

fbshipit-source-id: f717f5edb32957d59d03090117cfdb8123f03933
2020-03-11 17:35:37 -07:00
Xavier Deguillard
dafc8a15f6 pyworker: reduce flakiness of the quickcheck tests
Summary:
Thes test proved to be a bit flaky due to some invalid input from quickeck,
let's filter these cases and ask quickcheck for different input.

Reviewed By: quark-zju

Differential Revision: D20397604

fbshipit-source-id: cc97bef0e286009f1394c7aa2c0429d1e1b1c8c2
2020-03-11 17:17:21 -07:00
Adam Simpkins
55a2324219 skip automigration if the repository has an abandoned transaction
Summary:
A common cause for automigration failure is if the repository has an abandoned
transaction.  Just ignore the error and skip migration if this happens.
Otherwise important read-only commands (like `hg debugedenimporthelper`)
refuse to even start in this situation.

Reviewed By: farnz

Differential Revision: D20394546

fbshipit-source-id: abb75fe455e9ee815032431705df7f38ee50283a
2020-03-11 16:25:50 -07:00
Adam Simpkins
8e78254e55 fix a ProgrammingError bug in visibility migration
Summary:
The code to disable visibility was writing to files without a transaction,
which causes a `ProgrammingError` to be thrown when using metalog.

Reviewed By: farnz

Differential Revision: D20394547

fbshipit-source-id: c529de84ed7b127df18e7f60572cece2169dc520
2020-03-11 16:25:50 -07:00
Adam Simpkins
983a26875d update debugedenimporthelper's debug utilities to use ui.write()
Summary:
Print output using `repo.ui.write()` rather than directly using `print()` or
`sys.stdout`.  This is needed to make the output visible during the
Mercurial `.t` tests.

Reviewed By: farnz

Differential Revision: D20394549

fbshipit-source-id: 7ee50fe26e98c1c34b74ce054d2187050c42b2f3
2020-03-11 16:25:50 -07:00
Adam Simpkins
1c6360fe73 add more annotations for edenscmnative.parsers
Summary:
Add type annotations for the `edenscmnative.parsers` methods that handle
serializing and deserializing the dirstate data.

Reviewed By: quark-zju

Differential Revision: D19958218

fbshipit-source-id: 6e20efbc1b0a6ba15b297e47a1e6eec8ed47ee52
2020-03-11 16:21:30 -07:00
Xavier Deguillard
f466037b4b revisionstore: fix memcache test flakiness
Summary:
Since the mocked memcache is shared between the tests, we need to make sure the
keys used by the tests are different, otherwise they are just caching each
others data.

Reviewed By: ikostia

Differential Revision: D20388783

fbshipit-source-id: 0f2f926e0ffe0e52e55291e46142808ce0921288
2020-03-11 15:58:03 -07:00
Jun Wu
97e9b81ba5 indexedlog: remove compiler warnings on Windows
Summary:
Some `use`s are not used on Windows. The code was also formatted using the
latest rustfmt.

Reviewed By: xavierd

Differential Revision: D20379704

fbshipit-source-id: ffadcd68e4e0440dcbd2a4e1ad8532b47a9d83e2
2020-03-11 15:54:19 -07:00
Xavier Deguillard
c98b9cfff9 revisionstore: remove Arc from MetadataStore
Summary: Similarly to the ContentStore, remove the Arc from MetadataStore.

Reviewed By: quark-zju

Differential Revision: D20376838

fbshipit-source-id: 4321600b752c919b6d9fa7bdee6f6cb7ae083b10
2020-03-11 13:39:06 -07:00
Xavier Deguillard
7e704ec7fb revisionstore: remove the Arc from ContentStore
Summary:
The clients should use an Rc/Arc if they need the ability to clone it. This
makes it more obvious and reduces the number of pointer indirection.

Reviewed By: quark-zju

Differential Revision: D20376839

fbshipit-source-id: c56e7e8f89ab17727be621894c329e344a7f3adb
2020-03-11 13:39:05 -07:00
Pádraig Brady
79be195769 hg: make osutil.c PY_SSIZE_T_CLEAN
Summary:
From https://phab.mercurial-scm.org/D6198
Otherwise platform009 spits lots of dprecation warnings
breaking tests

Reviewed By: simpkins

Differential Revision: D20390703

fbshipit-source-id: c508176a39bdf80580aa2ba29d8c8b0834350815
2020-03-11 13:39:05 -07:00
Mark Thomas
02cb819b35 debugnetwork: prevent 'hostname' output when quiet is set
Summary:
If `ui.quiet` is set, debugnetwork still ends up outputting the output from the
remote `hostname` command.  Prevent this from happening by redirecting the
output to a buffer and logging it separately through `ui.status`.

Reviewed By: quark-zju

Differential Revision: D20384651

fbshipit-source-id: 375687a8e75187a27ef30b441b2ac3a5c0823d00
2020-03-11 11:27:00 -07:00
Mark Thomas
036ab864c2 debugnetwork add --connection and --speed options to limit which tests are run
Summary:
Allow selective running of a subset of the tests by passing options.

* `--connection` runs only the tests for determining connectivity
* `--speed` runs only the speed tests.

Not specifying any option runs all tests.

Reviewed By: quark-zju

Differential Revision: D20384652

fbshipit-source-id: 197e07809bec28ab2ce3fa73cfef6be0fb0fd5b7
2020-03-11 11:26:59 -07:00
Jun Wu
4960709aa3 dag: do not depend on types
Summary:
The dag crate is designed to work with any kind of binary commit hashes (ex. bonsai,
git or hg). The only use of `types` is to convert from binary to hex. Since dag
already has its own `to_hex` logic in `VertexName`. Let's use that instead.

Reviewed By: sfilipco

Differential Revision: D20378447

fbshipit-source-id: 00ecb551ea927fdb60dd91e5e645064f23139bcd
2020-03-11 10:49:31 -07:00
Jun Wu
9bff661020 commands: add debugdifftree
Summary:
This command can be used to diff two trees and only print changed paths,
without changed file contents.

With a customized template it can also print changed flags, which can be useful
for watchman use-cases.

Reviewed By: sfilipco

Differential Revision: D20377436

fbshipit-source-id: dad79f1b891182fa612c446114f9daceb4ec5881
2020-03-11 10:42:21 -07:00
Jun Wu
48a3a695df revset: remove _destupdate and _destmerge
Summary: Those experimental revsets are not used in the past month. Remove them.

Reviewed By: sfilipco

Differential Revision: D20355671

fbshipit-source-id: 22d6053af01a56f23b7227b86ebe271aa2b42f41
2020-03-11 10:42:21 -07:00
Jun Wu
3b3c1d62cb copies: repo.revs -> repo.nodes
Summary: Remove a use-case of revision numbers.

Reviewed By: sfilipco

Differential Revision: D20355670

fbshipit-source-id: d7aebb31dcf4bac9f592956d48f5d84a525394b4
2020-03-11 10:42:20 -07:00
Jun Wu
009ea22175 indexedlog: retry rename in atomic_write on Windows
Summary:
Recently there are some Windows-related test flakiness in . All of them are
caused by `file.persist(path)` in `atomic_write_plain` failing with
"Access Denied". Since that can be caused by Windows Anti-Virus scans or other
weird stuff, let's workaround around it using automatically retires.

Process Explorer does not provide extra information:

    indexedlog-d0c6135fd7ed9ece.exe	5868	SetRenameInformationFile	C:\Users\quark\AppData\Local\Temp\.tmpKERc5G\.tmpcfDsQQ	ACCESS DENIED	ReplaceIfExists: True, FileName: C:\Users\quark\AppData\Local\Temp\.tmpKERc5G\meta

A successful rename looks like:

    indexedlog-d0c6135fd7ed9ece.exe	5868	SetRenameInformationFile	C:\Users\quark\AppData\Local\Temp\.tmpKERc5G\.tmpbXEVw0	SUCCESS	ReplaceIfExists: True, FileName: C:\Users\quark\AppData\Local\Temp\.tmpKERc5G\meta

Reviewed By: ikostia

Differential Revision: D20379618

fbshipit-source-id: db3e6be3d785875486f7a517df11cbf58bf65ddd
2020-03-11 10:06:47 -07:00
Xavier Deguillard
5d230aef68 backingstore: use get_file_content to strip metadata
Summary:
Now that the ContentStore can automatically strip the metadata header, no need
for duplicated code in the backingstore.

Reviewed By: fanzeyi

Differential Revision: D20376812

fbshipit-source-id: e863e1cc2fcdc8b9e612a464b305fa25ceb66e13
2020-03-11 09:40:26 -07:00
Thomas Orozco
52380d76a5 connection pool: log remote path
Summary:
We currently log the server we talk to, which is very nice in order to
benchmark performance of Mononoke vs. hg.

Unfortunately, while this allows for breaking down the samples, it's a little
hard to identify the right samples to break down! Historically, we've
approximated this by looking at the client's hostname, but this isn't always
ideal.

Reviewed By: quark-zju

Differential Revision: D20369686

fbshipit-source-id: 785c67fde09e7b7fc4c30121d14f0bc26e92a355
2020-03-11 02:18:06 -07:00
Xavier Deguillard
99bb41e1f9 pyworker: remove one closure indirection
Summary:
No need for a closure when the function that will be called takes the same
arguments.

Reviewed By: quark-zju

Differential Revision: D20367309

fbshipit-source-id: 986299c4b691330bf17164abd70f3b49ed5263f8
2020-03-11 01:13:56 -07:00
Xavier Deguillard
1276e1c695 pyworker: ignore remove errors on Windows
Summary:
In some situations Windows may be unable to remove a file and Mercurial
cannot do anything about it. Instead of raising an error, just ignore it.

In the Python code, errors are ignored in multiple layers, but ultimately
batchremove ignore all OSError errors and just prints a warning about it. A
future diff will build a side channel for errors/warnings reporting, this will
be used to properly report this.

Reviewed By: quark-zju

Differential Revision: D20284803

fbshipit-source-id: 7df80f9e27e720ce819fb4116ea996fca390ad76
2020-03-11 01:13:55 -07:00
Xavier Deguillard
d1bcb3e604 pyworker: add a basic PathAuditor
Summary:
For now it only checks for symlinks outside of the repo, but can be extended to
check for more.

Caching is used to prevent syscalls to already checked directories, this cache
is intended to be done per-thread, and thus each directory may be checked a
maximum of N, with N being the number of threads. This is deemed reasonable for
now.

Things that the Python pathauditor does that this one doesn't:
 - Case checking for Windows,
 - Verifies no writes to .hg,
 - Windows shortnames aliases,

Reviewed By: quark-zju

Differential Revision: D20265276

fbshipit-source-id: 8e29bedadcaa6df2515e394894ab9e1dd5a9e9a7
2020-03-11 01:13:55 -07:00
Xavier Deguillard
d15b04d438 pyworker: handle symlinks and executable
Summary:
Symlinks are treated a bit differently from plain files, what is stored in the
ContentStore is the destination of the symlink, not it's content (well, the
content of a symlink really is it's destination).

For now, only unix platforms support symlinks, in reality this should be a
filesystem property as writing to ntfs-3g should have the same behavior as on
Windows.

For executable, we just need to mark the file as executable after writing to
it.

Reviewed By: quark-zju

Differential Revision: D20250943

fbshipit-source-id: 022dabc750125df32953a151df7da60db69b2cec
2020-03-11 01:13:55 -07:00
Xavier Deguillard
40bbe7b4da merge: add a Rust threaded file updater
Summary:
During `hg update`, Mercurial forks multiple processes to write files on disk
concurrently, this is done as fetching blobs from the content store, and
writing them to disk is CPU bound. Usually, threads would be the preferred way
of speeding up such process, but unfortunately, Python has GIL that severely
limit the available concurrency. So, multiple processes were chosen.

Unfortunately, the multi-process solution also brings a lot of other issues,
more recently, we've had cases where the connections to the server and memcache
had to be dropped after the fork. In some other cases, this caused deadlocks.
And the solution is not effective on Windows.

Now that Mercurial is getting more and more Rust, we could instead go back to
the threads solution by using them in Rust, and have Python just push work to
them, this is exactly what this change does.

Things that are left to be done, but I wanted to get a diff out first:
 - no file path audit
 - no file backup
 - no symlink creation
 - probably other things I'm missing

Reviewed By: quark-zju

Differential Revision: D20102888

fbshipit-source-id: d47829fd7818b97710586b9851880f178048e27b
2020-03-11 01:13:54 -07:00
Xavier Deguillard
185bc0f437 revisionstore: add an LfsMultiplexer store
Summary:
With this new store, blobs will be transparently written to either an LFS
store, or a non-LFS one, depending on their size.

Initially, and as long as getpackv2 is supported, we also need to support
parsing lfs pointer data that the server is sending and write these to the lfs
pointer store. This code is very adhoc and does manual parsing of the pointer
data, definitively not great, suggestion for a simple and better solution is
welcome :).

From a migration standpoint, the read-only LFS stores are added to the
ContentStore, this allows blobs written in it to be readable at all time even
when `remotefilelog.lfs` isn't set. The code will effecitvely be dormant for a
while until the option is turned on, if we need to disable it, the dormant code
will still be able to read all the blobs written to disk. This forces us to
deploy a release that contains this code to stable first, before setting
`remotefilelog.lfs`.

Reviewed By: quark-zju

Differential Revision: D19986878

fbshipit-source-id: 260f5a542d52e748c0c703bfa7bb8ffac0e7b388
2020-03-10 18:14:54 -07:00
Jun Wu
5f84fc8222 indexedlog: use dev-logger
Summary: This makes `RUST_LOG` work for indexedlog tests.

Reviewed By: xavierd

Differential Revision: D20286515

fbshipit-source-id: ff4a1476eb01a9067dabe3622fd598f65fe86a18
2020-03-10 14:16:39 -07:00
Jun Wu
7a12c33163 dev-logger: a simple library to enable env_logger for testing
Summary:
The tracing / env_logger integration works for hg as a binary. However I'd also
like to use it in library tests. This crate makes it easier to do so.

Reviewed By: xavierd

Differential Revision: D20286507

fbshipit-source-id: f5bf3288ce950591ddfe64b524ad51ce21ee4099
2020-03-10 14:16:38 -07:00
Jun Wu
cf72dc45f5 indexedlog: add some tracing information
Summary: Those has helped me debugging some issues.

Reviewed By: xavierd

Differential Revision: D20286513

fbshipit-source-id: 012ddb16c2d0efd8f8697a5ecd4564ea31d65630
2020-03-10 14:16:38 -07:00
Jun Wu
e7ed737a64 hgcommands: make env_logger show exit code
Summary: Move the scope of spans so the exit code is shown.

Reviewed By: xavierd

Differential Revision: D20286516

fbshipit-source-id: f39cbf60c86ea19a1bb0a09958748f04ff6a42e8
2020-03-10 14:16:37 -07:00
Jun Wu
bb9023c2cb hgcommands: move env_logger initialization to hgcommands
Summary:
Previously env_logger is only initialized if Python is initialized.
This diff makes env_logger initialized for Rust native commands.

Reviewed By: xavierd

Differential Revision: D20286517

fbshipit-source-id: 18fee96c2b41db1da9648d615d1e18809de90a63
2020-03-10 14:16:37 -07:00
Jun Wu
97d0a976fd tracing: make it write to the log eco-system
Summary:
This means crates like env_logger (which reads $RUST_LOG, and writes to stderr)
can be used for convenient debugging.

Reviewed By: xavierd

Differential Revision: D20286514

fbshipit-source-id: e3b80cc4830ba5cc6dbf7aa1cbb92a4f4f046a54
2020-03-10 14:16:37 -07:00
Jun Wu
796f199130 tracing: save static metadata from tracing to Spans
Summary:
Those metadata include module_path, target, line number, etc, in Rust native
format.  They will be used for the upcoming `log` integration.

Reviewed By: xavierd

Differential Revision: D20286510

fbshipit-source-id: 27019b941bef08c0bb3e505bbdae642282dcb141
2020-03-10 14:16:36 -07:00
Mark Thomas
9fc8716e85 debugnetwork: show how long it took to query server master bookmark
Summary:
It might be useful to know how long the end-to-end wireproto command to find
the master bookmark took, so log that.

Reviewed By: quark-zju

Differential Revision: D20344686

fbshipit-source-id: 8459a378a0c828a929eee5f9ffd34875a5b8d3cc
2020-03-10 05:36:23 -07:00
Mark Thomas
ed4d2ae9aa debugnetwork: allow multiple tests within a connection to aid warmup
Summary:
For high latency connections we will need to warm up the connection before
starting the download or upload test.  Facilitate this by making it possible to
run multiple tests within the same connection.

This changes the protocol for the speed-test command to be line-oriented commands.

Reviewed By: farnz

Differential Revision: D20344687

fbshipit-source-id: 1d2a815736caf974ed1aaaaf365b86343d41fe02
2020-03-10 05:36:23 -07:00
Jun Wu
fc911f4c3f sampling: make sure output JSON strings are valid utf-8
Summary:
On Python 2 the Mercurial JSON can be binary, which can break the telemetry
logger. Ensure the JSON string is valid utf-8 (although it might still be
invalid JSON).

Reviewed By: xavierd

Differential Revision: D20343845

fbshipit-source-id: 61e99e742bddf23c7fd5354a5754d79a0a452c28
2020-03-09 14:24:29 -07:00
Stefan Filip
d8b4ddcecf dag: split lock file acquisition to own function
Summary:
Spliting lock file acquisition from `IdDag::prepare_filesystem_sync` to its own
function.
Useful when looking ahead to split IdDag from IndexedLog.

Reviewed By: quark-zju

Differential Revision: D20316443

fbshipit-source-id: a0fd43439730376920706bb4349ce497f6624335
2020-03-09 10:18:07 -07:00
Stefan Filip
620cdd96f2 dag: add IdDag::iter_segments_with_parent
Summary:
This removes an inline use of the indexedlog indexes.
This is going to be useful when we try to separate IndexedLog specifics from
IdDag functionality.

Reviewed By: quark-zju

Differential Revision: D20316058

fbshipit-source-id: 942a0a71660bb327376c81fd3ac435d002ecca6e
2020-03-09 10:18:07 -07:00
Mark Thomas
1017318ecf rage: add debugnetwork
Summary:
Add `hg debugnetwork` to the things that `hg rage` collects.

Some of the output from `hg debugnetwork` comes from the peer connection, which is not captured when using `ui.pushbuffer`, as it is written using the remote ui object created when the peer connection is set up.

To handle this, add `ui._outputui` as a way to redirect ui output to another ui object, and use this to redirect the output from the remoteui to the local ui object which is buffering output for hg rage.

Reviewed By: quark-zju

Differential Revision: D20307725

fbshipit-source-id: 3b79a77a39c6e2c5f8a7d5cc271ec466653d4db3
2020-03-09 08:59:13 -07:00
Mark Thomas
f54c43c22f debugnetwork: add command for debugging network connection problems
Summary:
Add a command that performs various network tests to check the connection to
the Mercurial server for SSH peers.

These tests are:

* Check we can look up the server name in DNS.
* Check we can make a TCP connection to the SSH server.
* Check we can connect and authenticate over SSH and run `hostname`.
* Check we can make a Mercurial wireproto connection and find the `master` bookmark.
* Check the download and upload speed to the server.

Checking the speed requires a companion speed test program on the server.

Reviewed By: mitrandir77, farnz

Differential Revision: D20305227

fbshipit-source-id: adba02a6a1c40ffc20d7bf9d962a5fcf85e06544
2020-03-06 12:27:49 -08:00
generatedunixname89002005307016
4257f52a23 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: pradeep90

Differential Revision: D20290816

fbshipit-source-id: 210d6944c32314ca6dc0c295aa95d6fbdde04ecc
2020-03-06 12:14:56 -08:00
Kuba Zika
6a25dbee81 Simplify error pattern matching
Summary:
Instead of returning `anyhow::Error` wrapping an `ErrorKind` enum
from each Thrift client method, just return an error type specific
to that method. This will make error handling simpler and less
error-prone by removing the need to downcast the returned error.

This diff also removes the `ErrorKind` enums so that we can be sure
that there are no leftover places trying to downcast to them.

(Note: this ignores all push blocking failures!)

Reviewed By: dtolnay

Differential Revision: D20260398

fbshipit-source-id: f0dd96a7b83dd49f6b30948660456539012f82e6
2020-03-06 12:09:38 -08:00
Xavier Deguillard
bfae923336 changelog: the _delaybuf is a byte list
Summary: Make a bytestring with 'b""' to fix Python3

Reviewed By: DurhamG

Differential Revision: D20287313

fbshipit-source-id: 7455d1509684bfb0857a3b060bdcca7e658343fd
2020-03-06 10:29:33 -08:00
Xavier Deguillard
2a47ead18d debug: fix _quasirepr
Summary: Just remove the b.

Reviewed By: DurhamG

Differential Revision: D20286947

fbshipit-source-id: dabdf39fc7f8efa271059e9f179d7417a03f820a
2020-03-06 10:29:32 -08:00
Xavier Deguillard
36ff5d6a7d remotenames: fix expaths
Summary: We need to encode/decode utf8 when reading/writing to the hgrc file.

Reviewed By: DurhamG

Differential Revision: D20286068

fbshipit-source-id: b1d6828fb62a83ad22414de6883004411f302142
2020-03-06 10:29:32 -08:00
Xavier Deguillard
e19f3b97ff extensions: base64.decodestring is deprecated
Summary: Use the recommended base64.b64decode instead.

Reviewed By: quark-zju

Differential Revision: D20297574

fbshipit-source-id: 9d78bc5938ae1888d1d57377e376e6775c1c87d5
2020-03-06 10:29:31 -08:00
Stanislau Hlebik
9df1cc0028 remotefilelog: prefetch files in chunks
Summary:
We saw >10 timeouts on Mononoke side from people who fetch a lot of files from corp network (https://fburl.com/scuba/mononoke_test_perf/qd15c5f1). They all tried to download a lot of files, and they 90 mins timeout limit.

Let's try to download these files in rather large chunks (e.g. 200000 files). That should help with resumability and prevent timeout errors, and make retries smaller.

It adds an overhead for establishing a new connection after every 200000 files. That shouldn't be a big problem, and even if it's a big problem we can just increase remotefilelog.prefetchchunksize.

Reviewed By: xavierd

Differential Revision: D20286499

fbshipit-source-id: 316c2e07a0856731629447627ae65c094c6eecc5
2020-03-06 10:06:06 -08:00
Xavier Deguillard
b43f9b8d14 remotefilelog: retry fetches on dropped connections
Summary:
On bad network link (such as on VPN), the reliability of the connection to
Mercurial might be fairly flaky. Instead of failing fetching files, let's retry
a bit first, in the hope that the connection will be back by then.

Reviewed By: quark-zju

Differential Revision: D20295255

fbshipit-source-id: d3038f5e4718b521ae4c3f2844f869a04ebb25e3
2020-03-06 08:32:16 -08:00
Jun Wu
3103fcf62b indexedlog: reload content after obtaining a lock at open time
Summary:
The old code does "read, lock, write", which is unsound because after "lock"
the data just read can be outdated and needs a reload.

Reviewed By: xavierd

Differential Revision: D20306137

fbshipit-source-id: a1c29d5078b2d47ee95cf00db8c1fcbe3447cccf
2020-03-06 08:12:02 -08:00
Durham Goode
a7e62ec3de hggit: add ability to skip commits using hggit.skipgithashes
Summary:
We've had cases where a git commit goes in that shouldn't be translated
to Mercurial. Let's add an option to skip the commit. Instead of skipping it
entirely (which would require complicated logic to then parent the following
commit on the last converted commit), let's just convert the skipped commit as
an empty commit. This should cover the cases we've encountered so far.

Reviewed By: krallin

Differential Revision: D20261743

fbshipit-source-id: da401863b09c2ac727aae1ceef10a0e8d8f98a7e
2020-03-05 15:06:30 -08:00
Jun Wu
75e4ffc17f indexedlog: change IndexDef.lag_threshold back from entries to bytes
Summary:
I thought the index function could be the bottleneck. However, the Log reading
(xxhash, decoding vlqs) can be much slower for very long entries. Therefore
using bytes as the lag threshold is better. It does leaked the Log
implementation details (how it encodes an entry) to some extend, though.

Reverts D20042045 and D20043116 logically. The lagging calculation is using
the new Index::get_original_meta API, which is easier to verify correctness
(In fact, it seems the old code is wrong - it might skip Index flushes if
sync() is called multiple times without flushing).

This should mitigate an issue where a huge entry (generated by `hg trace`) in
blackbox does not get indexed in time and cause performance regressions.

Reviewed By: DurhamG

Differential Revision: D20286508

fbshipit-source-id: 7cd694b58b95537490047fb1834c16b30d102f18
2020-03-05 13:29:48 -08:00
Jun Wu
efff6f3592 indexedlog: add an API to get the Index meta that is not dirty
Summary: This will be used to more reliably detect index lags.

Reviewed By: DurhamG

Differential Revision: D20286518

fbshipit-source-id: c553b6587363a55603b75df12580588e3100e35f
2020-03-05 13:29:47 -08:00
Jun Wu
66e60bacb9 rotatelog: build indexes for older logs on access
Summary:
This ensures indexes are complete even if index format or definition has been
changed.

Reviewed By: DurhamG

Differential Revision: D20286509

fbshipit-source-id: fcc4ebc616a4501e4b6fd2f1a9826f54f40b99b8
2020-03-05 13:29:47 -08:00
Jun Wu
669c58bd56 blackbox: use RotateLog::iter_dirty()
Summary:
This avoids loading all blackbox logs when `init()` gets called multiple times
(for example, once in Rust and once in Python).

Reviewed By: DurhamG

Differential Revision: D20286511

fbshipit-source-id: ef985e454782b787feac90a6249651a882b6552e
2020-03-05 13:29:47 -08:00
Jun Wu
1c6310b9d6 rotatelog: add iter_dirty() API
Summary: This API has the benefit that it does not trigger loading older logs.

Reviewed By: DurhamG

Differential Revision: D20286512

fbshipit-source-id: 426421691ad1130cdbb2305612d76f18c9f8798c
2020-03-05 13:29:46 -08:00
Jun Wu
64ba669a51 nameset: add some tests for DagSet
Summary:
With the new crate-public interfaces and Debug implementations it's possible to
write tests for DagSet. So let's do it.

Reviewed By: sfilipco

Differential Revision: D20242561

fbshipit-source-id: 180e04d9535f79471c79c4307f6ab6e8e8815067
2020-03-05 11:46:18 -08:00
Jun Wu
3e80ba4f99 repo: skip data migrations if repo lock cannot be taken
Summary: This avoids deadlock with edenfs-triggered debugimporthelper.

Reviewed By: simpkins

Differential Revision: D20270678

fbshipit-source-id: 6d3e7664b375d10ad2a8caeecaef5fa895264472
2020-03-05 11:42:19 -08:00
Xavier Deguillard
ef70d9eb08 scratch: silence warnings
Summary: The compiler was complaining about these on Windows.

Reviewed By: quark-zju

Differential Revision: D20250719

fbshipit-source-id: 89405e155875a4a549b243e93ce63cf3f53b1fab
2020-03-05 09:35:58 -08:00
Xavier Deguillard
34bce8690f revisionstore: silence compiler warning
Summary:
Don't restrict constructing a c_api datapack store to only Unix, we can
construct it on Windows too by assuming that their path will be valid UTF-8.

Reviewed By: quark-zju

Differential Revision: D20250718

fbshipit-source-id: 07234b6a71b50c803cfe3b962fa727f57037c919
2020-03-05 09:35:57 -08:00
Xavier Deguillard
751fc53638 types: add an ancestors method to RepoPath
Summary: This returns the ancestors in the reverser order as the parents method.

Reviewed By: sfilipco

Differential Revision: D20265277

fbshipit-source-id: 83277cee3d8e9070fc56d20d4c1877e6782c22f7
2020-03-05 09:31:32 -08:00
Jun Wu
7c9e74aa09 pytracing: make ascii() return bytes on Python 2
Summary: Do not leak unicode to Python 2.

Reviewed By: simpkins

Differential Revision: D20269851

fbshipit-source-id: ebd1b0678b1335a951c9655210601dd80842336e
2020-03-05 07:35:26 -08:00
Durham Goode
e2ff8d5da2 infinitepush: remove transaction that spans pull
Summary:
D18538145 introduced a transaction that spans the entire infintepush
pull. This has a couple of unfortunate consequences:

1. hg pull --rebase now aborts the entire pull if the rebase hits a conflict,
since it's unable to commit the transaction.
2. If tree prefetching fails, it aborts the entire pull as well.

Tests seem to work fine if we scope down this lock.

Reviewed By: xavierd

Differential Revision: D20260480

fbshipit-source-id: d84228ababdb5572401645f74e78df035bf1461b
2020-03-04 19:49:26 -08:00
Jun Wu
bb1562604a dag: make some test APIs public in crate
Summary: Those will be reused by nameset::DagSet.

Reviewed By: sfilipco

Differential Revision: D20242563

fbshipit-source-id: 944e9a04aeb15439256ecea64355b67e326e5c89
2020-03-04 17:33:25 -08:00
Jun Wu
b8e1477401 nameset: impl Debug for other sets
Summary:
This is useful for `assert_eq!(format!("{:?}", set), "...")` tests.

It will be eventually exposed to Python as `__repr__`, similar to Python's
smartsets.

Reviewed By: sfilipco

Differential Revision: D20242562

fbshipit-source-id: 5373bb180db7cafebf273ace7cf2cb80fbfb8038
2020-03-04 17:33:25 -08:00
Jun Wu
fa069204e3 nameset: impl Debug for StaticSet
Summary:
In the Python world all smartsets have some kind of "debug" information. Let's
do something similar in Rust.

Related code is updated so the test is more readable.

Reviewed By: sfilipco

Differential Revision: D20242564

fbshipit-source-id: 7439c93d82d5d037c7167818f4e1125c5a1e513e
2020-03-04 17:33:24 -08:00
Jun Wu
0ae5a59e9e indexedlog: fix metadata-only updates for Indexes
Summary:
Previously, `flush()` will skip writing the file if there are only metadata
changes. Fix it by detecting metadata changes.

This can potentially fix an issue that certain blackbox indexes are empty,
lagging and require scanning the whole log again and again. In that case,
the index itself is not changed (the root radix entry is not changed), but
only the metadata tracking how many bytes in Log the index covered
changed.

Reviewed By: sfilipco

Differential Revision: D20264627

fbshipit-source-id: 7ee48454a92b5786b847d8b1d738cc38183f7a32
2020-03-04 15:59:12 -08:00
Jun Wu
33d65ac5eb test-doctor: fix test on filesystems without symlink
Summary:
On filesystems without symlinks, the test fails because ln prints errors.

Fix the test by using `#if symlink`.

Reviewed By: DurhamG

Differential Revision: D20260904

fbshipit-source-id: 1d0ffcc7e95d2718087fb01297369ca276b59013
2020-03-04 15:52:53 -08:00
Mark Thomas
8c6f30a688 renderdag: add auto-detection of best lines renderer
Summary:
The `lines` renderer doesn't work if the output encoding doesn't support the
curved line drawing characters.  In this case we should fall back to
`lines-square`.

Rename `lines` to `lines-curved`, and change `lines` to pick the best renderer
to use based on what is possible with the current output encoding.

Reviewed By: quark-zju

Differential Revision: D20248022

fbshipit-source-id: dfaf359426528a9cb515fb3e1d366fbfb15162ff
2020-03-04 11:05:29 -08:00
Mark Thomas
eb7f7aacd9 pager: allow overriding of encoding for the pager
Summary:
The pager may accept a different encoding than either the process encoding or
the output encoding.

For example, on Windows:
  * the process encoding may be cp1252 (which is used for all `...A` system calls.
  * the output encoding may be cp436 (which is used for writing directly to the console).
  * the pager encoding may be utf-8 (which is written to the console using more modern system calls).

To fix this, add a `pager.encoding` config option, which, when set, overrides
the output encoding when writing to the pager.

Reviewed By: quark-zju

Differential Revision: D20247650

fbshipit-source-id: 1e4d1246c95f2102763d879f9783d02acc193a73
2020-03-04 11:05:29 -08:00
Mark Thomas
6664cf259b encoding: outputencoding option overrides wrong module attribute
Summary:
The `--outputencoding` option should override `encoding.outputencoding`, not
`util.outputencoding`.

Reviewed By: quark-zju

Differential Revision: D20247651

fbshipit-source-id: b54cee6cd14fb1f3b6d5e8ffc0bf96b7ed924840
2020-03-04 11:05:29 -08:00
Xavier Deguillard
314d1978ef clidispatch: silence warning on windows
Summary:
Using `if cfg!` instead of `#[cfg]` allows for the compiler to understand
that the arguments aren't unused, and silence the warnings.

Reviewed By: quark-zju

Differential Revision: D20242280

fbshipit-source-id: 332dfe17b3a80a1096d15c91c9fb6644bd10e0cd
2020-03-04 09:49:15 -08:00
Xavier Deguillard
7d9d38017c configparser: silence compiler warning
Summary:
Compiling it on Windows produced a bunch of warning due to
`hgrc_configset_load_path` not being compiled on it. Fixed it so it no longer
depends on Unix specific imports.

Reviewed By: quark-zju

Differential Revision: D20241102

fbshipit-source-id: 3002f961191fbb9bc51aa9ac1154d6d50bd7fe23
2020-03-04 09:49:14 -08:00
Xavier Deguillard
db76b7d52b procinfo: address compiler warning
Summary:
The `.into_iter()` for this object is being deprecated and won't compile in
the future, fix it now.

Reviewed By: quark-zju

Differential Revision: D20241103

fbshipit-source-id: fdee463ed81cd07a65f3cc4c70a96c88928b3b87
2020-03-04 09:49:14 -08:00
Xavier Deguillard
be7ae642ea commitcloudsubscriber: silence compiler warning
Summary:
While compiling on Windows, this file issues a bunch of warnings, use `if
cfg!` instead of `#[cfg]` to silence them. The behavior is the same, but the
later allows the compiler to recognize that some is not unused.

Reviewed By: quark-zju

Differential Revision: D20241104

fbshipit-source-id: 2cd7f171c7a2f7220cc73bea9be3359260de19b2
2020-03-04 09:49:14 -08:00
Jun Wu
49464342fd indexedlog: try to use symlink for atomic_write on unix
Summary:
The change is in theory not necessary. However it improves the reliability on
OS crashes a bit, and can potentially workaround some bugs in filesystems
(as we saw in production where the atomic-written files are empty and the
system didn't crash).

The idea is, the `symlink` syscall does the file creation and "content" writing
together, while there is no way to create a file and write specific content
in one syscall. Note that the C symlink call uses 0-terminated string, and
the Rust stdlib exports it as accepting `Path`. To be safe, we encode binary
or non-utf8 content using `hex`.

For downgrade safety, the write path does not use symlink by default unless
format.use-symlink-atomic-write is set to true. This makes downgrade possible:
the read path is rolled out first, then we can turn on and off the write path.

The indexedlog Rust unit tests and test-doctor.t are migrated to use the new
symlink code paths.

Reviewed By: DurhamG

Differential Revision: D20153864

fbshipit-source-id: c31bd4287a8d29575180fbcf7227d2b04c4c1252
2020-03-04 07:23:48 -08:00
Jun Wu
def12896db indexedlog: add a utility function to read files crated by atomic_write
Summary:
This makes it possible to implement atomic_write differently (ex. use a
symlink).

Reviewed By: DurhamG

Differential Revision: D20153865

fbshipit-source-id: 07fa78c2f2dac696668f477c75f65cf70950b73f
2020-03-04 07:23:47 -08:00
Jun Wu
ea7a8b68a5 run-tests: fail instead of skipping tests for unknwon hghave features
Summary:
If hghave fails to check a feature because the feature name is unknown, treat
it as a test failure instead of skipping the entire test. This is especially
useful since `#if feature-name` only affects part of the test and failing to
test the feature should not skip the entire test. It also allows us to capture
issues about mis-spelled feature names or stale feature tests.

This has bitten us twice in the past:

- D18819680 removed `pure` and accidently disabled tests including
  `test-install.t`, `test-annotate.t` and `test-issue4074.t`. Those tests got
  re-enabled as part of D20155399, while they pass Python 2 tests,
  the Python 3 tests were failing.

- D18088850 removed svn related feature checks, which has caused some issues
  that got fixed by D18713921 and D18713922.<Paste>

Reviewed By: xavierd

Differential Revision: D20231782

fbshipit-source-id: 6adf99bd79b2a295d4e84ce4da5f9425a100936a
2020-03-03 19:17:59 -08:00
Jun Wu
73f0525b89 test-issue4074: fix py3 compatibility
Summary: There are multiple issues. Fix them.

Reviewed By: kulshrax

Differential Revision: D20231783

fbshipit-source-id: fc6be43fda088822fe8ff9dbd32410aa616c1772
2020-03-03 17:46:34 -08:00
Jun Wu
2e03deb89e test-annotate: fix py3 compatibility
Summary: The encoding.trim function needs update.

Reviewed By: kulshrax

Differential Revision: D20231780

fbshipit-source-id: 82ea022d815fe9077b8b72403f8de1049173956c
2020-03-03 17:46:34 -08:00
Jun Wu
96ef84b2d4 test-install: fix py3 compatibility
Summary: The test should not assert Python version is "2.*".

Reviewed By: kulshrax

Differential Revision: D20231781

fbshipit-source-id: 2e10c37bb4b665bc4d5d4b27329c4c2cb23d54e3
2020-03-03 17:46:33 -08:00
Jun Wu
7c5e47bab1 indexedlog: rename chunk_size_log to chunk_size_logarithm
Summary:
This makes it clear that `log` is a math concept, not an append-only file like
`Log`.

Reviewed By: DurhamG

Differential Revision: D20149376

fbshipit-source-id: 67d2e9584b15f48759ca9b6dfce4279a5b1365a0
2020-03-03 13:41:28 -08:00
Jun Wu
49de84398b bindings: use Str for return type of repair()
Summary: This makes it friendly to Python 2.

Reviewed By: sfilipco

Differential Revision: D20162233

fbshipit-source-id: 5beb7a0f52159afc454332ff6e37e13087177cc0
2020-03-03 13:41:27 -08:00
Jun Wu
5ba323af16 doctor: skip unknown visibleheads format
Summary:
When I run `hg doctor` in my www checkout it fails the assertion check of the
first line of visibleheads is "v1". Make it graceful so doctor can check and
fix other components.

Reviewed By: DurhamG

Differential Revision: D20147969

fbshipit-source-id: 6aee2cab962fcd0ef06a0611d288021e86621249
2020-03-03 13:41:27 -08:00
David Tolnay
e988a88be9 rust: Rename futures_preview:: to futures::
Summary:
Context: https://fb.workplace.com/groups/rust.language/permalink/3338940432821215/

This codemod replaces *all* dependencies on `//common/rust/renamed:futures-preview` with `fbsource//third-party/rust:futures-preview` and their uses in Rust code from `futures_preview::` to `futures::`.

This does not introduce any collisions with `futures::` meaning 0.1 futures because D20168958 previously renamed all of those to `futures_old::` in crates that depend on *both* 0.1 and 0.3 futures.

Codemod performed by:

```
rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| sed 's,TARGETS$,:,' \
| xargs \
    -x \
    buck query "labels(srcs, rdeps(%Ss, //common/rust/renamed:futures-preview, 1))" \
| xargs sed -i 's,\bfutures_preview::,futures::,'

rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| xargs sed -i 's,//common/rust/renamed:futures-preview,fbsource//third-party/rust:futures-preview,'
```

Reviewed By: k21

Differential Revision: D20213432

fbshipit-source-id: 07ee643d350c5817cda1f43684d55084f8ac68a6
2020-03-03 11:01:20 -08:00
Genevieve Helsel
528015f9fe allow more hg fastpath cases
Reviewed By: simpkins

Differential Revision: D20143888

fbshipit-source-id: 4b1a73159bde6835626ad1766b2cf9dcd2faf6c4
2020-03-02 07:43:39 -08:00
Jun Wu
c718a5dc19 pathmatcher: add a test about a bug in globset/aho-corasick
Summary:
Also patch aho-corasick to fix the issue.

The issue was introduced by [an optimization path](063ca0d253) added in aho-corasick 0.7 series (used by globset 0.4.3).
aho-corasick 0.6.x (globset 0.4.2) are not affected.

The next aho-corasick release (0.7.9) contains the fix.

See https://github.com/BurntSushi/aho-corasick/issues/53 for more context.

Reported by: yns88

Reviewed By: DurhamG

Differential Revision: D20125697

fbshipit-source-id: 592375b43d7ee494bb3e916a1cb11c18f9ebe425
2020-02-28 22:09:28 -08:00
Jun Wu
c1535925cf pydag: do not take parentfunc at __init__
Summary:
`parentfunc` is only needed when adding new nodes to the DAG.
Move it to `addheads` methods instead.

Reviewed By: sfilipco

Differential Revision: D20155398

fbshipit-source-id: 0bddd5f46e84c44891928b9f598a38206917aecb
2020-02-28 17:45:27 -08:00
Jun Wu
26127e91ec debugstrip: repo.revs -> repo.nodes
Summary: One step towards removing usage of revision numbers.

Reviewed By: sfilipco

Differential Revision: D20155397

fbshipit-source-id: f4f3823146217afd8be75120e46901691fbd24cd
2020-02-28 17:45:27 -08:00
Jun Wu
10bb5a144e revset: replace some repo.revs with repo.nodes
Summary:
Migrate away from some uses of revision numbers.
Some dead code in discovery.py is removed.

I also fixed some test issues when I run tests locally.

Reviewed By: sfilipco

Differential Revision: D20155399

fbshipit-source-id: bfdcb57f06374f9f27be51b0980652ef50a2c8e0
2020-02-28 17:45:26 -08:00
Jun Wu
5d253a75df amend: remove hiddenoverride
Summary:
`hiddenoverride` is a hacky implementation that preserves part of another hacky
`inhibit` extension. With our modern setup (inhibit or narrow-heads),
`hiddenoverride` is less useful. Therefore just remove it.

Reviewed By: sfilipco

Differential Revision: D20148011

fbshipit-source-id: f4a5f05b67ae6f315e9b07d50ef03018d6d05df5
2020-02-28 17:45:26 -08:00
Jun Wu
5b15556e60 pydag: replace SpanSet with NameSet in NameDag public APIs
Summary:
This makes it so that DAG calculations in NameDag are all using commit hashes.

The `id2node`, `node2id` APIs are still using integer ids, and hopefully their
usage can eventually be removed.

Reviewed By: sfilipco

Differential Revision: D20020527

fbshipit-source-id: ee32b1ccacabd5174ff1556e426b5ed32d2b8507
2020-02-28 16:35:25 -08:00
Jun Wu
7c6a84c8f5 pydag: add wrappers for NameSet
Summary:
This exposes the NameSet type to the Python world.
The code is similar to the SpanSet wrapper that exists in pydag.

Reviewed By: sfilipco

Differential Revision: D20020521

fbshipit-source-id: 840e009eadca7154f11ca61561da4c48022088f6
2020-02-28 16:35:25 -08:00
Jun Wu
0220b4a0c3 nameset: make NameIter Send
Summary: This makes it possible to use NameIter in py_class.

Reviewed By: sfilipco

Differential Revision: D20020529

fbshipit-source-id: b9147b7dccb38d18d8361b420507fcbe97e01351
2020-02-28 16:35:25 -08:00
Jun Wu
2bbbd3d956 pydag: handle null node special case
Summary:
Mercurial has a special case that b'\0' * 20 maps to rev -1 and means
"an empty commit". This cannot be cleanly supported by the zstore commit data,
since sha1("") is not '\0' * 20 and zstore does not allow faked SHA1 keys.

Therefore let's add the special case in the bindings layer. It's possible to
do this check in Python, but that'll be slower.

Reviewed By: sfilipco

Differential Revision: D20020520

fbshipit-source-id: 0686832666646f2e201035992e3951b47c32eb5a
2020-02-28 16:35:24 -08:00
Jun Wu
13d6e7c92f pydag: use NameDag
Summary: Use the new NameDag as the backing structure and expose its APIs.

Reviewed By: sfilipco

Differential Revision: D20020528

fbshipit-source-id: ccb49e1a5e757bd35a3f71cfb54ceccfb544664e
2020-02-28 16:35:24 -08:00
Jun Wu
782f2017aa dag: add hex prefix lookup
Summary: This will be used by commit hash prefix lookup.

Reviewed By: sfilipco

Differential Revision: D20020523

fbshipit-source-id: f2905ddf63098704b08dad8eb48272c3ffba7e25
2020-02-28 16:35:24 -08:00
Jun Wu
12441f48bf dag: re-export common types at top-level
Summary: Export common types at the top-level of the crate so it's easier to use.

Reviewed By: sfilipco

Differential Revision: D20020526

fbshipit-source-id: e9a0a8bc3cc91f81d0bc74e7530cd4613fc1dd61
2020-02-28 16:35:23 -08:00
Jun Wu
bc9f72ccf3 dag: implement DAG algorithms on NameDag
Summary: Those just delegate to IdDag for the actual calculation.

Reviewed By: sfilipco

Differential Revision: D20020522

fbshipit-source-id: 272828c520097c993ab50dac6ecc94dc370c8e8b
2020-02-28 16:35:23 -08:00
Jun Wu
b88da34fb0 dag: expose NameDag in tests
Summary: This allows tests to check NameDag APIs.

Reviewed By: sfilipco

Differential Revision: D20020525

fbshipit-source-id: 4ee8e4bcbd0731512ba17068e827b8045fc5d522
2020-02-28 16:35:23 -08:00
Jun Wu
194cd25f4f dag: add Arc<IdMap> to NameDag
Summary: This will be used to produce NameSet.

Reviewed By: sfilipco

Differential Revision: D20020519

fbshipit-source-id: abf6d73f2b985b74560d6b5db2800ff25450f02e
2020-02-28 16:35:22 -08:00
Jun Wu
7a343271b9 dag: rename NameDag::parents to NameDag::parent_names
Summary: This matches IdDag::parents (taking a set) and IdDag::parent_ids.

Reviewed By: sfilipco

Differential Revision: D20020524

fbshipit-source-id: 6e90727c355a7400f9a23e0b25e3392bdc032f49
2020-02-28 16:35:22 -08:00
Jun Wu
e3b28a683c nameset: add fast paths for DagSet
Summary: DagSet's SpanSet has fast paths for set operations. Use them.

Reviewed By: sfilipco

Differential Revision: D19912104

fbshipit-source-id: 24b55aa14d03be2f1be59c923e0b8e79d6bcbe6d
2020-02-28 16:35:22 -08:00
Jun Wu
587b06efee nameset: AllSet
Summary: This is similar to hg's fullreposet. It'll be useful as a dummy "subset".

Reviewed By: sfilipco

Differential Revision: D19912108

fbshipit-source-id: 33a95bcb3cf5931a431a1201d1a1f3c627cec7a1
2020-02-28 16:35:21 -08:00
Jun Wu
d41c55a13b nameset: SortedSet
Summary: SortedSet is a wrapper to other sets that marks it as topologically sorted.

Reviewed By: sfilipco

Differential Revision: D19912111

fbshipit-source-id: 2637e8fd29b97f6db0c5bae3f0decd7ac382eeb1
2020-02-28 16:35:21 -08:00
Jun Wu
51bea7aff7 nameset: LazySet
Summary: Similar to Mercurial's smartset.generatorset.

Reviewed By: sfilipco

Differential Revision: D19912110

fbshipit-source-id: 7d940b8578ec7090282e2addb1fde871cddb2b25
2020-02-28 16:35:20 -08:00
Jun Wu
5e451d07b1 nameset: DagSet
Summary:
Wraps SpanSet + IdMap so it only exposes commit names without ids.
There is no equivalent smartset in Mercurial.

Reviewed By: sfilipco

Differential Revision: D19912112

fbshipit-source-id: 0d257de11527dfa8836065ac94f652730a97a468
2020-02-28 16:35:20 -08:00
Jun Wu
e7e7a5b356 nameset: StaticSet
Summary: Similar to Mercurial's smartset.baseset. All names are statically known.

Reviewed By: sfilipco

Differential Revision: D19912105

fbshipit-source-id: e4fcf2d59291adb3ca01b3b90f1ac32c65ad7eaa
2020-02-28 16:35:20 -08:00
Jun Wu
349d1bc33e nameset: IntersectionSet
Summary: Similar to Mercurial's smartset.filterset.

Reviewed By: sfilipco

Differential Revision: D19912113

fbshipit-source-id: 7cf2101b2eb7ba34b542199293cdbfd3973ef72f
2020-02-28 16:35:19 -08:00
Jun Wu
c0a1a3ab22 nameset: DifferenceSet
Summary: Similar to Mercurial's smartset.filterset.

Reviewed By: sfilipco

Differential Revision: D19912107

fbshipit-source-id: a3187c94f8e0c64f6d92e924ba46e83ce74c3e19
2020-02-28 16:35:19 -08:00
Xavier Deguillard
ffced54dff packaging: add edenscm/hgext/convert/repo
Summary: The python files were missing in the package, let's add them.

Reviewed By: quark-zju

Differential Revision: D20163637

fbshipit-source-id: 0a7870a21c42d9b92a8b78b51e4954db0d96c593
2020-02-28 12:15:10 -08:00
Durham Goode
a50d0da7fe py3: fix blame tests
Summary:
Blame can use a templater which doesn't support bytes. Let's just force
all blame output to be unicode, since it doesn't make a ton of sense to blame
binary files anyway.

Also fix test-annotate.py

Reviewed By: quark-zju

Differential Revision: D19907530

fbshipit-source-id: a7a47246368ed50f65486e824f93552872adc09a
2020-02-28 11:32:16 -08:00
Durham Goode
54484268fb py3: more commit cloud fixes
Summary:
Notably, we drop all the encoding business when dealing with json
objects, and instead use mercurial.json.

Reviewed By: sfilipco

Differential Revision: D19888130

fbshipit-source-id: 2101c32833484c37ce4376a61220b1b0afeb175a
2020-02-28 11:32:16 -08:00
Durham Goode
84a42f3471 py3: fix a number of commit cloud tests
Reviewed By: xavierd

Differential Revision: D19888131

fbshipit-source-id: ce1bc011bf76e8cf4bb9bdc0930b8c916229d66d
2020-02-28 11:32:15 -08:00
Durham Goode
98ed0fc5b0 py3: fix a few test-dirstate* tests
Reviewed By: xavierd

Differential Revision: D19888129

fbshipit-source-id: 947ea1bd9c5425fe3babcc60d6b885bde8fc4e2f
2020-02-28 11:32:15 -08:00
Jun Wu
b6cea95ea5 dag: use Bytes to avoid some VertexName copies
Summary:
This is an example about how to use the new Bytes type. The performance change
is not obviously visible in benchmarks since the bottleneck is not at the bytes
copying.

Reviewed By: DurhamG

Differential Revision: D19818720

fbshipit-source-id: a431ae206cfa4fa08b2e162a48b3d7cbcd900f7f
2020-02-28 09:23:59 -08:00
Jun Wu
76ab726056 dag: switch from bytes to minibytes
Summary: The APIs are compatible so the switch is straightforward.

Reviewed By: DurhamG

Differential Revision: D19818713

fbshipit-source-id: 504e9149567c90eb661804e0dad20580a401aa76
2020-02-28 09:23:59 -08:00
Jun Wu
9e3920ca1c dag: fix benchmarks
Summary: D19559127 forgot those files.

Reviewed By: DurhamG

Differential Revision: D19818715

fbshipit-source-id: 92321492eae89ed9f748800b3bfcc306a54aab20
2020-02-28 09:23:59 -08:00
Jun Wu
c417232b1b mutationstore: update lag_threshold
Summary:
D20042045 changes the meaning of "lag_threshold". Update the value in mutation
store accordingly.

Reviewed By: DurhamG

Differential Revision: D20043116

fbshipit-source-id: 154e6dc2aa88ab0a9a9b21929ae5fa6163dcd403
2020-02-28 09:23:59 -08:00
Jun Wu
1962fd5f5b indexedlog: update lagging indexes at open time
Summary:
Previously indexes are only updated at `sync()` time. This diff makes it so
`open()` can also update lagging indexes. This should make index migration
(ex. D19851355) smoother - indexes are built in time and users suffer less from
the absent of indexes.

Reviewed By: DurhamG

Differential Revision: D20042046

fbshipit-source-id: 20412661a0ca4f5f67b671137c47b6373a42981d
2020-02-28 09:23:58 -08:00
Jun Wu
6da3bdadd2 indexedlog: extract logic writing indexes to disk to a method
Summary: The logic is currently only used by `sync()`. I'd like to reuse it at `open()`.

Reviewed By: DurhamG

Differential Revision: D20042044

fbshipit-source-id: 5c9734ff68bdcf8f8c8710c6a821b18d3afeaca0
2020-02-28 09:23:58 -08:00