Commit Graph

119 Commits

Author SHA1 Message Date
Jun Wu
7752e9e81f rustlib: move Node to a separate "types" crate
Summary:
The `Node` type will be used in multiple places. Let's move it to a standalone
crate so new libraries depending on it won't need to pull in all of
revisionstore's dependencies.

Note: I'd also like the `types` create to only define clean types. Given the
fact NULL_ID is not a great design in Mercurial (`Option<Node>` is a better
choice in Rust), it probably does not belong to the formal Rust `Node` type.
This diff is merely about moving things with minimal changes. NULL_ID will
be decoupled from `Node` in a follow-up.

Reviewed By: markbt

Differential Revision: D10132047

fbshipit-source-id: 5d05c5e0ac06a2d58556c4db11775503f9495626
2018-10-03 18:19:27 -07:00
Wez Furlong
d5726c9caa retry watchman commands if we hit a UseAfterFork error
Summary:
as it states in the comments, we ideally wouldn't get
in this state, but if we do, let's try to recover and continue
a bit more gracefully.

Reviewed By: quark-zju

Differential Revision: D9445209

fbshipit-source-id: a08e605f37f85a9296f71d595f950bbf110e204d
2018-08-23 12:05:29 -07:00
Wez Furlong
94e1767dcd sync with pywatchman upstream
Summary:
Sync up with pywatchman changes; some of these are rather
old now :-/

Reviewed By: quark-zju

Differential Revision: D9440040

fbshipit-source-id: a19b53bb21ffcb8e2566bfa7461a636bf1b739aa
2018-08-23 12:05:29 -07:00
Kostia Balytskyi
25a8ee686f hg: rename pathencoding into encoding
Summary:
In the later diffs I'll add some more functionality there, not strictly
related to encoding paths.

Reviewed By: quark-zju

Differential Revision: D9441427

fbshipit-source-id: 069ab30a24761038fa2c1a4f180bbc0699d38ef9
2018-08-22 09:06:20 -07:00
Durham Goode
a430982c51 revisionstore: fix historypack repacking
Summary:
The rust repack logic needs to check the appropriate ledger values for
historypacks.

Reviewed By: singhsrb

Differential Revision: D9367479

fbshipit-source-id: 9541b76156b6d8a8691b44b67c3935bc349cbe2b
2018-08-17 09:39:36 -07:00
Durham Goode
c7ff9e5572 pyrevisionstore: add known to getancestors
Summary:
The python getancestors implementation expects a known optional
argument. Unfortunately I can't get rust cpython to support optional arguments,
so for now we make it required.

Reviewed By: singhsrb

Differential Revision: D9367480

fbshipit-source-id: 47dd74e6cbd4fe5a774ebf0949e2114bae15844d
2018-08-17 09:39:36 -07:00
Bennett Magy
e31dcc3efe Updated parsing logic for .arcrc
Summary:
For some arcrc formats, hg commands prefer a deprecated blob in the .arcrc file which does not contain an oauth token, and only contains a phabricator cert (which is deprecated in favor of oauth)

This updates the logic to look for the phabricator.intern.facebook.com blob in the .arcrc to get an oauth token.

Reviewed By: mitrandir77

Differential Revision: D9351851

fbshipit-source-id: 11efe30b077480caa7b147c45a8d0eb78189277e
2018-08-16 13:50:53 -07:00
Durham Goode
c224eb6c81 pyrevisionstore: add cpython binding for HistoryPack
Summary:
Adds the cpython bindings that will let us call HistoryPack from rust
code.

Reviewed By: markbt

Differential Revision: D9273267

fbshipit-source-id: a29c97607d428255784c6508773cf14e283f287c
2018-08-15 15:24:40 -07:00
Durham Goode
3fd562904f pyrevisionstore: implement HistoryStorePyExt::get_node_info
Summary:
Implements the python get_node_info function on top of an existing
HistoryStore.

Reviewed By: markbt

Differential Revision: D9273266

fbshipit-source-id: c29ce2636394a6f46fc470508d8c789873850f74
2018-08-15 15:24:40 -07:00
Durham Goode
d3437f7352 pyrevisionstore: implement HistoryStorePyExt::get_missing
Summary:
Implements the python get_missing function on top of an existing
HistoryStore.

Reviewed By: markbt

Differential Revision: D9273262

fbshipit-source-id: ca6e123e670a57e740df83fbcc0a49582a6be3e2
2018-08-15 15:24:39 -07:00
Durham Goode
151cab342b pyrevisionstore: implement HistoryStorePyExt::get_ancestors
Summary:
Implements the python get_ancestors function on top of an existing
HistoryStore.

Reviewed By: markbt

Differential Revision: D9273263

fbshipit-source-id: 7c369a7681161cc93ffdda860081ae306ce3e06b
2018-08-15 15:24:39 -07:00
Durham Goode
970d6ad3eb pyrevisionstore: initial HistoryStorePyExt boiler plate
Summary:
Declares the HistoryStorePyExt trait and implements it for any class
that implements HistoryStore. In future diffs we'll implement each of the
functions, then call the functions from a rust cpython declared historypack
class.

Reviewed By: markbt

Differential Revision: D9273265

fbshipit-source-id: 8f2dabc54072076600a5cc22a814485df9035211
2018-08-15 15:24:39 -07:00
Durham Goode
7be1e07723 pyrevisionstore: move repack and datastore python wrappers
Summary:
In an upcoming diff we'll be adding HistoryStore python extension
methods, so let's move all the existing ones to their own files to keep things
clean.

Reviewed By: markbt

Differential Revision: D9273268

fbshipit-source-id: 56be3e3130c2c95d80510915d0d1a14e2fddc783
2018-08-15 15:24:39 -07:00
Durham Goode
1d43f39db1 pyrevisionstore: implements Repackable APIs
Summary:
Adds the python shim layer for calling repack operations on rust data
packs.

Reviewed By: quark-zju

Differential Revision: D8895339

fbshipit-source-id: 6ce6835b21591200cd546b548ba169ddeb6020c4
2018-07-26 12:17:20 -07:00
Durham Goode
8f3b150224 pyrevisionstore: use pathencoding to handle byte conversion
Summary:
Let's use the pathencoding crate instead of a lossy conversion to
strings.

Reviewed By: quark-zju

Differential Revision: D8992738

fbshipit-source-id: 2975b421a3de5d7fafb6688260d9482af701092e
2018-07-26 12:17:18 -07:00
Durham Goode
e1b153825b revisionstore: store paths on DataPack object
Summary:
The paths for each data pack are used in various situations (repack,
error reporting, etc) so let's store them and make them accessible via the
python api.

Reviewed By: quark-zju

Differential Revision: D8884773

fbshipit-source-id: 4108c98b4e303ba9bded1f264746fa4a84845c73
2018-07-26 12:17:17 -07:00
Jun Wu
cd91de7c43 codemod: use byte strings in cython files
Summary:
For some reason, buck cython build starts to treat unprefixed strings as
unicode strings. That breaks Mercurial where everything should be bytes.

Therefore add the b prefix to make them byte strings explicitly.

Reviewed By: DurhamG, ryanmce

Differential Revision: D9015176

fbshipit-source-id: 7a3ef9d735362e3ae02208ec19d0551bf0adaaa4
2018-07-26 09:53:23 -07:00
Durham Goode
2a037a6cc1 pyrevisionstore: convert getmissing to accept an iterator
Summary:
Previously it would only accept lists. This was fine for remotefilelog,
but treemanifest actually passes generators here, so we need to change this to
accept an iterator.

Reviewed By: quark-zju

Differential Revision: D8813143

fbshipit-source-id: 1d0cbf32d4c56521e26c55a6a061c22a1e618aed
2018-07-25 11:07:34 -07:00
Durham Goode
7241c3d13f pyrevisionstore: convert errors into the appropriate python errors
Summary:
Previously we converted all rust errors into python KeyErrors. Let's
cast KeyErrors into python KeyErrors and everything else into RuntimeErrors for
now. We can expand this as needed.

Reviewed By: farnz

Differential Revision: D8775753

fbshipit-source-id: f72e96db752167110d989226f2dedb9ff5bd82a3
2018-07-25 11:07:32 -07:00
Durham Goode
82a6a73b98 datastore: add get_delta function to DataStore trait
Summary:
This function is present on the python data store api, so let's
replicate it here. Later we should come back and refactor this to be a special
case of the get_delta_chain result, but for now we'll maintain the custom API so
we can start using this code from python.

Reviewed By: quark-zju

Differential Revision: D8774474

fbshipit-source-id: aabcff3a43ae68859a1bf3b23f433214571b1a9d
2018-07-25 11:07:32 -07:00
Adam Simpkins
49b000422f fix bug in py-cstore code deleting unallocated memory
Summary:
Fix subtreeiter_create() to avoid calling the `SubtreeIterator` destructor on
an object that it never constructed.

If an error is thrown constructing the `cmpNodes` vector or calling the
`SubtreeIterator` constructor, then the `SubtreeIterator` destructor should
not be called.  However, the `subtreeiter_create()` previously used
`Py_DECREF` to clean up the object, which always invoked
`subtreeiter_dealloc()` and called the `SubtreeIterator` destructor.

It looks like a lot of the other python object types declared in this file
have similar problems, and may incorrectly invoke C++ destructors on objects
that were never constructed if something goes wrong during object
initialization.  I have not fixed the other types yet as part of this diff.
The initialization logic for each type looks somewhat different, so they will
each need different fixes rather than this simple change of just calling
`PyObject_Del()` rather than `Py_DECREF()`.

Reviewed By: quark-zju

Differential Revision: D8963858

fbshipit-source-id: d610cac16133a7ff2350c17b13b5ebc7b7becc29
2018-07-24 09:32:02 -07:00
Durham Goode
39c3ffbbc5 datapack: add python datapack wrapper
Summary:
Now that all the business logic is reusable, let's create a python
datapack wrapper. In a future diff we'll allow Mercurial to instantiate this
instead of the existing cdatapack and datapack classes.

Reviewed By: quark-zju

Differential Revision: D8774486

fbshipit-source-id: 0df8ec0cc4ae7ebfc380c496b85555c78d5da505
2018-07-17 15:10:01 -07:00
Durham Goode
260e22ee9d pyrevisionstore: move python data store logic to DataStorePyExt trait
Summary:
In a future diff we'll be add a python datapack wrapper, in addition to
the existing datastore wrapper. The logic inside them is basically identical, so
let's move all the existing logic out to a trait that can wrap all DataStore implementations.

Reviewed By: quark-zju

Differential Revision: D8774257

fbshipit-source-id: ecb9a5d174decb803c1b1216db2d366b5215ab89
2018-07-17 15:10:01 -07:00
Stanislau Hlebik
e3c0c7ab65 mysqlutil: new utility for mysql
Summary:
Common library to interact with mysql. Will be used in the next diffs to record
pushrebase requests

Reviewed By: quark-zju

Differential Revision: D8801603

fbshipit-source-id: 1a926742cc40458e8f9da385620f0f3837f3ae09
2018-07-13 09:36:52 -07:00
Durham Goode
1ba7bce984 pyrevisionstore: fix delta chain base case name
Summary:
A recent change made delta base's be Option types, and when we
encounter a None we treat that as the end of a delta chain. In the python
translation layer code we turned this into a Key of ("", nullid) when it
should've been (filename, nullid). This broke a test.

Reviewed By: phillco, quark-zju

Differential Revision: D8768592

fbshipit-source-id: 858a8eadad8699d2e7e99040486f836710381a4f
2018-07-09 10:14:15 -07:00
Durham Goode
97ad2b1c85 pyrevisionstore: fix build breakage
Summary:
The recent change from delta.base being a Key to an Option<Key> needed
to update pyrevisionstore as well. I'll add this to buck build soon so we can
catch this.

Reviewed By: phillco, quark-zju

Differential Revision: D8752910

fbshipit-source-id: ecf6d2a8a74b72d10b6dc0fb24c7b9346f0f7ed8
2018-07-06 16:06:25 -07:00
Jun Wu
a487dacc4b codemod: reformat rest of the code
Summary:
Previous code format attempt (D8173629) didn't cover all files due to `**/*.py`
was not expanded recursively by bash. That makes certain changes larger than
they should be (ex. D8675439). Now use zsh's `**/*.py` to format them.

Also fix Python syntax so black can run on more files, and all lint issues.

Reviewed By: phillco

Differential Revision: D8696912

fbshipit-source-id: 95f07aa0c5eb1b63947b0f77f534957f4ab65364
2018-07-05 17:52:43 -07:00
Durham Goode
24a4751ff0 revisionstore: change Delta.data to Rc
Summary:
In a future diff we'll be returning data read from a pack file out as a
Delta. To avoid copies, we need to be able to return an Rc from DataPack. This
seems like it will be a common pattern, so let's go ahead and make Delta contain
its data as an Rc.

Reviewed By: quark-zju

Differential Revision: D8557949

fbshipit-source-id: 276005360bfa48e9154143dedce579a21129e976
2018-07-05 14:53:18 -07:00
Durham Goode
8057817dc1 revisionstore: add read/write functions to Metadata
Summary:
In a future diff we'll be serializing and deserializing metadata in
datapacks. Let's add the reader and writer functions for Metadata and some unit
tests.

Reviewed By: quark-zju

Differential Revision: D8303603

fbshipit-source-id: 7e7a7aa218c05179b205abf8b151b1488be674b3
2018-07-05 14:53:14 -07:00
Durham Goode
e35fa7b914 treemanifest: remove dependency on limits
Summary:
The windows compiler doesn't support this, so let's just hard code our
default value.

Reviewed By: singhsrb

Differential Revision: D8679518

fbshipit-source-id: 031a6e06d12c4980756e60cdeb76b6828ed8f775
2018-06-28 10:50:45 -07:00
Durham Goode
6d8f64bc0d treemanifest: change native tree walking to allow depth a parameter
Summary:
We're experiencing cases where users are pulling down far more trees
than they need. Let's enable the ability to download a certain depth of trees.

In this diff we just implement the actual iteration limiting in native code. In
a future diff we'll make the appropriate python changes and add a test.

Reviewed By: quark-zju

Differential Revision: D8523215

fbshipit-source-id: ccfeadee1525b86b1a5578631dbafe666de41f4c
2018-06-27 18:06:13 -07:00
Liubov Dmitrieva
7e4154021c Speed up hg status by using the fsmonitor.sockpath from the config
Summary:
provide sockpath in the config, rather than calling `watchman get-sockname` command from python.

the config variable was already deployed on all mac

this improves hg st by 250-300 ms

(the logic gives more priority when env var if specified (the env var override is usually used for testing))

the logic has a retry mechanism if we can't connect to the socket path specified in the config

next step: deploy config on dev servers (but we will have only few ms speed up there)

we use %i  (i for identity) notation for user

 [298] → hg conf | grep sockpath
fsmonitor.sockpath=/opt/facebook/watchman/var/run/watchman/%i-state/sock

Reviewed By: farnz

Differential Revision: D8549130

fbshipit-source-id: 31df9ebf3eb5133d3e6f64794022cda1b0fadec4
2018-06-25 03:51:24 -07:00
Liubov Dmitrieva
6db13f4759 fsmonitor: black format + unused import
Reviewed By: singhsrb

Differential Revision: D8551677

fbshipit-source-id: fe98ae41a382a499823bd52c518a269b5f8e3b40
2018-06-20 15:20:14 -07:00
Kostia Balytskyi
a322b60e97 datapackstore: use C++11-compatible chrono code
Summary:
D8410266 introduces the use of `chrono_literals` namespace, which requires
C++14. Since we don't use C++14 otherwise, let's not use it here as well.

Reviewed By: farnz

Differential Revision: D8418398

fbshipit-source-id: c2243c2cdf51587cda698bf7c2e96691cea2d305
2018-06-14 06:23:26 -07:00
Adam Simpkins
ce351de8fb ensure that DatapackStore::markForRefresh() actually refreshes the store
Summary:
This fixes how DatapackStore::refresh() computes if it needs to perform a
refresh.

Previously this code was using `clock()`, which returns the amount of CPU time
used by the program.  This seems like an undesirable metric to use: the amount
of CPU used by the current program doesn't seem like it should be relevant to
whether the files on disk need to be re-examined or not.  If the program has
slept for an hour we probably still want to refresh the files even though no
CPU time has been consumed.

As a result of how the computation was performed, markForRefresh() also would
not trigger a refresh if the program has used less than 100ms of CPU time so
far.

This was breaking some of the eden tests which create a repository pull some
packs into it, and then immediately refresh the store.  If all of this happens
in less than 100ms the DatapackStore code would not actually refresh the
store.

Reviewed By: chadaustin

Differential Revision: D8410266

fbshipit-source-id: f08d317b261ccfe89cff45bf3e511a2b87cf9fb5
2018-06-13 19:39:12 -07:00
Mark Thomas
af99203255 cstore: add treemanifest.listdir
Summary:
Add a new function to `cstore.treemanifest` to list the contents of a directory
in the tree manifest.

Reviewed By: ryanmce

Differential Revision: D8332425

fbshipit-source-id: db74f11a691cd6b8ac7d51aec6b7da8149c22027
2018-06-12 09:23:44 -07:00
Wez Furlong
31bcfbe58e hg: disable check-code tests for C code
Summary:
They're actively fighting against the clang-format config
and don't have an auto-fix.

Reviewed By: quark-zju

Differential Revision: D8283622

fbshipit-source-id: 2de45f50e6370a5ed14915c6ff23dc843ff14e8a
2018-06-05 19:21:43 -07:00
Durham Goode
c244d056b9 treemanifest: auto-format code
Summary: This fixes various clang formatter lint warnings.

Reviewed By: phillco, singhsrb

Differential Revision: D8283573

fbshipit-source-id: c466ccaf8d5e50a7421fd34e43cf49559431d416
2018-06-05 16:40:44 -07:00
Durham Goode
6bad025052 treemanifest: fix build warning about shadowed variables
Summary:
Optimized builds were giving a warning about shadowed variables, which
broke some of our continuous builds. Let's fix those.

Reviewed By: phillco

Differential Revision: D8287865

fbshipit-source-id: 8a2d023be93499ed6458a35ba8e8cb4d83d59e4a
2018-06-05 14:35:59 -07:00
Durham Goode
dee59f7ffc treemanifest: add a subdir tree walking api
Summary:
In a future diff we'll be adding the ability to request just a
subsection of a tree. In order to do that, we need to expose an api that can
iterate of just a subsection of the tree.

Since the treemanifest object itself acts mostly like a dictionary, and doesn't
expose sub-tree functionality, we expose sub-tree walks as a limited use class
level function.

Reviewed By: quark-zju

Differential Revision: D8216726

fbshipit-source-id: 0d72ef041fd6a973387f975b21e55c82f7ec789c
2018-06-05 11:45:25 -07:00
Saurabh Singh
5427b362d1 fix method naming
Summary:
A recent change renamed the methods assuming they were rust methods
but these methods are used in the python code and therefore, already had the
correct naming. This broke the one of the python tests calling the methods
which will pass now.

Reviewed By: DurhamG, quark-zju

Differential Revision: D8279742

fbshipit-source-id: 01761ad033c6669a0ae54dc1beb853a0d56df27d
2018-06-05 09:08:21 -07:00
Durham Goode
1ac8657f83 treemanifest: require setting the start path for SubTreeIterator
Summary:
In a future diff we'll be adding the ability to iterate over just a
subsection of a tree. In order for the resulting paths to be correct, we need to
be able to prime the start path. To do so, let's add a path argument to the
SubTreeIterator, and set it to empty string everywhere it's currently used.

Reviewed By: quark-zju

Differential Revision: D8216727

fbshipit-source-id: 1969f380f7ad13f54a7dbcd2283b0428c4480ab4
2018-06-04 18:23:03 -07:00
Durham Goode
6370628aeb treemanifest: move store logic to a separate function
Summary:
In a future diff we'll be adding a function that also needs to turn a
python store into a ManifestFetcher. So let's move that logic to a separate
function.

Reviewed By: quark-zju

Differential Revision: D8216728

fbshipit-source-id: f6d2e9577eccfcb015797a519264bd3b241ebae5
2018-06-04 18:23:03 -07:00
Durham Goode
18945e39b6 treemanifest: remove py_treemanifest from iterators
Summary:
Now that the subtree iterator doesn't contain a reference to the
treemanifest directly (it instead holds a ManifestPtr reference), we no longer
need to persist a reference to it at the python layer.

Reviewed By: quark-zju

Differential Revision: D8206301

fbshipit-source-id: 531d4399f0f54a47e0eb741f419e6242188a83ad
2018-06-04 18:23:03 -07:00
Durham Goode
aa1e1a5604 treemanifest: remove resultEntry from iterators
Summary:
Now that markPermanent no longer requires a ManifestEntry to update the
node, the resultEntry field on all the iterators is unused. Let's delete it.

Reviewed By: quark-zju

Differential Revision: D8156808

fbshipit-source-id: 21aeb050c91552c7e8973a33dd7e347457125a64
2018-06-04 18:23:03 -07:00
Durham Goode
4708242f44 treemanifest: remove logic that updates ManifestEntry.node
Summary:
Now that the node field is accessed via a getter that can lazily
compute it, let's get rid of the logic that proactively sets it. This will make
it easier to refactor the subtree iterator in a later diff.

Reviewed By: quark-zju

Differential Revision: D8156809

fbshipit-source-id: aabc3f68cc41baea0c166b9a2bd68bea6b1a6a03
2018-06-04 18:23:03 -07:00
Durham Goode
63834775d7 treemanifest: move ManifestEntry node behind an accessor
Summary:
Previously the ManifestEntry node field was public and consumers could
read it directly. This required that the node field be updated manually, which
added complications to other code paths. In a future diff we'll be simplifying
the SubTreeIterator code to not require setting node, and to do so we make node
calculated in this accessor.

Reviewed By: quark-zju

Differential Revision: D8156807

fbshipit-source-id: e1908b2149bc0ec8fb1279e37b8a66988ff125c6
2018-06-04 18:23:03 -07:00
Durham Goode
0bbc6b6666 treemanifest: switch native iterators to use ManifestPtr
Summary:
This switches the treemanifest native iterators to use the ManifestPtr
class instead of Manifest*. ManifestPtr does ref counting, and in a future diff
we'll use this ability to have the subtree iterator iterate over a portion of a
larger tree so we can serve just parts of trees to gettreepack requests.

Reviewed By: quark-zju

Differential Revision: D8156806

fbshipit-source-id: 4dbb60d008ac8d0c789c3f2db8f7e567c5869539
2018-06-04 18:23:03 -07:00
Saurabh Singh
7c9227818a refactor rust datastore to a consistent naming scene
Summary: This is just a refactor to address the naming scheme.

Reviewed By: quark-zju

Differential Revision: D8269217

fbshipit-source-id: 8c52d2c67837550e0b7dc1a45b3faf9a80319b61
2018-06-04 17:39:47 -07:00
Sergey Zhupanov
7d44cb5f01 Enabled additional compiler warnings in Eden.
Summary:
1. Enabled a number of additional C++ compiler warnings in Eden.
2. Fixed warnings-turned-errors that resulted from this change.

Reviewed By: simpkins

Differential Revision: D8132543

fbshipit-source-id: 2290ffaaab55024d582e29201a1bcaa1152e6b3e
2018-06-01 11:10:54 -07:00