Commit Graph

2838 Commits

Author SHA1 Message Date
Mark Thomas
2158e4c531 commitcloud: add Rust rendering of cloud smartlog
Summary:
Allow rendering of cloud smartlogs using renderdag.  Use the ability of renderdag
to reserve columns to provide the smartlog-like indentation of draft stacks.

Reviewed By: quark-zju

Differential Revision: D19272577

fbshipit-source-id: 3311d83511b0d5347b45f33c282ce26b8133d047
2020-01-06 15:00:08 -08:00
Mark Thomas
8e28741a8b smartlog: add Rust rendering of graphs
Summary: Allow rendering of smartlog graphs using renderdag.

Reviewed By: quark-zju

Differential Revision: D19272578

fbshipit-source-id: 1cd19753781c58e49038d72f12c8f5ebf3bad6f9
2020-01-06 15:00:08 -08:00
Mark Thomas
da3d898cd4 cmdutil: add Rust rendering of graphs
Summary:
Allow rendering of graphs using renderdag by setting `experimental.graph.renderer` to `ascii`, `ascii-large` or `lines`.

The minimum height of each row can be set using `experimental.graph.min-row-height`.

Reviewed By: quark-zju

Differential Revision: D19272580

fbshipit-source-id: ac5eff8446bd3c09d07624a193195b4224055ffc
2020-01-06 15:00:07 -08:00
Mark Thomas
0822231d79 pyrenderdag: add python bindings for renderdag
Reviewed By: quark-zju

Differential Revision: D19272576

fbshipit-source-id: f79019d3506efe03675f49b9ad728582b22bd205
2020-01-06 15:00:06 -08:00
Mark Thomas
e91c6ffa7c renderdag: make test fixtures common
Summary:
Move the test fixtures into a common module, so that they don't need to be
repeated in each test.  Since each fixtures is now a struct, this also makes it
clearer what each of the items are.

Reviewed By: quark-zju

Differential Revision: D19288290

fbshipit-source-id: 394805c652592177f11ccb096b8e5e95361456e4
2020-01-06 15:00:06 -08:00
Mark Thomas
cdd0f39805 renderdag: add test case for long messages
Reviewed By: quark-zju

Differential Revision: D19288289

fbshipit-source-id: d7d7023900d4f7c8d1ed14d15217548875a349c6
2020-01-06 15:00:05 -08:00
Mark Thomas
693ca3ff6a renderdag: Use builder pattern for output renderers
Summary:
Generalize construction of output renderers (renderers that render to `String`)
to avoid duplication of options.  At the moment there is only one, but later we
may add new options.

This also allows us to construct output renderers from any renderer that
renders to `GraphRow`, which means we can create adapters that modify or
re-order the rows of the graph.

Reviewed By: quark-zju

Differential Revision: D19286350

fbshipit-source-id: a5649ca2f48e263ee24584339179655fb612d3d1
2020-01-06 15:00:05 -08:00
Mark Thomas
213b3f086c renderdag: add a DAG rendering crate
Summary:
A new implementation for rendering DAGs.

This new crate implements a generic DAG renderer, that can convert a
topologically sorted sequence of DAG nodes into a sequence of strings suitable
for rendering to a terminal.

The new renderer differs from the old renderer in a few important ways:

* It prioritizes keeping commits linear, and will allow gaps to form if
  that will allow the history of the commits to be kept in a straight
  line.  This makes it easier to track long parallel histories.

* It supports octopus merges (nodes with more than two parents).  Even
  though Mercurial doesn't support octopus merge commits, summary DAGs
  with omitted nodes can still end up with logical octopus merges.

* It supports reservation of columns for specific nodes.  This can be
  used to support smartlog-style indentation of draft stacks without
  needing to hack around it by creating fake nodes.

* It separates out forming the graph from generating the lines.  This
  allows multiple back-ends for generating different styles of graph.

There are three back-ends implemented:

`AsciiRenderer` renders similar to the old graph renderer, using ASCII
characters.  For example:

```
  o  F
  |
  | o  E
  | |
  | | o  D
.-----'
o | |  C
+---'
o |  B
:/
o  A
```

`AsciiLargeRenderer` uses larger ASCII blocks to give a clearer picture of
complex graphs.  For example:

```
   o   F
   |
   |
   |  o   E
   |  |
   |  |
   |  |  o   D
  ______/
 / |  |
o  |  |   C
| ___/
|/ |
o  |      B
: /
:/
o   A
```

`BoxDrawingRenderer` uses Unicode box drawing characters to give a more
continuous rendering of the graph, however requires support for these
characters in the terminal font.  For example:

```
  o  F
  │
  │ o  E
  │ │
  │ │ o  D
╭─────╯
o │ │  C
├───╯
o │  B
├─╯
o  A
│
~
```

Reviewed By: quark-zju

Differential Revision: D19272579

fbshipit-source-id: bb6fa4685c965544cc3b6b9261df3a3ec161b41f
2020-01-06 15:00:04 -08:00
Jun Wu
8e3a606106 graphql: do not error out if signal_summary is None
Summary:
This can happen for "Reserved" diffs.

Reported By: hyr

Differential Revision: D19270860

fbshipit-source-id: 24e9b8c08fc16e3089e0dc3f8064a5e9671d9ace
2020-01-06 14:27:43 -08:00
Genevieve Helsel
a03dac0a83 reactivate test_abort_split_with_pending_add
Reviewed By: chadaustin

Differential Revision: D19167578

fbshipit-source-id: fa2c848a4e157bcf9c466b4b65132168201e4d97
2020-01-06 08:52:27 -08:00
Genevieve Helsel
26f4427200 add eden debug parents
Summary: adds a cli debug command to inspect the working copy parent. by default just returns eden's snapshot contents, but adds optional --hg flag to print Mercurial's dirstate information

Reviewed By: chadaustin

Differential Revision: D19167518

fbshipit-source-id: b65e112df6abe4e0e7a8a528a90b2e3d17297e66
2020-01-06 08:52:27 -08:00
Jon Maltiel Swenson
cc1a7ddcde Kill rsocket server stack
Summary: This stack is deprecated in favor of the rocket stack.

Reviewed By: rhodo

Differential Revision: D18123600

fbshipit-source-id: db6e3bf4add9c49cf8f1d2f12f97b207e87c7302
2020-01-03 15:53:10 -08:00
Jun Wu
a97842c8c2 fbscmquery: fix globalrev graphql query
Summary: `"globalrev"` is invalid. Use `GLOBAL_REV` instead.

Reviewed By: singhsrb

Differential Revision: D19271059

fbshipit-source-id: c26347b92b1b92a5f958f2f71dbdfdf3635a0876
2020-01-03 12:40:04 -08:00
Jun Wu
3db941beb4 phabstatus: handle JSON decode error
Summary:
Sometimes GraphQL does not return JSON result. Do not crash on the client-side.

Context:
https://fb.workplace.com/groups/scm/permalink/2565497036833234/

Reviewed By: farnz

Differential Revision: D19254348

fbshipit-source-id: 75ca93b1dc8648d5c59915ecf450b9366df13c01
2019-12-30 16:45:11 -08:00
Simon Farnsworth
deacaed311 Don't delete bookmarks in drawdag if there are none
Summary: In Mononoke tests, we have failures because `hg book -fd` aborts if it's not given any bookmark names. Fix up this function to not run `hg book -fd` if there are no bookmarks

Reviewed By: quark-zju

Differential Revision: D19251930

fbshipit-source-id: 2f1696d9207ad64a94c28941e72806d9b0e686fe
2019-12-30 15:41:14 -08:00
Adam Simpkins
e45e2c6f9a unbreak dirstate.status() in EdenFS repositories
Summary:
D19190259 broke `dirstate.status()` in EdenFS checkouts.  Fix the code to
properly check if the dirstatemap supports `nonnormalsetfiltered`

Reviewed By: quark-zju

Differential Revision: D19221147

fbshipit-source-id: 17f69f5b461467bfb67858fb21dc0230b928a740
2019-12-23 16:44:12 -08:00
Jun Wu
c214a2de9e test-profile: fix the test
Summary: Use `debugpython` to replave `python`

Reviewed By: akushner

Differential Revision: D19221125

fbshipit-source-id: 68f5d83f9abe38174492fdaaf7496875696c4302
2019-12-23 16:37:10 -08:00
Jun Wu
3170aa7cbc test-parse-index2: remove the test
Summary:
The test is broken by D19190496 because the test uses some weird test cases
about legacy Pythons.

The "parseindex2" test is revlog-related. The revlog is kind of stable, tested
indirectly in countless tests, and is also going away. We don't run the code
on legacy versions of Pythons.The "parseindex2" test does not provide much
value. Therefore just remove it.

Reviewed By: akushner

Differential Revision: D19221126

fbshipit-source-id: 5b904d97caa47f92098435ee85c1bb8b725c9f84
2019-12-23 16:37:10 -08:00
Jun Wu
9d36855838 bindings: add hgtime
Summary:
This makes it possible to use the hgtime parsing utilities in Python.
Namely, patterns like `since 6 days ago to now` can now be parsed.

Reviewed By: sfilipco

Differential Revision: D18946335

fbshipit-source-id: c12ea3437301f20a8c457525c0798f471b8f174a
2019-12-22 11:27:33 -08:00
Jun Wu
624e47ac1c hgtime: add a way to change "now" for testing
Summary:
The existing tests rely on this feature.
This requires replacing all `Local::` usage with `HgTime::now()`.

Reviewed By: sfilipco

Differential Revision: D18946336

fbshipit-source-id: 1a92183cc96f2fcb013b68a32e78f09f28a49452
2019-12-22 11:27:33 -08:00
Jun Wu
8812c8c97d hgtime: fix bounds of "a to b" range
Summary:
For example, `2018 to 2019` should be parsed as `2018-1-1 to 2019-12-31 23:59:59`,
not `2018-1-1 to 2019-1-1`.

Fix it to match the desired behavior.

Reviewed By: sfilipco

Differential Revision: D18946331

fbshipit-source-id: 640bbe49352d1f01855183ea9927bb0009646243
2019-12-22 11:27:33 -08:00
Jun Wu
c624847c84 hgtime: limit year in 1900 to 9999
Summary:
The Python `datatime` stdlib has limitations:

- `datetime.datetime` can only express year 1 to 9999.
- `strptime` requires year >= 1900.

Limit the `HgTime` to 1900 ..= 9999 range to be consistent.

Note: Mercurial has an `i32` range limit, which seems to problematic
since `i32::MAX` is Jan 19, 2038. So I kept using `i64`.

This addressed some XXX comments about not returning errors.

The code change is mostly because added error handling.

Reviewed By: sfilipco

Differential Revision: D18946333

fbshipit-source-id: 0e4756457b0f13451dc5008ef19d4670a7aaa7fb
2019-12-22 11:27:32 -08:00
Jun Wu
5c7acfc1ca dag: add a NamedDag that keeps Dag and IdMap consistent
Summary:
It turns out the interaction between dag and idmap can be complex, especially
when a non-master id gets re-assigned a master id.

A high-level structure is helpful here to handle the corner cases correctly.

This diff adds basic definitions, and one of the most complex function - build.
The build function is ported from pydag.

Reviewed By: sfilipco

Differential Revision: D18838994

fbshipit-source-id: a2f6db3b188d5fd04d8e1d6df40ba985e33281f6
2019-12-22 11:27:32 -08:00
Jun Wu
61e0f06417 dag: add ways to remove non-master ids in Dag and IdMap
Summary: First step to implement segment and idmap rewrites for non-master ids.

Reviewed By: sfilipco

Differential Revision: D18838996

fbshipit-source-id: 0380c0193d9078a2a2d7fde9c5f565e8dbc8e713
2019-12-22 11:27:32 -08:00
Jun Wu
784da69352 indexedlog: support efficient index deletion by prefix
Summary:
The index can delete all keys matching a prefix more efficiently than deleting
them one by one. Expose this feature.

The `dag` crate will use this feature to delete all "non-master" segments and
ids efficiently.

Reviewed By: sfilipco

Differential Revision: D18825296

fbshipit-source-id: b8531695609238a16913254af61004170f12954e
2019-12-22 11:27:31 -08:00
Jun Wu
e51daf1fb1 indexedlog: expose Index::remove in log::IndexOutput
Summary: This makes it possible to define an index function that can delete data.

Reviewed By: sfilipco

Differential Revision: D18825299

fbshipit-source-id: 4eb03a001683092d99b439c8efb8e7909f543c70
2019-12-22 11:27:31 -08:00
Jun Wu
177360c0b5 indexedlog: implement Index::remove
Summary:
This makes it possible to actually delete keys from the index, which can be
handy for certain use-cases. For example, `dag` wants to rewrite non-master
ids and segments in certain cases.

Reviewed By: sfilipco

Differential Revision: D18825298

fbshipit-source-id: 3b69ca5fc763ba0c57bd16a28a349f2f829a0759
2019-12-22 11:27:31 -08:00
Jun Wu
343f79cf37 indexedlog: move parameters of index.insert_advanced to a structure
Summary:
This just moves parameters to a structure without changing the actual logic.
This is to make it possible to add a "remove" API to index.

Some variables are prefixed with `old_` or `new_` to make the code more
consistent.

Reviewed By: sfilipco

Differential Revision: D18825297

fbshipit-source-id: 27bd8438e66125c906ebf2044d6ff978b99c5986
2019-12-22 11:27:30 -08:00
Jun Wu
fbdecc96bb cpython-ext: move foreign error handling to pyerror
Summary:
Make cpython-ext free from business logic. This adds a bit overhead.
But it should be fine given the error cases are considered rare.

Reviewed By: markbt

Differential Revision: D19186692

fbshipit-source-id: daaffc1369a36c781d1badea822bf62a144eb54e
2019-12-22 11:27:29 -08:00
Jun Wu
d4a19306ed cpython-ext: rename fallible to anyhow_result
Summary: We no longer use the `failure` crate. Rename related methods and traits.

Reviewed By: markbt

Differential Revision: D19186694

fbshipit-source-id: 1c83a90ee12db431b7d8e09a9c2cf1d43a4c0f93
2019-12-22 11:27:29 -08:00
Jun Wu
ef3f9b932d cpython-ext: rename mod failure to error
Summary:
We no longer use the `failure` crate. Rename the module.

`cpython-failure` is dropped since it was merged into `cpython-ext`.

Reviewed By: markbt

Differential Revision: D19186693

fbshipit-source-id: 410d1491bcadd8d3272c7e2df08ecbe66fc0fef2
2019-12-22 11:27:29 -08:00
Jun Wu
2824ac99f7 cpython-ext: drop PE type parameter from map_pyerr<PE>
Summary:
The `map_pyerr<PE>` API is kind of hard to use correctly since the
code that calls `map_pyerr` does not really know the best suitable error type.

The existing code also "encourage"s the use of stdlib error types like
RuntimeError, ValueError, etc since the code is shorter, which is not great.
Error types from `mercurial.error` are better choices.

With previous diffs in this stack, we now decide the Python error type based
on the Rust error type. It's no longer necessary to specify an error type
with `map_pyerr<PE>`. So let's just drop the type parameter.

A `RustError` was added for error types that `cpython-ext` does not know how
to convert. We should avoid leaking it to the Python land by just implementing
how to convert `anyhow::Error` to `PyErr` in `cpython-ext`.

Reviewed By: markbt

Differential Revision: D19169527

fbshipit-source-id: f4563c36174cd51201b526bbc92a3f1c8a3da864
2019-12-22 11:27:28 -08:00
Jun Wu
241fc4086c doctor: avoid constructing the repo object
Summary:
Constructing the repo object might read some broken storages (ex. reading
"allheads"). Avoid constructing the repo object for fixing mutationstore,
metalog and allheads.

Reviewed By: markbt

Differential Revision: D19169209

fbshipit-source-id: d792c09db20e25cce406bc8c1adb66a28410bd4d
2019-12-22 11:27:28 -08:00
Jun Wu
be20ec511c scmutil: prompt hg doctor for indexedlog errors
Summary:
Since we now have the indexedlog error type. Match it and print helpful
messages.

Reviewed By: markbt

Differential Revision: D19169207

fbshipit-source-id: cd874f651b681d2dbbb5aea613c56721c4ab6181
2019-12-22 11:27:28 -08:00
Jun Wu
4dd04bf02f hgpython: replace hgpython interpreter with native Rust implementation
Summary:
The hgpython interpreter was used to run Python scripts in tests that might
rely on Mercurial modules.

The previous hgpython implementation is Python PAR based, which does not have
access to native Rust modules like bindings. Change it to use the native
"hg debugpython" implementation that is more compatible.

Reviewed By: markbt

Differential Revision: D19190496

fbshipit-source-id: 9791dbf9ba0ed92de702291faa9145f01b05ec40
2019-12-22 11:27:27 -08:00
Jun Wu
4a4aeff284 bindings: expose IndexedLogError to Python
Summary:
Expose the indexedlog error type to Python so it can be used in `except`
clause.

Reviewed By: markbt

Differential Revision: D19169208

fbshipit-source-id: c41f08ec11f78f7714b435dbfc6a28c36b34617d
2019-12-22 11:27:27 -08:00
Jun Wu
d6b2eb80a7 cpython-ext: convert known error types to dedicated errors directly
Summary:
Convert indexedlog error and IOError to dedicated Python types so the Python
world can match them meaningfully by type and handle them accordingly.

Reviewed By: markbt

Differential Revision: D19169210

fbshipit-source-id: 1e7bfdf7cbaf917098efdcd63d600483a9427d33
2019-12-22 11:27:27 -08:00
Jun Wu
0c41aa6235 extensions: change error message to look non-fatal
Summary:
The current error message looks like fatal while it is not. Make it clear that
extension failures are not fatal.

Reviewed By: markbt

Differential Revision: D19166545

fbshipit-source-id: 7ce0231c90b0c5f50add15a12cb69b60b76dfcb1
2019-12-22 11:27:26 -08:00
Jun Wu
e5de1683e4 gitnode: try using commit extra first
Summary:
There are 3 extensions that can provide the `{gitnode}` template: "gitrevset",
"fbscmquery", "hggit". The last can read from commit extras. Fix the first two
to also read commit extras. At some point we need to unify the implementations.

Reviewed By: farnz

Differential Revision: D19198979

fbshipit-source-id: 24a0df0df4ceb7a9af9236a7f70babfd54e9802b
2019-12-20 16:14:25 -08:00
Jun Wu
e21a23cc17 blackbox: write less frequently to disk
Summary:
When there are many processes (ex. import helpers). Writing to blackbox can be
slow due to flock contention.

Change blackbox "flush" decision from timestamp based to buffer-size based to
mitigate the issue.

Reviewed By: DurhamG

Differential Revision: D19198470

fbshipit-source-id: 71f87e5e3b45ef4db8efda22ca89fd8ce1fae7fa
2019-12-20 16:14:25 -08:00
Durham Goode
e2bac56f2f dirstate: filter ignored files before looping over non-normal
Summary:
D17099990 changed the way status is computed and added a loop over the
nonnormal files to find any added, removed, or merged files. Unfortunately the
nonnormal file list can contain untracked ignored files in some cases, and if
that list is large (like if someone disabled a sparse profile) this loop can
take many seconds.

Let's updated the loop to filter out ignored files. This matches a similar loop
in fsmonitor, and we may want to think about removing nonnormal handling from
the fsmonitor code entirely now that it's handled in dirstate.py.

Reviewed By: quark-zju

Differential Revision: D19190259

fbshipit-source-id: 4ba4150507fdd72439bc4e5eb731a951c6100f5f
2019-12-20 16:14:24 -08:00
Jun Wu
e41e214a01 remotenames: avoid updating "selectivepullaccessedbookmarks" if unnecessary
Summary:
I encountered a 19s `hg sl` run where 13s were spent on
`remotenames.updateaccessedbookmarks` (8 times).

{F225347899}

The filesystem is unusually slow since the it's nearly full. However, the
updates are not really necessary since I'm not accessing more remote names.
Accessing one bookmark via smartlog rewrites the entire accessed file, which is
O(N^2) and undesirable.

Improve it by skipping writing if nothing has changed. In the future we might
want to optimize it further by:
- Only update (and do ui.log) "accessedbookmarks" at most once per command.
- Potentially drop the "accessedbookmarks" tracking by using "remotenames"
  directly - everything in "remotenames" is accessed.

Reviewed By: markbt

Differential Revision: D19191528

fbshipit-source-id: 46635d4e5c9d0034ace9cdafc1f42a4512aa8774
2019-12-20 16:14:24 -08:00
Thomas Orozco
82df66ffe9 lfs: avoid accidentally quadratic performance in download path
Summary:
Currently, hg's lfs extension used bytes concatenation to download a response
from the server-side. However, concatenating bytes in Python can be
inefficient, since it'll re-allocate the whole thing and copy it every time you
concatenate.

This makes repeated concatenation O(N^2) on the number of things you
concatenate, which is undesirable. This diff updates hg's lfs extension to not
do that.

Reviewed By: farnz

Differential Revision: D19194388

fbshipit-source-id: f4a38afd8ba41bc1c2e64e9127035675ecda6651
2019-12-20 16:14:24 -08:00
Thomas Orozco
2a4a6fab4e lfs: check content length after downloading content
Summary:
HTTP makes no provision to tell your client that you failed halfway through
producing your response and won't have the answer they're looking for. So, if a
LFS server fails while producing a response, then we'll report an OID mismatch.

We can do a little better and disambiguate between "the server sent us the
wrong blob" (very scary) and "the server crashed" (merely annoying) by looking
at the content length of the response we got back. If it's not what was
advertised, we can reasonably safely assume the server crashed.

Reviewed By: farnz

Differential Revision: D19194389

fbshipit-source-id: 569bd20cffe2901e2801261ce783e99bcf8358e2
2019-12-20 16:14:24 -08:00
Jun Wu
2038472340 test-fb-hgext-sshaskpass: require linux to run
Summary:
The test is flaky in recent OSX builds.

The test is about a chg feature. Right now we only use chg on Linux. So limit
the test to Linux only.

Reviewed By: singhsrb

Differential Revision: D19191582

fbshipit-source-id: ce506f3f50c4368253caea0d73a647539c649735
2019-12-20 16:14:24 -08:00
Jun Wu
df5dce4138 test-convert-hg-source: require execbit to fix it on Windows
Summary:
After D19043330, the test is failing on Windows (no execbit).

When converting a repo, we almost always want to preserve the execbit. So let's
just skip the test if execbit is not available.

Reviewed By: singhsrb

Differential Revision: D19191556

fbshipit-source-id: 8e65d0b4b03833216ac8f28e2ae25f87de72304f
2019-12-20 16:14:23 -08:00
Adam Simpkins
80b8e1bfd2 drop the log level for some debug messages
Summary:
Reduce the log level for a few messages to help reduce some less important
clutter when running with an elevated debug log level.

Reviewed By: chadaustin

Differential Revision: D19188773

fbshipit-source-id: 396bb15e119fc12765ecbc707e7a1dadbdd02422
2019-12-20 16:14:23 -08:00
Chad Austin
3d3c2a9f32 stop storing sizes in their own local store column
Summary:
Remove some half-baked, unnecessary logic for caching sizes separately
from SHA-1. Eden's backing stores do not support chunking large files
yet, so there's no value in caching content SHA-1 and size
separately. This fixes a scenario where fetching blob size and then
SHA-1 would result in two backing store imports.

Reviewed By: fanzeyi

Differential Revision: D19169096

fbshipit-source-id: dc32f3313e5f4230c06a5bbaa67da7bf0febaba8
2019-12-20 16:14:23 -08:00
Chad Austin
873fd0de43 enable tree caching in non-hg backends
Summary:
Troditionally, ObjectStore relied on HgBackingStore writing directly
to LocalStore in order to cache trees. This had the unfortunate side
effect that other backing store implementations did not benefit from
tree caching.

Move tree caching into ObjectStore so all backing stores benefit from
tree caching.

Reviewed By: simpkins, fanzeyi

Differential Revision: D19168211

fbshipit-source-id: b1019591ebb4760cc8b933b9adb82174b8e5fa1f
2019-12-20 16:14:23 -08:00
Chad Austin
f0ace30454 fix doctor tests when host has low disk space
Summary:
The doctor tests for available disk space checked the host's actual
disk, causing them to fail when run on machines with full disks. Add a
fake and use it by default.

Reviewed By: simpkins

Differential Revision: D19145853

fbshipit-source-id: b4202a4eabffd8b7a968de9fb4370c0a0ca99d4d
2019-12-20 16:14:23 -08:00