Commit Graph

46954 Commits

Author SHA1 Message Date
Jun Wu
11c712b09c hgcommands: log command finish event
Summary:
This has a bunch of benefits:
- "duration_ms" counts Python startup overhead, and does not count the missing
  "chg pager blocked" at the end of chg process.
  It's more desirable than other kinds of "duration"s.
- Max RSS is logged. So we might get rid of a seprate wrapper eventually.

Reviewed By: singhsrb

Differential Revision: D17423799

fbshipit-source-id: 94121787506d435875a22cc03d638297120dad00
2019-09-20 18:32:36 -07:00
Jun Wu
7d149487c0 hgcommands: log process start event
Summary:
This will provide the "fullargs" information needed by telemetry.

Log in "hgcommands", instead of "hgmain", or "clidispatch", because:
- "clidispatch" does not have  argv[0], and might be called multiple times
  (from Rust, then from the fallback Python -> bindings)
- Logs in "hgmain" won't be written to disk if chg is used.

I removed "env", since "hgcommands" does not have access to hgrc to decide what
env to log. It seems desirable if the "env" logging is move to a fb-only
backgroud logging binary.

Reviewed By: singhsrb

Differential Revision: D17423796

fbshipit-source-id: da3c54e916203f8368f8389fc7eed91e5299a75d
2019-09-20 18:32:36 -07:00
Jun Wu
6cc8e33337 hgmain: enable incremental compilation and disable lto
Summary: This helps compilation speed a bit.

Reviewed By: singhsrb

Differential Revision: D17429693

fbshipit-source-id: 98c7228392c3582fd811ac0137821a256d96f54a
2019-09-20 18:32:36 -07:00
Jun Wu
484939a75d hgmain: make bindings a builtin module
Summary:
Global states (For example, the global blackbox instance, potentially some
logging / tracing libraries) are separate in the Rust and Python worlds.

That is because related code gets compiled separately:

  bindings.so (top-level)
   \_ blackbox

  hgmain (top-level)
   \_ blackbox (have a different global instance than the above blackbox)

To address it, make `bindings` a builtin module in `hgmain`.

The builtin module was renamed from `edenscmnative.bindings` to `bindings` so
it does not require importing anything else (For example, `edenscmnative`).

This unfortunately makes `hg` 100+ MB. Fortunately it can be compressed well
(gzip: 31MB).

Reviewed By: singhsrb

Differential Revision: D17429688

fbshipit-source-id: bf16910d7a260ca58db0d272fc95d8071d47bbc6
2019-09-20 18:32:36 -07:00
Jun Wu
c3355e8af9 run-tests: use "hg debugpython" instead of "python" to run tests
Summary: This makes the test runner compatible with the next change.

Reviewed By: singhsrb

Differential Revision: D17429690

fbshipit-source-id: 100d2c9f341cfc64be22137b7013f5b234005771
2019-09-20 18:32:35 -07:00
Jun Wu
4e8707262f tests: change some 'python' to 'hg debugpython'
Summary:
In the future `python` will no longer be able to import `bindings`.
Change them to `hg debugpython` so they stay compatible.

I dropped the "custom hghave" feature. It breaks and I don't think there
are users of it.

Reviewed By: singhsrb

Differential Revision: D17429689

fbshipit-source-id: 96e55ef25a027bd4ad33fc279f27c1d5cbed6861
2019-09-20 18:32:35 -07:00
Jun Wu
b4a8819c72 tests: remove web / cgi related test
Summary:
We don't care about hgweb / cgi right now. The tests use `$PYTHON` and import
the `bindings` module. In a future diff `$PYTHON` no longer has access to
`bindings`. Remove the tests so the test is compatibile.

Reviewed By: xavierd

Differential Revision: D17429692

fbshipit-source-id: b3d7c7de34bdb7f28d8b7989e9df822435b84fb2
2019-09-20 18:32:35 -07:00
Jun Wu
03daebc5cb test-clonebundles: remove the test
Summary: We don't use clonebundles. Remove the test to reduce support burden.

Reviewed By: singhsrb

Differential Revision: D17483628

fbshipit-source-id: f63070dcd7bb7283d249d33ac760bdebbbc4261a
2019-09-20 18:32:34 -07:00
Jun Wu
33216d5840 commands: add a command to run Python interpreter
Summary:
This makes it possible to use `hg debugpython -- ...` to replace `python ...`.
An upcoming change makes `edenscmnative.bindings` non-importable. To continue
support Python tests, we need an alternative way to run Python.

Reviewed By: singhsrb

Differential Revision: D17423797

fbshipit-source-id: 21ece4d35c2fdc09c281b10d5a07ee8af2e78384
2019-09-20 18:32:34 -07:00
Jun Wu
2b076c4b17 blackbox: preserve session_id when replacing singleton
Summary:
The current API replaces `session_id` when the global blackbox switched
from in-memory to on-disk. It should preserve the session id.

Reviewed By: singhsrb

Differential Revision: D17429691

fbshipit-source-id: d37811c3d7622c4f86615c41bce40f4e479eabd2
2019-09-20 18:32:34 -07:00
Xavier Deguillard
a108ea0c6f commitcloudsubscriber: fix warnings
Summary: The 'dyn' keyword should now be used for trait objects, let's fix the warnings.

Reviewed By: singhsrb

Differential Revision: D17508558

fbshipit-source-id: 5dee1c2314be80fe7650dd023a44f02df8c70640
2019-09-20 15:49:00 -07:00
Xavier Deguillard
311de7ef9a whochanges: add buck target
Summary: In order to ship this in a package built by packman, we need a target for it.

Reviewed By: quark-zju

Differential Revision: D17507972

fbshipit-source-id: db363c43c8e852410711398b583205ce4e0bb0b3
2019-09-20 13:57:20 -07:00
Jun Wu
6f724d6e36 smartset: add a wrapper to the Rust SpanSet
Summary: Add a wrapper which handles "ordering" required by the smartset interface.

Reviewed By: sfilipco

Differential Revision: D17244560

fbshipit-source-id: 37f3746a5fdedf06e8d0a3f948c7568ee43746cf
2019-09-20 13:36:20 -07:00
Jun Wu
9703bfb0fe repoview: allow disabling repoview filtering
Summary:
The eventual goal is to disable repoview filtering once narrow-heads is set.

The repoview layer is using a blacklist approach - scan through all heads (or
all drafts), and figure out what to blacklist. The new dag structure has a
larger constant factor on time complexity when it comes to many heads.

This diff disables repoview filtering entirely if 'narrow-heads' gets turned
on, as the first step moving to the whitelist approach. There are other isues,
which will be fixed in upcoming diffs.

Reviewed By: sfilipco

Differential Revision: D17244557

fbshipit-source-id: 260214378abba4b0ecd0a0407d452352b6dc3c28
2019-09-20 13:36:19 -07:00
Jun Wu
35b7e438c4 test-narrow-heads: add a test about narrow-heads issues
Summary: The test contains issues in test-narrow-heads that need fixes.

Reviewed By: sfilipco

Differential Revision: D17244550

fbshipit-source-id: aca6ffa51ab95436a32b3bdf40dbf05a376dbdbe
2019-09-20 13:36:19 -07:00
Jun Wu
dcf2ddb57a changelog: add experimental.narrow-heads to change head() behavior
Summary:
Add a config option `experimental.narrow-heads`. Once set, "heads" get
redefined by a whitelist (visibility heads + remote names).

This is one step towards removing the blacklist (filteredrev) approach,
which does not scale with the new changelog design.

Reviewed By: sfilipco

Differential Revision: D17199845

fbshipit-source-id: 0feb300ad3ad7b2e33dd7781b4fc181233609a10
2019-09-20 13:36:19 -07:00
Jun Wu
55d32f3e9c indexedlog: avoid mem::swap which breaks Log internal state
Summary:
There are several places in Log that use `mem::swap` to swap out existing
Indexes, with the expectation that self.indexes will be replaced with updated
indexes soon. But that can fail and Log will be in a bad state.

Fix that by replacing `mem::swap` with clones so it is easy to verify that
the internal state of `Log` wouldn't be broken.

The extra `clone` makes certain `sync` operations a bit slower:

Before:

  log sync (write N)                                 31.155 ms      20 B /  9.259 MB
  log sync (read, new log 1, index lag N)             0.033 ms      42 B /      0 B

After:

  log sync (write N)                                 39.841 ms      20 B /  9.259 MB
  log sync (read, new log 1, index lag N)             3.343 ms      42 B /      0 B

This is caught by an assertion error at log.rs:1095, reported by fanzeyi.

Reviewed By: xavierd

Differential Revision: D17493796

fbshipit-source-id: 7e8b4329258ca4d24be74aa942ffa809397b2eaf
2019-09-20 12:01:58 -07:00
Durham Goode
73517f0380 lfs: add test for lfs-downgrade-after-rename issue
Summary:
Normally, when you push an lfs blob the server doesn't need to ever
download the lfs blob content because it can just compare the hashes. There's a
special case though, when a commit makes a blob go from lfs to non-lfs and the
previous version of the blob was a rename, then Mercurial must actually read the
file contents and compare it to know if it changed.

This adds a test to cover the case.

Reviewed By: quark-zju

Differential Revision: D17488079

fbshipit-source-id: 4313ee01e103d3ad13463e4774096d866d420b2e
2019-09-20 11:40:27 -07:00
Jun Wu
fc25f105d4 indexedlog: rename clone to try_clone
Summary:
The `clone` method can be confusing with the stdlib `Clone` trait.
Use `try_clone` to make it explicit that it returns a Fallible.

Boolean parameters are generally a bad idea, change it to `try_clone`
and `try_clone_without_dirty` explicitly.

Reviewed By: xavierd

Differential Revision: D17493978

fbshipit-source-id: 21ba6a08dda17bf0498726858593eecd220dcb0f
2019-09-20 11:02:07 -07:00
Stefan Filip
5d7a31d5dd tests: add treemanifest diff test
Summary:
Tree manifests want to have a different order than flat manifests.
This difference in orders can cause algorithms like diff to give wrong
results. This test aims to validate that the treemanifest implemetations
work correctly for cases where the orders are different.

Reviewed By: quark-zju

Differential Revision: D17492500

fbshipit-source-id: eabb5d0fed5804b3d81c12667621ec6d38e0bfce
2019-09-19 19:45:08 -07:00
Stefan Filip
674192a9ee manifest: add sort order edge case test for diff
Summary:
The diff algorithm assumes that the cursor iterates over the entries of the
manifest in order. The problem is that a tree manifest with sorted names
for the entries of the directories does not yield the same order as the
string sorted paths. The path separator: '/' is the problem. It is greater
than certain charater, like '-'. This test validates that the diff algorithm
works for manifests that would not yield string sorted order paths on DFS
iteration.

Reviewed By: quark-zju

Differential Revision: D17491659

fbshipit-source-id: 0754a19676ddd6500ea11b07446936d922b99652
2019-09-19 19:45:08 -07:00
Jun Wu
8d4d0a66a2 context: wait for wlock for dirstate fixup if watchman reports fresh instance
Summary:
This is an attempt to solve issues that watchman state in dirstate stays stale
and users have pretty bad experience.

Normally, `hg status` is a "read-only" operation that works in a lock-free way,
and `status` still work if other hg commands are taking a lock. However,
`hg status` does need to update watchman state (clock, need-check file list) to
stay performant.

In case watchman reports "fresh instance" case, watchman also returns all file
paths in the working copy, which means the current `status` has very bad
performance, and the next `status` call can still be bad if the watchman state
in dirstate does not get updated.

This diff adds special handling of "fresh instance", waits for the lock, and
attempts to update the watchman state. It should reduce user frustration about
continuously slow `hg status` commands. In case it failed to update the
watchman state, also print warning messages so the user is aware of the issue.
For example, if there is an ongoing `hg histedit` that waits for the editor.

Reviewed By: wez

Differential Revision: D17468790

fbshipit-source-id: ad06bb1d5d13c6904db328c42a470112c3ee9940
2019-09-19 19:07:50 -07:00
Jun Wu
ba26a79d75 testutil/dott: fix delayed exception handling
Summary:
D17277286 changed the error type to SystemExit to swallow the traceback and
make the error cleaner. But that breaks `except Exception` used in `__del__`,
because `isinstance(SystemExit, Exception)` is `False` (surprise !).

Fix it by listing `SystemExit` explicitly.

Also remove the noisy `exception ... in __del__ ignored` message by removing
the `raise`.

Make sure the delayed exception will be handled by adding an `atexit` handler.

Reviewed By: sfilipco

Differential Revision: D17493283

fbshipit-source-id: 2301e318e06708804486d8625118210ae2e42817
2019-09-19 19:05:45 -07:00
Stefan Filip
72bac53ce2 RepoPath: update sort order to component based
Summary:
Natural ordering on paths and ordering on components are different because
'/' is greater than certain names and greater than others.

Natural order: [foo-bar, foo/bar, foobar]
Component order: [foo/bar, foo-bar, foobar]

The component order is preferable for trees that have directories in their
inner nodes.
I am motivated to change the ordering for paths by tree manifests. This
update would make the DFS traversal be equivalent to sorting all the files
in the manifest.

Reviewed By: quark-zju

Differential Revision: D17456704

fbshipit-source-id: 5707ea11c49a6b95cff09459d3dd81062f1d6440
2019-09-19 16:51:49 -07:00
Stefan Filip
d104c36c0c RepoPath: update tests to use testutil
Summary: It makes the tests more readable.

Reviewed By: quark-zju

Differential Revision: D17456703

fbshipit-source-id: 041fd324c63da75bfba4bdd88e54829b1b4e8b88
2019-09-19 16:51:49 -07:00
Durham Goode
a0a2518bf6 hgsubversion: skip empty commits when pushing
Summary:
We're down to just one use of hgsubversion. In that use it's convienent
to skip empty commits when pushing. Let's add logic to bypass empty commits.

Differential Revision: D17452527

fbshipit-source-id: 5ef76df7d0a44f2d43f4ea0d8678e4174c0286ee
2019-09-19 15:44:19 -07:00
Jun Wu
099650d781 testutil/dott: remove unused logic in feature.py
Summary: Those belong to testtmp.py

Reviewed By: sfilipco

Differential Revision: D17483074

fbshipit-source-id: cbd27efca04ca5a9b8651f6612a5f78bedaea678
2019-09-19 11:41:41 -07:00
Jun Wu
b227af9b12 testutil/dott: do not rewrite $HGRCPATH
Summary: In case run-tests.py prepares $HGRCPATH, it should not be rewritten.

Reviewed By: sfilipco

Differential Revision: D17483075

fbshipit-source-id: d5d32aa65833dde68b37229802a39a75a32b37d0
2019-09-19 11:41:41 -07:00
Xavier Deguillard
e5c6715dcd revisionstore: hook edenapi into the ContentStore
Summary:
This allows the ContentStore to fetch data from EdenApi if nothing was found
locally.

Reviewed By: quark-zju

Differential Revision: D17437892

fbshipit-source-id: bdf7eedbb22c65b2ef73d0b5cc9a344006420772
2019-09-19 11:21:52 -07:00
Xavier Deguillard
8162fecfb2 revisionstore: add an EdenApi shim that implements DataStore/RemoteDataStore
Summary:
When plugged into the ContentStore, this will allow data not present locally to
be fetched via EdenApi.

Reviewed By: quark-zju

Differential Revision: D17437894

fbshipit-source-id: 06ccb7d7eeb5355c01bab23c2f3b44af4f3ca12a
2019-09-19 11:21:52 -07:00
Xavier Deguillard
77f25d449d revisionstore: move DataStore::prefetch onto RemoteDataStore
Summary:
The RemoteDataStore is expected to be implemented into the higher level types,
while we don't want low level ones to pretend to have a prefetch method.

Reviewed By: quark-zju

Differential Revision: D17437893

fbshipit-source-id: 52ec90a6edf9aa5dac852fb827275be7fd361080
2019-09-19 11:21:52 -07:00
Xavier Deguillard
5029409860 edenapi: remove dependency on revisionstore
Summary:
The revisionstore crate will soon need to build a `dyn EdenApi` object to fetch
data out of the network. Since the edenapi crate depends on revisionstore, this
would create a recursive dependency between these 2. Several approach were
thought of, including moving either the EdenApi, or the MutableDeltaStore trait
outside of their respective crates. In the end, I decided to remove the
dependency altogether and let the caller decide what to do about the data.

Reviewed By: quark-zju

Differential Revision: D17437895

fbshipit-source-id: cc3ec830562c0616d40d7d5d36f69674934d87b9
2019-09-19 11:21:51 -07:00
Xavier Deguillard
367e2f1de3 edenapi: Mutable{Delta,History}Store have internal mutability
Summary: These no longer needs to be passed in with &mut.

Reviewed By: quark-zju

Differential Revision: D17379054

fbshipit-source-id: b1d0591013d92aaa3cc60cc3b23f42a1f175d1cb
2019-09-19 11:21:51 -07:00
Xavier Deguillard
d13d693588 revisionstore: add a ContentStore struct
Summary:
The ContentStore struct is intended to be the main entry point for data and
cache management for both Mercurial and Eden. It takes care of finding the
proper underlying stores and aggregate them into one, this is roughly
equivalent to the repo.datastore object in Python, the main different being
that the Rust one isn't yet fetching any remote data. This will be added in a
future diff.

Reviewed By: quark-zju

Differential Revision: D17357935

fbshipit-source-id: a47575177cbb7315ea22e3da9f4043845698c61f
2019-09-19 11:21:51 -07:00
Carolyn Busch
d1fbf4280a workingcopy: ignore .hg in walk
Summary: Working copy walker should not traverse into .hg directory.

Reviewed By: xavierd

Differential Revision: D17403172

fbshipit-source-id: 3efe61db8e09b602bff40b42b0d863248e88aea1
2019-09-19 10:14:24 -07:00
Carolyn Busch
0304c45a44 workingcopy: initial walk implementation
Summary: Rewrite walk function from D17099990 for hg status in rust

Reviewed By: xavierd

Differential Revision: D17175006

fbshipit-source-id: f7cbdccc5a8f6693df5fad670b57ee494d1239dd
2019-09-19 10:14:24 -07:00
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