Commit Graph

43353 Commits

Author SHA1 Message Date
Jun Wu
6111ea14fd treestate: add basic tests for TreeState
Summary: Basic tests about serialization and add/remove/modify operations.

Differential Revision: D7769657

fbshipit-source-id: 767ee8fb1d813de5bc99a5d6c81978c89c51f298
2018-05-23 06:12:45 -07:00
Jun Wu
18317cc4b5 posix: improve error message about broken symlinks
Summary:
Improve `makedirs` error message so it would be more helpful when there are
broken symlinks.

Differential Revision: D8108794

fbshipit-source-id: 08013022642efde946ef9d5c6b06b4763f4ad68f
2018-05-23 06:12:45 -07:00
Jun Wu
ac486dcc7e templater: add "ifgt" function
Summary:
This will be used by the next change testing whether `{files|count}` is
exceeding a threshold for deciding which commit template to use.

Reviewed By: phillco

Differential Revision: D8101518

fbshipit-source-id: 51e918c6d8ab7d6e8b71708d9291945b2a09a632
2018-05-22 19:51:52 -07:00
Jun Wu
d76a7f6039 committemplate: show diff stats
Summary:
D5521665 added a `{stat}` template that can be used to show lines changes.
That gives more information than a plain template with just filenames, and
could serve as a hint about whether to split a diff or not.

Reviewed By: farnz

Differential Revision: D7960550

fbshipit-source-id: 5cb151b5d7ff72ce6260a7a76f15d7c17bd3bbd4
2018-05-22 19:51:52 -07:00
Shish Girling
1137cc5743 display 'Landing' status in hg ssl output
Summary:
It's super-useful to know the difference between "Accepted (You need to go and click the land button)" and "Accepted (We're just waiting for the land system to do its thing, no work for you right now)"

Alternative approach in D8074898

Reviewed By: mitrandir77

Differential Revision: D8074794

fbshipit-source-id: fdfda64e3a542518b8609e3a415d8cb3156373cf
2018-05-22 02:51:56 -07:00
Durham Goode
1733eb026c hgsql: refactor sql revision writing
Summary:
Let's move the sql revisions table writing to a function. In a future
diff we'll reuse this functionality to allow backfilling a database from an
existing repository.

Reviewed By: singhsrb

Differential Revision: D8066524

fbshipit-source-id: 173161d476eab6e35ccd0649494fd8f0f8b3093f
2018-05-21 11:38:52 -07:00
Durham Goode
1ce89cff9a hgsql: add sqltreestrip
Summary:
Adds a command for deleting trees from history, both in mysql and
locally. This will be useful for recovering from treemanifest corruption.

Reviewed By: singhsrb

Differential Revision: D8066231

fbshipit-source-id: 34a57572c526d99c62d7d4a9e48d60d668065547
2018-05-21 11:38:52 -07:00
Michael Bolin
a5e1820702 Split out a new hgevents extension from fsmonitor.
Summary:
This splits out the logic in the `fsmonitor` extension that is responsible for
publishing `hg.filemerge` and `hg.update` state changes to Watchman into
its own extension, `hgevents`. This is because we want the behavior of
`hgevents` when Hg is running in Eden, but we do not want the remaining
behavior of `fsmonitor` when Hg is running in Eden, so splitting the logic
into separate extensions is the most straightforward way to achieve that.

To achieve the split, we move some more logic that is common to both
`fsmonitor` and `hgevents` out of `hgext/fsmonitor/__init__.py` and into
`hgext/extlib/watchmanclient/__init__.py`. Then we move these lines
out of `extsetup()` in `fsmonitor` to create `extsetup()` in `hgevents`:

```
    extensions.wrapfunction(merge, 'update', wrapupdate)
    extensions.wrapfunction(filemerge, '_xmerge', _xmerge)
```

We also have to pull all of the transitive dependencies for this logic
into `hgevents`.

Finally, we also have to define a `reposetup()` function in `hgevents`
that does a subset of what `reposetup()` does in `fsmonitor`. Specifically,
it ensures that a Watchman client is created for a `repo`, as appropriate,
so that it can be used to dispatch state changes to Watchman in
`state_filemerge` and `state_update`.

Note that the utility functions `createclientforrepo()` and
`getclientforrepo()` have been added to ensure that only one
Watchman client is created (and shared) when both `fsmonitor`
and `hgevents` are enabled.

Today, when an Hg repo is created in Eden, we set `extensions.fsmonitor=!`
in the `.hg/hgrc`:

diffusion/FBS/browse/master/fbcode/eden/hooks/hg/post-clone.py$69

Therefore, to get existing repos (both Eden and non-Eden) to pick up
the `hgevents` extension automatically, we add it to the list of
`[extensions]` in `common.rc`:

diffusion/FBS/browse/master/fbcode/scm/hg/fb/staticfiles/etc/mercurial/repo-specific/common.rc$53-60

as this is where `fsmonitor` is configured. We do not enable it in
`scm/hg/fb/staticfiles/etc/mercurial/facebook.rc` because
there is no reason to enable `hgevents` on Hg servers. Therefore, we
also decline to add `hgevents` to the set of `DEFAULT_EXTENSIONS` in
`scm/hg/mercurial/extensions.py`.

Reviewed By: quark-zju

Differential Revision: D8003628

fbshipit-source-id: 4f23881f8c25f4638f5475c292537b0352ae8d15
2018-05-21 09:30:28 -07:00
Durham Goode
e1ec59a2f4 treemanifest: add key validation to the cachestore
Summary:
We had a bug where the cache store had a value that didn't correspond
with it's key. Let's add the key to the value so we can ensure they are always
paired correctly.

Reviewed By: phillco

Differential Revision: D8065151

fbshipit-source-id: 01be3a3432d1b4f5e9a234b35b8315c37b1869c3
2018-05-21 09:05:12 -07:00
Liubov Dmitrieva
aa61690c9a watchman rust client for hg: add test for arrays of objects
Summary:
watchman rust client: add tests for arrays of objects

this contains a reproducer test for broken compact arrays in combination with untagged enums

Reviewed By: sunshowers

Differential Revision: D7877495

fbshipit-source-id: 7fc3c05f1590e708a7645f0f9adbfd545e8bae42
2018-05-21 04:30:34 -07:00
Liubov Dmitrieva
44af40467e watchman rust client for hg: hg client
Summary:
Implement fsmonitor interfaces used by Mercurial fsmonitor extension, namely:

 - query_dirs
 - query_files
 - state_enter
 - state_leave

Reviewed By: quark-zju

Differential Revision: D7876428

fbshipit-source-id: 45c7a23bd0da4dcedcc473d75ac75fbd006a599a
2018-05-21 04:30:33 -07:00
Liubov Dmitrieva
7800d0ec9f watchman rust client for hg: initial implementation
Summary:
watchman rust client for mercurial needs

* describe responses and request with strong typing
* supports bser and json protocols
* command line transport and unix socket transport
* socket discovery (env or query command line client)
* read timeouts

Reviewed By: wez

Differential Revision: D7764586

fbshipit-source-id: 1f5725f6ce615e3e6e30395d09b5b37e0c2229d4
2018-05-21 04:30:32 -07:00
Jun Wu
b9b8f69767 repair: workaround ftruncate returning 1
Summary:
wjb has seen some weird truncate issues, which is caused by `ftruncate (2)`
returning 1 while its manpage says it returns <= 0. The recent contbuilds
also failed due to this.

While we're waiting for the upstream fix [1], let's workaround it from the
userspace to unblock the contbuild.

[1]: https://www.spinics.net/lists/linux-btrfs/msg78417.html

Reviewed By: DurhamG

Differential Revision: D8064611

fbshipit-source-id: df6c44255de47efa25a4c2b713a159ecd61b7478
2018-05-18 17:16:30 -07:00
Phil Cohen
9cae1acbc6 fix module imports for metrics.py
Summary: Didn't realize it was possible to land with a failure.

Reviewed By: DurhamG

Differential Revision: D8065037

fbshipit-source-id: abc34efeb4898f2068e57691adb0ddec8a64eabd
2018-05-18 16:31:30 -07:00
Phil Cohen
46bb070f04 move fbmetrics to __init__.py
Summary: Ran into an ImportError with the old layout.

Reviewed By: quark-zju

Differential Revision: D8061476

fbshipit-source-id: 6fc0b0c3a426e49eb5a43d59e13c69efd19fd453
2018-05-18 13:31:06 -07:00
Mark Thomas
d1b5faa3ac hint: allow hints to be defined and triggered in config
Summary:
Add a new config section, `[hint-definitions]` that describes additional hint
messages.  This can also be used to override built-in hint definitions.

Add a new template function `triggerhint(name)` that triggers the given hint.

Reviewed By: quark-zju

Differential Revision: D8056847

fbshipit-source-id: 5ffc945343133eb635ae0820190ecad9f16bc731
2018-05-18 11:19:35 -07:00
Durham Goode
5e95b0e32e treemanifest: change heuristic for sending local trees
Summary:
Previously if we were pulling between peers, we would not send trees
for public commits, since we assumed the receiving end could fetch them from the
server.

It turns out there are situations where public commits are actually local only
to the client (like when pulling directly from subversion before the server
does), so let's change our heuristic to send trees if they exist in the source
client's local data store.

This also required updating the server side tree pack generation logic to handle
the case when the client sends a base manifest node that the server doesn't know
how to handle. We now ignore those bad base manifests.

Reviewed By: phillco

Differential Revision: D7992502

fbshipit-source-id: 8ddd1836e6f325363ad2bb6eae34ddbbc84c2d11
2018-05-18 10:46:59 -07:00
Jun Wu
4c2fadcbba blackbox: add a way to label logs with a "request id"
Summary: This would help labeling interesting commands from callers.

Reviewed By: DurhamG

Differential Revision: D8057148

fbshipit-source-id: 647cc91be3baeaa0362799603a66dab0c6c570b8
2018-05-18 10:46:59 -07:00
Jun Wu
84cf12c3e7 logging: add logging about fsmonitor notefiles, clock and treedirstate root
Summary: Help investigate issues.

Reviewed By: DurhamG

Differential Revision: D8047436

fbshipit-source-id: de21b84330b3b90b06d81621ec362a20b5b747c7
2018-05-17 20:09:16 -07:00
Jun Wu
7049301036 fsmonitor: fix a potential issue with status calculation
Summary:
From the code context, if p2 is `context.overlayworkingctx`, we should avoid
update fsmonitor state.

Reviewed By: phillco, singhsrb

Differential Revision: D8044903

fbshipit-source-id: 82b750cc73a75a2aaa77a630bd73a1a77eedc4e9
2018-05-17 12:21:47 -07:00
Ryan McElroy
2e8e0f6fd0 rage: pretty-print fsmonitor output
Summary:
Previously we would print out all the contents of the file as-is but
this is very user-unfriendly and could produce huge unreadable outputs.

Now we print onyl the first 20 files and label the fields.

Reviewed By: phillco

Differential Revision: D8025914

fbshipit-source-id: c330c34ed4f31c3337bc414cd72c3e43cdd0caf5
2018-05-16 09:42:45 -07:00
Durham Goode
8a6a929876 lz4: add rust lz4 bindings
Summary:
The crates.io lz4 bindings only support the lz4 framed format, while
our python lz4 library produces custom framed compressed blobs. Let's add a new
wrapper around lz4-sys that handles are special framing. We can migrate to the
standard framing later.

Reviewed By: quark-zju

Differential Revision: D7855502

fbshipit-source-id: 04abb1bc784c6be7f22bcd80645d1b50debc93bd
2018-05-16 09:13:18 -07:00
Liubov Dmitrieva
86630f2155 infinitepush: add missing required escaping for mysql LIKE queries
Summary: we should escape \ as \\ according to the doc

Reviewed By: markbt

Differential Revision: D8024433

fbshipit-source-id: 14fb84741dfbd066d8278146bc6fef0cd76846c6
2018-05-16 08:50:41 -07:00
Saurabh Singh
a4f5e8aefc add tests for empty union date store
Summary:
These tests just test the expected outcome when the union data store
is empty.

Reviewed By: quark-zju

Differential Revision: D8018975

fbshipit-source-id: a2cc4c87509b857dbf5f6af506f165ea62080db8
2018-05-15 18:37:47 -07:00
Saurabh Singh
cab75fbb90 add common traits for Key
Summary:
This commit derives the common traits for the Key type just as we did
for the Node type in D7872300.

Reviewed By: quark-zju

Differential Revision: D8018973

fbshipit-source-id: 566a69be16d74529c6eb5f157b84de25835f780f
2018-05-15 18:37:47 -07:00
Saurabh Singh
88a2d8ff6b implement quickcheck::Arbitrary for Key in revisionstore
Summary:
We need to implement `quickcheck::Arbitrary` for Key so that it can be
used for the quickcheck tests.

Reviewed By: quark-zju

Differential Revision: D8018977

fbshipit-source-id: dbdbb34fbd7eaeb18321eafec4604d752f496a4d
2018-05-15 18:37:47 -07:00
Saurabh Singh
0b5b994973 implement quickcheck::Arbitrary for Node type in revisionstore
Summary:
We need to implement `quickcheck::Arbitrary` for Node so that it can
be used for quickcheck tests.

Reviewed By: quark-zju

Differential Revision: D8018978

fbshipit-source-id: ceda99622370bee6e9d05b839f9856c0526f553c
2018-05-15 18:37:47 -07:00
Saurabh Singh
411736dc7c add 'quickcheck' crate to revisionstore
Summary:
I am planning to use the `quickcheck` crate for testing the union data
store. This commit just adds the crate to the revisionstore.

Reviewed By: quark-zju

Differential Revision: D8018974

fbshipit-source-id: d390deeb01aa7d1bf1e66bb5bc948d48bd3f269e
2018-05-15 18:37:47 -07:00
Saurabh Singh
8688e1cc5e union data store: union data store implementation in Rust
Summary:
This commit just introduces the `UnionDataStore` and implements the
`DataStore` trait for it.

Reviewed By: quark-zju

Differential Revision: D7801615

fbshipit-source-id: 14eabd2aa1b1e085de94aec126a7108231ec6e8d
2018-05-15 18:37:47 -07:00
Saurabh Singh
d2b9c6c6ac union store: introduce common type for the union store implmentation
Summary:
We will be implmenting multiple union stores and therefore, it makes
sense to encapsulate the common logic in its own type. This also abstracts the
usage of `RefCell` within the union store.

Reviewed By: jsgf

Differential Revision: D7884651

fbshipit-source-id: a74b6d9df5ee0d7d04359219e276fd5713b3a00b
2018-05-15 18:37:47 -07:00
Saurabh Singh
bcb7ac0b32 node: add common traits for the node type
Summary:
Based on the review comments for D7801615, this commit adds the common traits
for the `Node` type

Reviewed By: jsgf

Differential Revision: D7872300

fbshipit-source-id: 44dedfc3ec0e18ac0dee0dcfc5f7dfc4aff2511d
2018-05-15 18:37:47 -07:00
Michael Bolin
36eb4d26f8 mv fsmonitor/watchmanclient.py to extlib/watchmanclient/__init__.py
Summary:
There is some logic in `hgext/fsmonitor/watchmanclient.py` that needs
to be shared between fsmonitor and the new extension we are trying to
split out of it as part of T29379329.

Reviewed By: quark-zju

Differential Revision: D8003255

fbshipit-source-id: de01c5ba1460d7dde22969980b296afb3a942dd7
2018-05-15 12:06:47 -07:00
Michael Bolin
54b487b301 Move hgext/fsmonitor/pywatchman/ to hgext/extlib/pywatchman/
Summary:
This is a precursor to splitting the fsmonitor extension, as both
it and the new extension will use pywatchman.

Reviewed By: quark-zju

Differential Revision: D8002713

fbshipit-source-id: 37983fe2898d23223d1178eb3f15685f17ff8868
2018-05-15 12:06:47 -07:00
Liubov Dmitrieva
76c5b37722 rebase: do not rely that every node in obsutil.allsuccessors present in the repo or changelog node map
Summary:
This is regulary not the case if Commit Cloud enabled, if a lot of work is done on one
machine 1, then cloud sync is done on another machine (machine 2), we sync draft not obsolete
heads and all history of obsmarkers, but there is no guarantee we download all
the obsoleted commits to the machine 2.

So, there can be a sequence of obsmarkers from commit A to commit B, when some commit in between hasn't been fetched to the machine 2.

Function obsutil.allsuccessors returns all successors (not only final successors) and it is intentionally do not check presence in the repo.

Reviewed By: DurhamG

Differential Revision: D8009823

fbshipit-source-id: f6b90011acaa518f71a2033eb2b885b27a7f06e7
2018-05-15 11:39:40 -07:00
Liubov Dmitrieva
eb93a4ce74 commit cloud: if option to show requests is on, also show the responses
Summary:
[hg] commit cloud: if option to show requests is on also show the responses

this is useful for investigating issues with Commit Cloud

the option is

```
[commitcloud]
debugrequests = true
```

only works with --debug

Reviewed By: markbt

Differential Revision: D7950549

fbshipit-source-id: ab7f07ad2a61f6bee9c627dfa3d3b43d6380e9cf
2018-05-15 08:17:35 -07:00
Durham Goode
8c6e5fd964 mpatch: add rust bindings
Summary:
Adds rust bindings around the existing mpatch c library.

Also fixes a bug in mpatch where it could reference uninitialized memory.

Reviewed By: quark-zju

Differential Revision: D7769299

fbshipit-source-id: bcc21df85c97ef6f5537ebff8fbf1b350ee64fc3
2018-05-14 16:06:32 -07:00
Alexandre Marin
5e3b491c6f importer - lowercase p4 path in p4->hg path mapping
Summary: This change makes all p4 paths lowercase when dealing with the mapping from p4 to hg, thus making the importer work fine with different case paths from Perforce.

Differential Revision: D7978382

fbshipit-source-id: 134705ac27d889e80e5de589ab165e8acfd52346
2018-05-14 14:46:48 -07:00
Jun Wu
e3010aca6b tests: restore simple error output for buck .t tests
Summary:
Partially revert D7584511 so buck test failures for `.t` tests would show
the `.t` output change instead of a long, less meaningful environment
variables.

Reviewed By: singhsrb

Differential Revision: D7992713

fbshipit-source-id: 64de5e19589277018e1e37968ea69a2329d67852
2018-05-14 13:00:29 -07:00
Mark Thomas
741ae1d88e smartlog: refactor smartlog templates
Reviewed By: ryanmce

Differential Revision: D7988363

fbshipit-source-id: 8f38f06360876af7f9b88a3e97c293e16dbd0f32
2018-05-14 12:05:13 -07:00
Durham Goode
0efe4fb7db infinitepush: add test for excess treemanifest downloads
Summary:
This adds a test that verifies that if we pull infinitepush commits and
received some normal-public commits as part of that pull, we will only receive
the tree data for the infinitepush commits. The commit cloud team had some
concerns here, since this will be much more common in that future.

Reviewed By: singhsrb

Differential Revision: D7993229

fbshipit-source-id: c91752e0da86a81142503ed97ac104668d1af874
2018-05-14 12:05:13 -07:00
Durham Goode
18697e3fb3 hg: implement getmissing() for Rust hgstore
Summary:
Initial implementation of getmissing for a simple Rust pass through
data store. Future diffs will extend this to implement the union data store
completely in Rust.

Reviewed By: quark-zju

Differential Revision: D7632405

fbshipit-source-id: e660d33f8231410805cfaba6d77c56f27b002f8e
2018-05-14 12:05:13 -07:00
Durham Goode
f2b4d7f2e0 hg: implement getmeta() for Rust hgstore
Summary:
An initial implementation of getmeta for the Rust hg data store. Future
diffs will add more functionality.

Reviewed By: quark-zju

Differential Revision: D7632404

fbshipit-source-id: 53bd3b96b777bc3c5aef2b4d07ce1a9d9a5a52ed
2018-05-14 12:05:13 -07:00
Durham Goode
39dde8552d hg: implement getdeltachain() for Rust hgstore
Summary:
An initial implementation of getdeltachain for a simple pass through
data store. Future diffs will add additional functionality.

Reviewed By: quark-zju

Differential Revision: D7632407

fbshipit-source-id: 1a38089ba8ea70f8772af95afd871ee493082d80
2018-05-14 12:05:13 -07:00
Durham Goode
880ff5d0a9 hg: implement datastore.get() for Rust hgstore
Summary:
Implements the get function for a simple pass through rust data store
layer. Future diffs will implement more functions, and then later we will
implement the entire union data store in Rust.

Reviewed By: quark-zju

Differential Revision: D7632403

fbshipit-source-id: 3a1d0a8500e3110213d70dc1cff637cf8eadd809
2018-05-14 12:05:13 -07:00
Durham Goode
a97e97e413 hg: initial boiler plate for new hgstore crate
Summary:
This will contain all the Python centric hg store code that will let
Python call into the Rust storage layer.

Reviewed By: quark-zju

Differential Revision: D7632406

fbshipit-source-id: 6b7bcc8f47a23e9c0121e1f92de1137369bf584e
2018-05-14 12:05:12 -07:00
Durham Goode
507677e8a0 infinitepush: add test for excess file downloads during pullbackups
Summary:
If a user runs hg pullbackup while their repository doesn't have the
latest commits, it's possible that pullbackups will deliver some public commits
to the user in order to then deliver the necessary draft commits on top. Let's
add a test that verifies the public commits are not delivered with remotefilelog
data.

Reviewed By: quark-zju

Differential Revision: D7927966

fbshipit-source-id: 8661a291c8b3a67359c9975e130f23fec643307d
2018-05-14 11:21:43 -07:00
Jun Wu
410cb5dcef xdiff: fix types on 32 bit systems
Summary:
Similar to upstream patches [1] [2].

[1]: 1b9f644050
[2]: https://phab.mercurial-scm.org/D3538

Reviewed By: DurhamG

Differential Revision: D7989782

fbshipit-source-id: fc11569d92f778c0a3509204fc9fa1690c078dcc
2018-05-14 11:14:38 -07:00
Jun Wu
f085bc4510 templatekw: define 'username' as current username
Summary:
This could be useful for implementing logic like "if this commit is by the
current user, show something differently".

Reviewed By: markbt

Differential Revision: D7964292

fbshipit-source-id: de1ac0b5edde838dbaae646a88ebf636b4925b22
2018-05-14 11:14:38 -07:00
Liubov Dmitrieva
77e1cb22e8 commitcloud: do not use filtered set of heads when update infinitepush state
Summary:
commitcloud: do not use filtered set of heads when update infinitepush
state

hg cloud sync command can be interrupted when pulling

some of commits will be pulled, but not written to the commit cloud and
infinitepush states

the next run of cloud sync is smart, it will not pull what has been already pulled in but will fix the
commit cloud state

but because we used the filtered list of heads for infinitepush state, it will not fix the infinitepush
state

So, we shouldn't use the filtered set

Reviewed By: markbt

Differential Revision: D7972200

fbshipit-source-id: 94c01694d4ac77beeed647f77cbdb30fe3f7a404
2018-05-14 06:42:19 -07:00
Jun Wu
5851c126a5 tests: fix helpers-usechg.sh
Summary:
I noticed some tests were running slower without chg. Upon investigation,
`alias hg=...` seems stop working. Similar to D7563731, let's define
functions explicitly instead.

Reviewed By: singhsrb

Differential Revision: D7964291

fbshipit-source-id: 08a69c865ffef6be7e84dd66a7cece9284b94e60
2018-05-11 16:20:55 -07:00