Commit Graph

2392 Commits

Author SHA1 Message Date
Jun Wu
0742dc6293 dag: make to_set API bind the dag
Summary:
This affects the `tonodes` API in the Python world. Practically this will bind
the main commit graph to sets like draft, public.

The `ToSet` requirement on `DagAlgorithm` has to be removed to avoid stack
overflow of rustc resolving constraints.

Reviewed By: sfilipco

Differential Revision: D23036077

fbshipit-source-id: 912b924e29611680ab6b2ee4dbcd7ab39824409a
2020-08-21 13:00:45 -07:00
Jun Wu
adf027742e nameset: add flatten API
Summary: This will be useful for the `obsolete()` set.

Reviewed By: sfilipco

Differential Revision: D23036072

fbshipit-source-id: 2f944ef31cf19f902622d90545fa02b7dda89221
2020-08-21 13:00:45 -07:00
Jun Wu
f23b1112f0 nameset: a & b should not use id-based fast path if id map is incompatible
Summary:
If two sets have different IdMap, their Ids cannot be compared directly
for correctness.

Reviewed By: sfilipco

Differential Revision: D23036068

fbshipit-source-id: e800e8273b95c1f8174236e0f30445db7fd44556
2020-08-21 13:00:45 -07:00
Jun Wu
c1e596dbd6 nameset: use real id map snapshot instead of a pointer in hints
Summary: This is similar to the previous change. This allows "binding" IdMaps to sets.

Reviewed By: sfilipco

Differential Revision: D23036058

fbshipit-source-id: ec1b1ec73e949ad4865aecf17bfcc5c1ca723e0d
2020-08-21 13:00:45 -07:00
Jun Wu
0ac5f05097 nameset: use real dag snapshot instead of a pointer in hints
Summary:
This trades a bit performance (calculating the snapshot) for correctness (no
pointer reuse issues) and convenience (set captures dag information with them
and enables use-cases like converting NameSet from another dag to the
current dag without requiring extra `dag` objects).

Reviewed By: sfilipco

Differential Revision: D23036067

fbshipit-source-id: 2e691f09ad401ba79dbc635e908d79e54dadca5e
2020-08-21 13:00:45 -07:00
Jun Wu
759ceb6212 nameset: do not swap x & y if they come from different graphs
Summary:
If `x` and `y` come from a same graph, `x & y` is more efficient than
`y & x` if `y` is larger. However, if `x` and `y` are from different
graphs, the `FULL` hint can no longer accurately predict which one
is larger. Therefore the swap should be avoided.

Reviewed By: sfilipco

Differential Revision: D23036081

fbshipit-source-id: fe3970fc38c853b36689bfd0ee1dec20643ace78
2020-08-21 13:00:45 -07:00
Jun Wu
762603455a nameset: new metaset for separate iter+contains lazy/fast paths
Summary:
For sets like `obsolete()`, `merge()`, they could have a fast "contains" path:
Just check the given commit without calculating a full set. It's also possible
to have a relatively efficient code path to return StaticSet (for obsolete()),
or IdStaticSet (for merge(), by checking flat segments). This diff adds a
`MetaSet` that allows defining two fast paths separately.

This will be used for the `obsolete()` set in upcoming changes.

Reviewed By: sfilipco

Differential Revision: D23036059

fbshipit-source-id: 06e6f90e7e9511626a12cfa729c306ff539256d2
2020-08-21 13:00:45 -07:00
Jun Wu
7d8f4ef92f dag: fix re-assigning master flush
Summary:
Before this change, `flush` with empty changes but `master` moves will cause an
error, because the `parents_func` only contains "pending changes", aka. new
vertexes. The `parents_func` does not know `master` and `master` is needed to
re-assign them from the non-master to the master group.

With the snapshot API, things become easier. We just take a snapshot before
reloading, and use the snapshot to answer parent_names.

Reviewed By: sfilipco

Differential Revision: D22970569

fbshipit-source-id: 99a25857ba98792edff69985c16df118a560ffb0
2020-08-21 13:00:45 -07:00
Jun Wu
f666cb1cf0 dag: add DagAlgorithm::snapshot_dag
Summary:
This API allows the underlying Dag to provide a snapshot. The snapshot can then
be used in places that do not want a lifetime (ex. NameSet).

Reviewed By: sfilipco

Differential Revision: D22970579

fbshipit-source-id: ededff82009fd5b4583f871eef084ec907b45d33
2020-08-21 13:00:45 -07:00
Jun Wu
b8e7828edd dag: add NameDag::snapshot_dag
Summary:
Make it possible to snapshot a Dag. This is useful for cases where another
struct wants access to the Dag without lifetimes. Namely, the LazySet can
might want to keep a snapshot of Dag.

Reviewed By: sfilipco

Differential Revision: D22970568

fbshipit-source-id: 508c38d3ffac2ffcd2e682578c3c5e5787ea3bcf
2020-08-21 13:00:45 -07:00
Jun Wu
741d050f10 dag: drop inverse DAG
Summary:
The only intended use of the inverse DAG is to implement the Python dag
interface in `dagutil.py`. D22519589 (2d4d44cf3d) stack changed it so the Python dag
interface becomes optional. Therefore there is no need to keep the inverse DAG
interface, which is a bit tricky on sorting.

Reviewed By: sfilipco

Differential Revision: D22970581

fbshipit-source-id: 58a126b41d992e75beaf76ece25cb578ee84760b
2020-08-21 13:00:45 -07:00
Jun Wu
a16c1c3e28 changelog2: preserve laziness of 'ancestors'
Summary:
This is important for performance. Especially, `copies.py` uses it, and a
non-lazy `ancestors` would slow down common operations like rebase or histedit
or `log -p` because they all use `copies.py`.

Before, `log -pr. -T. --profile>/dev/null`:

```
  2859        \ pathcopies                      copies.py:234
  2858         | _forwardcopies                 copies.py:202
  2858         | _committedforwardcopies        copies.py:166
    11          \ computeforwardmissing         remotefilelog/__init__.py:508
     3            \ _computeforwardmissing      copies.py:156
     7            \ prefetch                    fileserverclient.py:237
     5             | __get__                    util.py:982
     5             | fileslog                   shallowrepo.py:47
     5             | __init__                   remotefilelog.py:465
     5             | makeruststore              remotefilelog.py:519
* 2836          \ ancestors                     changelog2.py:462
     3        \ difffn                          patch.py:2696
     3         | trydiff                        remotefilelog/__init__.py:667
     3         | prefetch                       fileserverclient.py:237
Total time: 3114 ms
```

After:

```
   11        \ pathcopies                       copies.py:234
   10         | _forwardcopies                  copies.py:202
   10         | _committedforwardcopies         copies.py:166
   10         | computeforwardmissing           remotefilelog/__init__.py:508
    3          \ _computeforwardmissing         copies.py:156
    7          \ prefetch                       fileserverclient.py:237
    5           | __get__                       util.py:982
    5           | fileslog                      shallowrepo.py:47
    5           | __init__                      remotefilelog.py:465
    5           | makeruststore                 remotefilelog.py:519
    3        \ difffn                           patch.py:2696
    3         | trydiff                         remotefilelog/__init__.py:667
    2         | prefetch                        fileserverclient.py:237
```

Reviewed By: sfilipco

Differential Revision: D23036057

fbshipit-source-id: 815cb167d38d0e5d1640ea6156b0891c72253933
2020-08-21 13:00:45 -07:00
Jun Wu
e1013decd2 smartset: add Rust nameset wrapper
Summary:
The nameset serves as a bridge for Rust NameSet sets. It's different from the
Rust IdSet in a way that it supports all kinds of Rust NameSet (lazy or
non-lazy).

Unlike the native Rust binding, the added nameset uses rev numbers and fit in
the Python smartset framework.

Reviewed By: sfilipco

Differential Revision: D23036066

fbshipit-source-id: 060b3927dda6cd2275af21b093729c7e0e88ee7c
2020-08-21 13:00:45 -07:00
Jun Wu
8070ad66e1 changelog: do not use nullid as "master node"
Summary: The Rust "flush(masternodes)" API does not handle nullid. Filter it out from Python.

Reviewed By: sfilipco

Differential Revision: D22970578

fbshipit-source-id: 671fe950948067a0b3f97c5b65ff2b9b7ed4b631
2020-08-21 13:00:45 -07:00
Jun Wu
e5d816c812 changelog: tonodes(idset) has a fast path
Summary:
By default, `torevs` calls Python iteration for non-list, non-spans Python
objects. The `idset` object has the `spans` which can be used as a fast
path.

Reviewed By: DurhamG

Differential Revision: D22970580

fbshipit-source-id: f491404ba803c4468c17cd74daaea90f46b8b38b
2020-08-21 13:00:45 -07:00
Jun Wu
1649714542 changelog: expose algorithmbackend API
Summary:
This allows certain code paths to use `dageval` with the idea that `dageval` is
going to be faster.

Reviewed By: sfilipco

Differential Revision: D22970576

fbshipit-source-id: ba4536a55691de63640e574c898320629c6d7b2f
2020-08-21 13:00:45 -07:00
Jun Wu
af7142c7fe changelog2: add ways to migrate between formats
Summary: This allows migrating between a few changelog formats we have.

Reviewed By: DurhamG

Differential Revision: D22970571

fbshipit-source-id: d6b577ae5beb72a43fff999c26c35fcdc33e8f83
2020-08-21 13:00:45 -07:00
Jun Wu
fa25f42fea pydag: add an API to migrate from one DAG to segmented DAG
Summary:
This will be used for migrating revlog DAG to segmented changelog. It does not
migrate commit text data (which can take 10+ minutes).

Reviewed By: DurhamG, sfilipco

Differential Revision: D22970582

fbshipit-source-id: 125a8726d48e15ceb06edb139d6d5b2fc132a32c
2020-08-21 13:00:45 -07:00
Jun Wu
9f8961a75c commands: add debugchangelog command
Summary: For now it just prints some details about the changelog backend.

Reviewed By: DurhamG, sfilipco

Differential Revision: D22970573

fbshipit-source-id: 719a5e5bb6f3856df3c9357e47daa9e7c8584952
2020-08-21 13:00:45 -07:00
Jun Wu
8af2cb0a03 doctor: repair hgcommits directory too
Summary: Make `hg doctor` repair the `hgcommits` directory.

Reviewed By: singhsrb

Differential Revision: D23249534

fbshipit-source-id: fd252479638e1e8ed4665531a804d2862993d25e
2020-08-21 13:00:45 -07:00
Liubov Dmitrieva
5e30b262ec add an option to serve commit cloud smartlog from the original
Summary:
This option is needed to validate Mononoke Smartlog against the original
infinitepush Commit Cloud Smartlog. This option is advanced and can be removed
after full migration to the Mononoke backend.

Reviewed By: markbt

Differential Revision: D23241251

fbshipit-source-id: e550334b104d18bb58d39acb8540ebdc9e711c4e
2020-08-21 13:00:45 -07:00
Wez Furlong
95785a5308 mercurial: tidy up eden import helper mononoke detection
Summary:
We've been using a hard coded list to determine whether
mononoke is available, and that list is falling behind the current
state of our backend migration.

This commit removes the hard coded list in favor of testing
`remotefile.reponame`.  If that is configured then it holds
the mononoke reponame.

I'm making the assumption that it being set implies that mononoke
is available for that repo.  That may not be 100% true, but
it appears to be effectively true for the intersection of repos
known to `fbclone` and the migrated set of repos.

If this code decides that mononoke is supported, the behavior
in EdenFS is to then attempt to use the SCS to fetch tree
data using the returned `repo.name`.  That appears to be the
only way that this information is used today.

Reviewed By: quark-zju

Differential Revision: D23214471

fbshipit-source-id: 17b6475b891df5423dca0c18ddae0838795f713a
2020-08-21 13:00:45 -07:00
Durham Goode
b2ece412fd configs: handle timestamp anomalies in dynamicconfigs
Summary:
Dynamicconfigs compares the timestamp of config files with the current
timestamp to determine when to regenerate. If the timestamp of the config file
is newer than the current timestamp, Rust throws an exception. Let's handle that
case and treat it as if the file was just created instead of crashing.

Reviewed By: quark-zju

Differential Revision: D23230216

fbshipit-source-id: ca185de7dfca46953e04ec08c84668eda6d749bd
2020-08-21 13:00:45 -07:00
Mark Thomas
61ad0a9c62 commitcloud: complete the transaction to sync from the cloud
Summary:
If a cloud sync requires both fetching from the cloud and uploading new state to the cloud,
commit the transaction between the two steps, so that a successful cloud fetch is not
rolled back by failure to send to the cloud.

While we're here, limit the number of sync attempts to 3 in one go.

Reviewed By: farnz

Differential Revision: D23211846

fbshipit-source-id: fa97165d94eee973284ff3d00466387b3041306c
2020-08-21 13:00:45 -07:00
Mark Thomas
1466a17259 commitcloud: don't send obsmarkers if evolution is not enabled
Summary: Avoid trying to send local obsmarkers if evolution is not enabled.

Reviewed By: farnz

Differential Revision: D23210800

fbshipit-source-id: dc247a18e92f6f5454eeed520854dd6254f66257
2020-08-21 13:00:45 -07:00
Mark Thomas
ee216cd207 commitcloud: only send most recent obsmarkers
Summary:
Large numbers of pending obsmarkers can cause commit cloud `update_references`
requests to fail.

Prevent this from happening by only syncing the most recent obsmarkers.
Obsmarkers are in the process of being deprecated and removed, so this
shouldn't be a problem for long.

Reviewed By: farnz

Differential Revision: D23211621

fbshipit-source-id: 56a2e103722c3c162eacdb62638ff8ff614d5815
2020-08-21 13:00:45 -07:00
Mark Thomas
4d18561ab8 bgprogress: Stdio is only used on Unix
Summary: This fixes the Windows build.

Reviewed By: farnz

Differential Revision: D23212195

fbshipit-source-id: 159f3ddebf6a97f52f9b6c80ef19315c8f4b0c85
2020-08-21 13:00:45 -07:00
Jun Wu
1024afc05a pydag: update bindings
Summary: Update bindings to expose the DoubleWrite backend and the DescribeBackend API.

Reviewed By: sfilipco

Differential Revision: D22970574

fbshipit-source-id: bdb52ff21dd0b9ffa0be214b4a4824025f460092
2020-08-21 13:00:45 -07:00
Jun Wu
6b64f9a2bf dag: add import_and_flush API
Summary:
This allows importing from other DAGs. It will be used to import revlog DAG to
the new segmented format.

Reviewed By: sfilipco

Differential Revision: D22970572

fbshipit-source-id: 0a183e7b64831574cc9c60d4639124d02d19cf43
2020-08-21 13:00:45 -07:00
Jun Wu
c448e0f575 renderdag: move to dag
Summary:
This allows dag to use renderdag in tests to verify graph result. Previously
it was hard because dag <-> renderdag would form circular dependency.

It also make it possible to implement more efficient and integrated fast paths
for graph rendering.

Reviewed By: sfilipco

Differential Revision: D22970570

fbshipit-source-id: 526497339bd7aa8898d1af4aa9cf6d2a6797aae0
2020-08-21 13:00:45 -07:00
Jun Wu
d047f07b70 commits: add a trait to describe storage backend and use-cases
Summary: This will be used to describe what the commit graph backend is.

Reviewed By: sfilipco

Differential Revision: D22970577

fbshipit-source-id: 753efdbdd4466730ece758d9f4789fbd21e2801b
2020-08-21 13:00:45 -07:00
Jun Wu
b77355ca0c commits: add double write commits backend
Summary:
This allows us to try segmented changelog while maintaining revlog
compatibility.

Reviewed By: sfilipco

Differential Revision: D22970583

fbshipit-source-id: 7c43cdadd76300e76e89f38aac5ed3ecc0cff728
2020-08-21 13:00:45 -07:00
Jun Wu
c785e333af remotefilelog: do not resolve linkrev for changelog.add
Summary: The value of linkrev is invalid with segmented changelog. Do not resolve it.

Reviewed By: sfilipco

Differential Revision: D23036079

fbshipit-source-id: 8f8b097458bc694327db6ba4e2dc4107bdf44157
2020-08-21 13:00:45 -07:00
Durham Goode
a2940dbbde py3: fix hex encoding for phrevset in git backed repos
Summary:
Phabricator reports some repos as being backed by git, and the phrevset
code path in that case uses the python 2 hex encoding. Let's just use the hex
function directly.

Reviewed By: quark-zju

Differential Revision: D23207771

fbshipit-source-id: 88de3153e52a3db456c17ab4ca4b9c9dd6049855
2020-08-19 10:53:12 -07:00
Mark Thomas
f64f57eed1 debuginstall: don't fail if no templates are installed
Reviewed By: quark-zju, ikostia

Differential Revision: D23154918

fbshipit-source-id: 18193103e0c765ec7064bb67b39548d32b289366
2020-08-19 00:32:19 -07:00
Mark Thomas
44b7724014 run-tests: add internal:none editor
Summary: Rather than using a Python program, simulate having no editor during tests using `internal:none`.

Reviewed By: quark-zju, ikostia

Differential Revision: D23152446

fbshipit-source-id: 5560f58885ee5959c62f0ac8bcf0483b9c3072f6
2020-08-19 00:32:19 -07:00
Mark Thomas
a25521a48b tests: remove uses of $PYTHON -c
Reviewed By: quark-zju, ikostia

Differential Revision: D23151936

fbshipit-source-id: f5dc1bf1e2007fe82c8ea67fa94c7b5aa3fd9a0c
2020-08-19 00:32:19 -07:00
Durham Goode
d31488e3fa py3: fix commandserver args to be string
Summary:
The commandserver was setting args as bytes when they should be
strings. This was breaking arg parsing for users using hglib, which communicates
with hg via the commandserver.

Reviewed By: sfilipco, singhsrb

Differential Revision: D23202623

fbshipit-source-id: f71e4145211069b2f7ed6935fe86585061cbf8b3
2020-08-18 21:36:47 -07:00
Jun Wu
324e79fac4 setdiscovery: enforce new discovery logic for rust changelog
Summary:
The old discovery logic is incompatible with the rust changelog because
the changelog is not based on revlog.

Reviewed By: sfilipco

Differential Revision: D23036065

fbshipit-source-id: 633fdf8726d40cb14e63c3df2f5573d35cb1640a
2020-08-18 20:43:29 -07:00
Jun Wu
0b0cd2da97 setdiscovery: use new dag APIs if possible
Summary:
They are faster if the new dag backend is used. For example, `headsancestors`
will be backed by a fast native path, where the `head(ancestors(x))` revset
would be unusably slow if the new dag backend is used.

Reviewed By: sfilipco

Differential Revision: D23036069

fbshipit-source-id: 75df1e2240520a6e560bc5d8414ba2f4fb7a4674
2020-08-18 20:43:29 -07:00
Durham Goode
6632d69936 py3: fix hg doctor in shared repos
Summary:
It read the sharedpath manually but needed to read it as utf8, not
bytes.

Reviewed By: quark-zju

Differential Revision: D23194858

fbshipit-source-id: aa73c2cc782070ba6c4d2c441d6f5338842b137f
2020-08-18 14:57:51 -07:00
Durham Goode
59f867a442 ssh: prevent double cleanup of sshpeer
Summary:
sshpeers were being cleaned up twice. Once during the explicit close()
and once during the __del__ destruction. This caused it to double count the
reported _totalbytesreceived.

Reviewed By: quark-zju

Differential Revision: D23178435

fbshipit-source-id: da76158be561511f2f2a5e255fd03aa4a6b78da0
2020-08-18 14:49:58 -07:00
Durham Goode
d7b036c29a Enable fb features for cargo test diff runs
Summary:
We missed a Windows http client breakage because our LFS server integration
wasn't run on Windows. Let's enable the fb feature for all our cargo test runs.

Reviewed By: singhsrb

Differential Revision: D23140315

fbshipit-source-id: 46cc533c1e543ffc32d472b49a8f6daeee3b5009
2020-08-18 14:01:01 -07:00
Meyer Jacobs
656e3c90d6 edenapi: Introduce serde annotations for wire protocol compatibility and compact wire representation
Summary:
Aux data wire protocol part 1: field annotations & basic compatibility model.

Annotates fields in `file`, `tree`, and `complete_tree` wire structs with `#[serde(rename = "N", default, skip_serializing_if = "is_default")]`. I've avoided using `#[serde(default)]` on the container structs themselves because this can cause some confusion / incorrect behavior if not used carefully. Consider a wire struct `FooRequest` with a field of type `Option<Bar>`. `Option<Bar>` defaults to `None`. If `FooRequest`'s `Default` implenentation sets the field's default to `Some(bar)`, a `FooRequest` explicitly constructed with `None` for the field will be serialized with the field omitted (because it passes `is_default`) and will be deserialized on the server as `Some(bar)`, causing incorrect behavior. To address this, we'd need to change the `is_default` function used with `skip_serializing_if` to check against the field's default value as set by the container, which isn't trivially possible without some sort of reflection (please correct me if you know a good way to achieve this). This is unfortunate, as it'd be very desirable for the container to be able to set defaults different from the individual field type defaults, for cases where one boolean, for instance, should default to true. As-is, we'd need to address this with wrapper types instead, where we can fully control the `Default` implenentation.

We can, of course, address this by providing an alternate `skip_serializing_if` function to fields with default that doesn't match that set by the container. This will need to be done carefully, though, to avoid the issue I described above.

Currently the JSON module manually serializes and deserializes all the top-level request objects, so the rename annotation doesn't impact it. We can add `#[serde(alias = "rustfieldname")]` if we'd like the server and client to be able to accept manually-crafted requests and responses with explicit field names. This could also be useful to replace the manual parsing in the JSON module, but can't replace the manual serialization in a clean way. We'd need to introduce a second copy of the wire types, without the serde `rename` attribute, to allow serializing with the actual rust field name.

I've only modified the `tree`, `file`, and `complete_tree` modules. I intend to eventually update the rest of the edenapi protocol later on, when the implementation of `file` and `tree` are complete / stable. This will give us a chance to fix any mistakes before copying the design to more places.

Note: I do not intend to keep to proper wire protocol compatibility at this stage in the implementation. Expect field numbers to be re-used by non-compatible changes.

Reviewed By: kulshrax

Differential Revision: D23172756

fbshipit-source-id: 39976ed4bede892bd6981f9c3f23557a91f9028b
2020-08-18 13:44:35 -07:00
Liubov Dmitrieva
a9b5e8668b Add create option and validate that workspace exists
Summary:
hg `cloud join -w myworkspace --switch/--merge` should require --create option for all not default
workspaces if the workspace doesn't already exist.

I also enabled reusing of http connection, so it makes `hg cloud switch` much faster.
It is less than 2 sec now.

Reviewed By: markbt

Differential Revision: D23188491

fbshipit-source-id: 9a2ba2df4ba91e9dba9484cd49fc886f70b09880
2020-08-18 09:46:22 -07:00
Meyer Jacobs
a01e4e3503 filemerge: Fix regex to use bytestring pattern for bytestring data.
Summary: In py3, a string pattern cannot be used to match against a bytestring text. Convert the pattern to a bytestring, which should be compatible with python2 without additional changes.

Reviewed By: DurhamG

Differential Revision: D23135472

fbshipit-source-id: fcc0b111c646011f5b556f032ef85ef326cb9511
2020-08-18 09:14:07 -07:00
Xavier Deguillard
88c3bf4826 revisionstore: remove translate_lfs_missing
Summary:
As noted in the documentation for it, this can be removed once get and prefetch
return a continuation. This is now done, and thus we can remove it entirely.

Mis-use of it caused data to be fetched twice: once by memcache, and the second
one by getpackv2.

Reviewed By: singhsrb

Differential Revision: D23123344

fbshipit-source-id: 9ac0594faaba94ead04a8bb9035e14809a706641
2020-08-17 17:05:58 -07:00
Durham Goode
fe6cb9dc13 configs: fix handling shared path with trailing new lines
Summary: The python code stripped new lines but the Rust code did not.

Reviewed By: singhsrb

Differential Revision: D23167515

fbshipit-source-id: add33ec6e4cfd9169e6fef8208490e0aeede38bd
2020-08-17 15:53:08 -07:00
Durham Goode
36a49b9b2b rotatelog: fix tests on windows
Summary:
The tests weren't windows compatible. Let's get rid of the path
separators.

Reviewed By: quark-zju, singhsrb

Differential Revision: D23170573

fbshipit-source-id: f934691cd2891205442885a12debe3a28d275fc5
2020-08-17 14:08:26 -07:00
Liubov Dmitrieva
e6509babef enable automated migration from old backups to cloud sync
Reviewed By: markbt

Differential Revision: D22802064

fbshipit-source-id: c56e65e1a93e8cc94296cf69227bc51eb52f59c3
2020-08-17 10:58:38 -07:00