Commit Graph

2574 Commits

Author SHA1 Message Date
Durham Goode
fe56f44ca0 treemanifest: prevent fetching nullid
Summary:
Mononoke throws an error if we request the nullid. In the long term we
want to get rid of the concept of the nullid entirely, so let's just add some
Python level blocks to prevent us from attempting to fetch it. This way we can
start to limit how much Rust has to know about these concepts.

Reviewed By: sfilipco

Differential Revision: D23332359

fbshipit-source-id: 8a67703ba1197ead00d4984411f7ae0325612605
2020-08-27 09:59:40 -07:00
Durham Goode
4d4e425624 configs: add fbitwhoami tiers to dynamicconfig inputs
Summary:
Corp has a different concept of tier than prod. Let's load the corp
tier into our tier set as well.

Reviewed By: quark-zju

Differential Revision: D23354056

fbshipit-source-id: c9543b8253f042c7b1224578e0687b4bdf21738e
2020-08-27 09:24:28 -07:00
Durham Goode
c190d283ec py3: don't use universal newlines for patch import
Summary:
The Python 3 email library internally stores the message as text, even
though our input and requested output is bytes. Let's make our own wrapper
around the parser to use ascii surrogateescape encoding so we can get the
actual bytes out later and not get universal newlines.

Based off the upstream 7b12a2d2eedc995405187cdf9a35736a14d60706,
which is basically a copy of the BytesParser implementation (https://github.com/python/cpython/blob/3.8/Lib/email/parser.py) with
newline=chr(10) added.

Reviewed By: quark-zju

Differential Revision: D23363965

fbshipit-source-id: 880f0642cce96edfdd22da5908c0b573887bed12
2020-08-27 09:21:04 -07:00
Liubov Dmitrieva
06c1d37383 move try up in the rejoin command
Summary:
`hg cloud rejoin` command is used in fbclone and it is supposed to print a
message on RegistrationError but this has been broken recently.

Reviewed By: markbt

Differential Revision: D23342773

fbshipit-source-id: 4f3318848953656dea65a2b5d4d832694f6b353c
2020-08-27 06:53:28 -07:00
Liubov Dmitrieva
bd63a78f96 add more information to hg cloud leave command
Summary:
There are users who prefer run `hg cloud leave` if they notice they are
connected to commit cloud sync.

Proving more information and add a prompt might help them to change their mind.

For some users who left new fbclone will connect them back. So on next leave they can learn more information about Commit Cloud Workspaces.

Reviewed By: markbt

Differential Revision: D23346091

fbshipit-source-id: 72f170f7133cd64b772ec75ae29a85dc8809e351
2020-08-26 22:43:20 -07:00
Durham Goode
8f9c0899cc update: fix performance of updating to null commit
Summary:
When updating to the null commit, the logic that computes the update
distance was broken. The null commit is pre-resolved to -1, which when passed to
a revset raw gets resolved as the tip commit. In large repositories this can
take a long time and use a lot of memory, since it's computing the difference
between tip and null.

Let's fix it to not pass the raw rev number, and also to handle the case of a 0
distance update.

Reviewed By: quark-zju

Differential Revision: D23358402

fbshipit-source-id: 3b0a1fe1bbcb07effba4d0ab2c092e66bdc02e67
2020-08-26 22:14:59 -07:00
Jun Wu
12d23ba64d revisionstore: fix GitHub build (#46)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/46

See https://github.com/facebookexperimental/eden/runs/1034006668:

   error: unused import: `env::set_var`
      --> src/lfs.rs:1539:15
       |
  1539 |     use std::{env::set_var, str::FromStr};
       |               ^^^^^^^^^^^^
       |
  note: the lint level is defined here
      --> src/lib.rs:125:9
       |
  125  | #![deny(warnings)]
       |         ^^^^^^^^
       = note: `#[deny(unused_imports)]` implied by `#[deny(warnings)]`

  error: unnecessary braces around method argument
      --> src/lfs.rs:2439:36
       |
  2439 |         remote.batch_upload(&objs, { move |sha256| local_lfs.blobs.get(&sha256) })?;
       |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these braces
       |
  note: the lint level is defined here
      --> src/lib.rs:125:9
       |
  125  | #![deny(warnings)]
       |         ^^^^^^^^
       = note: `#[deny(unused_braces)]` implied by `#[deny(warnings)]`

  error: aborting due to 2 previous errors

  error: could not compile `revisionstore`.

I dropped `#![deny(warnings)]` as I don't think warnings like the above ones
should break the build. (denying specific warnings that we care about explicitly
might be a better approach)

Reviewed By: singhsrb

Differential Revision: D23362178

fbshipit-source-id: 02258f57727edfac9818cd29dda5e451c7ca80a7
2020-08-26 20:40:25 -07:00
Arun Kulshreshtha
30e2cf4413 cargo_from_buck: reenable autocargo for edenapi
Summary: Now that it is possible to control which features are enabled on manually-managed dependencies, we can reenable autocargo for `edenapi`. See D23216925, D23327844, and D23329351 (840e6dd6f6) for context.

Reviewed By: dtolnay

Differential Revision: D23335122

fbshipit-source-id: 8ce250c3a106d2a02f457f7ed531623dd866232f
2020-08-26 19:16:48 -07:00
Jun Wu
d60e80796a py3: fix absorb -i
Summary: The command does not crash but `-` lines are ignored.

Reviewed By: DurhamG

Differential Revision: D23357655

fbshipit-source-id: f48568bc193f947503bc19f3e192b33346c317e1
2020-08-26 17:21:01 -07:00
Jun Wu
039419d281 configparser: fix non-fb dependencies (#45)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/45

Fix referring to 'version' without proper codegen by making 'version' compile
without codegen. This fixes configparser test when version/src/lib.rs was not
generated.

Make unneeded deps without 'fb' feature optional.

This would hopefully fix the "EdenSCM Rust Libraries" GitHub workflow.

Reviewed By: DurhamG

Differential Revision: D23269864

fbshipit-source-id: f9e691fe0a75159c4530177b8a96dad47d2494a9
2020-08-26 16:31:00 -07:00
Jun Wu
0705bd3b8d pydag: use dag::delegate to simplify code
Summary: This makes the code simpler.

Reviewed By: sfilipco

Differential Revision: D23269858

fbshipit-source-id: bb9ac0bd1696f7429ca1856e6c63e04fabc2757a
2020-08-26 15:32:26 -07:00
Jun Wu
55116e223f hgcommits: use dag::delegate to simplify code
Summary: This makes the code simpler.

Reviewed By: sfilipco

Differential Revision: D23269866

fbshipit-source-id: 30c9e9d218378c0d6df8b822b2a81df2b38f5b01
2020-08-26 15:32:26 -07:00
Jun Wu
85b3cea8ee dag: define delegate macro for other main traits
Summary: Will be used to simplify code.

Reviewed By: sfilipco

Differential Revision: D23269859

fbshipit-source-id: bed0c4dca075ff60900025642af1d84bdd03452d
2020-08-26 15:32:26 -07:00
Jun Wu
6b3096c7a4 dag: avoid other 'impl<T> Trait for T' usecases
Summary:
`impl<T> Trait for T` in the current Rust makes it impossible to have
`impl<Q> Trait for Q`. Avoid using it for IdConvert and PrefixLookup.

Reviewed By: sfilipco

Differential Revision: D23269861

fbshipit-source-id: a837f3984ff4e1bd5a3983dd1642b9f064f51a36
2020-08-26 15:32:25 -07:00
Jun Wu
4a2ee4c522 dag: avoid impl<T> DagAlgorithm for T
Summary:
`impl<T> Trait for T` in the current Rust makes it impossible to have
`impl<Q> Trait for Q`. Avoid using it for DagAlgorithm.

Reviewed By: sfilipco

Differential Revision: D23269860

fbshipit-source-id: 031e75e9bf1f1eec2b9e8f36220ef8b817a143a5
2020-08-26 15:32:25 -07:00
Jun Wu
846768fb53 dag: drop LowLevelAccess
Summary: LowLevelAccess is a subset of NameDagStorage. Use the latter instead.

Reviewed By: sfilipco

Differential Revision: D23269865

fbshipit-source-id: 81ebb1e986d8b02c968a9a237ad9a97d4afd54bf
2020-08-26 15:32:25 -07:00
Jun Wu
f4021486ab dag: move beautify to default_impl
Summary: This makes `ops.rs` look simpler.

Reviewed By: sfilipco

Differential Revision: D23269863

fbshipit-source-id: ddb55ab8eb3b2d3e7c4b2ccbc2252395d62317a1
2020-08-26 15:32:25 -07:00
Jun Wu
e12b6c81de debugbenchmark: add a command to benchmark revsets
Summary:
Provide a way to benchmark revsets, optionally on different backends.

Some example benchmarks:

On the linux.git repo:

  $ git clone https://github.com/torvalds/linux --filter=tree:0 -n
  # might need edit .git/config, set repositoryformat to 0
  $ hg debuginitgit --git-dir=linux/.git linux-hg
  $ hg debugbenchmarkrevsets --cwd linux-hg -x v2.6.26 -Y v5.8  -m
  # x:  bce7f793daec3e65ec5c5705d2457b81fe7b5725  (v2.6.26)
  # y:  bcf876870b95592b52519ed4aafcf9d95999bc9c  (v5.8)

  | revset \ backend | segments | revlog | revlog-cpy |
  |------------------|----------|--------|------------|
  | ancestor(x, x)   |    0.1ms |  0.1ms |      0.1ms |
  | ancestor(x, y)   |    0.1ms |   10ms |       11ms |
  | ancestors(x)     |    0.2ms |   10ms |      264ms |
  | ancestors(y)     |    0.2ms |  175ms |      3.0 s |
  | children(x)      |    0.2ms |   12ms |      955ms |
  | children(y)      |    0.2ms |  0.3ms |       54ms |
  | descendants(x)   |     75ms |  164ms |       69ms |
  | descendants(y)   |    1.6ms |  0.6ms |      0.7ms |
  | y % x            |    0.2ms |   18ms |      863ms |
  | x::y             |     75ms |  160ms |       68ms |
  | heads(_all())    |    0.1ms |  9.8ms |      843ms |
  | roots(_all())    |    0.5ms |   15ms |      1.6 s |

On the git.git repo with lots of merges but relatively short history:

  # x:  a3eb250f996bf5e12376ec88622c4ccaabf20ea8  (v0.99)
  # y:  4d4165b80d6b91a255e2847583bd4df98b5d54e1  (v2.9.5)

  | revset \ backend | segments | revlog | revlog-cpy |
  |------------------|----------|--------|------------|
  | ancestor(x, x)   |    0.1ms |  0.1ms |      0.1ms |
  | ancestor(x, y)   |    0.7ms |  0.6ms |      0.6ms |
  | ancestors(x)     |    0.2ms |  0.4ms |      1.7ms |
  | ancestors(y)     |    0.8ms |  4.4ms |      140ms |
  | children(x)      |    0.2ms |  1.1ms |       75ms |
  | children(y)      |    0.2ms |  0.4ms |       20ms |
  | descendants(x)   |     16ms |  8.2ms |      2.9ms |
  | descendants(y)   |    4.2ms |  1.8ms |      0.9ms |
  | y % x            |    0.8ms |  1.2ms |       42ms |
  | x::y             |     13ms |  5.8ms |      1.7ms |
  | heads(_all())    |    0.2ms |  0.6ms |       46ms |
  | roots(_all())    |    0.4ms |  1.0ms |      102ms |

On large repo 1 with lots of drafts (and heads):

  # x:  94fccdcc90d52995bf47f1d9259372c290257420  (94fccdcc90 & public())
  # y:  afa87d815d528afadbe5622278e285346d5376f4  (afa87d81 & draft())

  | revset \ backend | segments | revlog | revlog-cpy |
  |------------------|----------|--------|------------|
  | ancestor(x, x)   |    0.1ms |  0.2ms |      0.1ms |
  | ancestor(x, y)   |    0.1ms |   40ms |       62ms |
  | ancestors(x)     |    0.2ms |  1.2 s |      6.8 s |
  | ancestors(y)     |    0.2ms |  2.7 s |       16 s |
  | children(x)      |    0.2ms |   52ms |      5.2 s |
  | children(y)      |    0.2ms |  5.4ms |      357ms |
  | descendants(x)   |    6.0ms |  616ms |      149ms |
  | descendants(y)   |    1.0ms |  0.9ms |      1.5ms |
  | y % x            |    0.2ms |   73ms |      4.2 s |
  | x::y             |    2.3ms |  557ms |      159ms |
  | heads(_all())    |    184ms |   87ms |       10 s |
  | roots(_all())    |     22ms |  110ms |       16 s |

On large repo 2 with mostly linear history:

  # x:  a5b69b059257f732c3b06e5af4ace9fd58ba87e4  (10000)
  # y:  e1e93ca550a89f7803e5a8fe5d388342c44bdd13  (e1e93ca5)

  | revset \ backend | segments | revlog | revlog-cpy |
  |------------------|----------|--------|------------|
  | ancestor(x, x)   |    0.1ms |  0.1ms |      0.1ms |
  | ancestor(x, y)   |    0.1ms |  354ms |      541ms |
  | ancestors(x)     |    0.1ms |  1.1ms |       13ms |
  | ancestors(y)     |    0.1ms |   16 s |       59 s |
  | children(x)      |    0.1ms |  371ms |       32 s |
  | children(y)      |    0.1ms |  0.1ms |      1.3 s |
  | descendants(x)   |    0.3ms |  5.7 s |      1.3 s |
  | descendants(y)   |    0.2ms |  0.2ms |      5.5ms |
  | y % x            |    0.1ms |  583ms |       30 s |
  | x::y             |    0.3ms |  5.7 s |      1.4 s |
  | heads(_all())    |    0.1ms |  317ms |       28 s |
  | roots(_all())    |    0.1ms |  493ms |       47 s |

Notes about the segments backend:
- Optimized for (common) ancestors calculation.
- x::y, or descendants are sensitive to the number of merges.
- descendants or heads are sensitive to the number of heads.
- Not optimized for too many heads. But with narrow-heads, `descendants(x)` is re-written to `x::visible_heads()` and it could be less of an issue if heads are "narrowed".
- More efficient IdDag implementation would improve performance by a constant time factor.
  Namely, having the Index pre-checksum the byte range would make it about 2x faster.

Reviewed By: DurhamG

Differential Revision: D23106173

fbshipit-source-id: b88770e2fc9f0f626bb65e214a83da1a0b927344
2020-08-26 15:32:25 -07:00
Jun Wu
bb461d2240 dag: improve range calculation in repos with many heads
Summary:
If there are too many heads, the current `descendants` algorithm would visit
all "old" heads. For example, with this graph:

      head9999  (N9999)
     /
    Z (master)
    :
    : (many heads)
    :/
    : head2 (N2)
    :/
    C head1 (N1)
    |/
    B head0 (N0)
    |/
    A

`A::head9999` or `Z::head9999` will visit N0, N1, ..., N9999, because
`descendands_up_to` is provided with `max_id = N9999` and Z as a vertex in the
master group, is before N0 in non-master.  The current algorithm also means
`descendands_up_to` gets linearly slower as the user uses the repo more, which
is quite undesirable.

This diff changes `descendands_up_to` to take an `ancestors` set, which is
`::head9999` in this case, and iterate non-master flat segments in it. So it
will skip N0 to N9998 directly by finding the N9999 flat segment and only use
it. The number of heads will have a smaller impact on performance.

Another slowness is `draft::draft_heads`, if there are too many `draft_heads`,
the internal calculation of `::draft_heads` can be slow. Optimize it by
limiting `draft_heads` to `draft:`. Practically this affects `y::` revset as
`y::` is translated to `y::visible_heads` and `visible_heads` can be large.

`cargo bench --bench dag_ops -- '::-master'` shows significant difference:

Before:

  range (master::draft)                              18.112 s
  range (recent_draft::drafts)                        2.594 s

After:

  range (master::draft)                              72.542 ms
  range (recent_draft::drafts)                       14.932 ms

In my fbsource checkout there were 20k+ heads. The improvement of
`master::recent_draft` (`x::y`) is pretty visible, and `y::` is also improved:

    % lhg debugbenchmarkrevsets -m -x 'p1(min(7e8c86ae % master))' -Y 'draft() & 7e8c86ae' -e 'x::y' -e 'y::' --no-default
    # x:  168f5228e570fb6b2ff7f851bd82413102748d84  (p1(min(7e8c86ae % master)))
    # y:  7e8c86aec68ebc6e0b8254afcb381315991fd21c  (draft() & 7e8c86ae)

    # before
    | revset \ backend | segments | revlog | revlog-cpy |
    |------------------|----------|--------|------------|
    | x::y             |     17ms |  0.1ms |      0.5ms |
    | y::              |    3.3ms |  0.7ms |      1.3ms |

    # after
    | revset \ backend | segments | revlog | revlog-cpy |
    |------------------|----------|--------|------------|
    | x::y             |    0.2ms |  0.1ms |      0.6ms |
    | y::              |    1.0ms |  0.7ms |      1.3ms |

Reviewed By: sfilipco

Differential Revision: D23214387

fbshipit-source-id: 4d11db84cd28f4e04e8b991cbc650c9d5781fd27
2020-08-26 15:32:25 -07:00
Jun Wu
a3cbda76bb dag: add a benchmark for x::y with lots non-master heads
Summary:
Lots of non-master heads is not an exercised graph in the benchmarks.
Add it as it practically happens.  This will be used by the next change.

Reviewed By: sfilipco

Differential Revision: D23259879

fbshipit-source-id: 7fe290d14403e42e6d135bde56e2d5c8519ae530
2020-08-26 15:32:24 -07:00
Jun Wu
89570e223a dag: use non-master group in fuzz test
Summary:
Currently the fuzz test only uses the master group. Let it exercise non-master
group too.

Reviewed By: DurhamG

Differential Revision: D23214388

fbshipit-source-id: 7108a1055fbdda2b012f93c5948fb83ef3b9a96f
2020-08-26 15:32:24 -07:00
Jun Wu
293d53c12a repo: cache 'headrevs()'
Summary:
The calculation can take tens of milliseconds. Cache it.
Invalidate the cache on transaction commit.

This will improve perf on revsets like `descendants` that will use
`head()`.

Reviewed By: DurhamG

Differential Revision: D23196412

fbshipit-source-id: 2913310ebb97e1c0346198c1e2738799799c740a
2020-08-26 15:32:24 -07:00
Jun Wu
ded7c2e380 hgcommits: add explain_internals to print human-readable segments
Summary: Provide a way to see segments.

Reviewed By: sfilipco

Differential Revision: D23196408

fbshipit-source-id: b1418f945a5a3364ac73b0f97466d973dd4b6300
2020-08-26 15:32:24 -07:00
Jun Wu
9666dab916 dag: implement Debug for NameDag
Summary:
Provide a way to print out all segments with resolved names. This will be used
in a debug command.

Reviewed By: sfilipco

Differential Revision: D23196410

fbshipit-source-id: 1712bfda0271aa548699fe4a6b8603c5ec07af7f
2020-08-26 15:32:23 -07:00
Jun Wu
5829fc4e20 dag: children(small set) has a fast path
Summary:
Use the parent-child index to answer children query quickly.

`cargo bench --bench dag_ops -- children`:

Before:

  children (spans)                                  606.076 ms
  children (1 id)                                   124.105 ms

After:

  children (spans)                                  602.999 ms
  children (1 id)                                    10.777 ms

Reviewed By: sfilipco

Differential Revision: D23196411

fbshipit-source-id: 37195d5ccaa582d35314e0000352ef477287d38c
2020-08-26 15:32:23 -07:00
Jun Wu
a5a396027d dag: expose API to lookup children by parent
Summary: This will be used to optimize "children(single vertex)" query.

Reviewed By: sfilipco

Differential Revision: D23196409

fbshipit-source-id: 050c0859faf83b909e3174bb7c7bd6e7725165c0
2020-08-26 15:32:23 -07:00
Jun Wu
bad2ae41ef dag: maintain non-master parent-child indexes
Summary:
Update the parent index to store non-master group too. To make
"remove_non_master" work, the index contains a "child group" prefix that
allows efficient range invalidation.

This will allow answering "children(single vertex)" query more efficiently.

This diff does not expose an API to query the index yet.

Reviewed By: sfilipco

Differential Revision: D23196406

fbshipit-source-id: 9137da5ffa8306bdafbcabc06b6f0d23f38dcf57
2020-08-26 15:32:23 -07:00
Jun Wu
6c468b7ac0 dag: add benchmark about children(1 id)
Summary:
Practically, the input of `children` is often one vertex instead of a large set.
Add a benchmark for it.

It looks like:

  children (spans)                                  606.076 ms
  children (1 id)                                   124.105 ms

Reviewed By: sfilipco

Differential Revision: D23196407

fbshipit-source-id: 0645b59ac846836fd061386384f6386a57661741
2020-08-26 15:32:23 -07:00
Jun Wu
6f3616a2b8 nameset: make dag and idmap immutable in hints
Summary: They can be figured out at Hints initialization time. So they don't need to be mutable.

Reviewed By: sfilipco

Differential Revision: D23182518

fbshipit-source-id: 133375fdf27a2546a50b63fb130534acdadc5938
2020-08-26 15:32:22 -07:00
Jun Wu
682365f14d nameset: make Id{Static,Lazy}Set require Dag on construction
Summary:
Both IdSet and IdLazy set require both Dag and IdMap to construct.
This is step 1 torwards making Dag and IdMap immutable in hints.

A misspeall of "lhs" vs "hints" in the union set is discovered by the change
and fixed.

Reviewed By: sfilipco

Differential Revision: D23182520

fbshipit-source-id: 3d052de4b8681d3672ebc45d953d1e784f64b2a4
2020-08-26 15:32:22 -07:00
Jun Wu
3ba655abf3 dag: add DummyDag for testing
Summary:
It will be used in places (ex. tests) where a Dag is required but constructing
a real Dag is troublesome.

Reviewed By: sfilipco

Differential Revision: D23182517

fbshipit-source-id: 736911365778e5071c1e0b9615090a4e960392a0
2020-08-26 15:32:22 -07:00
Jun Wu
bd7769b34a dag: rename snapshot_dag to dag_snapshot
Summary: This is more consistent with `id_map_snapshot`.

Reviewed By: sfilipco

Differential Revision: D23182519

fbshipit-source-id: 62b7fc8bfdc9d6b3a4639a6518ea084c7f3807dd
2020-08-26 15:32:22 -07:00
Jun Wu
4d798c39d9 dag: add new range algorithm
Summary:
Similar to descendants, the new range algorithm avoids potentially expensive
checks about whether high-level segments can be used or not. Practically this
is overall an improvement.

`cargo bench --bench dag_ops -- range`:

Before:

  range (2 ids)                                     115.380 ms
  range (spans)                                     243.666 ms

After:

  range (2 ids)                                     123.274 ms
  range (spans)                                      23.101 ms

It is 100x faster with the range x::y benchmark added later on `git.git`.

Reviewed By: sfilipco

Differential Revision: D23106175

fbshipit-source-id: 691e0418ba2b7ad9f52ac15b5cd6088ec28d5f48
2020-08-26 15:32:22 -07:00
Jun Wu
c2e03b9129 dag: add new descendants algorithm
Summary:
The old algorithm tries to make use high-level segments.
However, the code to test whether a high-level segment can be used is
often too expensive for the benefit. Often, high-level segments cannot
be used most of the time and it's similar to O(flat segments).

This diff adds a simpler algorithm that just iterates through the flat
segments. It's faster in most practical cases.

`cargo bench --bench dag_ops -- descendants` shows improvements too:

Before:

  descendants (small subset)                        436.515 ms

After:

  descendants (small subset)                         33.460 ms

Reviewed By: sfilipco

Differential Revision: D23106174

fbshipit-source-id: e6101483d8539b2b1c881be2ccfd0071f122352f
2020-08-26 15:32:22 -07:00
Jun Wu
e22b816a12 dag: add iddag.iter_segments_ascending API
Summary: This will be used by upcoming changes.

Reviewed By: sfilipco

Differential Revision: D23106177

fbshipit-source-id: 9bf183f7464c06b801be64fd938db0babd544756
2020-08-26 15:32:21 -07:00
Jun Wu
0dcf08e509 dag: add SpanSetAsc struct
Summary: This internal struct will be used by upcoming changes.

Reviewed By: sfilipco

Differential Revision: D23106172

fbshipit-source-id: 6d5b9bc1c810984814d0912100acca38a2565a63
2020-08-26 15:32:21 -07:00
Durham Goode
201f63be32 build: rename third-party rust fbthrift crate
Summary:
Our internal build infra creates a workspace and workspaces don't like
it when two crates have the same name. Eden scm had third-party rust crates that
were simple redirects to the internal location, but had the same name. This
caused breakages once these crates became part of the edenfs open source build.
Let's rename them to avoid this issue.

Reviewed By: kulshrax

Differential Revision: D23252539

fbshipit-source-id: 9ff2fa160a19c6bc54e015c71f9da7044ce659a7
2020-08-26 12:26:21 -07:00
Durham Goode
2ab69d47f0 configs: disable chmod based test on Windows
Summary:
Windows doesn't seem to follow the same write permission rules, so
let's just skip that part of the test for now.

Reviewed By: xavierd

Differential Revision: D23348515

fbshipit-source-id: bfcfa4f8adf94413047b045987e570ba98f9078d
2020-08-26 09:19:35 -07:00
Stanislau Hlebik
d3ae17350c add hgcache size logger
Summary:
We'd like to keep track of hg cache size on users' machines. It's generally
useful, but it will be even more important with megarepo rollout. The job will be triggered by cron.

This is a very simple implementation, most of it was copy-pasted from
https://fburl.com/diffusion/g8ysyxo1.

Note that I intentionally didn't call hg to get hgcache size.
Since this binary will be triggered by cron, it will run as
root without a direct access to user's repository.

A few notes for the future:
1) Currentlly I'm planning to get hgcache path value from opsfiles.
I'm not sure if we'd need to change this  later when dynamic configs are fully
rolled out. CC DurhamG
2) We might want to track size of pack files (are they still used at all?) and
indexed log files separately

Reviewed By: ikostia

Differential Revision: D23341149

fbshipit-source-id: 2a600d7a8034ac887014788f1024fb9866c3ef76
2020-08-26 04:24:50 -07:00
Liubov Dmitrieva
50e7fd7ddd add enablestatus and enableprogress options to commitcloud
Summary:
Some user may think that the progress reporting is spammy, others can like it.
Make it configurable without disabling status completely.

We could explain the new config 'enableprogress' in the wiki for those who would like to disable the messages.

Also add 'enablestatus' under commitcloud section of config.

Reviewed By: markbt

Differential Revision: D23304206

fbshipit-source-id: 7735ae3284d19b9f1ea9da38b705a8932b34f91b
2020-08-26 02:51:37 -07:00
Liubov Dmitrieva
4f233b33f4 improve workspace information in hg cloud status
Summary:
It will be clearer to provide both names because all other commands (like `cloud
sl`, `cloud join`) use short names and if you would like to use the long one you would need to provide
'--raw-workspace' option and this is an advanced option.

Reviewed By: markbt

Differential Revision: D23274288

fbshipit-source-id: d751346a2e49cab21d1054eb196f7977c72c8764
2020-08-26 02:49:02 -07:00
Stefan Filip
72db1cbedb async-runtime: crate for async job scheduling from blocking threads
Summary:
We have a thread blocking application. We have async libraries. This crate
provides common utilities for communicating between the blocking world and the
async world. It is intended to be a guide so that not all developers have to
get in depth understanding of Tokio in order to use async functions.

Reviewed By: quark-zju, xavierd

Differential Revision: D23222876

fbshipit-source-id: b9a61795bc917bfc664c9d6da95c9e5e2d506c79
2020-08-26 00:57:32 -07:00
Arun Kulshreshtha
a99837c818 revisionstore: fix unused variable warnings on EdenApiStoreKind
Summary: The default method implementations on this trait were causing unused variable warnings. Prefix them with underscores to silence the warning and add `#![deny(warnings)]` to `revisionstore` to prevent future warnings from slipping through the cracks.

Reviewed By: singhsrb

Differential Revision: D23334309

fbshipit-source-id: d17b27ca0dd462e1613eac918fb595faa8637741
2020-08-25 21:53:22 -07:00
Durham Goode
8fa5577b30 tests: fix test-debugdynamicconfig.t again
Summary: My OSX fix broke Centos :(

Reviewed By: sfilipco

Differential Revision: D23331182

fbshipit-source-id: 07aa3f67f218e96f0021d10198aa4e0da0f6e2e8
2020-08-25 15:56:40 -07:00
David Tolnay
840e6dd6f6 edenapi: Unmanage Cargo.toml
Reviewed By: quark-zju

Differential Revision: D23329351

fbshipit-source-id: e07440a2ac5f93efda19e7a3c7d5e7ae18598c7d
2020-08-25 15:37:55 -07:00
Zeyi (Rice) Fan
619904bc69 re-implement normalize_windows_path
Summary: This diff fixes the issue that mkscratch does not build on Rust < 1.45.0

Reviewed By: xavierd

Differential Revision: D23325087

fbshipit-source-id: 7e737eb5bc0d75255a84c8ac353bf3a17c269300
2020-08-25 12:38:07 -07:00
Durham Goode
cbd1d445d0 tests: fix test-debugdynamicconfig.t
Summary:
This was just a dumb issue. I added a test that depended on the
previous logic which didn't run on OSX.

Reviewed By: kulshrax, singhsrb

Differential Revision: D23324601

fbshipit-source-id: 259175c91c9eb54e8350f196770ff967b53ee841
2020-08-25 11:59:32 -07:00
Durham Goode
18b20f4b24 configs: move dynamicconfig to be before system configs
Summary:
We want to eventually get rid of system and repo configs, but for now
they should take precedence over the dynamicconfigs. Previously we relied on
validation to remove any entries from dynamicconfig that interferes with a
system rc config, but in some code paths we didn't run that validation (like if
we loaded configs purely from Rust).

Let's just make dynamicconfig load before system configs. If validation doesn't
run, we might miss the case where dynamicconfig sets a value and the system rc
doesn't. But that's probably fine.

Reviewed By: quark-zju

Differential Revision: D23305711

fbshipit-source-id: 77b5f49d348cfa116694a641ed17e6d1184a81ab
2020-08-25 07:33:28 -07:00
Durham Goode
d643f48c8c configs: remove loaddynamicconfig option
Summary:
Dynamicconfigs are now part of our critical path. Let's remove the
option to not load them. This also let's us get rid of a circularl dependency
where loading dynamicconfigs required having already loaded some configs. This
will let us move dynammicconfig loading to be before system rc loading in a
later diff.

Reviewed By: sfilipco

Differential Revision: D23309090

fbshipit-source-id: 5138059a8ed944c3616007e7c1289b6a57be0e65
2020-08-25 07:33:28 -07:00
Durham Goode
a0184dde57 configs: validate config during all load paths
Summary:
An earlier diff moved all dynamicconfig loadding into Rust, but it lost
some of the config validation along the way. This allowed dynamicconfig values
to take precedence over system rcs when they shouldn't yet. Most notably the
remotefilelog.cachepath value.

Let's ensure validation is run on all load paths. A future diff will go a step
farther and move dynamicconfigs to be loaded before system configs so we can
ensure system configs always take precedence, until we can remove them entirely.

Reviewed By: quark-zju

Differential Revision: D23305712

fbshipit-source-id: 33a6b4c56d97fa2e2e8f3acc343a8a8868b797ef
2020-08-25 07:33:27 -07:00
Harvey Hunt
d7f58b3cfc python3: Don't access socket.error using an index to get errno
Summary:
Python 2's `socket.error` type provided a tuple of (errno, error
string) that could be used for identifying the specific error type. In Python 3
this was switched to an object that doesn't expose such an interface. As a
result, accessing `socket.error` using an index will cause an exception, such
as:

```
  File "/opt/fb/mercurial/edenscm/mercurial/keepalive.py", line 608, in safesend
    if v[0] == errno.EPIPE:  # Broken pipe
TypeError: 'BrokenPipeError' object is not subscriptable
```

Replace the use of indexing with accessing `.errno` instead, as this works for
both python 2 and python 3.

Differential Revision: D23294090

fbshipit-source-id: 5f901493c2db270817949d93840c6d469b17a560
2020-08-25 05:21:11 -07:00
Durham Goode
c42a494668 dynamicconfig: don't block read operations on dynamicconfig write permission errors
Summary:
Dynamicconfig was throwing errors if hgrc.dynamic wasn't writable.
Let's eat those errors for normal read operations. We still treat it as an error
for straight hg debugdynamicconfig invocations.

Reviewed By: quark-zju

Differential Revision: D23301100

fbshipit-source-id: ed0bd1282d2c7ee747f0909c238a5fa07b7bc9bc
2020-08-24 21:40:00 -07:00
Durham Goode
9b7b351ed9 configs: introduce test demonstrating permission denied error
Summary:
We've seen user reports of this error. Let's add a test to demonstrate
it. The next diff will fix it.

Reviewed By: sfilipco

Differential Revision: D23309612

fbshipit-source-id: 6fb9e4e65d3351fa29812fc75095d054465cfe13
2020-08-24 21:40:00 -07:00
Zeyi (Rice) Fan
7f0f310af3 handle extended-length on Windows
Summary:
On Windows, Rust's `std::fs::canonicalize` [1] will generate extended-length path that will include a `\\?\` prefix [2]. This has subsequently cause `encode` to generate a path that contains a question mark, which is an invalid path on Windows.

This diff teaches `encode` to handle extended-length path on Windows. It essentially converts the path back so it no longer contains the prefix.

[1] http://doc.rust-lang.org/1.45.2/std/fs/fn.canonicalize.html
[2] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation

Reviewed By: wez

Differential Revision: D22956659

fbshipit-source-id: 54691e204d7cb481bdb40f62c6520c0f70c3f648
2020-08-24 21:38:12 -07:00
Durham Goode
4a8a5290e8 curses: eat curses error for weird inputs
Summary:
In python 3 curses sometimes throws an error when weird keys are
pressed. I'm not certain exactly what key causes the problem, but let's just
prevent all such errors from crashing the process.

Reviewed By: quark-zju

Differential Revision: D23310301

fbshipit-source-id: a9684ce6f690d0753ff9956ef9f13c330eb0a77b
2020-08-24 20:16:41 -07:00
Jun Wu
7872c44fdf configparser: stabilize tests
Summary:
Add locking for tests reading / mutating global env vars.
Restore HG_TEST_REMOTE_CONFIG after testing.

Reviewed By: DurhamG

Differential Revision: D23269862

fbshipit-source-id: d61141b25c923a059de07c3dc8479f3bee06dce7
2020-08-24 12:36:09 -07:00
Pavel Aslanov
69e57b232d fix panic in slice index
Summary:
Based on [user report](https://fb.workplace.com/groups/scm/permalink/3128221090560823/).
Note that slices in rust behave differently and if index exceeds slice size this will always be panic. My fix was based on assumption that behavior should be similar to python.

Reviewed By: quark-zju

Differential Revision: D23263922

fbshipit-source-id: 3d2a1a1b59f14e43b1f1a2b7102982b11637c0b4
2020-08-24 05:24:58 -07:00
Jun Wu
34df768136 log: add a config to simplify graphs
Summary:
This could help simplify the graph a lot for repos with lots of merges. For
example, logging tags on linux.git looks like:

  o                      fb893de3  Yesterday at 17:28  master
  ├─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  bcf87687  Aug 02 at 14:21  v5.8
  ╷ ╷ ╷ ╭─────┬─┬───┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  92ed3019  Jul 26 at 14:14  v5.8-rc7
  ╷ ╷ ╷ ╭─────┬─┬─┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  ba47d845  Jul 19 at 15:41  v5.8-rc6
  ╷ ╷ ╷ ╭─┬─┬─┬─┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  11ba4688  Jul 12 at 16:34  v5.8-rc5
  ╷ ╷ ╷ ╭─┬─┬─┬─╯
  ╷ ╷ ╷ ╷ ╷ ╷ o  dcb7fd82  Jul 05 at 16:20  v5.8-rc4
  ╷ ╷ ╷ ╭─┬─┬─┤
  ╷ ╷ ╷ ╷ ╷ o ╷  9ebcfadb  Jun 28 at 15:00  v5.8-rc3
  ╷ ╷ ╭─┬─┬─╯ ╷
  ╷ ╷ ╷ ╷ o   ╷  48778464  Jun 21 at 15:45  v5.8-rc2
  ╷ ╷ ╷ ╭─╯   ╷
  ╷ ╷ ╷ o     ╷                      b3a9e3b9  Jun 14 at 12:45  v5.8-rc1
  ╭─┬─┬─┼─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─╮
  ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  3d77e6a8  May 31 at 16:49  v5.7
  ╭─┬─┴───────┬───────────┬─┬───┬─╮
  ╷ o   ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  9cb1fd0e  May 24 at 15:32  v5.7-rc7
  ╷ ╰─────────┬─────────────┬─┬─┬─╮
  ╷     ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  b9bbe6ed  May 17 at 16:48  v5.7-rc6
  ╭───────────┬─────────────┬─┬─┬─╯
  ╷     ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  2ef96a5b  May 10 at 15:16  v5.7-rc5
  ╭───────────┬─────────────┬─┬─╯
  ╷     ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  0e698dfa  May 03 at 14:56  v5.7-rc4
  ╭───────────┴───────────┬─┬─╮
  o     ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷  6a8b55ed  Apr 26 at 13:51  v5.7-rc3
  ╰─────────────────┬───────┬─╮
        ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ ╷ o  ae83d0b4  Apr 19 at 14:35  v5.7-rc2
        ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ ╭─┤
        ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷ ╷ o ╷  8f3d9f35  Apr 12 at 12:35  v5.7-rc1
  ╭─┬─┬───────┬─────┬─┬─┬─┬─┼─╮
  ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷  7111951b  Mar 29 at 15:25  v5.6
  ╷ ╭─────────┬─────┬─┬─┬─┴───╮
  ╷ ╷ ╷ ╷ ╷ ╷ o ╷ ╷ ╷ ╷ ╷   ╷ ╷  16fbf79b  Mar 22 at 18:31  v5.6-rc7
  ╷ ╷ ╭───────┴─────┬─┬─┬─────╮
  ╷ ╷ ╷ ╷ ╷ ╷   ╷ ╷ ╷ ╷ ╷   ╷ o  fb33c651  Mar 15 at 15:01  v5.6-rc6
  ╷ ╭─┬─────────────┬─┬─┬─────╯
  ╷ ╷ ╷ ╷ ╷ ╷   ╷ ╷ ╷ ╷ o   ╷  2c523b34  Mar 08 at 17:44  v5.6-rc5
  ╷ ╭─┬─────────────┬─┬─╯   ╷
  ╷ ╷ o ╷ ╷ ╷   ╷ ╷ ╷ ╷     ╷  98d54f81  Mar 01 at 14:38  v5.6-rc4
  ╷ ╭─┴─────────────┬─╮     ╷
  ╷ ╷   ╷ ╷ ╷   ╷ ╷ ╷ o     ╷  f8788d86  Feb 23 at 16:17  v5.6-rc3
  ....

And with simplification turned on, it looks like:

  o    fb893de3  Yesterday at 17:28  master
  ├─╮
  o ╷  bcf87687  Aug 02 at 14:21  v5.8
  ╷ ╷
  o ╷  92ed3019  Jul 26 at 14:14  v5.8-rc7
  ╷ ╷
  o ╷  ba47d845  Jul 19 at 15:41  v5.8-rc6
  ╷ ╷
  o ╷  11ba4688  Jul 12 at 16:34  v5.8-rc5
  ╷ ╷
  o ╷  dcb7fd82  Jul 05 at 16:20  v5.8-rc4
  ╷ ╷
  o ╷  9ebcfadb  Jun 28 at 15:00  v5.8-rc3
  ╷ ╷
  o ╷  48778464  Jun 21 at 15:45  v5.8-rc2
  ├─╯
  o  b3a9e3b9  Jun 14 at 12:45  v5.8-rc1
  ╷
  o  3d77e6a8  May 31 at 16:49  v5.7
  ╷
  o  9cb1fd0e  May 24 at 15:32  v5.7-rc7
  ╷
  o  b9bbe6ed  May 17 at 16:48  v5.7-rc6
  ╷
  o  2ef96a5b  May 10 at 15:16  v5.7-rc5
  ╷
  o  0e698dfa  May 03 at 14:56  v5.7-rc4
  ╷
  o  6a8b55ed  Apr 26 at 13:51  v5.7-rc3
  ╷
  o  ae83d0b4  Apr 19 at 14:35  v5.7-rc2
  ╷
  o  8f3d9f35  Apr 12 at 12:35  v5.7-rc1
  ╷
  o  7111951b  Mar 29 at 15:25  v5.6
  ╷
  o  16fbf79b  Mar 22 at 18:31  v5.6-rc7
  ╷
  o  fb33c651  Mar 15 at 15:01  v5.6-rc6
  ╷
  o  2c523b34  Mar 08 at 17:44  v5.6-rc5
  ╷
  o  98d54f81  Mar 01 at 14:38  v5.6-rc4
  ╷
  o  f8788d86  Feb 23 at 16:17  v5.6-rc3
  ....

Under the hood, the difference is how `reachableroots` gets calculated.
See also D22657197 (a5c36fd0b1) and D22368827 (da42f2c17e).

Since the old behavior almost always seems confusing to human. The new
config is turned on by default (but only takes effect if the "segments"
backend is used).

Reviewed By: sfilipco

Differential Revision: D23095468

fbshipit-source-id: f0fc631d2d9a00e3b36744e4236b43d230d10687
2020-08-21 17:10:36 -07:00
Mark Thomas
b9c0772f2f commitcloud: handle missing optional fields
Summary:
The files in commit cloud `References` structures are optional.  Handle them
not being present.

Reviewed By: quark-zju

Differential Revision: D23266786

fbshipit-source-id: ed7128bc7e6b762d3509d77b40a00b77885191b9
2020-08-21 13:52:02 -07:00
Jun Wu
e7f3167810 hgcommands: show milliseconds on RUST_LOG output
Summary: This makes it a bit easier to track down perf issues printed by RUST_LOGs.

Reviewed By: sfilipco

Differential Revision: D23095463

fbshipit-source-id: 78221a1992389f512fac6e6e633be6d19123e04a
2020-08-21 13:00:45 -07:00
Jun Wu
b4c9b6a7a1 test-git-changelog: fix the test on Windows
Summary:
Use `git config core.autocrlf false` to silent warnings like:

```
   $ git add alpha
+  warning: LF will be replaced by CRLF in alpha.
+  The file will have its original line endings in your working directory
```

Reviewed By: sfilipco

Differential Revision: D23270146

fbshipit-source-id: af3bf241edb9f615bcc285b51cc491385f208039
2020-08-21 13:00:45 -07:00
Liubov Dmitrieva
56e9cd9ed7 add undelete workspace command
Summary: The command is needed to restore a deleted workspace

Reviewed By: markbt

Differential Revision: D23250376

fbshipit-source-id: e24a7cbc0aad004291853b4c34d7474789aa9c2b
2020-08-21 13:00:45 -07:00
Jun Wu
d7cbb641ff dag: fix fuzz tests
Summary:
The fuzz tests need `TestContext::id_dag()`, which was removed by D20471712 (1fb5acf242).
Restore it so fuzz tests can run. This is mainly to check the new `range`
function.

The `range` fuzz test does find an issue caused by `>` written as `>=`
relatively quickly.

Reviewed By: sfilipco

Differential Revision: D23106176

fbshipit-source-id: e9540cc932503a9d54246d24c70bac829fcb13df
2020-08-21 13:00:45 -07:00
Jun Wu
60ebf5c2a0 changelog2: add SHA1 verification
Summary: Ensure that the commit text is verified, but do not verify git hashes.

Reviewed By: DurhamG

Differential Revision: D23095464

fbshipit-source-id: e62341f6c7258c6f18b7cc75088c25dfc7040ab1
2020-08-21 13:00:45 -07:00
Jun Wu
0dc28f689f changelog2: initial support for segmented git changelog
Summary:
The immediate goal is to run benchmarks on a commit graph provided by a git
repo without converting a whole (large) repo from git to hg. Note git repos can
be cloned in a shallow way so it only contains the commit graph. For example:

  git clone https://github.com/torvalds/linux --filter=tree:0 -n

Note: The above command writes repositoryformat=1 in `.git/config`
which is not supported by libgit2. Manually editing it to repositoryformat=0
would enable libgit2 to read it for this crate's use-case.

In the longer term we might want to extend the support so refs/trees/files can
be read/written directly via the git repo based on this work. However that's
currently beyond scope.

Reviewed By: DurhamG

Differential Revision: D23095467

fbshipit-source-id: 868beb0c7de60453b47962639863eb8f7e3f5753
2020-08-21 13:00:45 -07:00
Jun Wu
749602e534 hgcommits: add gitsegments backend
Summary:
The backend translates git commit graph to segments. It's useful for
benchmarking on git commit graphs.

Reviewed By: DurhamG

Differential Revision: D23095470

fbshipit-source-id: 21a28869e91ef8f38bbf9925443eb4ac26f05e3d
2020-08-21 13:00:45 -07:00
Jun Wu
d352133d6d hgcommits: use concrete error types
Summary: Migrate to concrete types so it can be typechecked.

Reviewed By: DurhamG

Differential Revision: D23095469

fbshipit-source-id: 27c6da30ca8a1329df544cd2ded7d9734593e48a
2020-08-21 13:00:45 -07:00
Jun Wu
e5527715b7 gitdag: crate to build segmented dag from git history
Summary:
Read git commit graph and migrate them to `dag::Dag`.

This allows using Rust dag abstractions on the git
commit graph.

Reviewed By: DurhamG

Differential Revision: D23095471

fbshipit-source-id: 2163701350ce82ce6e97074e56ad5877f3c9c158
2020-08-21 13:00:45 -07:00
Jun Wu
aa6575e377 revset: optimize revset functions using rust fast paths
Summary:
Add alternative paths will be faster if changelog2 is used, since they are
backed by native paths.

Add a config option to disable the fast paths if they cause issues.

Reviewed By: DurhamG

Differential Revision: D23036074

fbshipit-source-id: 489b6eac64148867c209d595623d0b9c21ad1d5a
2020-08-21 13:00:45 -07:00
Durham Goode
7fbac081e2 configs: fix osx test runs
Summary:
OSX doesn't support touch -d. Let's just skip that part of the test on
that platform. This fixes the OSX build.

Reviewed By: singhsrb

Differential Revision: D23253475

fbshipit-source-id: 0eccb884cbdd4bf0a4068fbf943ba7dac9df4e04
2020-08-21 13:00:45 -07:00
Jun Wu
d6bff56df1 smartlog: migrate some revset calculation to a faster path
Summary:
Detect the "segments" backend and calculate the revset differently.

Practically, with collapse-obsolete disabled, the time of related revset
calculation drops from 0.14s to 0.03s in my fbsource repo.

The `obsolete()` set calculation is expensive (0.4-0.6s) and a bit more
expensive with the new DAG APIs, which will be addressed in upcoming
changes. EDIT: Addressed by D23036063.

Reviewed By: DurhamG

Differential Revision: D23036055

fbshipit-source-id: 71140a88599cc68bfa90d564c786da89b3ebd38b
2020-08-21 13:00:45 -07:00
Jun Wu
8c9f1f5cee test-smartlog: avoid using rev numbers
Summary: Migrated by `./fix-revnum.py`.

Reviewed By: DurhamG

Differential Revision: D23036082

fbshipit-source-id: cf456b3625e39329c817c696691494dc6725bc22
2020-08-21 13:00:45 -07:00
Jun Wu
fb38ea9152 test-smartlog: use explicit template
Summary:
The `compact` template is rarely used and is coupled with rev numbers (ex. rev
number decides what "parents" to show). Use explicit templates.  This makes the
test change easier to check.

Reviewed By: DurhamG

Differential Revision: D23036076

fbshipit-source-id: f2cc0f25191711fa7d846a8ad38aee8fb9171273
2020-08-21 13:00:45 -07:00
Jun Wu
e1ad0df320 commitcloud: optimize revset for segmented changelog backend
Summary:
The `notbackedup()` revset is used as part of `summary` that prints information
at the end of `smartlog`. It can take hundreds of milliseconds if there are
many heads. Detect segmented changelog and use a fast path for it.

Practically this reduces `summary` from 594ms to 91ms for me:

With segmented changelog (doublewrite backend) and new code path:

    91    \ summary                             status.py:23
     2      \ currentworkspace                  workspace.py:121
     3       | _get (2 times)                   workspace.py:110
     3       | read (2 times)                   config.py:195
     3       | parse (2 times)                  config.py:116
     2       | compile (14 times)               util.py:1464
     3      \ __init__                          syncstate.py:44
    82      \ revs                              localrepo.py:1203

With revlog and old code path:

   594    \ summary                             status.py:23
     2      \ currentworkspace                  workspace.py:121
     4       | _get (2 times)                   workspace.py:110
     3       | read (2 times)                   config.py:195
     3       | parse (2 times)                  config.py:116
     3       | compile (14 times)               util.py:1464
     3      \ __init__                          syncstate.py:44
    46      \ revs                              localrepo.py:1203
   539      \ _iterfilter                       smartset.py:647
   538       | <lambda> (1565 times)            commitcloud/__init__.py:371
   537       | __contains__ (1565 times)        smartset.py:1039
   533       | _consumegen (17355 times)        smartset.py:1122

Reviewed By: markbt

Differential Revision: D23036075

fbshipit-source-id: 09dcc34f34a42814c6526e558d40b4d75ba9d75f
2020-08-21 13:00:45 -07:00
Jun Wu
f26dfc7d46 pymutationstore: make getdag support selecting successors or predecessors
Summary: Expose the Rust API so `getdag` can choose to skip successors or predecessors.

Reviewed By: markbt

Differential Revision: D23036056

fbshipit-source-id: 30cd437c5420d2d10176e33ef9de98814046f4ce
2020-08-21 13:00:45 -07:00
Jun Wu
45db3bbf96 mutationstore: add a native path to calculate 'obsolete()'
Summary:
The new path does not calculate the complicated `successorssets`, and is
known to make wez's repo operations significantly faster (which, I suspect is
slowed by a very long chain).

The new code is about 3x faster on my repo too:

  # before
  In [1]: list(repo.nodes('draft()'))
  In [2]: %time len(m.mutation.obsoletenodes(repo))
  CPU times: user 246 ms, sys: 42.2 ms, total: 288 ms
  Wall time: 316 ms
  Out[2]: 1127

  # after
  In [1]: list(repo.nodes('draft()'))
  In [2]: %time len(m.mutation.obsoletenodes(repo))
  CPU times: user 74.3 ms, sys: 7.92 ms, total: 82.3 ms
  Wall time: 82.3 ms
  Out[2]: 1127

Reviewed By: markbt

Differential Revision: D23036063

fbshipit-source-id: afd6ac122bb5d8d513b5cdc033e04d2c377286eb
2020-08-21 13:00:45 -07:00
Jun Wu
78477ad9c5 mutationstore: optimize get_dag
Summary:
Optimize get_dag:
- Avoid parsing mutation entries once they are parsed, by keeping an in-memory
  `parent_map`.
- Pass `heads` to `add_heads` so the segments are less fragmented, cycle break
  helper is more efficient.

The `heads` optimization is effective. Practically this makes `get_dag` about 2x faster.

This has a subtle change on cycle handling - full cycle without any non-cycle heads will
be ignored. Practically cycles are rare so it might be okay.

Together with improvements on the `dag` side, `get_dag` is about 4x faster.

Reviewed By: markbt

Differential Revision: D23036062

fbshipit-source-id: 3dc407b562f7ebf2543a87c5cd651ad6a2339d67
2020-08-21 13:00:45 -07:00
Jun Wu
be2d28fb95 dag: fix non-master high-level segments building
Summary:
If there is no new master segments, it's still possible to have new non-master
segments. Fix the loop condition so we don't skip building non-master segments.

Reviewed By: sfilipco

Differential Revision: D23095465

fbshipit-source-id: 46eb9d5b5f2b04241981558646e0bc090652abce
2020-08-21 13:00:45 -07:00
Jun Wu
e11f36e96b dag: test high-level segments building for non-master
Summary:
I noticed that high-level segments are somehow not built for non-master vertexes.
Add a test to demonstrate the issue.

Reviewed By: DurhamG, sfilipco

Differential Revision: D23095466

fbshipit-source-id: c5a6da14bdfabcf7c432f6c6dfe096c71cc10ee9
2020-08-21 13:00:45 -07:00
Jun Wu
23074edd9b dag: add some tracing spans
Summary: This is useful to investigate internals of dag calculations.

Reviewed By: sfilipco

Differential Revision: D23095473

fbshipit-source-id: 4750c1b4ffad32b1317051d17db9659aaaed59c4
2020-08-21 13:00:45 -07:00
Jun Wu
cd9aa9cb6c dag: improve segment building perf by using precalculated flat segments
Summary:
Follow up of the previous change by actually using the flat segments to build
segments. This significantly improved the perf. `cargo bench --bench dag_ops`
shows:

  building segments (old)                           774.109 ms
  building segments (new)                           143.879 ms

Besides, a `O(N^2)` update to `head_ids` is changed. It improves performance
when the graph has many heads (ex. the mutation graph).

Reviewed By: sfilipco

Differential Revision: D23036080

fbshipit-source-id: 033565700f253c6f20e30a00adb6b579921d6679
2020-08-21 13:00:45 -07:00
Jun Wu
9c9ecbc82b dag: make IdMap::assign_head calculate flat segments
Summary:
While testing the `obsolete()` set, I found an in-memory segmented DAG takes
10x time to build than a HashMap DAG.

Part of the inefficiency is to use a translated "parent_func" that round-trips
through Id and Vertex, used by segment building logic. This diff makes
`IdMap::assign_head` return flat segments, so we don't need a translated
"parent_func" to build flat segments.

This diff only adds checks to make sure the parent_func (Id version) matches
the segments. The next diff switches the segment building to not use the
translated parent_func.

Reviewed By: sfilipco

Differential Revision: D23036060

fbshipit-source-id: 99137f4b5be455cdf43218ba23eb3954b6d9e05a
2020-08-21 13:00:45 -07:00
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
Mark Thomas
2117806dc7 tests: convert dummyssh and get_free_socket to python3
Summary: Convert dummyssh and get_free_socket to full python3 binaries.

Reviewed By: johansglock

Differential Revision: D23105490

fbshipit-source-id: 6c39c32ba0728cde108b42245acece1d7828ac7c
2020-08-17 02:42:14 -07:00
Durham Goode
33a634167e dynamicconfig: support a disallowlist config
Summary:
This new disallowlist will let us specify config section.key's which
should not be accepted from old rc files. This will let us incrementally disable
loading of those configs from the old files, which will then let us delete them
from the old rc's and eventually delete the old rc's entirely.

This diff also removes hgrc.local and hgrc.od from the list of configs we
verify, since those are not on the list of configs that need to be removed in
this initiative.

Reviewed By: quark-zju

Differential Revision: D23065595

fbshipit-source-id: 5cd742d099efd651174cab5e87bb7cdc4bae8054
2020-08-16 16:56:00 -07:00
Durham Goode
0cf7ebeffe configs: make backingstore load hg configs through the approved path
Summary:
Previously the backing store was loading configs manually. Now that
system, dynamic, user, and repo config loading are unified, let's go through
that approved path.

Reviewed By: kulshrax

Differential Revision: D22736338

fbshipit-source-id: 232023e660107a096691e9d99bf89c04c218dfbd
2020-08-16 16:56:00 -07:00
Durham Goode
6da00020eb configs: move all dynamic and repo config loading out of Python
Summary:
The last few diffs prepared Rust for loading dynamic and repo configs.
This diff finally changes Python so that we're no longer doing any of this work
in Python.

Reviewed By: quark-zju

Differential Revision: D22712625

fbshipit-source-id: 0b71e81d79d10ea3ce7a1b31f315ada5728af9a9
2020-08-16 16:56:00 -07:00
Durham Goode
2da121cb60 configs: add rust support for loading dynamic and repo configs
Summary:
This threads the calls to load_dynamic and load_repo through the Rust
layer up to the Python bindings. This diff does 2 notable things:

1. It adds a reload API for reloading configs in place, versus creating a new
one. This will be used in localrepo.__init__ to construct a new config for the
repo while still maintaining the old pinned values from the copied ui.
2. It threads a repo path and readonly config list from Python down to the Rust
code. This allows load_dynamic and load_repo to operate on the repo path, and
allows the readonly filter to applied to all configs during reloading.

Reviewed By: quark-zju

Differential Revision: D22712623

fbshipit-source-id: a0f372f4971c5feac2f20e89a0fb3fe6d4a65d6f
2020-08-16 16:56:00 -07:00
Durham Goode
6b0014490c configs: implement dynamic and repo config loading in Rust
Summary:
In a future diff we'll enable dynamic and repo config loading purely
from Rust. To do so we need load functions for both cases.  A future diff will
call these.

The dynamicconfig loading is based off the Python equivalent in uiconfig.py

Reviewed By: quark-zju

Differential Revision: D22712624

fbshipit-source-id: ff46f6315fb80d4cd9e31d875ac60264563b12f2
2020-08-16 16:56:00 -07:00
Durham Goode
194e815245 configs: move HGRCPATH loading to load_system
Summary:
Previously load_system would skip loading if HGRCPATH was present and
then load_user would actually load the HGRCPATH. In an upcoming diff I add
load_dynamic, which happens after system but before user. The tests for
dynamicconfig depend on HGRCPATH being loaded when load_dynamic runs, so let's
move HGRCPATH loading up to load_system.

Reviewed By: quark-zju

Differential Revision: D22712627

fbshipit-source-id: 91175d9d7f85b9392ffea4af815a4facebbfe7c1
2020-08-16 16:56:00 -07:00
Durham Goode
ef9ba19dc5 configs: make Options clonable
Summary:
In a future diff we'll allow an outside caller to pass an Options down
to configparsers::hg::load() so that filters can be applied during loading. Inside
hg::load() we need to use the options multiple times with different values, so
let's make Options clonable.

Reviewed By: quark-zju

Differential Revision: D22712626

fbshipit-source-id: 975145f38d35afe7d4a6c8e87071b0fb0ae74797
2020-08-16 16:55:59 -07:00
Durham Goode
0cea385252 configs: remove config from repo.rs API
Summary:
A future diff will move all dynamic and repo config loading to be in
configparser. As part of this, let's simplify the repo.rs API to not pass
configs around everywhere.

Reviewed By: quark-zju

Differential Revision: D22712628

fbshipit-source-id: 79f23991aa826ce8b4f7430b45d7702efdc6b982
2020-08-16 16:55:59 -07:00
Durham Goode
26564596a1 utils: add background process utility
Summary:
Similar to the Python runbgcommand (extutil.py), this is a Rust utility that runs a
detached background process in a cross platform way.

This will be used in a later diff to run dynamicconfig generation in the
background.

Reviewed By: quark-zju

Differential Revision: D22712629

fbshipit-source-id: a317465bf03c96d977a203678e2bef13ce57cc12
2020-08-16 16:55:59 -07:00
Durham Goode
0b123ba41d configs: move Rust dynamicconfig generation into configparser::hg
Summary:
As part of moving all hg config loading and generation logic into Rust,
let's move the config generation logic from hgcommands and pyconfigparser to
configparser, unifying them at the same time.

Future diffs will move config loading in as well.

Reviewed By: quark-zju

Differential Revision: D22590208

fbshipit-source-id: d1760c404a6a5c57347df30713c20de55cfdb9a4
2020-08-16 16:55:59 -07:00
Durham Goode
7ff28d3e1c configs: move dynamicconfig into configparser
Summary:
A future diff will unify all config loading into configparser::hg, but
to do so we need dynamicconfig to live in configparser, so it can load
dynamicconfigs. Let's move everything in.

Reviewed By: quark-zju

Differential Revision: D22587237

fbshipit-source-id: 5613094175b6e1597aa113ee3e6d92ce7ec79f6d
2020-08-16 16:55:59 -07:00
Durham Goode
a40331be8d configs: unify system+user config loading into pure rust layer
Summary:
We had two spots that loaded system and user configs, one in the
pyconfigparser layer, and one in the pure rust config layer. In an upcoming diff
I'd like to move dynamicconfig loading down into the pure rust layer, so let's
unify these.

Reviewed By: quark-zju

Differential Revision: D22585554

fbshipit-source-id: 0cea7801ae1d5a3a3c12b80ee23b37f9e690e2bc
2020-08-16 16:55:59 -07:00
Durham Goode
3129f032a4 contentstore: make history rotatelog size configurable
Summary:
In a future diff we'll increase the size of the rotatelog temporarily
during clones. To do so we need it to be configurable.

Reviewed By: quark-zju

Differential Revision: D23089539

fbshipit-source-id: ebfc3beaf3c0fe5b01b87d97c19455b0a24afa72
2020-08-16 16:44:16 -07:00
Durham Goode
b821ab3766 contentstore: make data rotatelog size configurable
Summary:
In a future diff we'll increase the size of the rotatelog temporarily
during clones. To do so we need it to be configurable.

Reviewed By: quark-zju

Differential Revision: D23089541

fbshipit-source-id: 5010e417a83a2611283322f1dbb7023f4286f503
2020-08-16 16:44:16 -07:00
Durham Goode
76d3d46837 revisionstore: remove from_path from LocalStore
Summary:
from_path is an awkward constructor because it doesn't pass any other
information, like a config object. It also requires that the constructor be very
generic across all the stores. Right now it's only needed for pack files, so
let's move it to it's own trait that is limited to pack files.

This will allow us to make the indexedlog store constructors more versatile in a
later diff. Once we get rid of pack files we can delete the StoreFromPath trait
entirely.

Reviewed By: xavierd

Differential Revision: D23089542

fbshipit-source-id: ea6c50853e5d5390a029002ef5d15c74fe41fe69
2020-08-16 16:44:16 -07:00
Jun Wu
f61aaf3a15 repo: add dageval API
Summary:
Similar to `changelog.dageval`, but provides extra functions like `public`,
`draft`, `obsolete`, etc.

Reviewed By: sfilipco

Differential Revision: D23036070

fbshipit-source-id: b985f2b338a3dce11bddf53c00c30e4887762676
2020-08-14 22:00:26 -07:00
Jun Wu
a3531f9a8e changelog2: improve dageval
Summary:
Make it work with closure and `lambda dag: dag.only(...)`.
This is useful when there is a name conflict with a local variable, like:

   only = ...
   cl.dageval(lambda: only(...)) # only refers to the local variable.
   cl.dageval(lambda dag: dag.only(...)) # only refers to the dag operation.

Besides, drop `func_` so they are Py3 compatible.

Reviewed By: sfilipco

Differential Revision: D23036064

fbshipit-source-id: 8d32a34c51b6ba945cda5be313f9d71464f813b7
2020-08-14 22:00:26 -07:00