Commit Graph

47118 Commits

Author SHA1 Message Date
Thomas Orozco
38e82ab70c lfs: log lfs_url
Summary:
This adds the `lfs_url` to our logs, which makes it easier to identify the
vip we're trying to talk to, and will make it easier to monitor for errors if
any come up.

Reviewed By: HarveyHunt

Differential Revision: D17474943

fbshipit-source-id: 5f67665cffa878966e5d49fae672ff1be571690e
2019-09-19 05:16:32 -07:00
Jun Wu
b737973619 merge: make it possible to manually specify a rename destination
Summary:
When the rebase destination has renamed a file, and copytrace failed to figure
out anything useful, make it possible to manually input the rename destination.

I'm using it to resolve conflicts caused by landing the bindings rename.

Reviewed By: xavierd

Differential Revision: D17367857

fbshipit-source-id: 55d9ed3a9641e40cc43518e9662fd803cbc00620
2019-09-18 20:44:05 -07:00
Xavier Deguillard
a55686ab8e remotefilelog: split remotefilelog.cacheprocess config option
Summary:
The cacheprocess config is of the form: memcache_client key. With the memcache
client moving in process, the memcache_client binary is not of interest, but
the key is.

Reviewed By: quark-zju

Differential Revision: D17438697

fbshipit-source-id: 925c6e4c390f975825afef01fbd87a9331894e81
2019-09-18 08:57:03 -07:00
Ron Mordechai
4d1577a9c2 merge-tools: look for merge-tools inside repo when relative path is supplied
Summary:
This is useful when writing merge tools that are checked into the repo. We can now reference a tool in the repo. Suggested use case:

  [merge-tools]
  mytool =
  mytool.executable = scripts/mytool.py

Reviewed By: quark-zju

Differential Revision: D17342897

fbshipit-source-id: ffdb160dfea8404721c4fc94fdfcab2d86cca08d
2019-09-18 07:12:18 -07:00
Jun Wu
0dda4d7bae bindings: add a way to calculate heads(ancestors(revs))
Summary:
Per team meeting, we want to remove whole changelog scans that are incompatible
with the upcoming dag changes.

Heads calculation is one of such "whole changelog scans".

The plan is to use visibility heads + remote names to answer `head()`. However,
remote names are not guarnateed to be heads. For example, `stable` might be
an ancestor of `master`. To get the right answer about `head()`, some
calculation like `heads(::(remotenames() + visible-heads()))` needs to be done.

Calculating `heads(ancestors(...))` in Python is quite slow. This diff provides
a native fast path for it. It still requires a partial changelog scan, but will be
compatible with the future dag-based commit graph.

Reviewed By: sfilipco

Differential Revision: D17199841

fbshipit-source-id: 6ea4367b8877209899d56094f8d8ee1aff1ad6f3
2019-09-17 18:15:20 -07:00
Jun Wu
22526b0f3f bindings: add a way to calculate phases by heads
Summary:
Add a function to do "head-based phases" calculation on the revlog. So we can
experiment the breaking change, since phases are no longer root-based, and
are probably defined by remotenames and visibility heads.

The segmented changelog structure will drop support for root-based phases for
performance.

Reviewed By: sfilipco

Differential Revision: D17199844

fbshipit-source-id: 4a4dba183bb5f751b0cf454b9fc2b7e601e8c491
2019-09-17 18:15:19 -07:00
Jun Wu
d2fbb0164e bindings: add revlogindex
Summary:
This module is inteneded to have native paths for some operations that need to
scan the whole changelog. It allows us to experiment some breaking changes,
namely, head-based visibility without "filtered revs", head-based phases on
the revlog format, before the more advanced structure taking over.

This diff adds a revlog index reader that can answer do simple queries like
"length", "parents".

Reviewed By: sfilipco

Differential Revision: D17199837

fbshipit-source-id: 2574f64c980419fa966200fd52fa5ddf873baae4
2019-09-17 18:15:19 -07:00
Jun Wu
493a96a006 bindings: add more methods to dag.spans
Summary:
Expose more methods in Rust to Python.

As we're here, change `__contains__` to take a signed int so `-1 in set` test
won't trigger an error.

Reviewed By: sfilipco

Differential Revision: D17244562

fbshipit-source-id: 0b8b9069bd0a35615066d1328933ca50b09b4a25
2019-09-17 18:15:19 -07:00
Jun Wu
75ebf84a46 changelog: add a method to get public/draft nodes from remotenames
Summary:
One step towards redefining heads with remote heads.

Debugshell was teached to skip IPython for non-interactive input.

(For some reason most part of this diff got folded into the previous one)

Reviewed By: sfilipco

Differential Revision: D17199842

fbshipit-source-id: 1594658e3e5f2f2c51f817bc1074d28329df7786
2019-09-17 18:15:19 -07:00
Jun Wu
5dd6fe1be3 configparser: add type conversions
Summary:
This is to match APIs like `ui.configbool` in the Python land.

The new APIs use string types to make them easier to use.

Reviewed By: xavierd

Differential Revision: D17423798

fbshipit-source-id: 747b094c4cc6afef2e818a1862e820647328c4c2
2019-09-17 15:43:11 -07:00
Aleksei Kulikov
239651f2fa snapshot: add snapshot to setup.py
Reviewed By: markbt

Differential Revision: D17427796

fbshipit-source-id: 57346df9201d8d372b9191e96d97f4bc830a3469
2019-09-17 13:57:22 -07:00
Jun Wu
eab358c1b0 dag: implement descendants
Summary: The implemenation is based on `range`.

Reviewed By: sfilipco

Differential Revision: D17002967

fbshipit-source-id: f59e1686306b9fc08dbca9891c2b6d6c42be2717
2019-09-17 12:36:45 -07:00
Jun Wu
d583737041 dag: implement Dag::all
Summary:
This function sets the proper "upper bound" in the Dag. It can be used together
with other functions, like `roots` and `heads`.

Reviewed By: sfilipco

Differential Revision: D17002968

fbshipit-source-id: 581a2acea73d6439ffb47442f12e8f009ba6aa8c
2019-09-17 12:36:44 -07:00
Jun Wu
74f1c789eb dag: rename functions and constants to clarify the index also takes "level"
Summary: Make it clear that the index takes `level`.

Reviewed By: sfilipco

Differential Revision: D17002966

fbshipit-source-id: 376347964b684579b49d40fc202a37797131ac65
2019-09-17 12:36:44 -07:00
Jun Wu
a672bc059f dag: rename find_segment_including_id to find_flat_segment_including_id
Summary:
The function is capable of handling all levels. But practically only used for
the flat level. Rename it and drop the `level` parameter.

Reviewed By: singhsrb

Differential Revision: D17002969

fbshipit-source-id: e5b99142b6612a80237b4af2706eba51f3794c88
2019-09-17 12:36:44 -07:00
Jun Wu
d10dab5342 dag: make sure Dag has complete high-level segments when SyncableDag gets dropped
Summary:
Previously, `SyncableDag` and `Dag` can co-exist. Dropping SyncableDag involves
error handling and is not panic-free. If we want to make sure `Dag` has complete
high-level segments, then it would have been implemented in `SyncableDag::drop`,
making it more sensitive to panic.

Change the API so `SyncableDag` is independent from `Dag`, so `Dag` always
has complete segments, and changes to `SyncableDag` are invisible to `Dag`,
so `SyncableDag` cannot mess up existing `Dag` structures.

Reviewed By: sfilipco

Differential Revision: D17000969

fbshipit-source-id: 1ceed4ea335d3d64848b7430d48076846b90695d
2019-09-17 12:36:44 -07:00
Jun Wu
c28623ef7d indexedlog: implement Log::clone
Summary: Similar to Index::clone, this makes it possible to clone a Log.

Reviewed By: sfilipco

Differential Revision: D17379310

fbshipit-source-id: f28c4b60d256b282491a93c3cd39138ebbe71131
2019-09-17 12:36:43 -07:00
Jun Wu
a0ede6c4c6 progressfile: include pid in progress information
Summary:
This provides a way to check if the hg process was gone unexpectedly.
The motivation was to make it less likely that Nuclide shows an hg operation
was ongoing but the process was long gone.

Reviewed By: xavierd

Differential Revision: D17372808

fbshipit-source-id: 19e51f8bbd0fdf14b7e0a4bdb8247d1b4277ee48
2019-09-16 19:02:38 -07:00
Jun Wu
257b0b053d bindings: add vlq.read API
Summary: This makes it possible to decode VLQ from a stream.

Reviewed By: alexeyqu

Differential Revision: D17404066

fbshipit-source-id: 4a3b0e5333664c3cfc0f76bbdc7db80c25a3a49c
2019-09-16 14:01:15 -07:00
Xavier Deguillard
2621bdd5bf util: add a create_dir function
Summary:
The function just wraps `std::fs::create_dir` and ignore the errors when the
directory already exists.

Reviewed By: quark-zju

Differential Revision: D17357936

fbshipit-source-id: 3a0b2d027aa9425877b288e43feeb9dbeba78651
2019-09-16 09:42:36 -07:00
Xavier Deguillard
5aaaef2d1d util: move revisionstore::vfs into it
Summary: The util crate is better fitted for this.

Reviewed By: quark-zju

Differential Revision: D17379053

fbshipit-source-id: 0d440eed2275572aadff2749d9068d38f7545f9d
2019-09-16 09:42:35 -07:00
Xavier Deguillard
b6b296ab11 revisionstore: add Mutable{HistoryPackStore,DataPackStore}
Summary:
Similarly to the IndexedLog based store, let's also enable writing to the
packstore. One big benefit of doing that is that it will greatly reduce the
need for rescanning the filesystem when new packfiles are created.

The read-only version are for now kept as they are being exposed to Python,
long term, the read-only will be made private and the Mutable version renamed.

Reviewed By: kulshrax

Differential Revision: D17357937

fbshipit-source-id: 0f440d5668ca8b412300ff3519a233d1449a464d
2019-09-16 09:42:35 -07:00
Wez Furlong
227bd1e176 mkscratch: add $REPO_OWNER_HOME
Summary:
$HOME and $USER can vary depending on whether sudo is used or
not.  In the mixed owner situations that tend to crop up at FB we
generally want to consider the user and home dir of the owner of the
repo rather than whatever the current user is.

This diff adds a `REPO_OWNER_HOME` replacement token that resolves
the owner of the repo and then looks up their home directory.

Reviewed By: simpkins

Differential Revision: D17335435

fbshipit-source-id: bf81565abdf66084b93c3411ae6b58af0c4a6143
2019-09-16 08:50:48 -07:00
Wez Furlong
5d370cf8be mkscratch: if run as root, chown files/dirs to the repo owner user
Summary:
If we are run as root then set the owner of any files or
directories that we create to the owner of the repo.

This helps to avoid some classes of problems if there are mixed
invocations with root and repo owner.

Note that I picked a string to represent the user largely because
I can see us wanting to specify the user in the config file
using a string at some point in the future.

It is also slightly more portable (even though it isn't native)
than doing something funky with uid/gid on posix and something
involving security descriptors or DACLs on windows.

Reviewed By: chadaustin

Differential Revision: D17335433

fbshipit-source-id: 33c1d1cdbe4d07ce4d4f2581206f1308e3b29290
2019-09-16 08:50:48 -07:00
Wez Furlong
4bb0fd30d2 mkscratch: use PasswordEntry::by_uid for looking up existing info
Summary:
This is a trivial change to use the new helpers added
in the previous diff

Reviewed By: chadaustin

Differential Revision: D17335434

fbshipit-source-id: feb6fa5cee2e2775e89ba330916327e52ffe9394
2019-09-16 08:50:47 -07:00
Wez Furlong
2389af5ae0 mkscratch: add helpers for looking up user information
Summary:
These make it slightly more ergonomic to lookup
user information either by name or uid on unix systems
in the diffs that follow in this stack.

Reviewed By: chadaustin

Differential Revision: D17335436

fbshipit-source-id: 61cabe368504ad32dfa9ca52bbdd106ddbca289a
2019-09-16 08:50:47 -07:00
Jun Wu
bbd4b91102 remotenames: move 'remotenames' state to storevfs
Summary:
In the future the changelog would need to access 'remotenames' to figure out
public heads. Move the state file to svfs so it can be read by the changelog
object, which only has access to svfs.

Reviewed By: sfilipco

Differential Revision: D17199834

fbshipit-source-id: 9000e0d8e8bb8d398d6c77b5b395da904fef6418
2019-09-13 20:19:09 -07:00
Jun Wu
47a4b0a347 indexedlog: make it possible to clone Index without dirty parts
Summary:
This will be used in a later change.

I found ChecksumTable::clone crash when the file is empty. That was fixed as
part of the change.

Reviewed By: sfilipco

Differential Revision: D17379311

fbshipit-source-id: 0e43e8559f0628008e10f1e619a0523474c4094f
2019-09-13 19:31:04 -07:00
Jun Wu
5b55b7e3a1 dag: disallow Deref from SyncableDag to Dag
Summary:
SyncableDag might have lagging high-level segemnts that break the "high-level
segements cover all flat segments" assumption by some DAG algorithms (children,
range).

Remove Deref so those DAG algorithms cannot run on a SyncableDag.

Reviewed By: sfilipco

Differential Revision: D17000967

fbshipit-source-id: 953589ddd8388340a2913b530f442028810296de
2019-09-13 19:31:03 -07:00
Jun Wu
9541d0e129 dag: remove unused parameter
Summary: After D17000965, the parameter is no longer used.

Reviewed By: sfilipco

Differential Revision: D17379312

fbshipit-source-id: c6a12ee27a54efcec5caa1769f04095e16dd5995
2019-09-13 19:31:03 -07:00
Jun Wu
b3eb5bf97d dag: refactor segment building APIs
Summary:
Previously, the `Dag` has 2 low-level `build_segemnts` APIs:

- Dag::build_flat_segments(..., last_threshold)
- Dag::build_high_level_segments(..., drop_last)

They allow customization about whether the segments are lagging or not.

However, certain algorithms (ex. children and range) now require the high level
segments to cover everything covered by the flat segments. The above APIs
wouldn't ensure that.

This diff refactors the segment building APIs so that:

- Make `build_flat_segments`, and `build_high_level_segments` private to
  prevent misuse.
- Ensure high level segments cover flat segments at `Dag::open` and
  `Dag::build_segments_volatile`, the only ways to change `Dag`.
- Provide different APIs suitable for different (one-time in-memory vs
  on-disk) use-cases. The on-disk `build_segments_persistent` API makes high
  level segments lagging to avoid fragmentation, while the in-memory
  `build_segments_volatile` does not.

To satisfy the existing test need, a `set_segment_size` API was added to
override the default segment size.

Most callsites become simpler because they no longer need to figure out
details about segment size, level, and lagging.

Reviewed By: sfilipco

Differential Revision: D17000965

fbshipit-source-id: 78bb0c7674c99e91be6011bb7e623cd4f63b1521
2019-09-13 19:31:03 -07:00
Jun Wu
00188de9fe dag: add parent_ids function
Summary:
Parents are ordered and the order can be important. The flat segments preserve
the order but there are no APIs exposing the parent order. Define one.

Reviewed By: markbt

Differential Revision: D17000966

fbshipit-source-id: 66beb53d9cef651a53391707c0b690a1e3b76ce2
2019-09-13 19:31:03 -07:00
Jun Wu
56e112d11d indexedlog: add a way to remove dirty entries in Log
Summary: See the previous diff for motivation.

Reviewed By: sfilipco

Differential Revision: D17000964

fbshipit-source-id: 3bf112e4b608cf06bf9082d993635df1d65a81fa
2019-09-13 19:31:02 -07:00
Jun Wu
b1a8692ec9 indexedlog: add a way to remove dirty entries in Index
Summary:
Segmented changelog wants:
- Entries stored on disk is lagging (i.e. the last segment per each level is
  dropped to avoid fragmentation)
- Entries in memory is not lagging.

To ensure that, the easiest way seems to be:
- Upon initializing the dag structure, build missing segments in memory.
- When preparing writing to disk, drop the in-memory segments.

This diff makes it possible to drop in-memory index changes.

Reviewed By: sfilipco

Differential Revision: D17000970

fbshipit-source-id: 554746c9a868cc3881dd836dc3a3cda265b54287
2019-09-13 19:31:02 -07:00
Jun Wu
4ddc46ad21 dag: add an optimization to not add meaningless higher level segments
Summary:
Higher level segments need to be producing fewer segments. If they cannot do that,
there is no point creating those levels.

This makes it possible to auto-detect the maximum segment level.

Reviewed By: sfilipco

Differential Revision: D17000968

fbshipit-source-id: bfb35f7451a40612803cb232be163db12bcab2fd
2019-09-13 19:31:02 -07:00
Jun Wu
5bbc59aff0 dag: implement DAG range
Summary: Implement the "dag range" (aka. "x::y" in mercurial) query.

Reviewed By: sfilipco

Differential Revision: D16988046

fbshipit-source-id: 2733a1ec7831c5bace6056b9376dce53c6aafb0c
2019-09-13 19:31:01 -07:00
Jun Wu
f6deec39ec dag: implement roots
Summary: Similar to `heads(x) = x - parents(x)`, `roots(x) = x - children(x)`.

Reviewed By: markbt

Differential Revision: D16976381

fbshipit-source-id: 0606cc907951b49cbbd7b75ccd11a222bc9bd0fe
2019-09-13 19:31:01 -07:00
Jun Wu
84361f6dfc dag: implement fast path for children
Summary:
The fast path takes advantage of high-level segments and avoids visiting lower
level segments if possible.

`cargo bench --bench dag_ops children` before:

  children                                           16.842 s

after:

  children                                          427.577 ms

Reviewed By: markbt

Differential Revision: D16976385

fbshipit-source-id: ae1b5f26b6ce2213f5ce1f28c4ac1cf49678992f
2019-09-13 19:31:01 -07:00
Jun Wu
bf0277b8e2 dag: show "has_root" flag in ASCII graphs
Summary: This allows us to check if the "HAS_ROOT" flag is correctly set or not.

Reviewed By: sfilipco

Differential Revision: D16976384

fbshipit-source-id: a5bb73b0bc414e422afd7c8690c55ee1076ef9f2
2019-09-13 19:31:01 -07:00
Jun Wu
9a4f837d57 dag: add a flag storing whether a segment has roots
Summary:
This would allow us to implement the fast path in `children`.

This is a breaking change in file format. But we haven't been really using the
segmented dag format in production yet. So it's fine to not have a migration
path.

This potentailly makes the future format migration easier since there are 7
bits left to use.

Reviewed By: markbt

Differential Revision: D16976382

fbshipit-source-id: 0110c03d4ff2ce0a882b3fb8ce8ee12d2087f41f
2019-09-13 19:31:00 -07:00
Jun Wu
1a32a56b82 dag: implement children
Summary:
The children operation is now O(flat segments) = O(merges). But it has
potential to be faster with more precalculated information in segments.
See added comments for details.

Reviewed By: markbt

Differential Revision: D16976383

fbshipit-source-id: 80bfd2cefa5aa5ceabfd7e40d46d06f7e2b64d34
2019-09-13 19:31:00 -07:00
Jun Wu
10d61c1311 dag: make common_ancestors scale with large set inputs
Summary:
This makes dag_ops benchmark runnable.

Example benchmark result run with `sudo nice -20`:

  building segments                                 489.076 ms
  ancestors                                         378.471 ms
  common_ancestors (spans)                          495.074 ms
  gca_one (2 ids)                                   607.611 ms
  gca_one (spans)                                   509.784 ms
  gca_all (2 ids)                                   977.349 ms
  gca_all (spans)                                   570.267 ms
  heads                                             248.168 ms
  heads_ancestors                                   248.524 ms
  is_ancestor                                       295.376 ms
  parents                                           246.623 ms

Reviewed By: sfilipco

Differential Revision: D16992731

fbshipit-source-id: 838f9240ca942f442fa395c1cf7bf914c52652c2
2019-09-13 19:31:00 -07:00
Jun Wu
0181efeb2c dag: add dag_ops benchmark
Summary:
This will guide optimizations.

Right now, gca_one "large sets" can take forever to run.

The code to build the mozilla DAG was extracted to a single file to be sharable.

Reviewed By: sfilipco

Differential Revision: D16992730

fbshipit-source-id: 1538f5b0098cd06cb179bd556df285055e1d62b6
2019-09-13 19:30:59 -07:00
Jun Wu
2e640ac84f dag: add SpanSet::push
Summary:
This is the mutable operation that allows other code paths to add spans to a
SpanSet. It will be used in a later change.

Reviewed By: markbt

Differential Revision: D17169483

fbshipit-source-id: be9286e67bfa64e961ee75482432aa61dfc0e6ed
2019-09-13 19:30:59 -07:00
Jun Wu
b2b78f66b9 test-fncache: remove the test
Summary:
We don't use fncache. It does not scale. The test break with narrow-heads.
This diff just removes the fncache test.

Reviewed By: singhsrb

Differential Revision: D17293478

fbshipit-source-id: b41dba333276ad63973b7556dfc400f4b33f6f5d
2019-09-13 17:36:17 -07:00
Xavier Deguillard
69d76149d2 remotefilelog: add the indexedlog to remotefilelog.shareddatastores
Summary:
Ondemand has been complaining that their hgcache was growing very quickly, and
looking at logs and scuba data, this appears to be caused by refetching
everything from the network and writing it to the indexedlogdatastore.

Looking at the prefetch code, I realized that the indexedlogdatastore wasn't
present in the repo.fileslogs.shareddatastore list, and therefore may be
omitted from the stores in which we look for data.

Reviewed By: kulshrax

Differential Revision: D17374761

fbshipit-source-id: 9e9f279d4c8154e2491312a57d24bc5fd7da79fc
2019-09-13 15:29:40 -07:00
Xavier Deguillard
6b6701fdc2 edenapi: remove unecessary tokio dependency
Summary: This is no longer used, let's remove it.

Reviewed By: quark-zju

Differential Revision: D17337442

fbshipit-source-id: 2272c2662440bc2be2a3ff29ef11fc4e0eb3605f
2019-09-13 15:16:57 -07:00
Xavier Deguillard
3e1eccd586 replace std::sync{Mutex, RwLock, Condvar} with parking_lot
Summary:
The parking_lot crate is more convenient to use than std::sync, on top
of everything else listed at https://crates.io/crates/parking_lot. Let's
use it everywhere.

Reviewed By: quark-zju

Differential Revision: D17337444

fbshipit-source-id: b5489be0b7d2bd5f6a6edc5d1d6eea366a6c05b9
2019-09-13 15:16:57 -07:00
Jun Wu
14d1ae5689 amend: do not rebase obsoleted commits for next --rebase
Summary:
I hit this when editing the dag stack. This resolves a "BUG" in the
test-amend-nextrebase.t test.

Reviewed By: singhsrb

Differential Revision: D17357387

fbshipit-source-id: 309efe34dee71180abdbdb5a9fe2e7b731230051
2019-09-12 20:00:28 -07:00
Arun Kulshreshtha
f1b2353793 manifest: move test helpers to new testutil module
Summary: Now that several of the submodules in the Manifest crate have their own unit tests, let's de-duplicate the test helper functions across those tests by moving them to a `testutil` submodule (which only gets built in `cfg(test)`).

Reviewed By: xavierd

Differential Revision: D17352890

fbshipit-source-id: 1b7d7cb754ee501def8d1d508f2af5733d548f4d
2019-09-12 18:28:44 -07:00