Commit Graph

801 Commits

Author SHA1 Message Date
Mark Thomas
94ff729e43 commitcloud: close connection between cloud sync pulls
Summary:
Connecting to large workspaces can result in many pulls within a single sync.
This re-uses the connection to the server.  We have seen instances where the
server can't serve all of these pulls and crashes with a MemoryError.

Pragmatically close the connection between each pull to prevent this.

Reviewed By: farnz

Differential Revision: D16858728

fbshipit-source-id: 7561c6f01c38df2706bd7fd76f5a7387e9728dc8
2019-08-16 10:19:25 -07:00
Aleksei Kulikov
0f11c07409 snapshot: fix windows tests and make hashes deterministic
Summary:
So far the hashes of manifest/commits may vary, mostly because of
different path separators on different platforms (`/` vs `\\`) and its serialization to string in the snapshot manifest.

Reviewed By: markbt

Differential Revision: D16856130

fbshipit-source-id: a19dff113b9b24f1c7f387b9bc5a5e39e83ef8af
2019-08-16 10:15:05 -07:00
Shu-Ting Tseng
150798aac8 translate from hg to git hash should use the extras
Summary:
Now that we are writing the git hash inside the commit itself, if we are translating
from hg to git hash, we should just use that rather than loading the entire map and
build a dict and look it up.

The performance of this translation will also improve quite a lot.

Some small sample benchmarking:

```
suiting@devvm5006:configerator  (659199b|remote/master)$ time ~/fbcode/scm/hg/hg log -r master -T '{node} || {gitnode}\n' --config exte
nsions.fbconduit=! --config extensions.hggit=
659199bf7c7850ea9ffa9e0ad50eb84597977dea || 69f05aeec13f09c44dd00d2a85fe9d461ba6841e

real    0m0.563s
user    0m0.004s
sys     0m0.007s
suiting@devvm5006:configerator  (659199b|remote/master)$ time ~/fbcode/scm/hg/hg log -r master -T '{node} || {gitnode}\n'
659199bf7c7850ea9ffa9e0ad50eb84597977dea || 69f05aeec13f09c44dd00d2a85fe9d461ba6841e

real    0m14.706s
user    0m0.006s
sys     0m0.006s
```

Reviewed By: quark-zju

Differential Revision: D16833526

fbshipit-source-id: 7d3096649cf24967d13596e70463bc125081ba4f
2019-08-16 07:09:31 -07:00
Jun Wu
bf056a2962 revset: start deprecating revision number resolution
Summary:
The upcoming changelog change will *have to* use a different set of numbers.
Some of the numbers might be generated on demand, which has difficulity
resolving a number to a commit hash.

There are a lot of internal (especially, tests) usecases of revision numbers.
The deprecation message is only shown for user-provided inputs (ex. things
that go through `scmutil.revrange`).

This does not affect the use of `{rev}` template yet.

Reviewed By: sfilipco

Differential Revision: D16795522

fbshipit-source-id: 7a5578ecc0afdcc86830238471ff95203c96dc3f
2019-08-15 13:24:56 -07:00
Jun Wu
8b4c670550 changelog: get access to config options
Summary: Pass `uiconfig` to changelog so it can read config options.

Reviewed By: sfilipco

Differential Revision: D16683785

fbshipit-source-id: a64cfbe2cefa6b20ec695d2766bcfe878c764323
2019-08-15 12:47:35 -07:00
Jun Wu
6d7c287ab2 ui: split config handling to a separate class
Summary:
A large portion of `ui` is config handling. Split it to a separate class so we
can pass that separate class to places that need pure configuration.

Some `develwarn`s are skipped since the new class does not have access to fout
or ferr.

Reviewed By: DurhamG

Differential Revision: D16683787

fbshipit-source-id: d823b9e5fc6f8ed08fff3401ab3502ad3c434f00
2019-08-15 12:47:35 -07:00
Aleksei Kulikov
ad771fcaec snapshot: minor codestyle fixes
Summary: Minor changes.

Reviewed By: mitrandir77

Differential Revision: D16829944

fbshipit-source-id: 08876408bab9a367b852e85e1d7ca86dc0da08a3
2019-08-15 10:48:42 -07:00
Aleksei Kulikov
97c6c6ddaf snapshot: add debugcheckoutsnapshot command
Summary:
Allow the user to check out on the snapshot by its revision id.
Snapshot == "a commit with extra containing a key `snapshotmanifestid`".
This corresponding value can be `None`, that would mean that snapshot does not contain untracked/missing/merge files.

Reviewed By: mitrandir77

Differential Revision: D16788479

fbshipit-source-id: bf4a9508acc940290b18123d3dd7b7fefae83782
2019-08-15 10:48:41 -07:00
Aleksei Kulikov
b45ba7a551 snapshot: add --force option to manifest checkout
Summary:
Now `hg debugcheckoutsnapshotmanifest` overwrites files if given the `--force` flag.
It also gives a more detailed output on the changes it makes.

Reviewed By: mitrandir77

Differential Revision: D16786334

fbshipit-source-id: b41d6241ffb478bd6c30a01c154b095d1ea92d78
2019-08-15 10:48:41 -07:00
Aleksei Kulikov
169465460a snapshot: add debugsnapshot command
Summary:
Add the `debugsnapshot` command, which will be renamed to `snapshot` later.

It creates a snapshot manifest that features information about
* untracked files,
* missing files,
* merge state artifacts from `.hg/merge` and `.hg/rebasestate`.
The snapshot manifest is stored in local lfs.

Then it creates the actual snapshot -- a fake commit, which has the snapshot oid in extra data.
It does not handle unresolved merge conflicts and other difficult states on this stage.

~~Finally, it restores the working copy and dirstate to status quo.~~
It doesn't need to be done, now we create only the commitctx, which does not wreck the dirstate.

Reviewed By: mitrandir77

Differential Revision: D16716359

fbshipit-source-id: 743f7427ce89c3fca6f844487bac1c456338e613
2019-08-15 10:48:41 -07:00
Mohammad Ayoub
075801c976 sync checkout locations on update
Summary:
Whenever a checkout is done, the new commit is sent to commitcloud.
This currently works with the hook on update, but the hooks on commit are not working

Reviewed By: mitrandir77

Differential Revision: D16687423

fbshipit-source-id: a0b861d301c84764f31787454cdec594b0519fa3
2019-08-15 08:37:14 -07:00
Jun Wu
2dad4c70d1 fastlog: add an option to use fastlog for files
Summary:
The fastlog code says it cannot handle file renames, which is not true as far
as I know. Therefore, try use it for files. This affects the `follow()` revset.

I picked a random file, and fastlog is faster than the alternative code path
even with warm cache:

With fastlog:

  % ./hg log edenscm/mercurial/smartset.py --time --pager=off -T '.' --debug --config fastlog.files=1
  found common parent at a320f95a23716d0d106d922fa07ffcf0f838d3ff
  starting fastlog at a320f95a23716d0d106d922fa07ffcf0f838d3ff
  .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
  time: real 2.060 secs (user 1.870+0.000 sys 0.290+0.000)

Without fastlog, cold cache:

  % sudo rm /var/cache/hgcache/fbsource/packs/*.hist*; ./hg log edenscm/mercurial/smartset.py --time --pager=off -T '.' --debug --config fastlog.files=0
  fastlog: not used because fbcode/scm/hg/edenscm/mercurial/smartset.py is not a directory
  .fetching content for 1 file over HTTPS
  35.56 kB downloaded in 147 ms over 1 request (0.24 MB/s; latency: 147 ms)
  fetching history for 1 file over HTTPS
  445 B downloaded in 56 ms over 1 request (0.01 MB/s; latency: 56 ms)
  running ssh -oControlMaster=no hg.vip.facebook.com 'hg -R '\''/data/scm/fbsource?stage1_read'\'' serve --stdio'
  sending hello command
  sending between command
  remote: 713
  remote: capabilities: unbundlehash gettreepack pushkey getfile getflogheads listkeyspatterns knownnodes getbundle lookup treeonly stream_option remotefilelog known unbundle=HG10GZ,HG10BZ,HG10UN clienttelemetry branchmap changegroupsubset unbundlereplay batch bundle2=HG20%0Ab2x%253Ainfinitepush%0Ab2x%253Ainfinitepushmutation%0Ab2x%253Ainfinitepushscratchbookmarks%0Ab2x%253Arebase%0Abookmarks%0Achangegroup%3D01%2C02%0Adigests%3Dmd5%2Csha1%2Csha512%0Aerror%3Dabort%2Cunsupportedcontent%2Cpushraced%2Cpushkey%0Ahgtagsfnodes%0Alistkeys%0Apushkey%0Aremote-changegroup%3Dhttp%2Chttps%0Atreemanifest%3DTrue%0Atreemanifestserver%3DTrue%0Atreeonly%3DTrue streamreqs=generaldelta,lz4revlog,revlogv1 getannotate stream-preferred
  remote: 1
  sending clienttelemetry command
  connected to hg020.prn2.facebook.com
  sending getpackv2 command
  ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
  876 files fetched over 876 fetches - (1 misses, 99.89% hit ratio) over 5.98s
  (running background incremental repack)
  time: real 11.920 secs (user 5.050+0.000 sys 0.470+0.000)

Without fastlog, warm cache:

  quark@devvm33994 ~/fbcode/scm/hg % ./hg log edenscm/mercurial/smartset.py --time --pager=off -T '.' --debug --config fastlog.files=0
  fastlog: not used because fbcode/scm/hg/edenscm/mercurial/smartset.py is not a directory
  .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
  time: real 2.530 secs (user 2.050+0.000 sys 0.070+0.000)

This is one step forward getting rid of the legacy filenode / ancestormap
logic. It regresses on offline experience, but we can build simple caches
around the `follow()` revset later.

Reviewed By: markbt

Differential Revision: D16365331

fbshipit-source-id: 16ffd6c3ec2daa5530fed94fb9c41fe75efd6182
2019-08-13 19:12:17 -07:00
Xavier Deguillard
3f21c278d4 remotefilelog: Rust repack is the default
Summary:
This option has been on for several months now, let's enable it by default in
the tests too. Since the behavior is slightly different, the tests had to be
adjusted:
  - The packfile hashes are different due to a different repack algorithm,
  - test-fb-hgext-remotefilelog-gcrepack.t removed due to gc not being a thing
    with the Rust repack,
  - test-fb-hgext-remotefilelog-repack-corrupt.t corrupt packs aren't detected
    and removed at repack time, but later,
  - test-fb-hgext-remotefilelog-repack.t we no longer re-delta context in the
    Rust repack

Reviewed By: quark-zju

Differential Revision: D16774858

fbshipit-source-id: 7b7a3d96598c1ded0f64237047c3d97510050e4a
2019-08-13 10:50:02 -07:00
Kostia Balytskyi
3767b9c61a remotefilelog: remove unneeded len comparison
Reviewed By: HarveyHunt

Differential Revision: D16782324

fbshipit-source-id: 6924763fa423d4fa516052e01e5e13b0262a8779
2019-08-13 03:59:28 -07:00
Xavier Deguillard
97a6bc8e6a remotefilelog: run python repack even if the pack directory doesn't exist
Summary:
When rust repack is default, and the packs directory doesn't exist, we wouldn't
try to run the loosefile repack, even if we had some. Let's move the packs
directory check a bit later to allow the loosefile repack to run.

Reviewed By: quark-zju

Differential Revision: D16774857

fbshipit-source-id: 1d1b67ae93c1b3aa2d07d5d15325e9be16a01196
2019-08-12 20:08:00 -07:00
Xavier Deguillard
d257546639 remotefilelog: simplify options management in repack
Summary:
Let's always make options non-None. This was causing some issues when switching
to the Rust repack by default.

Reviewed By: quark-zju

Differential Revision: D16774856

fbshipit-source-id: 16fcda0b5a38327d389ed03f87c73d8bd00d5877
2019-08-12 20:08:00 -07:00
Kostia Balytskyi
f4042cad44 remotefilelog: add censorship handling at a filelog level
Summary:
Currently, only contents coming from `getfiles` request can replace
`BLACKLISTED_CONTENT` with `BLACKLISTED_MESSAGE`, because this is implemented
in `basestore.py`. Let us add an additional piace of logic to the
`remotefilelog.revision`, which would handle this the same way.

Note: this diff does not remove the old implementation. I think we need to do
this, but I want to focus on solving immediate problem, which is the absense
of support for censored results in `getpackv1`/`getpackv2`, before I fix the
tech debt. Note also that current doubling of the replacement logic does not hurt,
since it can't apply twice.

Reviewed By: xavierd

Differential Revision: D16735899

fbshipit-source-id: f10b72997614c58432476bcf95a3bde774bc278e
2019-08-12 08:04:58 -07:00
Aleksei Kulikov
98ae814cd0 snapshot: add merge/rebase data to snapshot
Summary:
This diff adds handling of mergestate and rebasestate -related data from the `.hg` directory.
That is the whole `.hg/merge` folder (both for merge and rebase state) and the `.hg/rebasestate` file.

We do not store any other information in lfs (e.g. number of parents for merge state).
Snapshot manifest oid will be added as an extra field to a fake snapshot commit, which will contain such data.

Differential Revision: D16708733

fbshipit-source-id: efc9b72b7593d85063307528c713c363e061065b
2019-08-12 03:51:58 -07:00
Jun Wu
98086c8f4d treemanifest: fix a null pointer undefined behavior
Summary:
`path.next(&word, &wordlen)` might choose to do nothing if `path.isfinished()`
is already true. In that case, null pointer `word` would be passed to callback
functions and that breaks UBSAN:

  scm/hg/edenscm/hgext/extlib/ctreemanifest/manifest.cpp:84:23: runtime error: null pointer passed as argument 1, which is declared to never be null
  glibc/include/string.h:140:33: note: nonnull attribute specified here
      #0 0x7f7068badb26 in Manifest::findChild(char const*, unsigned long, FindResultType, bool*) scm/hg/edenscm/hgext/extlib/ctreemanifest/manifest.cpp:84
      #1 0x7f7068bc07cb in get_callback(Manifest*, char const*, unsigned long, FindContext*, ManifestPtr*) scm/hg/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp:315
      #2 0x7f7068bbdbce in treemanifest::find(ManifestEntry*, PathIterator&, FindMode, FindContext*, FindResult (*)(Manifest*, char const*, unsigned long, FindContext*, ManifestPtr*), ManifestPtr*) scm/hg/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp:218
      #3 0x7f7068bbfd4b in treemanifest::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const**, FindResultType, ManifestPtr*) scm/hg/edenscm/hgext/extlib/ctreemanifest/treemanifest.cpp:355
      #4 0x7f7068c1e8bb in treemanifest_contains(py_treemanifest*, _object*) scm/hg/edenscm/hgext/extlib/cstore/py-treemanifest.h:1400
      #5 0x7f707746ba7e in PyEval_EvalFrameEx (libpython2.7.so.1.0+0x108a7e)
      ....

This unblocks D16716742.

Reviewed By: singhsrb

Differential Revision: D16750880

fbshipit-source-id: f0afe19f98b97660698b2cb90f24a0243f1e728f
2019-08-09 20:59:52 -07:00
Arun Kulshreshtha
73e1fc5143 remotefilelog: return after HTTP file fetch
Summary: We were accidentally double-fetching data over both HTTP and SSH due to a missing return statement in the HTTP path. Fix it so that we only fetch data once. (The return was originally there, but was accidentally removed as part of a refactor.)

Reviewed By: xavierd

Differential Revision: D16745110

fbshipit-source-id: e06f129d39dec3801a32f90257367266006bb1cc
2019-08-09 16:37:12 -07:00
Saurabh Singh
437c059dc6 phabricator: handle AttributeError while parsing graphql query
Summary:
We have can have situations where the parsing is broken because we are
parsing an attribute that does not exist. See T48658402 for an example.

Reviewed By: kulshrax

Differential Revision: D16745842

fbshipit-source-id: f693bc5aca29923b074a789b952e24b5ce72cdfd
2019-08-09 15:31:17 -07:00
Shu-Ting Tseng
f26bbc7e98 fix hg svn info
Summary:
The logic is currently a bit broken in a weird combination:

The current configurations are
- usefirstpublicancestorinsvninfo=False
- useglobalrevinsvninfo=True

This means hg will have to traverse back to the last hg commit with svnrev. It will get
[slower and slower](https://fburl.com/scuba/skfj8p7u) to find those commits as we are having more commits without snvrev.

Ideally we can turn `usefirstpublicancestorinsvninfo` to True and that will then only traverse back to the last public ancestor. However it will trigger another bug because this public ancestor won't be in the old svn revmap and therefore hg will just bail with "Not a child of an svn revision".

Therefore the fix is to fix that bug by moving the `if pn not in hashes:` into the else part of the config and also get the subdir value from config rather than from the `extras['convert_info']`.

The next step is to set
- usefirstpublicancestorinsvninfo=True
- useglobalrevinsvninfo=True
- usereposubdirinsvninfo=True
once this diff is deployed to stable.

Reviewed By: DurhamG

Differential Revision: D16717554

fbshipit-source-id: c05b9882aa9ddeeeefd9315b478ba085fbc9bae7
2019-08-08 14:19:03 -07:00
Aleksei Kulikov
1bb26d4ad2 snapshot: refactor extension code
Summary:
Created some classes and refactored the code.
Now it looks better. :)

Reviewed By: markbt

Differential Revision: D16690240

fbshipit-source-id: f26127d55c5cace7b88e225c85ec13cc278150c8
2019-08-08 04:13:39 -07:00
Aleksei Kulikov
6b7127c966 snapshot: add debug command to checkout on snapshot manifest
Summary:
It would really help to be able to checkout the manifests, restoring all the data from them.
Deleting the missing files, creating the unknown files, adding mergestate info to svfs (not available yet :) ).

Reviewed By: mitrandir77

Differential Revision: D16668312

fbshipit-source-id: 62af8a1fb11541c162f7b5ceb8d6d058cad9a319
2019-08-08 04:13:38 -07:00
Mark Thomas
6a6c0fea7a commitcloud: add automigrate to automatically connect to commitcloud
Summary:
Add automigrate to commitcloud, which will automatically connect the user's
repo to commit cloud on pull.

Reviewed By: mitrandir77

Differential Revision: D16666810

fbshipit-source-id: a1d0857164d2ce6bf1db5784360681f04d35ed90
2019-08-08 03:09:24 -07:00
Mark Thomas
2e3cda1ade commitcloud: cloud leave should always clear the workspace name
Summary:
Running `hg cloud leave` on a repo that was never connected should mark the
repo as explicitly disconnected so that automatic joining will not try to
connect the repo later on.

Reviewed By: quark-zju

Differential Revision: D16687470

fbshipit-source-id: 0552ffa42a1dac40874bba30eeb93509a2227aeb
2019-08-08 03:09:24 -07:00
Mark Thomas
0c6db94ffb commitcloud: simplify subscription manager
Summary:
The `SubscriptionManager` is never a long-lived object, and cannot be
constructed if the user is not connected to a workspace.  Simplify this to
function calls, which are safe to call at all times.

Reviewed By: quark-zju

Differential Revision: D16687467

fbshipit-source-id: c7f81290a3e8012f7b154af3398771ac9254387f
2019-08-08 03:09:24 -07:00
Mark Thomas
be096ab1c6 commitcloud: make cloud rejoin always join if possible
Summary:
`hg cloud rejoin` limits joining to when the user has an authentication token
and the workspace already exists.  If the user uses a different authentication
method, or if the workspace is brand new, the rejoin does nothing.

Change this to always attempting to join, and only printing a message if the
join failed because of an authentication error, prompting the user to authenticate.

Reviewed By: mitrandir77

Differential Revision: D16666365

fbshipit-source-id: 3ea4542125a1b5266711fab2c31d9455ab764cef
2019-08-08 03:09:23 -07:00
Arun Kulshreshtha
18d9581d7e treemanifest: add single-node lazy HTTP tree fetching
Summary:
When `treemanifest.usehttp` is enabled, make `remotetreestore` fetch tree nodes over HTTP rather than SSH.

Note that unlike the SSH prefetch operation, this downloads only a single tree node, which will change the I/O behavior of Mercurial to fetch manifest nodes on demand. In general, this will result in excessive round trips, but for certain commands (such as `hg cat`), this works reasonably well.

Future diffs will expand upon this functionality to make the HTTP behavior more performant. For now, this won't affect anyone unless they specifically enable the aforementioned config option.

Reviewed By: xavierd

Differential Revision: D16663197

fbshipit-source-id: 4117e057996ed30f0bfd186238264e31484c2620
2019-08-07 19:09:46 -07:00
Aleksei Kulikov
cf0570d74a snapshot: add a command to upload snapshot manifest to remote lfs
Summary:
Add the `debuguploadsnapshotmanifest oid` command.

It checks that the local lfs has `oid`, then uploads it and all the related blobs to remote lfs.

Differential Revision: D16667158

fbshipit-source-id: 2978a6c0e7c58c3710f8253cf7b9ab36b24886ce
2019-08-07 05:57:45 -07:00
Arun Kulshreshtha
7302c42b77 remotefilelog: start HTTP file fetching progress bars at 0
Summary:
Previously, we would use `None` as the start value for HTTP data fetching progress bars so that the bar would be rendered as a spinner until we received a response (which would contain a content size header, allowing us to set the progress bar total).

This would result in incorrect behavior if the server took a long time to return a response, because by default if no start value is provided the progress bar framework will display the number of seconds that have elapsed. Given that we've specified a byte count format function for the progress value, the progress bar would end up displaying the number of seconds elapsed as a byte count, which was very confusing.

Reviewed By: quark-zju

Differential Revision: D16663124

fbshipit-source-id: 0e224b3b670abc803356214cd12205a6f4259cd9
2019-08-06 17:14:58 -07:00
Stefan Filip
5bc614c767 bindings: add finalize implementation for tree manifests
Summary: Matching more of the existing API.

Reviewed By: quark-zju

Differential Revision: D16607233

fbshipit-source-id: 7a71f22089067ecfccbfcb2ad072fbf21e360439
2019-08-06 14:24:31 -07:00
Arun Kulshreshtha
8ba2df04d9 treemanifest: remove bulky HTTP prefetch
Summary:
The initial attempt at supporting tree fetching over HTTP involved reimplementing the existing Mercurial prefetch functionality (corresponding to the gettreepack wireproto command) in the API server. Unfortunately, while this worked from a functionality perspective, it was far too slow to be usable in practice.

Rather than maintaining this unused code path, let's remove it and repurpose the config flag for a more sensible version of HTTP tree fetching.

Reviewed By: farnz

Differential Revision: D16663198

fbshipit-source-id: a489d5ca177b788f93383b8a9f758316e889ca5b
2019-08-06 11:40:05 -07:00
Xavier Deguillard
9937459abe remotefilelog: remove old files in the hgcache that aren't packfiles
Summary:
The hgcache packs directory is being written to in several places, most of the
files being created there are temporary ones and renamed once ready to be
visible. In some cases, when hg crashes midway, or when the packfile is mmap'ed
on windows, temporary files are left around.

While we were trying to remove these files before, the solution taken involved
removing files we knew were safe to be removed. Unfortunately, that meant we
missed some of the temporary files. Let's instead switch to removing everything
but packfiles and the repacklock.

Reviewed By: kulshrax

Differential Revision: D16657105

fbshipit-source-id: f4dd45aa71c02acba52a745b9bec3019d20e03c4
2019-08-06 10:34:27 -07:00
Mark Thomas
bafa640cde unhide: improve performance of unhide revset
Summary:
Add `not public()` to the unhide revset to improve its performance.  We can't
unhide public commits anyway, as they can't be hidden.

Reviewed By: mitrandir77

Differential Revision: D16645983

fbshipit-source-id: f9f23e7e31050e652f1389489734416fe3278219
2019-08-06 09:52:02 -07:00
Aleksei Kulikov
cbf11e8ca8 snapshot: add command debugcreatesnapshotmanifest
Summary:
Add a self-descriptive command `debugcreatesnapshotmanifest`.
For now it supports only deleted and unknown files.

1) Uploads all the untracked files to the local lfs storage.
2) Creates a json-like snapshot with the following structure:
```
{
  "deleted": {
    "path/to/file": None, # this is done for consistency
    "path/to/another/file": None
  },
  "unknown": {
    "added": {
        "oid": "oid in local blobstore",
        "size": 42
    }
    "another/added": {
        "oid": "another oid in local blobstore",
        "size": 24
    }
  }
}
```
...and stores it in the local blobstore.

Reviewed By: markbt

Differential Revision: D16621864

fbshipit-source-id: 6c497d1bb756561b3c3368483b838a2307b0b5f9
2019-08-05 11:10:17 -07:00
Jorge Lopez Silva
a1fd50cc9b Upgrade smc/hg to cpython/python-sys 0.3
Summary: Bump cpython and python27-sys to 0.3.

Reviewed By: quark-zju

Differential Revision: D16634957

fbshipit-source-id: 9f6b45baf8098399109ad03bf440da42f4483fcb
2019-08-05 09:56:45 -07:00
Shu-Ting Tseng
bbc6d19715 use manifest lookup to speed up operations
Summary:
The original code path is extremely slow because it has to iterate all files in manifest.
The new path instead only has to lookup the entries in keptdirs and therefore is O(change).

Reviewed By: mitrandir77

Differential Revision: D16646075

fbshipit-source-id: cb2c152d236ffa6f01349c223c9470205c540379
2019-08-05 05:22:40 -07:00
Johan Schuijt-Li
77f0d3fd04 lfs: rewind fp on retries
Summary:
To avoid the scenario where we are incorrectly uploading the data that we're
supposed to upload, we need to reset the file pointer to read from the
beginning so that for each retry of uploading we get the correct data.

Previously before this patch, Mercurial would have nothing to upload on a retry
and the connection would 'hang' waiting for the data to be send to the server.

Reviewed By: krallin

Differential Revision: D16620072

fbshipit-source-id: 2238b99ff612e06dc0640717bc42fe345c35037d
2019-08-02 05:15:57 -07:00
Arun Kulshreshtha
0f9f07b6a1 remotefilelog: make HTTP retries configurable
Summary: Make the number of retries for HTTP operations configurable. Previously, they were hardcoded to 3, which may not be ideal in situations where the retries are caused by server side timeouts. (If a single timeout takes 30 seconds it would take 90 seconds to fall back to SSH.)

Reviewed By: quark-zju

Differential Revision: D16592862

fbshipit-source-id: a9ba5273a1271532ff9814bcc47cb32e60ee87b7
2019-08-01 12:54:35 -07:00
Stefan Filip
71bff70aea manifest: rename filesnotin argument from match to matcher
Summary:
Similar to diff, the `match` argument can't be easily expressed using CPython
crate bindings. This argument is not used a lot so we can rename it.

Reviewed By: quark-zju

Differential Revision: D16571840

fbshipit-source-id: 19c7dea82924b7ec4c0b66d1675b9ad4569f8b62
2019-08-01 10:35:53 -07:00
Mohammad Ayoub
c3bb7153e0 change cloud sl --version_number to --workspace-version
Summary: Change --version_number flag to --workspace-version

Reviewed By: quark-zju

Differential Revision: D16561670

fbshipit-source-id: 797a7b2fee2c3e260263ae3029d793452def3033
2019-08-01 02:18:05 -07:00
Stefan Filip
71ab0b4b3d manifest: rename match to matcher in diff argument list
Summary:
`match` is a keyword in Rust. This is causing troubles in adding Rust bindings
for functions that use that as a keyword argument. Renaming the argument to
something else seems to be the easiest path forward.

Reviewed By: quark-zju

Differential Revision: D16496134

fbshipit-source-id: c923f49577564527a99d43dda3d3d9da43122b3e
2019-07-31 10:06:48 -07:00
Stefan Filip
5d1f390ca0 manifest: remove the clean argument from diff
Summary:
The diff algorithm takes the `clean` flag. When `clean` is used all the files
that are not changed between the two manifests are returned. In short the set
of files is equal to |files(M1) U files(M2)|.

This functionality would have to be implemented in the Rust manifest. I don't
feel that a flag on the diff algorithm should be used in this case. First, I
don't like how it interacts with the core diff algorithm, it changes it to the
point where it feel like it should be a different function. Second is that this
behavior can be achieved by getting all the files in the manifest and removing
the items in the diff. Third is that this operation is done quite rarely, being
so expensive.

The downside is that the places where this flag is used get a bit more
expensive.

Reviewed By: quark-zju

Differential Revision: D16496136

fbshipit-source-id: 205dcc23517b896de5c14634683bcbd5f2aa6666
2019-07-31 10:06:47 -07:00
Shu-Ting Tseng
97f4a710b9 don't use revmap to look for ancester in hg svn info
Reviewed By: singhsrb

Differential Revision: D16561866

fbshipit-source-id: 156477a4ecc7bf205158c13e57960a0cf1dc368e
2019-07-31 09:16:23 -07:00
Shu-Ting Tseng
acec61a376 hg svn info should print globalrev
Summary:
This is used by Jellyfish and sent to Phabricator. In the future, we won't have svnrev
and therefore we should use globalrev instead.

More context: https://fb.workplace.com/groups/248282915800791/permalink/372855146676900/

Reviewed By: singhsrb

Differential Revision: D16561651

fbshipit-source-id: 284ad26b1bf77f222086bb7e2104b1c2dbf65449
2019-07-31 09:16:23 -07:00
Shu-Ting Tseng
01394c9202 hg debugcrdump should also use globalrev
Summary:
This command uses svnrev directly. However once we migrate to www-hg, this fields will
go and we can only use globalrev instead.

Let's add that and put it behind a config.

More context: https://fb.workplace.com/groups/248282915800791/permalink/372855146676900/

Differential Revision: D16560447

fbshipit-source-id: de3100ed1e6cc39eaaeff2fe11af04d2f1e2c41a
2019-07-31 09:16:23 -07:00
Mateusz Kwapich
6b7f8fe167 autoformat all of fbcode/scm with black
Summary: blackpylogo

Reviewed By: krallin

Differential Revision: D16543521

fbshipit-source-id: 75977d00329e1068a92a344c99e0ad0392601c54
2019-07-30 08:21:05 -07:00
Jun Wu
67cd8c9b81 demandimport: blacklist IPython dependencies
Summary: This makes IPython work without disabling demandimport.

Reviewed By: xavierd

Differential Revision: D16509106

fbshipit-source-id: d4443d8b58c90a0fd7a34c620756e88f4f788337
2019-07-29 13:45:44 -07:00
Saurabh Singh
459d04df3f hgsubversion: allow disabling the svnrev template keyword
Reviewed By: quark-zju

Differential Revision: D16546466

fbshipit-source-id: d3d3005b250856d2e93fbd52f178e9cd8bdf6ef2
2019-07-29 13:29:39 -07:00
Mohammad Ayoub
880e757390 add skip 1 day buttons to interactive history
Summary: Added shortcuts a, d that allow you to skip 1 day forward or back in the historical smartlogs interactive view

Reviewed By: mitrandir77

Differential Revision: D16438722

fbshipit-source-id: e61a126ed7390b5ee77ee71694d8b23f3351854a
2019-07-29 08:52:13 -07:00
Mohammad Ayoub
a9fdfb3049 quick fix to add limit to hg cloud sl --history command
Summary: The interactive view doesn't support the pager, so it is problematic for longer smartlogs. As a quick fix the interactive view only contains two weeks of commits. The full version is accessible through hg cloud sl --version_number

Reviewed By: mitrandir77

Differential Revision: D16496065

fbshipit-source-id: 7224258b426724872bf796af618ef70cbf4c9d0b
2019-07-29 07:28:21 -07:00
Xavier Deguillard
efad0cf903 cstore: remove py-cdatapack
Summary:
With fastdatapack gone, the cdatapack bindings are no longer necessary and can
be removed.

Reviewed By: singhsrb

Differential Revision: D16476584

fbshipit-source-id: 130a9c5aed4e4f005876c420961f09d398f6e6aa
2019-07-26 10:35:46 -07:00
Xavier Deguillard
f36d8a8fe1 remotefilelog: remove basepack
Summary: This is no longer used anywhere, we can remove it.

Reviewed By: singhsrb

Differential Revision: D16476582

fbshipit-source-id: fe6a8f33cbc3c37fb1d8fb33226352e41bcbaa2a
2019-07-26 10:35:46 -07:00
Xavier Deguillard
28d7ef620b remotefilelog: remove fastdatapack
Summary: This code isn't used anywhere, let's get rid of it.

Reviewed By: singhsrb

Differential Revision: D16476583

fbshipit-source-id: d42376dbb2cf631a170ade3e2764d1f70922d882
2019-07-26 10:35:45 -07:00
Xavier Deguillard
6cdcb360ed remotefilelog: remove mutablebasepack
Summary: This code is no longer used anywhere.

Reviewed By: singhsrb

Differential Revision: D16462343

fbshipit-source-id: 3e11994575a6de75562cb1ebd8839f7058abc075
2019-07-26 10:35:45 -07:00
Aleksei Kulikov
59bb951024 amend: make next prefer draft commits
Summary: Add an option `update.nextpreferdraft` that makes `hg next` prefer single draft child commits.

Reviewed By: markbt

Differential Revision: D16500162

fbshipit-source-id: 3a20bb487d35b7acf92792e9a7b7424c9b163b64
2019-07-26 10:00:07 -07:00
Shu-Ting Tseng
86bdaeb464 make pushes faster in our reverse sync case
Summary:
Our reverse sync job is too slow when pushing to svn. It seems like the slowness comes
keep doing push-pull-rebase which doesn't seem necessary in our case.

From my understanding, we need to do push-pull-rebase because we have multiple writers.
In our sync job, we only have one writer and therefore can we skip the pulls and rebases?

Reviewed By: DurhamG

Differential Revision: D16442559

fbshipit-source-id: 926d1c516e8e6d59298d310fc67927ace37f72c9
2019-07-26 07:21:37 -07:00
George-Catalin Tintareanu
f91262be22 Enum creator
Summary:
Util method to generate Enum, since some machines don't have the
python library installed.

Reviewed By: suitingtseng

Differential Revision: D16491020

fbshipit-source-id: e06470a609605c482f591418583b516918c49d93
2019-07-25 07:24:36 -07:00
Xavier Deguillard
9b21206b39 remotefilelog: remove python mutablehistorypack
Summary: There no users left, let's get rid of it.

Reviewed By: kulshrax

Differential Revision: D16423137

fbshipit-source-id: 6898e681f800ab677010d7b6cdd36d377e3ef644
2019-07-24 10:34:32 -07:00
Xavier Deguillard
10a59c9b75 remotefilelog: remove python mutablehistorypack from mutablestore
Summary: The Rust code is the default.

Reviewed By: kulshrax

Differential Revision: D16423134

fbshipit-source-id: 30baf041a5e7c786a28b31cfe5025e893b34594c
2019-07-24 10:34:32 -07:00
Xavier Deguillard
e86e388661 remotefilelog: remove python mutabledatapack code
Summary: Goodbye.

Reviewed By: kulshrax

Differential Revision: D16392290

fbshipit-source-id: 541b945e274f097b722b5e79ca03e104c4cfd6a0
2019-07-24 10:34:31 -07:00
Xavier Deguillard
bd88a79858 remotefilelog: remove python mutabledatapack reference from mutablestores
Summary:
The Rust code is now always taken, let's start removing all the references to
the python mutabledatapack code.

Reviewed By: kulshrax

Differential Revision: D16392287

fbshipit-source-id: dfccd4f4ec052a46975b6f9144106b51c3282988
2019-07-24 10:34:30 -07:00
Xavier Deguillard
334e0c0c2e remotefilelog: the rust mutable stores are the default
Summary: This is now enabled for the entire fleet, let's hardcode this in the code now.

Reviewed By: kulshrax

Differential Revision: D16392289

fbshipit-source-id: 462152ded12d00cf8218526d51a911d6fe5975ca
2019-07-24 10:34:30 -07:00
George-Catalin Tintareanu
15f36ceede hg client handler for blacklisted files
Summary: Checks if the retrieved content of a file is equal to a `magic string` representing a blacklisted file. If so, then the content is replaced by a readable text which suggests a `rebase` or `update` to a newer commit.

Reviewed By: ikostia

Differential Revision: D16260011

fbshipit-source-id: ac1d40132b9c947927271d8e6efda98b19dce984
2019-07-24 03:41:20 -07:00
Arun Kulshreshtha
a491bb06ea remotefilelog: only print debug messages during interactive usage
Summary: The debug messages from Eden API provide Source Control team members with useful diagnostic information about HTTP data fetching, but they have the potential to be spammy when written to log files. To prevent log spam, let's only print these messages during interactive usage.

Reviewed By: quark-zju

Differential Revision: D16445346

fbshipit-source-id: 001dc75e440eaf797f4f953648453086421f624e
2019-07-23 15:13:59 -07:00
Xavier Deguillard
7478874389 remotefilelog: remove maintenance repack memcache fetch
Summary:
When using fetchpacks, memcache will write to an indexedlog, which can't be
repacked. I'm also suspecting that there is a race between this repack, and
hg_memcache_client opening the newly created packfiles which can cause the
misses to not be sent to memcache.

Reviewed By: kulshrax

Differential Revision: D16432538

fbshipit-source-id: 62362682474883bcd58249791c02b9fed5cb8fea
2019-07-22 22:31:38 -07:00
Shu-Ting Tseng
5c49bedd8b add a trailing newline when committing to svn
Summary:
By adding a newline, we can ensure the meta message is always on its own line.

This is to address the comment in D16340374.

link to comment: https://our.intern.facebook.com/intern/diff/D16340374/?transaction_id=732272950561759&src_number=86745022

Reviewed By: quark-zju

Differential Revision: D16417344

fbshipit-source-id: caaae1748018bbe5ddbb587adacd45b8709da8cc
2019-07-22 14:06:12 -07:00
Stefan Filip
cb57f5d7ac bindings: add manifest python classes
Summary: Bindings so that the rust manifest code can be used in Python.

Reviewed By: quark-zju

Differential Revision: D16352532

fbshipit-source-id: 34d4522f5e084f531f31bcd21770950f15f2fe13
2019-07-22 13:03:00 -07:00
Stefan Filip
a1a75d5d73 tremanifest: rename tree holding variable to _tree
Summary: Minor rename

Reviewed By: quark-zju

Differential Revision: D16352529

fbshipit-source-id: 658f9843041d858e1471c07554b5715db011d17c
2019-07-22 13:02:58 -07:00
Jared Bosco
3c30d27350 copytrace: remove copytrace flag from mutating global options table
Summary:
Copytrace modified the global definitions table which was making it very difficult to keep track of side-effects as the code was executed, as well as making it harder to replace the fancyopts calls with native Rust.

Since the copytrace behavior can be achieved through a configuration, it now will no longer modify the global definitions table, and will display the correct flag for a user to use in order to get this same behavior.

Reviewed By: quark-zju

Differential Revision: D15902449

fbshipit-source-id: 1c254162d56823e65085b7047bb37513f187b487
2019-07-20 01:06:33 -07:00
Xavier Deguillard
8f47102275 fixcorrupt: fix debugfixcorrupt on treeonly repos
Summary:
Treeonly repos doesn't use revlogs, and thus debugfixcorrupt shouldn't try to
fix them.

Reviewed By: quark-zju

Differential Revision: D16373142

fbshipit-source-id: 6517b9516358223bfb6c646fd22aaa99c26b0372
2019-07-19 20:15:36 -07:00
Matt Glazar
9b88f1e59b Fix slow rebase for commits which move files
Summary:
When rebasing or showing a diff for a commit which moved files, remotefilectx.ancestors (called by _tracefile) calculates the linkrev for each ancestor. Sometimes [1], this is a disaster:

* remotefilectx._linkrev executes its slow path and scans the change log.
* For each entry in the change log, remotefilectx._linkrev downloads trees if needed.
* Hg downloads trees one-by-one (as of D15964145).

remotefilectx.ancestors is only calculating linkrevs so it can sort the ancestors topologically. _tracefile only needs the ancestors to be ordered topologically, not by linkrev. remotefilectx.ancestors's calls to remotefilectx._linkrev are redundant.

Optimize _tracefile's use of remotefilectx.ancestors: order remotefilectx objects topologically (breadth-first) without sorting by linkrev. Create a new function for this purpose (topological_ancestors) to avoid possibly breaking other callers of remotefilectx.ancestors. As a side effect, make this new function return remotefilectx objects lazily, similar to the filectx.ancestors function.

On my machine, with warm caches, this speeds up 'hg diff -c' and 'hg rebase' for a modestly-sized commit. 'hg diff -c' takes 0.64 seconds, down from 65.6 seconds.

[1] Hypothesis: After 'hg amend', 'hg bundle' packages linkrevs which refer to the pre-amend commit (which is not serialized into the bundle) rather than the post-amend commit. 'hg unbundle' thus creates linkrevs referring to a missing commit.

Reviewed By: DurhamG

Differential Revision: D16297426

fbshipit-source-id: 407597d5e36fc06b33719c28f5ea5052e01dc7a3
2019-07-19 12:35:22 -07:00
Aida Getoeva
3c81066860 commitcloud: fix sync when remotebooks sync disabled on one of the copies
Summary:
If one of the repo checkouts doesn't have remote bookmarks synchronization enabled, it must not affect the Cloud's remote bookmarks state.

I also changed `localserver` (is used for our tests) because Commit Cloud server deletes the "old" bookmark names from the db and inserts "new". However, the `localserver` just set the "new" books dictionary as a new state, which is not quite correct.

Reviewed By: simpkins

Differential Revision: D16338257

fbshipit-source-id: d77d9218b1c35ea1a097bbe7393d0910ce7b4d38
2019-07-19 10:04:25 -07:00
Aida Getoeva
6ab4fcf8f8 commitcloud: fix remote bookmarks' merge on sync
Summary: While checking if one public commit is an ancestor of another public commit, I used string hashes instead of binary nodes. Fixing.

Reviewed By: farnz

Differential Revision: D16338256

fbshipit-source-id: e27ed8d79ec9ed3a188cdee93366ab2f96526152
2019-07-19 10:04:25 -07:00
Saurabh Singh
c137206645 globalrevs: return globalrevs while resolving svnrev template keyword
Reviewed By: quark-zju

Differential Revision: D16361887

fbshipit-source-id: 547b03af9c17aa7ab033f9d1bd733f4a63830d07
2019-07-18 12:23:00 -07:00
Saurabh Singh
0766f36b29 hgsubversion: refactor method for svnrev template keyword to easy wrapping
Summary:
This commit is just a simple refactor of the method for the resolving
the `svnrev` template keyword. In particular, we split the method so that it
can be easily wrapped by other extensions like globalrevs in D16361887.

Reviewed By: quark-zju

Differential Revision: D16361888

fbshipit-source-id: 9f20fb33afd2b286c4f30571fa257b8284f2bb54
2019-07-18 12:23:00 -07:00
Shu-Ting Tseng
fd5abc16e3 rewrite svn commit message with hg hash
Summary:
When we are migrating www to hg as source of truth, we would like to maintain the
reverse sync for some time in case we need to rollback.

In order to achieve that, we need to know the latest svn and hg commit to operate on. We
would like to record this information in the svn commit itself so it doesn't require
extra syncing and transaction.

In ordre to get this info, we can run `svn log -l 1` and parse the commit message from
there.

Reviewed By: quark-zju

Differential Revision: D16337012

fbshipit-source-id: acf66babdb48c07f95e9eb49daac0d3d3e6a96a0
2019-07-18 10:06:05 -07:00
Jun Wu
cb0126cb4a util: add istest() method
Summary:
There are multiple places that want to know whether the code is running inside
tests or not. Add `util.istest` for that and migrate those callsites to use it.

Reviewed By: xavierd

Differential Revision: D16344715

fbshipit-source-id: faa4261c83e4d889d59d63968b440954c4cac2ce
2019-07-17 21:11:29 -07:00
Xavier Deguillard
18191934a6 remotefilelog: consider memcache write failure as a cache miss
Summary:
We've had cases where hg_memcache_client failed to write to the
indexedlogdatastore, but since it was returning a success code, hg wouldn't
find the node, and crash.

Let's add a new error code to signify that all the requested objects should be
considered as misses.

Reviewed By: quark-zju

Differential Revision: D16344530

fbshipit-source-id: 4e627fee1603f9e4d5f542ef2d1f0e881a085bad
2019-07-17 14:52:33 -07:00
Mohammad Ayoub
2257f3210d fix default value in cloud sl --version_number and hg cloud sync --workspace-version
Summary:
the default value was being set to type int, changed it in both occasions to "".

in cloudsync I had to do some parsing for the version into an int not to break the rest of the code

Reviewed By: mitrandir77

Differential Revision: D16340048

fbshipit-source-id: 7f7142ea4c7862c0a093a68d5c8ceb1d2e22df24
2019-07-17 13:03:13 -07:00
Marla Azriel
36d7d7604d commands: help text for undo
Summary: Updated help text for hg undo and fixed test

Reviewed By: kulshrax

Differential Revision: D15937058

fbshipit-source-id: 577d05fb9c16237f8b879ef9ebf60341d5fdf37e
2019-07-17 10:43:01 -07:00
Mohammad Ayoub
9b54adf9d8 add interactive cloud sl --history command
Summary: Added an interactive view for viewing historical versions of smartlogs.

Reviewed By: mitrandir77

Differential Revision: D16260236

fbshipit-source-id: 94582e2b6351dff50dc15c030aa73495b900d346
2019-07-17 05:29:47 -07:00
Mohammad Ayoub
ed8cf87d5e Add date and version options to hg cloud sl
Summary: Modified the hg cloud sl command to have two options --date and --version_number that display that historical version of the smartlog

Reviewed By: mitrandir77

Differential Revision: D16120273

fbshipit-source-id: 4f202ed49488247f43bd682574ff52dcf17c958e
2019-07-17 00:58:50 -07:00
Durham Goode
97b7106d24 historypack: add logic to prevent history cycles
Summary:
Bad callers could try to add nodes that had the same value as the
parent. Let's catch this and prevent it.

Reviewed By: quark-zju

Differential Revision: D16189602

fbshipit-source-id: 08220c18ee96743e4eda00e5e953a5946b40d95c
2019-07-12 10:47:29 -07:00
Adam Simpkins
691ef10cff fix fsmonitor on Windows
Summary:
The python runtime update in D15894694 broke ctypes for all APIs that accept a
Windows `HANDLE`.  This was used by the `fsmonitor` code that tries to connect
to watchman on windows.

As a result Mercurial would silently fail to use watchman.  Commands like
`hg status` became very slow, with no user-visible output to indicate that
anything was wrong.  (It wouldn't print a progress bar or any other
information either.)

Reviewed By: quark-zju

Differential Revision: D16198869

fbshipit-source-id: 675007674e0ac742c5b62739d766b8c3016e0c1b
2019-07-11 11:39:03 -07:00
Saurabh Singh
91e1b369e7 globalrevs: simplify the logic to resolve globalrev/svnrev to commit hash
Summary:
Following D16198896, we can really simplify the logic for resolving
globalrev/svnrev to commit hash. In particular, we can make much more stronger
assumptions about what is indexed now and therefore, narrow the search to only
the commits that are not cached.

Reviewed By: quark-zju

Differential Revision: D16199072

fbshipit-source-id: cec66cbda24ee6df200fc77aeed42c11c29edeba
2019-07-11 11:39:03 -07:00
Saurabh Singh
484346dd87 globalrevs: add svnrev to the globalrev map for fast lookup
Reviewed By: quark-zju

Differential Revision: D16198896

fbshipit-source-id: cc6fc4fdca8df51a24c701abdf43cea42776fa26
2019-07-10 21:30:00 -07:00
Mark Thomas
33b103a8bc remotefilelog: override fetchdepth when looking for linkrevs
Summary:
When looking for the matching filenode when searching for the linkrev of a
filectx, override fetchdepth to 1 so that we don't download the whole manifest
just to examine a single file, and add tracing and a progress bar, as this can
be slow.

Reviewed By: mitrandir77

Differential Revision: D15964145

fbshipit-source-id: d338de330c82d4240bed5569caf25769778458aa
2019-07-10 16:41:54 -07:00
Mark Thomas
398067390d remotefilelog: disable descendantrevfastpath by default
Summary:
With treemanifest and the eden api, descendantrevfastpath (which downloads all
the manifests) is slower than just downloading the history from the eden api.

We still want to record the descendantrev if we already know the real linkrev
of the current filenode, as that will still be fast.

Reviewed By: quark-zju

Differential Revision: D15943076

fbshipit-source-id: c6013801822bdfa3196e60cbcd34a9ce184c5c5f
2019-07-10 16:41:54 -07:00
Mark Thomas
5f2b5fbeb6 remotefilelog: add progress bar and perftrace for adjustlinknodes
Summary:
Adjusting linknodes can sometimes take a long time.  Add a progress bar and perftrace
for when this happens.

Reviewed By: sfilipco

Differential Revision: D15943077

fbshipit-source-id: f91bc6bb9f7c6d39ffe9ac7b2bf4ab0f32b4d9d3
2019-07-10 16:41:54 -07:00
Mark Thomas
d306b09539 commitcloud: disable prefetch and migrate during sync
Summary:
During `cloud sync`, disable the following options, as they slow sync down and
aren't really necessary.

* Set `pull.automigrate` to False, as there is no need to perform pull migrations
  in the sync pull.
* Set `treemanifest.pullprefetchrevs` to False, as we won't have updated the
  remote bookmarks, so there is no need to try to prefetch the trees.
* Set `treemanifest.prefetchdraftparents` to False, as synced commits are not
  usually checked out immediately, so there is no need to prefetch the tree.

Reviewed By: quark-zju

Differential Revision: D16054353

fbshipit-source-id: 0eeab49e5242fdddc593843ed67e6a17281ec912
2019-07-10 16:30:02 -07:00
Mark Thomas
5815917003 treemanifest: add prefetchdraftparents option
Summary:
Add `treemanifest.prefetchdraftparents`, which controls whether or not to
prefetch the trees for the parents of newly added draft commits.

We will want to avoid this in commit cloud, as the prefetch may take too
long, and the user might not access the commits anyway.

Reviewed By: quark-zju

Differential Revision: D16054354

fbshipit-source-id: cf590451fb5252d215748567d6ad421c589ed581
2019-07-10 16:30:02 -07:00
Shu-Ting Tseng
10125c8e19 make the svn call lazy
Summary:
Previously I tried to not call to SVN if we have the 2 configs set. However I made a
mistake that the args will always be evulated anyway (computer science 101).

Let make it really lazy and add a test for that.

Reviewed By: ikostia

Differential Revision: D16163470

fbshipit-source-id: 6ec0f855b10164ae9a210bc70789b2f59fd19858
2019-07-10 05:27:59 -07:00
Saurabh Singh
ac9bb62a88 fbconduit: fix translating the globalrev for a commit not in repository
Reviewed By: quark-zju

Differential Revision: D16168059

fbshipit-source-id: 94276dbb3fb78f9e8d7f0e2b27ddc31225f2c256
2019-07-09 13:43:28 -07:00
Xavier Deguillard
ca0d0269fc remotefilelog: set umask before creating the repacklock
Summary:
On a shared host (like the devgpu), the shared cache will be used by many
users, and thus the repacklock needs to be able to be read/write by all the
users. Despite the code trying to open it as 664, the umask downgraded it to
644, only allowing the file creator to run repack.

Reviewed By: quark-zju

Differential Revision: D16151053

fbshipit-source-id: 4d3ecc19f2f6fbf9a8b831f7ea39d0a53bc4b8e9
2019-07-08 17:48:19 -07:00
Aida Getoeva
1e4f33a984 commitcloud: fix remote books sync
Summary:
Fixing bugs I've discovered by enabling remote bookmarks sync for myself:

* turned out, adding "None" to the dict field in Python doesn't work as a null-value of optional field in C++ Thrift structure

* I didn't update lastsyncstate in some of the cases, also fixing

Reviewed By: mitrandir77

Differential Revision: D16131799

fbshipit-source-id: bdee423f519820d702719b3dfe76865a7547221e
2019-07-08 02:24:15 -07:00
Jun Wu
9636711893 logging: move shortlist util to blackbox.py
Summary: It will be used in non-fsmonitor cases.

Reviewed By: markbt

Differential Revision: D15755286

fbshipit-source-id: 75ba7c5f227e1c9224c5d092b7e766afdf45c428
2019-07-06 02:46:19 -07:00
Jun Wu
1145e2541b logging: migrate fsmonitor to new blackbox API
Summary:
The new log is typed and concise.

Old log:

  [fsmonitor]> clock='c:1559600325:3956709:1:34762' len(nonnormal)=0
  [fsmonitor]> setlastclock 'c:1559600325:3956709:1:36405'
  [fsmonitor]> setlastisfresh False
  [fsmonitor]> watchman returned ["x"]
  [fsmonitor]> getlastclock 'c:1559600325:3956709:1:36405'
  [fsmonitor]> set clock='c:1559600325:3956709:1:36405' notefiles=["x"]

New log:

  [fsmonitor] clock: "c:1559600325:3956709:1:34762" -> "c:1559600325:3956709:1:36405"; need check: [] + ["x"]

In JSON form:

  {"fsmonitor":{"new_clock":"c:1559600325:3956709:1:36425","new_files":{"len":1,"short_list":["x"]},"old_clock":"c:1559600325:3956709:1:34762"}

The new logging does not cover every information exposed by the old logging.
For example:

- Non-treestate events like why fsmonitor state gets invalidated.
  Assuming most clients are on treestate now. These are removed.
- "fsmonitor_state = normal | unavailable | fresh" scuba logging. This can be
  inferred, and will be added in a later diff.
- New "notefiles". The next "fsmoniotr" event will log the information.

Reviewed By: markbt

Differential Revision: D15710672

fbshipit-source-id: 5c4cad08c0072c7dc711e5c1e65aa7552940699e
2019-07-06 02:46:17 -07:00
Jun Wu
0467d7ad61 logging: migrate watchman command logs to new blackbox event
Summary: Migrate ui.log("watchman", <str>) to blackbox.log(<Rust Event::Watchman>).

Reviewed By: markbt

Differential Revision: D15710675

fbshipit-source-id: e5aabb4447b03921adc968bb8f03f140f6056501
2019-07-06 02:46:16 -07:00
Jun Wu
e09af5792b logging: remove fastmanifest logging
Summary:
We don't actually use fastmanifest nowadays. Remove logging to reduce noise in
blackbox.

Reviewed By: markbt

Differential Revision: D15710673

fbshipit-source-id: 10d99b4276e76313bf43ffba87e5f2584a67d639
2019-07-06 02:46:16 -07:00
Xavier Deguillard
e533349097 remotefilelog: add hg debugindexedlogdatastore command
Summary:
This has the exact same behavior as `hg debugdatapack` but on
indexedlogdatastore. Since nodes can be added concurrently to the indexedlog,
we can't verify that nodes aren't duplicated, so disable that logic.

Reviewed By: kulshrax

Differential Revision: D16073582

fbshipit-source-id: b7bbefdca8062c8b797432cb76b0de9df850148e
2019-07-03 19:29:39 -07:00
Xavier Deguillard
e389d8ecd7 remotefilelog: remove python historypack code
Summary: All the users are now using the Rust code.

Reviewed By: kulshrax

Differential Revision: D16039092

fbshipit-source-id: 1341ed33ab9a17f30b541b02eaa577db56959e31
2019-07-03 19:29:38 -07:00
Xavier Deguillard
e901daf72e bindings: add iterentries for Rust historypack
Summary:
This allows switching hg debughistorypack to using Rust historypack code
instead of Python. Similarly to the iterentries for datapack, we collect all
the data in memory instead of using an iterator.

Reviewed By: kulshrax

Differential Revision: D16039098

fbshipit-source-id: 8b61c04e43a319a4601cc1aaae2eb46922d4a851
2019-07-03 19:29:38 -07:00
Xavier Deguillard
0eb3be2397 remotefilelog: remove Python datapack code
Summary:
This has now been entierely replaced by Rust code.

Goodbye.

Reviewed By: kulshrax

Differential Revision: D16039096

fbshipit-source-id: 8c3ce2eb5595a5f90c3ecab413a242a3d0afcb89
2019-07-03 19:29:37 -07:00
Xavier Deguillard
133a9820a1 treemanifest: replace use of Python datapack with Rust one
Summary: This is the last use of Python datapack in treemanifest

Reviewed By: kulshrax

Differential Revision: D16039101

fbshipit-source-id: 205b6fed0811ae86542f72aeed95cec81a61d741
2019-07-03 19:29:37 -07:00
Xavier Deguillard
5dcf797aad remotefilelog: use Rust datapack in repack
Summary: This is the last place in remotefilelog where the Python datapack is used.

Reviewed By: kulshrax

Differential Revision: D16039095

fbshipit-source-id: 848157111231d85ba9b74cb7b5dc0631e9997ef5
2019-07-03 19:29:36 -07:00
Xavier Deguillard
cfc38ccef1 remotefilelog: add iterentries to Rust datapack
Summary:
This is needed to switch `hg debugdatapack` to the Rust datapack. One major
difference with the Python code is that the Rust code builds a Vec instead of
an iterator. Implementing iterators with cpython-rust is hard (is it actually
possible?), but since the stored content isn't returned the Vec shouldn't use
too much memory.

For now, the implemention is tied to a packfile, but it shouldn't be too hard
to implement for the IndexedLogDataStore too.

Reviewed By: kulshrax

Differential Revision: D16039097

fbshipit-source-id: 567809785263bbf8cd3e1a9c24ecbb989b5c2496
2019-07-03 19:29:36 -07:00
Arun Kulshreshtha
edaebf9431 edenapi: add a configurable error message for tls errors
Summary:
Similar to what was done in D15992903 for bad certificates, this diff adds a new `edenapi.tlshelp` config parameter that allows the administrator to set up a custom error message on TLS exceptions. Given that such exceptions are often caused by user misconfiguration, the error message can be set to point the user to some relevant troubleshooting steps.

This diff also changes the existing `edenapi.badcertmessage` config parameter to `edenapi.authhelp` to bring it in line with the new parameter, as well as the convention used for such configurable help messages by Commit Cloud. (This won't break anything since we have not shipped any configs that set `edenapi.badcertmessage` yet.)

Reviewed By: xavierd

Differential Revision: D16086608

fbshipit-source-id: ead83eefbd5e9bc1bf06a3aeccdc1f0737720871
2019-07-02 15:23:21 -07:00
Arun Kulshreshtha
82b9916517 edenapi: retry fetch after proxy error
Summary: Proxy errors are often due to something going wrong between the proxy and backing server. These kinds of errors are transient and the request usually succeeds upon retrying. As such, let's retry such errors (up to 3 times) before falling back to SSH.

Reviewed By: xavierd

Differential Revision: D16086240

fbshipit-source-id: c585a27d3f387bade1ae498587774e2f61566f1c
2019-07-02 15:23:20 -07:00
Aida Getoeva
3b80ff4aa9 selectivepull: fix clone and push
Summary: do not override remote bookmrks with all available on remote, if selective pull is enabled

Reviewed By: mitrandir77

Differential Revision: D16084215

fbshipit-source-id: ab0f1b393c620bc57b41805c0633ae793785ce55
2019-07-02 11:30:56 -07:00
Aida Getoeva
dac9448582 selectivepull: always pull accessed + default books
Summary:
always pull only accessed bookmarks and default, do not take remote books from `remotenames` file

also adding handling of `CorruptedState` error to delete `selectivepullaccessedbookmarks` file in that case. it will help mercurial not to crash in case the file was corrupted and self-fix next time.

Reviewed By: mitrandir77

Differential Revision: D16079548

fbshipit-source-id: a2983ee63fb17d2922f3c230c3d6e36aa6591b62
2019-07-02 11:30:55 -07:00
Aida Getoeva
c08bd8af0e selectivepull: small refactoring of selectivepullenabled file
Reviewed By: mitrandir77

Differential Revision: D16078909

fbshipit-source-id: 9dfd3b0849598b43853810223b3e8c0d3990aaf4
2019-07-02 11:30:54 -07:00
Shu-Ting Tseng
f4a2f2875f stop hg svn rebuildmeta/updatemeta from talking to svn server
Summary:
# RFC, not sure if I know what I am doing but I know my goal as follow

In case of the entire `.hg/svn` missing, in order to get the subdir and uuid information,
hgsubversion needs to talk to svn server. In our cases, it's polluting our logging and
it's hard to know who is really using svn server.

In this diff I want to disable this by writing these 2 information directly in config
and hgsubversion will just read from there.

Reviewed By: mitrandir77

Differential Revision: D15989449

fbshipit-source-id: fd9cead094245b3c0baf6e7e1099cc302899668f
2019-07-02 09:36:52 -07:00
Arun Kulshreshtha
2bd15eca26 remotefilelog: move edenapi error logging into dedicated function
Summary: We need to log (and in debug mode print out) Eden API exceptions in several places in the code. Let's factor out this logic into a function in the edenapi module.

Reviewed By: xavierd

Differential Revision: D16027147

fbshipit-source-id: 76c8e97dcaaa114e0c22448d117caae948fb60f4
2019-06-28 15:06:18 -07:00
Mark Thomas
367a4a7cea commitcloud: fix misplaced notice arg
Summary:
The `notice` arg should be provided to `ui.warn`, not the translation `_`
function.

Reviewed By: xavierd

Differential Revision: D16055534

fbshipit-source-id: bb1e0213147fc591671c2ef4c79aab3f9e4a2987
2019-06-28 13:16:35 -07:00
Aida Getoeva
664550d95f commitcloud: fixed creating References with remotebookmarks
Summary: I added remotebookmarks field to the References object earlier, but forgot to change object constructions in couple of places

Reviewed By: markbt

Differential Revision: D16052722

fbshipit-source-id: b0b46739a89c911541eababd35b5f43812e66c4a
2019-06-28 11:52:03 -07:00
Jun Wu
df81aa9464 simplecache: fix check-code
Summary: As the title.

Reviewed By: xavierd

Differential Revision: D16039564

fbshipit-source-id: e4388347b4e93f30cf1e21de90b4c8756fe0e6d5
2019-06-27 18:07:41 -07:00
Jun Wu
5003daafa0 simplecache: respect TESTTMP
Summary:
By default, simplecache puts its local cache in a global location that persists
across test runs. That can cause surprises. Change the location to be inside
$TESTTMP under tests.

Reviewed By: xavierd

Differential Revision: D16036296

fbshipit-source-id: c73b573b87d49798f4ad146a1c0a559f5d94caf1
2019-06-27 13:10:20 -07:00
Jun Wu
64e06423c5 packfile: do not rely on fp.tell()
Summary:
On Windows, fp.tell() might return unreliable data for files with mixed reads
and writes.

Reviewed By: xavierd

Differential Revision: D16035564

fbshipit-source-id: d6cbb018e2664dd1e4323c52e7b0c73df07d7796
2019-06-27 13:10:20 -07:00
Jun Wu
6ad31bbf6a codemod: replace os.fdopen with util.fdopen
Summary:
`util.fdopen` now adds workarounds for read+write+seek files on Windows.
This should solve issues we have seen on Windows behaviors.

See https://www.mercurial-scm.org/repo/hg/rev/3686fa2b8eee for the Windows weirdness.

Here is a minimal program to reproduce the weirdness:

```
import os

f = open("a.txt", "wb+")

# Write 12 bytes
f.write(b"b" * 12)

# Read byte slice 2..5
f.seek(2, os.SEEK_SET)
data = f.read(3)

# Try SEEK_END
f.seek(0, os.SEEK_END)
print("%d (expect 12)" % f.tell())  # got 5 using some python.exe
```

Reviewed By: xavierd

Differential Revision: D16033678

fbshipit-source-id: 4f17c463d9bfcc0cdd38d1b15f2a9e38e5b4c132
2019-06-27 13:10:20 -07:00
Jun Wu
e4ce4c6416 debugshell: define more modules
Summary:
Add more shortcuts to common modules.
This make it easier to test changed code paths.

Reviewed By: markbt

Differential Revision: D15952263

fbshipit-source-id: c0eca6a61902d36a26a99f85e29dc70f431eca59
2019-06-27 12:24:23 -07:00
Arun Kulshreshtha
6cea11189e edenapi: rename BadCreds to BadCertificate
Summary: Rename `ApiErrorKind::BadCreds` to `ApiErrorKind::BadCertificate`. This makes it clearer to users who see the error name in log output that the problem is with a TLS client certificate, since "credentials" is otherwise pretty broad.

Reviewed By: xavierd

Differential Revision: D16024751

fbshipit-source-id: 1dea342036519a33dc48abaa41ab891be1a3637d
2019-06-27 11:28:32 -07:00
Aida Getoeva
7b16c3f851 commitcloud: update remote bookmarks
Summary: Turned on synchronization, fixed couple of bugs, made test-cases pass.

Reviewed By: markbt

Differential Revision: D16006689

fbshipit-source-id: f9481bf71d9d07c04f38ff9ac3a7c30c846cb8c8
2019-06-27 08:10:59 -07:00
Aida Getoeva
b55f9db1f0 remotenames: applychanges for remotebookmark store
Summary:
The changes from commit cloud sync are supposed to be applied in-memory and committed with cloudsync-transaction to the disk. For example, for bookmarks the changes first are applied to the existing dict of bookmarks and with the transaction are being written to the disk into the `bookmarks` file.

Ideally I need to have similar thing for remote bookmarks. However, the current implementation provides of remotenames only read-only store with only possibilty to change something on the disk (`remotenames` file) and upload it to memory.

We're planning to rewrite the whole extension at some point, but currently to move forward I added a new method to the store, which will apply changes to the `remotenames` file and reload the remotenames store.
It's not transactional and uses existing function `saveremotenames`, which I refactored a little bit, so it could apply changes for multiple remotes at the same time. I also removed deletion of `remotedistance` file as it is deprecated and not used a long time.

Reviewed By: markbt

Differential Revision: D15921983

fbshipit-source-id: d6b2638db689c0c1b66a6291fc9f0f2c9dac978c
2019-06-27 08:10:58 -07:00
Aida Getoeva
df1e2fd288 commitcloud: merging remote bookmarks
Summary:
Added implementation of the remote bookmarks merging.

1. If remote books changed in cloud since the last sync and local didn't, then local remote books will be updated with the cloud changes.

2. If otherwise, cloud remote books are the same and local are different from the last sync, then the local changes will be submitted to the cloud.

3. If both local and cloud remote books changed from the last sync, the merging becomes more difficult. There are several cases for what particular changes could be. The current implementation is the first and simpliest, so some of the decisions I made here may be improved later.

  3.1. If both changed and not deleted, then the local remote book will be updated to the newest node between local and cloud's.
  This is not always a correct state. For example, the local remote bookmark's commit is newer (further in the stack), but the bookmark was moved back in the stack on the server and the cloud now has this bookmark on the older commit. After syncing the local book will be kept as it was before and it's node will be submitted to the cloud.
  However it's not that bad, as after `hg pull` it will point back to the right revision.

  3.2. If one changed and another was deleted. There are two case when it could happen: (a) the bookmark was deleted on the server, (b) the client unsubscribed from the remote bookmark (functionality is not implemented yet). The current implmentation will just keep local remote bookmark as it is if it was deleted in the cloud and submit changes back to cloud.

Reviewed By: markbt

Differential Revision: D15899944

fbshipit-source-id: b17ca4d01fd1a1230d74588e2b9ca5c6d58df751
2019-06-27 08:10:58 -07:00
Aida Getoeva
5d7f245f80 commitcloud: support remote bookmarks sync
Summary:
Made changes to the commit cloud sync to support remote bookmarks. Here I only declared steps of future remote bookmarks sync and will add the implementation further in the stack.

Processing a merge state between cloud remote bookmarks state, last sync and local state is done earlier in the workflow, than, for example, for local bookmarks, because to update remote bookmarks we may need to fetch new public heads from the server and so need to get them first.

Reviewed By: mitrandir77

Differential Revision: D15898740

fbshipit-source-id: ca77f66b0f1244a811b4b549e5b189c5f1772708
2019-06-27 08:10:58 -07:00
Aida Getoeva
2bb6071bd8 commitcloud: add remote bookmarks to the get/update references
Summary: Adding support of remote bookmarks to the get/set references of Commit Cloud client service.

Reviewed By: mitrandir77

Differential Revision: D15852515

fbshipit-source-id: 9d5331955f5fc95ecb4bfe8e060d3b1d67952a41
2019-06-27 08:10:58 -07:00
Arun Kulshreshtha
802dbcd5a1 remotefilelog: log exception type on ssh fallback
Summary: When Eden API falls back to SSH, log the exception type and message (in addition to the traceback) to the `hg_errors` table. Note that previously, we were attempting to log the error message but failing because we were using the wrong column name. (`msg` instead of `exception_msg`).

Reviewed By: xavierd

Differential Revision: D16014833

fbshipit-source-id: 06460574f66999b1293ea31b43b5c7ec89737144
2019-06-26 20:17:11 -07:00
Arun Kulshreshtha
5b17733c4d remotefilelog: catch all exceptions during Eden API client setup
Summary: Now that Eden API returns specific exception types rather than always raising a `RuntimeError` when things go wrong, the fallback path needs to be updated to catch all exception types, not just `RuntimeError`.

Reviewed By: xavierd

Differential Revision: D16013115

fbshipit-source-id: d5c2d88acede7e70519eda8915401bb8ee394038
2019-06-26 14:40:47 -07:00
Jun Wu
282fb28151 amend: show deprecation warnings about --fixup
Summary:
`--fixup` is not really a great flag name and it came from a legacy
implementation.  Suggest `restack` instead.

Reviewed By: kulshrax

Differential Revision: D15978952

fbshipit-source-id: 4e8c2e79be01f6d8f13628409a446d42ae22c0af
2019-06-26 11:24:15 -07:00
Jun Wu
164b3ff4da amend: do not rebase unrelated commits
Summary:
See the test change for what this change is about.

The new code has side effect on linearizing things for `<rebase_src>::`. This
is reflected on the second last test change. The new behavior is arguably more
desiable - The new code can fail if rebasing D onto C2 causes conflicts. If
that happens, and rebasing C+C2+D onto the new B does not cause conflicts, then
the old behavior is better. We can add fallback code to the old behavior if
there are conflicts later, by calling a plain `rebase` instead of `restack`.

Reviewed By: kulshrax

Differential Revision: D15978953

fbshipit-source-id: 20b9d62c6125ce2faf8e21bd86f6aad31ac38a0c
2019-06-26 11:24:14 -07:00
Jun Wu
86e119ea37 restack: allow the callsite to override rebaseopts["rev"]
Summary: This allows the callsite to control what revs to rebase.

Reviewed By: kulshrax

Differential Revision: D15978954

fbshipit-source-id: 73174475411c3986f3a8e93a1a61ce5b857f454b
2019-06-26 11:24:14 -07:00
Arun Kulshreshtha
693deae060 remotefilelog: add configurable warning for bad TLS certificates
Summary: When the Eden API Rust client raises a CredsError exception, print out a configurable error message to the user (defined by the `edenapi.badcertmessage` config option). This allows us to provide specific instructions on how the user should renew their certificate.

Reviewed By: xavierd

Differential Revision: D15992903

fbshipit-source-id: 8316e33c3a5d86da272deea6402271d4a65548f4
2019-06-26 11:16:40 -07:00
Xavier Deguillard
9d18031708 remotefilelog: hardcode using Rust {data,hist}pack implementation
Summary:
We've had these 2 options turned on for a while now. Let's stop pretending
we'll switch them off, and just hardcode them over the codebase.

Some places are still using either the C code, or the Python one explicitely,
future changes will switch them to the Rust code.

Reviewed By: kulshrax

Differential Revision: D15981631

fbshipit-source-id: c23e474a84e887a2b92c9a304d63ef8d680cdf2d
2019-06-26 11:10:54 -07:00
Jun Wu
d172be76bf logging: stop logging requirements
Summary:
The requirements field is only interesting for non-remotefilelog or
generaldelta repos. Nowadays it's probably safe to assume clients are
remotefilelog and "requirements" is less useful.

Reviewed By: xavierd

Differential Revision: D15710676

fbshipit-source-id: 65f04b64760c652432471c4a8dda7acc4cf45466
2019-06-26 11:03:28 -07:00
Jun Wu
c754e0147b commands: provide in-core blackbox command
Summary:
The in-core blackbox command displays blackbox entries in the given time range.

The `blackbox` command provided by the blackbox extension was removed. They
can still be accessed via `.hg/blackbox.log`, though.

Tests are updated. Most `| grep` patterns were changed to use structured pattern
matching `--pattern` instead. Tests that are not interesting (ex. bundlebackup,
since we are moving away from bundle files slowly) are just removed.

Reviewed By: markbt

Differential Revision: D15640718

fbshipit-source-id: 7e5da60ca2b15ae9495d0242b340a066979d5a4f
2019-06-26 11:03:27 -07:00
Jun Wu
8640eccbeb blackbox: initial integrate with mercurial Python code
Summary:
Add a `mercurial.blackbox` module which just delegates to the Rust
binding. This means blackbox is no longer optional.

Change `ui.log` to log to the native blackbox as `LegacyLog` event.
The plan is to slowly migrate users from `ui.log` to `blackbox.log`,
which supports well-defined event types (instead of `LegacyLog`).

This does not change the `blackbox` command, which still uses the
legacy blackbox implementation. That will be changed in a later diff.

Reviewed By: markbt

Differential Revision: D15640720

fbshipit-source-id: de171f46e1430060083c9b7aee0a96dde315d021
2019-06-26 11:03:27 -07:00
Arun Kulshreshtha
b7dd8dd0ba remotefilelog: add python wrapper class around edenapi.client
Summary: This diff adds wrapper class around the Rust `edenapi.client` class defined in the bindings crate whose purpose is to catch any exceptions raised by the Rust bindings. For now, the wrapper class simply re-raises all exceptions; later diffs will use this to add special-case handling for certain exception types. (For example, for showing helpful messages when an error is due to a client certificate issue.)

Reviewed By: quark-zju

Differential Revision: D15975435

fbshipit-source-id: 21cef44dac84d5f468cb0e1d9eaddc2a1e93bfda
2019-06-25 09:37:10 -07:00
Xavier Deguillard
26aa32152f remotefilelog: add getpackv2 to the wireprotocol
Summary:
The getpackv1 API doesn't support LFS blobs as no metadata flags are sent over
the wire. This means that repositories like ovrsource can't use it, which
prevents these repos from moving away from loosefiles...

The getpackv2 is similar to getpackv1, except that it also sends the metadata
alongside the data. This means that the LFS flag is properly sent over the
wire.

Reviewed By: DurhamG

Differential Revision: D15905425

fbshipit-source-id: dab8dcb75c8d9db8c661f11f87318feca7d0f6a9
2019-06-24 11:20:39 -07:00
Xavier Deguillard
969b2a02eb remotefilelog: simplify _getdeltachain for getpackv1
Summary:
The getpackv1 is never sending delta chains, as the full content is always
requested.  We don't have plans to change this, so let's simplify the code a
bit.

Reviewed By: DurhamG

Differential Revision: D15905431

fbshipit-source-id: f853da08391185b525d8b3da2382519b5f8d76b2
2019-06-24 11:20:38 -07:00
Mark Thomas
eae1cdf956 remotefilelog: use _n for plurals of strings
Summary:
Use _n for plurals of strings, rather than hard-coding the suffix, and don't
retranslate the string after is has already been translated.

Reviewed By: kulshrax

Differential Revision: D15940244

fbshipit-source-id: 26ef175fe201bcc5211ad05c8b3894fbc22d61b6
2019-06-24 05:08:20 -07:00
Xavier Deguillard
f00c1f1a70 simplecache: fix infinite loop when reading from memcache socket
Summary:
In S179901, we've seen a couple of instances of `hg status` consuming as much
memory as they could until getting OOM killed. Looking at backtraces for these
processes (P67246356) the code spins trying to read data from memcache. The
connection is however closed and therefore `recv` returns an empty string,
which is then added to a list and the `recv` is retried again.

Reviewed By: kulshrax

Differential Revision: D15947154

fbshipit-source-id: f1216e26b0ce159377ff8e82bedc13a7cc3d0444
2019-06-21 14:17:27 -07:00
Jun Wu
a17a87bf4f setup: move native extensions to edenscmnative
Summary:
This just moves things around. So native and pure Python modules are split to
different Python packages. This makes it possible to use the standard zip
importer without hacks (ex. `hgdemandimport/embeddedimport`).

This diff is mostly about moving things. While `make local` still works,
it does break nupkg build, which will be fixed in a later diff.

Reviewed By: kulshrax

Differential Revision: D15798642

fbshipit-source-id: 5d83f17099aa198df0acd5b7a99667e2f35fe7b4
2019-06-19 17:55:49 -07:00
Mark Thomas
8bdf725c15 watchman: add perftrace annotations for state enter and exit
Summary: Add perftrace annotation for entering and exiting watchman state.

Reviewed By: quark-zju

Differential Revision: D15758925

fbshipit-source-id: 4b894bba1a6a4e5d13c527d5eaa2244303ad3396
2019-06-19 10:25:36 -07:00
Mark Thomas
c89454c5a2 commitcloud: add perftrace annotations for sync
Summary: Add perftrace annotation for `hg cloud sync`.

Reviewed By: quark-zju

Differential Revision: D15758926

fbshipit-source-id: 451416f2afb8cc8ca8e84b62797f0fded6a847fb
2019-06-19 10:25:35 -07:00
Mark Thomas
2fa2074f9a commitcloud: don't record backed up heads for failed transactions
Summary:
When cloud sync pulls in new commits from commitcloud, it also adds them to the
backedup heads, so that the next backup doesn't try to push them to the server
again.  However, the pull happens in a transaction, which may fail.  If it does
fail, the backedup heads are still recorded.

Update the write to the backedup heads file to take place inside the
transaction in this case, so the update only happens if the transaction
succeeds.

If any unavailable heads have been recorded, ignore them.

Reviewed By: mitrandir77

Differential Revision: D15898056

fbshipit-source-id: e7affce1b10f507e2ee924d9bc78000c835ccd65
2019-06-19 07:30:55 -07:00
Arun Kulshreshtha
3f6affebab edenapi: make streaming independently configurable for each operation
Summary: Previously, there was a single config option (`edenapi.streaming`) that would turn on streaming responses for all Eden API operations. It turns out that not all operations benefit from streaming, and in some cases, streaming actually hurts performance. As such, we need more fine-grained control of whether streaming is enabled. This diff adds options for each major operation (fetching data, history, and trees) to toggle streaming as desired.

Reviewed By: xavierd

Differential Revision: D15838619

fbshipit-source-id: ce5eb70f8b391788405af1c90de9009876e9f1f9
2019-06-17 14:16:28 -07:00
Xavier Deguillard
305a5e7df0 tests: add a test to verify rust mutable history store
Summary:
Verify that the behavior of the Rust history store is the same as the Python
one. A handful of changes needed to be made to both to account for small
difference in behavior regarding getancestors, and empty copyfrom paths.

Reviewed By: kulshrax

Differential Revision: D15721524

fbshipit-source-id: e03b7e8dcbc6f9f1941c64536b8de39b77f637c9
2019-06-17 14:01:32 -07:00
Xavier Deguillard
84f87d7690 remotefilelog: use Rust mutablehistorystore
Summary:
When format.userustmutablestore is turned on, all the history data will be
written into a Rust mutable history store.

Reviewed By: kulshrax

Differential Revision: D15717844

fbshipit-source-id: 417ec44f4b6f9566ef4c8d46c35b1e2dca7e583a
2019-06-17 14:01:31 -07:00
Xavier Deguillard
abc90590a4 remotefilelog: mutablehistorypack no longer support linkrev
Summary:
Now that linkrev are no longer added to mutablehistorypack, let's remove the
code that deals with it. This will enable using a Rust based historystore in
the future.

Reviewed By: kulshrax

Differential Revision: D15684623

fbshipit-source-id: d305e01cdfc0366c9432e0418854fd3b43a35539
2019-06-17 14:01:30 -07:00
Xavier Deguillard
74e48dfde3 treemanifest: delay packfile addition when using linkrev
Summary:
In order to provide fast "hg blame" for a file, Mercurial keeps an auxiliary
data attached to every filenode: the linknode. This linknode is a backpointer
to the revision that introduced the linknode.

While the linknode allows for very fast blame, it also has a big drawback: the
commit DAG has cycles. This makes for an awkward commit logic where the data
needed by a commit also needs the commit hash.

The solution that was taken up to now was to delay the write to the historypack
until it's closed and use "linkrev" until then. By the time the historypack is
closed the changelog will have been updated and the linkrev can be resolved to
a valid linknode. The drawback of this solution is that the historypack (and
other future stores) needs to have an understanding of what the changelog is to
be able to interpret linkrevs. It also prevents the store from being able to
blindly store data on disk as it is received.

For now, let's solve this by moving the handling of linkrev one layer up, and
recognizing when a linkrev is used and simply waiting until the changelog is
updated before adding the resolved linknode to the historypack.

A better solution to this problem is to simply not have a linknode in the
historypack, and instead have an auxiliary file where linknodes are stored.
This will remove the chicken-egg issue as this auxiliary file can be written
after the changelog is updated.

Most of the logic in this patch was inspired by a similar hack in
remotefilelog.

Reviewed By: DurhamG

Differential Revision: D15684624

fbshipit-source-id: 578c42349d6c6f572ff578de0495f2e762814cd2
2019-06-17 14:01:30 -07:00
Aida Getoeva
a527bf0d5d remotenames: fix positional args for selectivepull
Summary:
Enabled selective pull for myself and found issue with the passing positional args in the remotename wrapper of `exchange.py:pull(..)`.
`hg pull` failed because `heads` were passing uboth as positional args and as kwaargs. Fixed the issue explicitly specified args of the function.

Reviewed By: mitrandir77

Differential Revision: D15855502

fbshipit-source-id: 91b9bcfc122db069f9c6382e50f3185736103202
2019-06-17 11:45:55 -07:00
Thomas Orozco
cfaec40232 infinitepush: add replaybookmarksqueue
Summary:
This adds a new queue to replay scratch bookmark changes into Mononoke, which will allow us to replay them there.

There's not a lot going on in Mercurial (i.e. in this diff) to achieve this: we simply record bookmark changes as they happen in infinitepush, and allow for excluding some bookmarks. Specifically, we'll want to exclude backup branches, which we don't want to copy, since a) there's way too many of them and b) they're deprecated in favor of Commit Cloud.

Currently, this does not allow for replaying deletions. That would require further rework of how we delete things, since right now we do it my matching on bookmark names in the DB, which means the Python side of things is not aware of which bookmarks exactly were deleted. I'm not aware of how much use this is currently getting, but I'll research that and add it in if necessary.

Finally, one thing that's worth calling out here is the `bookmark_hash` column in this table. This is here in case we need to scale out the replication of bookmarks across multiple workers.

Indeed, we'll always want the replication of any given bookmark to happen sequentially, so we should perform it in a single worker. However, if we have too many bookmarks to replicate, then that could become a bottleneck. If that happens, we'll want to scale out workers, which we can do by having each worker operate on separate bookmarks.

The `bookmark_hash` column allows us to evenly divide up the space of bookmarks across workers if that becomes necessary (e.g. we could have 16 workers: one for each first hex digit of the hash). We won't use `bookmark_hash` immediately, but since it's very cheap to add (just compute one hash in Mercurial and put it in the table), I'm adding it in this diff now in case we need it later to avoid the friction of having to re-redeploy hg servers for that.

Reviewed By: StanislavGlebik

Differential Revision: D15778665

fbshipit-source-id: c34898c1a66e5bec08663a0887adca263222300d
2019-06-17 06:19:12 -07:00
Saurabh Singh
458cf27e86 globalrevs: avoid scanning changelog when looking for commit with svnrev 0
Summary:
There is no commit associated with the Subversion revision 0 and therefore, we
can bail out early in this case.

Reviewed By: kulshrax

Differential Revision: D15838376

fbshipit-source-id: bed3bfb8af4ac177a67f33078778beccc83f0573
2019-06-14 18:29:40 -07:00
Arun Kulshreshtha
225b204f31 edenapi: add support for streaming responses
Summary: This diff adds an `edenapi.streaming` config option; when set, Mercurial will request streaming responses from the API server for Eden API operations, and will handle the results as a stream of individually-serialized CBOR values.

Reviewed By: xavierd

Differential Revision: D15788328

fbshipit-source-id: e5eeb573bc6b4f0382ae545547670e8308306bca
2019-06-13 10:18:46 -07:00
Mohammad Ayoub
ef2721d49e add hg cloud status in hg pasterage output
Summary: The hg pasterage is the command that people run to share debug info when something is wrong with their repository. Having the information about CommitCloud related stuff will help with all the future debugging of that.

Reviewed By: mitrandir77

Differential Revision: D15744065

fbshipit-source-id: 094ccdf79c38fed78f5106a1617a5af09e1870e8
2019-06-13 05:53:22 -07:00
Mohammad Ayoub
48c061efcc add hg cloud status command
Summary: implement "hg cloud status" command

Reviewed By: mitrandir77

Differential Revision: D15738154

fbshipit-source-id: 774562d726c0f03d89d3b06696794e129668816f
2019-06-13 05:53:22 -07:00
Jun Wu
7a090c3975 remotefilelog: do not use osutil directly
Summary: The `osutil` module is re-exported by `util`. Use `util` instead.

Reviewed By: xavierd

Differential Revision: D15798643

fbshipit-source-id: 3b5ec4ce737664d70859889b1aaa18d09c2feb19
2019-06-13 00:16:52 -07:00
Xavier Deguillard
8c1828cf3a remotefilelog: use the indexedlogdatastore exclusively
Summary:
The multiplexing has been on for hg_dev hosts for a while, with no issues,
let's use it exclusively when the indexedlogdatastore config is set.

Reviewed By: kulshrax

Differential Revision: D15763914

fbshipit-source-id: 9d33c215f700c57bf3cf0d8e55117b1020bb422a
2019-06-12 10:45:37 -07:00
Xavier Deguillard
a366a363ef remotefilelog: indexedlogdatastore is no longer experimental
Summary:
We've had this on for the hg_dev servers for a while, with no notable issues.
Let's move it out of the experimental folder.

Reviewed By: kulshrax

Differential Revision: D15763915

fbshipit-source-id: ff1059d0b77fd8b564f4d02753606f2800146949
2019-06-12 10:45:36 -07:00
Xavier Deguillard
e8a00b0274 remotefilelog: move indexedlogdatastore path to a separate function
Summary:
Let's avoid the copy/paste of code. This will also allow to move it out of the
experimental path more easily.

Reviewed By: kulshrax

Differential Revision: D15763917

fbshipit-source-id: 4f61bfa8562cdd836d61efc96c180908f07ea74f
2019-06-12 10:45:36 -07:00
Saurabh Singh
95b3919e95 globalrevs: fix resolving 'svnrev' revset while using fast lookup
Summary:
Wayfinder 2.0: Marker shouldnt capture touches

[Exit: 0] singhsrb@devvm33590:~/fbsource/fbcode/scm/hg(225ed0e)$ hg prev
update complete
[dba7dce] Additional logging to verify that we are randomly not cleaning up completed child workflows
[Exit: 0] singhsrb@devvm33590:~/fbsource/fbcode/scm/hg(dba7dce|remote/master)$ ./hg -R ~/www log \
--rev="svnrev('5177822')" \
--config globalrevs.fastlookup=True \
--config globalrevs.scmquerylookup=False
[Exit: 0] singhsrb@devvm33590:~/fbsource/fbcode/scm/hg(dba7dce|remote/master)$
```

 - Ran all the tests.

Reviewed By: quark-zju

Differential Revision: D15780925

fbshipit-source-id: 654d332c8751ec2ccc51328f67527087bb0ca92c
2019-06-12 08:38:34 -07:00
Thomas Orozco
da844439e1 infinitepush: add forwardfillerqueue
Summary: This adds (behing a feature flag) the option for Mercurial servers to record bundles they ingest into a `forwardfillerqueue`. This queue is consumed by the commit cloud forwardfiller (see stack rooted at D15712911 for that) to replay those commits into Mononoke.

Reviewed By: farnz

Differential Revision: D15759638

fbshipit-source-id: 70660343408bbaa865fc8f51f49f590eaf525cce
2019-06-12 07:41:19 -07:00
Thomas Orozco
3210553e4c mononoke: review bookmarks: embed hg extension
Summary:
With listserverbookmarks in hg, we have to wait for an hg release to be able to run our monitoring, which isn't ideal.

Furthermore, the listserverbookmarks method command is unlikely to be used by anyone else, so we might as well provide it directly for review-bookmarks (like we do in e.g. the commit cloud backfiller for, though if we change our minds later we can always just revert this diff and the corresponding fbpkg change).

Reviewed By: farnz

Differential Revision: D15778340

fbshipit-source-id: d8fd6c9e1d33a420f95bdb4fadb582b864c51d5f
2019-06-12 06:13:28 -07:00
Xavier Deguillard
c45df4c166 remotefilelog: refresh the store after hg_memcache_client wrote to it
Summary:
After asking hg_memcache_client to fetch some data, we need to refresh the
underlying store. This refresh needs to be done after hg_memcache_client wrote
to it, not after we do the request.

Reviewed By: quark-zju

Differential Revision: D15763916

fbshipit-source-id: 99e88ffa13dba4394344c9340eba3f12fcfe0b76
2019-06-11 22:50:39 -07:00
Thomas Orozco
b77c7e0bf5 checkserverbookmark: add list command
Summary:
This adds a listserverbookmarks command to list bookmarks at a path without a
repository.

Reviewed By: ikostia

Differential Revision: D15737661

fbshipit-source-id: e2cd5dbcfe5c24868dd1d2b6685ebe13b1762676
2019-06-11 02:10:53 -07:00
Arun Kulshreshtha
9a0ca34302 edenapi: improve debug messages
Summary: Update the messages in the debug output for HTTP data fetching to specify whether we're downloading file content or file history.

Reviewed By: xavierd

Differential Revision: D15749426

fbshipit-source-id: e6fdff87d2cdc439549773c85a83341650652755
2019-06-10 18:11:12 -07:00
Arun Kulshreshtha
3273c6402e treemanifest: print HTTP stats in debug output
Summary: Print out download stats for HTTP tree fetching when `edenapi.debug` is set.

Reviewed By: xavierd

Differential Revision: D15746069

fbshipit-source-id: ab7f5bc67f4af64116a3095dd4424cfef9198f80
2019-06-10 18:11:11 -07:00
Xavier Deguillard
16da1f1b4a treemanifest: split _addtopack
Summary:
In order to not have to deal with linkrev in mutablehistorypack, let's split
_addtopack in 2. This will allow _addtreeentry to be wrapped later to deal with
linkrev.

Reviewed By: kulshrax

Differential Revision: D15684625

fbshipit-source-id: 772ffa25ce7b72f95f057d0ae00c89c7dc91bf18
2019-06-10 11:11:33 -07:00
Aida Getoeva
2c14a5a806 selectivepull: keep info about enabled remotes
Summary:
Selective pull, when just enabled, will filter only remote bookmark for the active remote repo at that time. When user will try to pull next time from the different remote, bookmarks for that remote won't be filtered, because the selective pull will think that it's already enabled and the remotenames file already has only interesting bookmarks.

I changed `selectivepullenabled` file to keep track of the remotes which selectivepull has been enabled for.

Reviewed By: markbt

Differential Revision: D15583506

fbshipit-source-id: dec09baf1e1a0c80d1d5987ac6f85fe1202b2dab
2019-06-10 09:31:16 -07:00
Aida Getoeva
f23fadb314 selectivepull: setup with accessed bookmarks
Summary: Now slective pull, when enabled, will keep not only configured remote bookmarks, but accessed, that were recoreded earlier, as well.

Reviewed By: markbt

Differential Revision: D15583505

fbshipit-source-id: 8c8d300afc333a94427513d9844c1c1af3cf7f32
2019-06-10 09:31:16 -07:00
Aida Getoeva
9e5636b9b7 selectivepull: fetch remote bookmarks on --remote
Summary:
If selective pull is enabled, the old implementation of `--remote` doesn't show all available remote bookmarks, but only locally available ones.
New implementation uses `listkeys` API to fetch remote bookmarks from the server.

However because `remote-path` flag belongs to the infinitepush extension, if the extension is not enabled, than `--remote` will show only bookmarks from the default remote.

Reviewed By: markbt

Differential Revision: D15547513

fbshipit-source-id: b7c79a0cc7237bbf086c64a71d6ed313aa520582
2019-06-10 09:31:15 -07:00
Aida Getoeva
8f19ab012c selectivepull: add list-subscriptions flag
Summary:
With selective pull feature we need to have ability to list locally available remote bookmarks - the bookmarks the user is subscribed to.
As current implementation of `--remote` does exactly that, pointing subscription to the same implementation.

Reviewed By: markbt

Differential Revision: D15547515

fbshipit-source-id: d3ac7295fee3391076855fbe1bed00124dab973f
2019-06-10 09:31:15 -07:00
Aida Getoeva
f2a68e1174 selectivepull: show hint in hg log to fetch remotename
Summary: When selective pull will be enabled, `hg log` won't be able to show any information about the remote bookmarks that are not in subscriptions for particular user. So we need to hint the user that they may want to explicitly pull the remote bookmark first, if hg log fails to find it.

Reviewed By: quark-zju

Differential Revision: D15516462

fbshipit-source-id: 5be77b0048d8e175a737f76a8e89768f4c837f60
2019-06-10 09:31:15 -07:00
Xavier Deguillard
363b35897a tests: add a test to verify rust mutable delta store
Summary:
As we're working towards moving exclusively to Rust based mutable stores, let's
modify the existing datapack unit tests to test them.

Reviewed By: kulshrax

Differential Revision: D15673688

fbshipit-source-id: 847ec0f5f5316e6f8ba72f27a7665dd3bf46c5fc
2019-06-07 16:14:09 -07:00
Arun Kulshreshtha
c95ee2c583 edenapi: remove cachepath
Summary: Now that EdenAPI's methods take in a MutableDeltaStore to perform writes, EdenAPI no longer needs to know about the cache path, as this is an implementation detail of the store. This field was no longer used anywhere (except by the constructor code which created the cache directory if it didn't exist -- this behavior is now handled by the MutableDeltaStore), so let's remove it.

Reviewed By: quark-zju

Differential Revision: D15715777

fbshipit-source-id: 11908c6be49f8846e1b7ba5890200d08529441e8
2019-06-07 11:06:51 -07:00
Arun Kulshreshtha
9c2782c969 remotefilelog: add debug command that fetches files serially
Summary: Add a new command, `hg debugserialgetfiles`, which works just like `hg debuggetfiles` except that each file is fetched serially via a separate call to `edneapi`'s `get_files` method. This is designed to simulate a pathological case where Mercurial performs a series of individual file fetches, depriving the Eden API client of the opportunity to use batching, etc. In particular, this command is intended to be used to test TCP connection reuse inside of libcurl.

Reviewed By: quark-zju

Differential Revision: D15707993

fbshipit-source-id: d57550639839ed597347228059f51ed343151867
2019-06-06 22:01:20 -07:00
Arun Kulshreshtha
b0be100cf0 remotefilelog: nicely format byte counts in HTTP progress bars
Summary: Use a formatting function to pretty print byte counts in progress bars for HTTP data fetching. Also correctly pluralize the progress bar message. (i.e., treat "1 file" as a special case.)

Reviewed By: quark-zju

Differential Revision: D15700946

fbshipit-source-id: d2baaa757787ebeeb94d4b987128d8fafd12f19b
2019-06-06 14:57:46 -07:00
Arun Kulshreshtha
0ef2f86732 treemanifest: add http tree prefetching
Summary: This diff adds a new `treemanifest.usehttp` config option. When set, Mercurial will attempt to prefetch trees from the API server, falling back to SSH if HTTP fetching fails.

Reviewed By: markbt

Differential Revision: D15506807

fbshipit-source-id: a5c5fcf14f29aee083c9fa0daeb0aedb5c1ec9a9
2019-06-06 12:20:56 -07:00
Abinesh Ramakrishnan
0a00a38f49 remotefilelog: log when hash verification fails
Summary: D13838772 introduce validation of hashes when fetching data from mercurial/memcache. We'd like to get insights in to how often this would happen, and potentially attach alarms to notify.

Differential Revision: D15472456

fbshipit-source-id: ad2f28e91824e4bbfc02284f230111e2d4cb3f00
2019-06-04 14:26:31 -07:00
Saurabh Singh
57e0d8c5b5 globalrevs: allow scmquery based lookups from 'globalrev->hash' on clients
Summary:
The clients don't have any mapping from `globalrev->hash` locally but
they can do this lookup quickly using ScmQuery. We do not want to invest too
much effort on supporting globalrev based lookups on the clients as this is a
workflow we want to discourage anyway. But, for now, existing workflows may
break if this lookup is slow on the clients. Therefore, for the interim, lets
just have this lookup backed by ScmQuery. We can later improve or completely
discard this based on the future direction for globalrevs.

Reviewed By: quark-zju

Differential Revision: D15588420

fbshipit-source-id: 61f91414248ca1defe6eac4311243ee8029a92cf
2019-06-04 11:59:12 -07:00
Saurabh Singh
d4d9a6a6d9 globalrevs: clean up 'globalrev' revset string to not rely on hgsubversion
Summary:
We will eventually get rid of the `hgsubversion` extension and
therefore, we want to remove any dependency on it in the long term. This commit
removes any dependency on the `hgsubversion` extension for resolving the revset
string corresponding to the globalrev.

Reviewed By: quark-zju

Differential Revision: D15586218

fbshipit-source-id: 79685ce96075a162d40ce2ce48d347333d768d7a
2019-06-04 11:59:12 -07:00
Mark Thomas
55437fa6a1 mutation: add bundlerepo support
Summary:
Support bundlerepos with mutation data.

Infinitepush is currently the only place where bundles may include mutation
data.  This is used when rebundling infinitepush bundles to send back to the
client.

Reviewed By: mitrandir77

Differential Revision: D15604475

fbshipit-source-id: 111a3211044c742d3d1c75d06c6e6114f754e396
2019-06-04 04:50:53 -07:00
Xavier Deguillard
72328305a5 indexedlog: make files read/write for owner and group
Summary:
The tempfile crate creates temporary files with the mode 0600 and thus when one
is persisted, it keeps these permissions. This effectively prevents a shared
indexedlog to be used by anybody but the owner.

Reviewed By: quark-zju

Differential Revision: D15580364

fbshipit-source-id: 06ca3872287b618bfbab28327644a143db7282c9
2019-06-03 11:58:48 -07:00
Mark Thomas
76ad6db18f githelp: update branch -d suggestions
Summary:
Update `hg githelp -- git branch -d` suggestions to suggest `hg hide -B`.

Also fix up the code so that trailing `-B` options are not produced.

Reviewed By: farnz

Differential Revision: D15575864

fbshipit-source-id: bd0d0b23f2a509e02554bcbb453718bebe8ea11a
2019-06-03 08:48:25 -07:00
Mark Thomas
212ac73eb2 strip: alias strip to hide instead of prune
Reviewed By: quark-zju

Differential Revision: D15562713

fbshipit-source-id: d483909975ae2a1bb3721420a58575932103646a
2019-06-03 08:48:25 -07:00
Mark Thomas
4f8aadb257 hide: pluralize messages
Reviewed By: quark-zju

Differential Revision: D15562714

fbshipit-source-id: 54bb2526fce470ebfe8f0f29baab3c4d823f74c1
2019-06-03 08:48:25 -07:00
Mark Thomas
48e3c2e21f hide: add -B option to the hide command
Summary:
Add support for `hg hide -B bookmarkname`.  This hides all commits that are
uniquely reachable by the provided bookmarks.  This means if a bookmark is at
the head of a stack, `hg hide -B bookmark` will hide the stack.

Reviewed By: quark-zju

Differential Revision: D15562715

fbshipit-source-id: 9fdb3383b534faea982396a4f4782c03e4910dc3
2019-06-03 08:48:25 -07:00
Mark Thomas
30549a98dd bookmarks: commonize debugstrip -B and prune -B handling
Summary:
Make the code for calculating which revisions the `-B` options to `hg prune`
and `hg debugstrip` affect common to both commands.

The remotenames modification of `repair.stripbmrevset` is wrong.  It should
exclude all ancestors of commits that have remotenames, not just those that
don't share a bookmark with the remotename.  Fix it.

Reviewed By: quark-zju

Differential Revision: D15562716

fbshipit-source-id: 507002505100e7d60c395f242cc8e1062b91cc20
2019-06-03 08:48:24 -07:00
Mark Thomas
1d329cae5d rust: update to 2018 edition
Summary:
Update all rust crates that compile on Rust 2018 to use the 2018 edition.

The `commitcloudsubscriber` crate only compiles with Rust 2015, so make that
explicit in `Cargo.toml`.

Reviewed By: farnz

Differential Revision: D15601648

fbshipit-source-id: 7380e6e695fc3049913af91fcbde105dfe1be4bc
2019-06-03 07:22:36 -07:00
Thomas Orozco
4a77a90d3c infinitepush: log pushes to Scuba
Summary:
This will allow us to efficiently identify scratch pushes that are not properly being pushed to both Mercurial and Mononoke.

When we roll out `infinitepush-other`, this will be helpful to make sure all repositories are properly configured to push to both destinations.

Reviewed By: farnz

Differential Revision: D15577201

fbshipit-source-id: 17912b90a934f65ed21851170402ae498b127c14
2019-06-03 05:30:44 -07:00
Thomas Orozco
d6c8fef226 infinitepush: alias "default" path into "infinitepush"
Summary:
Through Scuba, we can identify quite a few users that are doing `hg push default` for an infinitepush: https://fburl.com/scuba/6vz3ien7.

This is typically happening in repositories where the `default-push` destination is not the hg repository.

In fact, we actually prompt users to use hg push default if they try to perform a scratch push to a svn repository a few lines below!

markbt suggested we should just replicate the push in this case as well, which I think is a good idea.

Simply replicating the push in this case is not quite enough, however!

Indeed, for our infinitepushes to go to both Mercurial and Mononoke, we would have to maintain an number of consistency rules between `default`, `infinitepush`, and `infinitepush-other`:

- `default` and `infinitepush-other` must point to opposite repositories (i.e. one Mercurial, one Mononoke), to serve users using `hg push default`.
- `infinitepush` and `infinitepush-other` must point to opposite repositories, to serve users using `hg push` without a path.

This effectively means `default` and `infinitepush` must be the same, and `infinitepush-other` must be the other. We could do this with path markers, but this is getting so complicated that I don't foresee us getting it right.

At the end of the day, the root cause of this complexity stems from the fact that we're using a destination that is now effectively a read path (`default`) for infinitepush writes. I think this was perfectly valid when default meant "Mercurial, not subversion", but not so much now that we have Mononoke in the mix.

Of course, we could just update the message and ask our users to use `hg push infinitepush` instead, but this would mess with their muscle memory as well as their shell history (not to mention that `hg push default` would silently do the wrong thing).

So, this patch updates the code to use the infinitepush "write" destination for writes when that is what the user intended.

 ---

As a side note, note that the current behavior is actually a little broken. Indeed, if one were to do `hg push default --to scratch/$FOO` while Mononoke is serving reads, the scratch would go to Mononoke. In this scenario, the scratch push would in theory have been accepted but would have had its bookmarks discarded (at least until we support htose in Mononoke :) ).

This probably never happened in practice, however, for two reasons:

- Most users and systems that actively push scratch bookmarks are actually pushing to a specific `hg.vip` path instead of `default` (one notable exception is On Demand WWW).
- `hg push` to Mononoke for a scratch bookmark doesn't actually work if you have the pushrebase extension code loaded in some way (either by enabling the extension, or enabling an extension that uses it). See D15576199 for the details.

Reviewed By: farnz

Differential Revision: D15576545

fbshipit-source-id: c28b808632505bb8e8f4d114029f7d8c17c9749e
2019-06-03 05:30:44 -07:00
Saurabh Singh
ecfe13aa97 globalrevs: clean up the 'globalrev' template to not rely on hgsubversion
Summary:
We will eventually get rid of the `hgsubversion` extension and
therefore, we want to remove any dependency on it in the long term. This commit
removes any dependency on the `hgsubversion` extension for retrieving the
`globalrev` corresponding to a commit. Note that the `globalrev` for the older
commits is just the `svnrev`.

Reviewed By: quark-zju

Differential Revision: D15579401

fbshipit-source-id: 021e6d93d008b07591e1b7801062d9c5fbfc7651
2019-05-31 12:16:54 -07:00
Thomas Orozco
14b1c5bda9 disable pushrebase during infinitepush
Summary:
Infinitepush is not a pushrebase, so we should not send the b2x:commonheads part when we do an infinitepush.

Mercurial doesn't actually care about this, but Mononoke does (because it peeks at the stream to know if we're dealing with a pushrebase or a regular push).

Reviewed By: ikostia

Differential Revision: D15576199

fbshipit-source-id: a90adb5884b00ad65208697fa17983535aacb9c6
2019-05-31 08:57:14 -07:00
Mark Thomas
0d4069eb53 commitcloud: only take the lock when reading backup state for sync or backup
Summary:
In D15468485 calls to read the backup state started taking the repo lock to
ensure a consistent state.  This had the unintended side-effect of making
revset predicates like `backedup` take the lock on what would normally be a
read-only path.

It's only necessary that sync and backup get a consistent view - it's ok if
logging functions see a slightly stale view of the repo.  Move the lock out of
the `BackupState` constructor to the places it is called in sync and backup.

Reviewed By: mitrandir77

Differential Revision: D15575458

fbshipit-source-id: c4f2a62839e5f22a64ff6d6a4e78ef4c65cb8b15
2019-05-31 03:44:08 -07:00
Saurabh Singh
fcd4d42859 fbconduit: introduce method for retrieving mirrored rev
Summary:
This commit just introduces a method for retrieving a mirrored
revision using the relevant ScmQuery API. The eventual objective is to use this
method to also be able to get the `hash` corresponding to a `globalrev` on the
Mercurial clients.

Reviewed By: quark-zju

Differential Revision: D15571470

fbshipit-source-id: cc0506356d27450594a690aa29a2a2a608aac5c0
2019-05-30 19:11:52 -07:00
Xavier Deguillard
34344946cd remotefilelog: use util.unlink instead of os.unlink
Summary:
The former will always succeed on Windows, while the later raise an Exception
when the file is opened elsewhere.

Reviewed By: quark-zju

Differential Revision: D15571023

fbshipit-source-id: b7ee739dce49f9a9ba5087ec785a6dc332eb88c8
2019-05-30 18:47:46 -07:00
Xavier Deguillard
105901302a remotefilelog: close temporary packfiles on abort
Summary:
On Windows, keeping the files open prevent them from being deleted.
Make sure we close them temporary packfiles on abort so they can be
removed properly.

Differential Revision: D15550431

fbshipit-source-id: eca557ffd852ef0255fe991c50ce35a6a8ee7fa0
2019-05-30 11:45:50 -07:00
Thomas Orozco
b26f3f5a25 replicate hg push for scratch branches to infinitepush-other
Summary: This updates `hg push` to replicate pushes to the `infinitepush-other` path. This ensures that we replicate pushes to scratch branches to Mononoke once we enable this mechanism.

Reviewed By: markbt

Differential Revision: D15538790

fbshipit-source-id: 0baa31f26f516cf5d2f6ec5a14d8006c912766c2
2019-05-30 08:34:31 -07:00
Mark Thomas
57ed970fed blackbox: only log current commit if the changelog has been loaded
Summary:
When writing a blackbox log entry, only include the current commit if the repo
has already loaded the changelog.  Otherwise, finding out what the current
commit is will load the changelog, which is wasteful, and may cause a
re-entrant call back into blackbox logging.

Reviewed By: xavierd

Differential Revision: D15539413

fbshipit-source-id: 48c27b053b9db7ce5c2d4b1991020adaea720c21
2019-05-30 04:02:54 -07:00
Mark Thomas
449153038a commitcloud: use lastsyncstate omittedheads for lastsyncstate head omissions
Summary:
When computing which of the lastsyncstate heads should be available in the repo,
use the omittedheads from the lastsyncstate, not the new omitted heads.

Reviewed By: mitrandir77

Differential Revision: D15535780

fbshipit-source-id: 215f037215b20d1188999abfa42e7a45391b7723
2019-05-29 07:25:22 -07:00
Chad Austin
b8a32252c9 remotenames: include the filename in the file corrupted error
Summary:
We have seen reports of this file getting corrupt on Windows when
peoples' machines are hard-rebooted. Handle that corruption with a
more helpful error message.

Reviewed By: quark-zju

Differential Revision: D15506345

fbshipit-source-id: 66d998a156bc11953b5afb440270ff77af4677fc
2019-05-28 13:26:35 -07:00
Xavier Deguillard
c1b4591cc8 remotefilelog: use store.flush instead of store.close
Summary:
The Rust code doesn't have a close method, but it has a flush one. This has the
drawback of removing the ledger argument from the close method which is used to
guarantee that data gets into the packfile before the rename operation.

For now, let's always sync the file content before closing the mutable
packfile.

Reviewed By: kulshrax

Differential Revision: D15504680

fbshipit-source-id: 09dbda8820351b128038d6c3ea1843fef9c5bc48
2019-05-28 10:06:51 -07:00
Xavier Deguillard
a0888345c8 revisionstore: replace manual uses of mutabledatapack/mutablehistorypack
Summary:
By using a wrapper over them, it becomes easier to switch the underlying
implementation to be a Rust one.

Reviewed By: kulshrax

Differential Revision: D15504679

fbshipit-source-id: ac87311e015bd4c3baafb8e8e77ab6ed4890cdcc
2019-05-28 10:06:51 -07:00
Durham Goode
788387206b remotefilelog: make test output more -i friendly
Summary:
We have to use globs in tests everywhere they output durations. It's
annoying when you have to update many tests, so let's force the output to 0 when
in tests.

Reviewed By: quark-zju

Differential Revision: D15382069

fbshipit-source-id: eaed82e2ba685d594267433494d98fce5de3663e
2019-05-28 03:17:02 -07:00
Durham Goode
ad813edcbd treemanifest: enable treemanifest by default in tests
Summary:
Now that all our repos are treemanifest, let's enable the extension by
default in tests. Once we're certain no one needs it in production we'll also
make it the default in core Mercurial.

This diff includes a minor fix in treemanifest to be aware of always-enabled
extensions. It won't matter until we actually add treemanifest to the list of
default enabled extensions, but I caught this while testing things.

Reviewed By: ikostia

Differential Revision: D15030253

fbshipit-source-id: d8361f915928b6ad90665e6ed330c1df5c8d8d86
2019-05-28 03:17:02 -07:00
Mark Thomas
065309255e commitcloud: serialize cloud sync attempts with other transactions
Summary:
Cloud sync backs up commits before it takes the lock.  If, during this backup
process, another transaction adds new commits to the repository, the cloud sync
process will not be able to sync properly, as some of the commits won't have
been backed up.

Furthermore, because the backup state may have been updated between opening the
changelog and reading the backup state, which means the backup state may
reference commits that are not available in the changelog to the current
process.

Serialize these operations by:

* Reading the backup state file under the repo lock.  This, unfortunately, means
  `hg cloud backup` needs to take the lock, but it should only be for a very
  brief period while a file is read.

* When cloud sync has completed the backup and is about to start syncing, check
  that the repository hasn't changed while the backup was running.  If it has,
  abandon this sync attempt.  Another background sync will have been scheduled
  that will backup the new commits and then sync everything.

Reviewed By: quark-zju

Differential Revision: D15468485

fbshipit-source-id: 706ada05dfb1f539638104722a044493c7e3e62f
2019-05-28 02:40:08 -07:00
Mark Thomas
456d9e8829 commitcloud: use a transaction to perform sync
Summary:
Ensure cloud sync gets a consistent view of the repository, and that the sync
operation is a single update, by taking in the lock and using a transaction for
the whole cloud sync.

The commits are backed up before we take the lock, so for syncs that don't pull
in any new commits, this should still be relatively fast: we will only have the
lock for the duration of the request to the commit cloud service.  In the case
that we do need to pull new commits, we were already taking the lock anyway.

Reviewed By: quark-zju

Differential Revision: D15468487

fbshipit-source-id: 37abeac85dad8d2cfb4ad160c5f417dde087d74c
2019-05-28 02:40:08 -07:00
Mark Thomas
cfe64a31f7 blackbox: add util.log for blackbox logging when no ui object is available
Summary:
If a ui object is not available, then callers can't make blackbox logs.  However,
the blackbox extension has `lastui()` which lets it find a ui object.

Add `util.log`, a hook point for blackbox that lets callers log to blackbox without
having a ui object to hand.

Reviewed By: quark-zju

Differential Revision: D15495215

fbshipit-source-id: b468647ccacc6992f71b9a8be2552db860d16ebe
2019-05-28 02:40:07 -07:00
Mark Thomas
d9f5e7c757 commitcloud: use util.timer for timing commands
Summary: Use `util.timer` to time commands, to make these times stable in tests.

Reviewed By: quark-zju

Differential Revision: D15468482

fbshipit-source-id: 7d15d725ba436915dff5da514398514dd0b113f7
2019-05-28 02:40:07 -07:00
Kostia Balytskyi
45755289bd mononoke-replay: move unbundlereplay and checkserverbookmark to util.timed
Reviewed By: StanislavGlebik

Differential Revision: D15494128

fbshipit-source-id: 4a76a5f9dbffa989f17c9a5d2e78d130bb46635f
2019-05-25 10:57:49 -07:00
Kostia Balytskyi
865b8b3a46 checkserverbookmark: add an extension to check server bookmark location
Summary:
This extention will return 0 if the bookmark points to an expected hash and
non-0 otherwise. We plan to use it in Mononoke.

Reviewed By: StanislavGlebik

Differential Revision: D15450801

fbshipit-source-id: 36d938fb6912046ada229a4e35b76e9cf13f0a74
2019-05-24 16:23:46 -07:00
Arun Kulshreshtha
54fc1fe804 remotefilelog: log http fetch latency
Summary: Log HTTP fetching latency to dev_command_timers.

Reviewed By: xavierd

Differential Revision: D15493101

fbshipit-source-id: 60f155d4a68972fa17ea1c01f67868becb5986e4
2019-05-24 14:30:01 -07:00
Durham Goode
2dfd48c8de treemanifest: default to treeonly
Summary:
Now that all our repos are treeonly, let's default the extension to
using treeonly. This opens the doors for moving all the tests to operating on
treeonly repos in a future diff.

Reviewed By: quark-zju

Differential Revision: D15030251

fbshipit-source-id: cd289775174bbacd6a6cdc7a5b07fe7e41238584
2019-05-24 10:00:49 -07:00
Durham Goode
6210607c36 manifest: remove readfast, replace readdelta
Summary:
Previously readfast was an optimization that sometimes returned a delta
against p1, but other times returned the full manifest. This was weird and
caused certain algorithms to sometimes be O(changes) but other times O(repo).
In a tree world we no longer need this optimization, so let's drop it.

readdelta is similar in that it would read the difference between a manifest and
it's delta base. This has no relationship to the delta between a manifest and
it's parent, so it's weird and we should get rid of it.

There is a legitimate use case for wanting to know what entries are new in a
manifest, like when deciding what to send over the wire. So let's add a new
readnew() function that is explicitly for reading what entries were introduced
by this tree. The implementation is basically the same as readdelta, but
deltaing against p1 instead of the deltabase.

Reviewed By: markbt

Differential Revision: D15344434

fbshipit-source-id: dc8dca326f66b2fc55cc76f93c7ce48aa7efedf3
2019-05-24 10:00:49 -07:00
Thomas Orozco
1619f10b07 sendunbundlereplay: allow passing a log file for output
Summary:
This makes it easier for a wrapping job to associate output with a given command it ran.

Note that creating a SSH peer creates its own copy of the `ui` object, which is why we have to push a buffer to both `ui` instances.

Reviewed By: ikostia

Differential Revision: D15468456

fbshipit-source-id: c6f1937749447e27332801577538d9874eb18898
2019-05-24 03:40:45 -07:00
Marla Azriel
774d69dbaf commands: help text for uncommit, unamend
Summary: Updated help text for hg uncommit, hg unamend

Reviewed By: mitrandir77

Differential Revision: D15424275

fbshipit-source-id: 39091707195c2478b17ec0c1a8c5062304cb8709
2019-05-23 21:39:22 -07:00
Jeremy Fitzhardinge
c33b298154 Convert scm/hg/edenscm/hgext/extlib/indexes to Rust 2018
Summary:
Rust 2018 updates to:
  //scm/hg/edenscm/hgext/extlib/indexes:indexes
  //scm/hg/edenscm/hgext/extlib/indexes:indexes-unittest

Reviewed By: xavierd

Differential Revision: D15465446

fbshipit-source-id: e6065b27ebac52525ecb435a2f5b3d407cd96e91
2019-05-23 17:36:33 -07:00
Arun Kulshreshtha
ed8d097a80 remotefilelog: show number of files in http progress bar
Reviewed By: quark-zju

Differential Revision: D15481359

fbshipit-source-id: fd18996c6919ebe70a8809fff63939ff14c29c20
2019-05-23 15:47:11 -07:00
Arun Kulshreshtha
7243726f8e remotefilelog: add progress bars to edenapi debug commands
Summary: Add progress bars to remotefilelog's debug commands for HTTP data fetching. This makes it obvious whether there is activity occurring or whether Mercurial is stuck.

Reviewed By: quark-zju

Differential Revision: D15480683

fbshipit-source-id: 8c67c306488e5ec82a32143eb1748879474e3ec9
2019-05-23 15:47:11 -07:00
Xavier Deguillard
df8fc5d0fe remotefilelog: add an option to switch to rust mutable store
Summary:
While mutable datapack are used in several places, most of the writes are
coming through the pendingmutablepack class, so let's start switching these
to use the Rust code.

Reviewed By: kulshrax

Differential Revision: D15482770

fbshipit-source-id: d0e4aae38a5ef2ba625a40ff907420623e6efd11
2019-05-23 15:41:44 -07:00
Xavier Deguillard
0ac1e9ffa8 remotefilelog: prepare pendingmutablepack to use a Rust store
Summary:
Both the Rust and Python mutable stores support a flush method, but while
Python support an abort method, Rust will simply cleanup temporary files when
the object is destroyed. We can implement a similar scheme in Python by
implementing __del__.

Reviewed By: kulshrax

Differential Revision: D15482771

fbshipit-source-id: 4c9647ab7dd9fa078a8fc3c8b00962fbc0823dfd
2019-05-23 15:41:44 -07:00
Durham Goode
55575572b8 hgsql: use mmap for hgsql revlog validation
Summary:
Opening all the revlogs to validate them is showing up as a performance
bottleneck for hgsql transactions. Let's switch them to using mmap to avoid
reading a bunch of data from disk.

Actually making this have an effect on our servers will also require setting the
experimental.mmapindexthreshold config.

Reviewed By: quark-zju

Differential Revision: D15441867

fbshipit-source-id: 4edde0bc3419ef75f82a4234c9dfc6604c6db9f4
2019-05-23 10:50:29 -07:00
Arun Kulshreshtha
cafacdf6b4 remotefilelog: print HTTP stats in debug output
Summary: Print out download stats when `edenapi.debug` is set. Pretty printing of the stats has been improved to make these numbers more useful to humans.

Reviewed By: xavierd

Differential Revision: D15466702

fbshipit-source-id: 6fac9ca5976b98874fc7a5f9b89d42975e1520ce
2019-05-23 09:22:04 -07:00
Arun Kulshreshtha
16cd491afe remotefilelog: use gated ui.warn instead of ui.develwarn
Summary:
When EdenAPI encounters an error, the current behavior is to print an error message and then fall back to SSH. In addition to the fallback notice, we were previously printing the exception message using `ui.develwarn`, with the understanding that this information is only really useful to Mercurial developers.

Instead of using `develwarn`, let's use `ui.warn` but gate the call so that only users with `edenapi.debug` set to `True` see the error message.

I initially tried printing the entire backtrace with `ui.traceback`, but this proved too verbose to print out in the middle of normal command output. The full traceback is logged to Scuba, and can be obtained from the `hg_errors` Scuba table, so just logging the exception message should be sufficient.

Reviewed By: quark-zju

Differential Revision: D15466332

fbshipit-source-id: 43d40eff47e4f68fe860383e7bd519fbd0052830
2019-05-22 23:20:27 -07:00
Arun Kulshreshtha
7863b7badf remotefilelog: use 'HTTPS' instead of 'HTTP' in user-facing output
Summary: On the Source Control team, we've been referring to the project to replace parts of the Mercurial wire protocol with the Mononoke API server as "HTTP data fetching". This has caused confusion for other teams in the past (particularly teams with a security-related focus), as this nomenclature makes it seem as if we're using unsecured HTTP. (This is not true; we are always using HTTPS.) In light of this, let's make sure that user-facing messages always use the term "HTTPS" instead of "HTTP" to avoid this confusion.

Reviewed By: quark-zju

Differential Revision: D15465390

fbshipit-source-id: b556ed222dc01979ceaa0d4a7aa921cb1c38d75e
2019-05-22 23:20:26 -07:00
Arun Kulshreshtha
a48dfc7f14 remotefilelog: add logging for edenapi
Summary: Log metrics about HTTP data fetching to `dev_command_timers`, and log HTTP fetching errors to `hg_errors`.

Reviewed By: quark-zju

Differential Revision: D15464791

fbshipit-source-id: 1027383b6aa0dc6915351332bfbc2d20d540cc4e
2019-05-22 23:20:26 -07:00
Arun Kulshreshtha
1a1fad0c56 edenapi: check for valid TLS certs at client setup
Summary: Check that the user's configured TLS credentials exist during client setup and disable HTTP if they aren't present.

Reviewed By: quark-zju

Differential Revision: D15459917

fbshipit-source-id: f20664c6522e47f2960cec1f02ef1a5f4c7e2c8c
2019-05-22 23:20:26 -07:00
Arun Kulshreshtha
f2f3af316f edenapi: add methods to DownloadStats callable from Python
Summary: Add several methods to the DownloadStats FFI wrapper to allow Python code to easily access various metrics.

Reviewed By: xavierd

Differential Revision: D15458802

fbshipit-source-id: 9e19d2a9b3fcb6e3a066f040fd110510a2f0d63e
2019-05-22 16:03:06 -07:00
Arun Kulshreshtha
00313b170a edenapi: make fetch commands return metrics
Summary: Make all of the EdenAPI data fetching methods return an object containing metrics. These can then be logged by the Python code.

Reviewed By: xavierd

Differential Revision: D15440641

fbshipit-source-id: 4a5fd090066a9020ae32986ab45ee8fb70c8de53
2019-05-22 12:59:29 -07:00
Durham Goode
148e70118a treemanifest: sort trees by linkrev before inserting
Summary:
Previously we sorted the trees topologically before inserting them. On
a revlog-backed server, this may mean that trees are written in a different
order from the actual commits. hgsql-backed servers rely on the data being
written in linkrev order so they can be replayed in linkrev order on other
machines, so this broke hgsql replication.

Let's instead sort by linkrev, which will be both topological and satisfy
hgsql's requirements.

Reviewed By: quark-zju

Differential Revision: D15437953

fbshipit-source-id: d4aaaa03b392a6cb6cf1be478aed2583ecb757c5
2019-05-22 09:09:03 -07:00
Durham Goode
1bf9700af1 treemanifest: disable manifest verify when treemanifest is on
Summary:
We had this disabled in a config we ship in rpms, but if we want the
tests to work in treeonly mode we want this disabled in all tree cases.

Reviewed By: xavierd

Differential Revision: D15296199

fbshipit-source-id: 0f9751583eefa10c275bd499bb5998adfbe644a4
2019-05-22 08:37:11 -07:00
Mark Thomas
7e32ae71dd commitcloud: provide legacy pushbackup and isbackedup commands
Summary:
`hg pushbackup` and `hg isbackedup` can be called from scripts with `HGPLAIN`
set, and so can't be provided by aliases.  Instead, provide deprecated wrapper
commands.

Reviewed By: mitrandir77

Differential Revision: D15436286

fbshipit-source-id: 3fbbf9a5fb4d0e8de2026a17c41ee11a139d645f
2019-05-21 15:32:10 -07:00
Mark Thomas
1eaa46bd64 commitcloud: log sync state to blackbox log
Summary: Improve debugability of cloud sync by logging updated sync state to the blackbox logs.

Reviewed By: mitrandir77

Differential Revision: D15434890

fbshipit-source-id: c5065455985a48777a855997a99e32ce0b31cc72
2019-05-21 15:32:09 -07:00
Mark Thomas
30e5b3eb26 commitcloud: remove omitted bookmarks that are available locally
Summary:
When syncing, if a locally-available bookmark is synced to a new commit that
has been omitted, remove the local bookmark to ensure that the next cloud sync
doesn't move the bookmark back to where it used to be.

Reviewed By: mitrandir77

Differential Revision: D15414172

fbshipit-source-id: 71aaa2d89f734e4c575c24da2c0ef6b59ca4deaa
2019-05-21 15:32:09 -07:00
Xavier Deguillard
8e9bc8c347 pyrevisionstore: implement flush for PythonMutableDataPack
Summary:
A new flush method is added to mutablebasepack that just close and re-init
self.

Reviewed By: kulshrax

Differential Revision: D15416708

fbshipit-source-id: 79cdcb20b51b9688a5e95402057c7da27883003c
2019-05-21 15:25:26 -07:00
Durham Goode
3403a1dc36 hooks: remove "incoming" hook
Summary:
This hook fires for every commit that is introduced in a pull. When
doing pulls with hundreds of thousands of commits, this introduces a noticable
delay. We don't use this hook anywhere, and it's not particularly scalable, so
let's delete it.

Reviewed By: singhsrb

Differential Revision: D15424697

fbshipit-source-id: 98d76bca703e625adf5be8f6234436befd260fc4
2019-05-21 15:01:16 -07:00
Kostia Balytskyi
fb54cc5694 hgsubversion: move to absolute import
Summary:
Let's move hgsubversion to absolute_import, just to be consistent with the rest
of Mercurial codebase.

Reviewed By: markbt

Differential Revision: D15392154

fbshipit-source-id: e4c32939aff0616790828da508f3feea158669e1
2019-05-21 09:15:21 -07:00
Arun Kulshreshtha
da6f7284a5 fileserverclient: do not return pack paths from data fetching functions
Summary: As of D15154509, the data fetching functions in remotefilelog write to shared mutable packs rather than opening new packs. As such, there is no need to return pack paths. In fact, the code has already been updated so that the returned paths are always `None`, so the code removed in this diff is already dead.

Reviewed By: xavierd

Differential Revision: D15419765

fbshipit-source-id: c999d5388042b429a8bda9f72a06569364d8e2e1
2019-05-20 14:23:24 -07:00
Arun Kulshreshtha
ce5b9382c8 edenapi: add tree fetching
Summary: This diff adds an `hg debuggettrees` command that downloads trees from the API server and stores them in a datapack.

Reviewed By: xavierd

Differential Revision: D15301607

fbshipit-source-id: 7820d82d7d021c420e911a6a2e9bfce62b69fa2e
2019-05-20 11:52:59 -07:00
Mark Thomas
157325e38d commitcloud: limit the number of backup bookmarks the client sends
Reviewed By: mitrandir77

Differential Revision: D15373957

fbshipit-source-id: a197a39fc5b423f57e07ab92aa6544f62439d9d3
2019-05-20 06:19:49 -07:00
Mark Thomas
a2db36c434 commitcloud: log background backup command and start time
Summary:
Improve logging of background backup commands by including the command that was
run and the time it was started in the background backup logs.

Reviewed By: mitrandir77

Differential Revision: D15334879

fbshipit-source-id: 932e91a43033c5cb06c79ede7b5224da2e34eb7d
2019-05-20 06:19:49 -07:00
Mark Thomas
7f08a38705 commitcloud: pull heads in small groups
Summary:
When pulling heads from commit cloud during sync, pull them in small groups
of heads from around the same time, to prevent overloading the server when
pulling a large number of heads.

Reviewed By: mitrandir77

Differential Revision: D15317184

fbshipit-source-id: 5e69eb970b18292a4f5d643b25fac80c90c5d537
2019-05-20 06:19:49 -07:00
Mark Thomas
3d5a86db59 commitcloud: refactor remote path handling
Summary:
Lift determination of the correct remote path to connect to up to the top-level
command.  This prevents the need to pass around the command-line `**opts` in
all of the commit cloud functions.

Differential Revision: D15295811

fbshipit-source-id: 0e14c1643bad96022c7a01126b447b2a6fcabaed
2019-05-20 06:19:48 -07:00
Mark Thomas
7359c3df5d commitcloud: refactor sync processing
Summary:
Refactor how commit cloud sync works.

Sync is simplified by delegating backup processing to the existing backup code.
This happens first, which means the user's work is backed up earlier, and the
sync processing can assume that all backed up commits are available in the
cloud storage.

Sync no longer attempts to handle the case where cloud storage has changed.
Instead, backup processing should ensure that all local commits are backed up
to the current cloud storage.

If a commit can't be backed up, then treat this as a normal failure to
sync and ignore that commit for this sync attempt.  If a commit can't be
downloaded from the server then the sync fails.

Reviewed By: mitrandir77

Differential Revision: D15295499

fbshipit-source-id: d371c5bf0daedbbe42e8c7d4a0c3d1a40c21a36f
2019-05-20 06:19:48 -07:00
Mark Thomas
5de98a79fb commitcloud: refactor commitcloudutil into separate modules
Summary:
Move token location into the `token` module.

Move subscription management into the `subscription` module.

Move obsmarker management into the `obsmarkers` module.

Move everything else to a `util` module which can be disambiguated at import time.

Differential Revision: D15282859

fbshipit-source-id: 7f20c449fd79ffc33b069236a05fc73fac0e7d63
2019-05-20 06:19:48 -07:00
Mark Thomas
4d832ec6b1 commitcloud: rename commitcloudcommands to commands
Summary:
The name is too long.  We can disambiguate with `edenscm.mercurial.commands` at
import time if required.

Differential Revision: D15282860

fbshipit-source-id: e55357a121b583d9fd659f27dd5e2adc8a3d4d2f
2019-05-20 06:19:47 -07:00
Mark Thomas
7188ff5a82 commitcloud: refactor errors into the error module
Differential Revision: D15282858

fbshipit-source-id: b832b593588290cf94d1826ea20af7ce8d410468
2019-05-20 06:19:47 -07:00
Mark Thomas
4f3b9594b9 commitcloud: refactor backuplock and sync progress into the backuplock module
Differential Revision: D15282857

fbshipit-source-id: 666a8cab25ef1a837dd4340f118e9e88b2b109a2
2019-05-20 06:19:47 -07:00