Commit Graph

356 Commits

Author SHA1 Message Date
Kostia Balytskyi
f2b8b4571f hgpython: rename hgenv to be buildenv
Summary: As per quark-zju's request in the earlier diff.

Reviewed By: quark-zju

Differential Revision: D10173168

fbshipit-source-id: 20ab1fbc597b8329bbfec5dabd501d202571bdec
2018-10-12 14:55:09 -07:00
Kostia Balytskyi
0946205e68 hgmain/hgpython: add copyright headers
Reviewed By: farnz

Differential Revision: D10145635

fbshipit-source-id: 0d88c18a44a86a8eb19f40ddba0c13f9570f3a76
2018-10-12 14:55:09 -07:00
Kostia Balytskyi
682e4bed1a hgpython: extract hgpython from hgmain
Summary:
Following the conversation with quark-zju, this in future will help us conditionally dynamically load
the `hgpython` `.dll`/`.so` only if we need it.

Reviewed By: quark-zju

Differential Revision: D10084949

fbshipit-source-id: c20ef014ad9922913ee36d1ec28b0555b64f7d1f
2018-10-12 14:55:09 -07:00
Saurabh Singh
1ffa44eae3 zstd-sys: update the package version
Summary: The old version cannot be found and its making the build fail.

Reviewed By: markbt

Differential Revision: D10255834

fbshipit-source-id: d14572885423622ecfe3730bbda07ae1bee7363a
2018-10-09 07:26:31 -07:00
Lukas Piatkowski
d01ebe2166 rust-crates-io: add crossbeam to tp2
Reviewed By: ikostia

Differential Revision: D10244968

fbshipit-source-id: 8d06bb64b6a1227ae589caf0588a1f3657603ce9
2018-10-08 21:32:00 -07:00
Saurabh Singh
2def7c19e2 packaging: back out D10213071 to fix continuous build
Summary: D10213071 broke the continuous build. Therefore, backing it out.

Reviewed By: ikostia

Differential Revision: D10238353

fbshipit-source-id: 0b387f6dd802614112cdc969944cbe4c40582b3d
2018-10-08 08:54:08 -07:00
Jun Wu
1cde64ae27 rustlib: move Cargo.toml to top-level
Summary:
This makes all crates' cache shared and unifies Cargo.lock, which
is used by the next diff.

Reviewed By: ikostia

Differential Revision: D10213071

fbshipit-source-id: 48a979c41423a8e8a9795ff102646cce13c39ff4
2018-10-05 16:43:47 -07:00
Jun Wu
100c360e54 indexedlog: mark block as non-code
Summary:
The code block is not a valid Rust program. Mark it as "plain".
This fixes `cargo doc`.

Reviewed By: markbt

Differential Revision: D10137806

fbshipit-source-id: 1197d3a2ebc1450a0738686fa6cfa7c7b79dcb0d
2018-10-03 18:19:27 -07:00
Jun Wu
7752e9e81f rustlib: move Node to a separate "types" crate
Summary:
The `Node` type will be used in multiple places. Let's move it to a standalone
crate so new libraries depending on it won't need to pull in all of
revisionstore's dependencies.

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

Reviewed By: markbt

Differential Revision: D10132047

fbshipit-source-id: 5d05c5e0ac06a2d58556c4db11775503f9495626
2018-10-03 18:19:27 -07:00
Jun Wu
a4434458e6 configparser: fix "%include /foo" on Windows
Summary:
Before this patch, `%include` support on Windows is:

  # Works fine - UNC path: `\\?\c:\1.rc`.
  %include c:\1.rc

  # Works fine - UNC path: `\\?\c:\1.rc`.
  %include \1.rc

  # Works fine - UNC path: `\\?\c:\1.rc`.
  %include c:/1.rc

  # Bad - UNC path: `\\?\c:/1.rc`.
  %include /1.rc

People expect `%include /1.rc` to work on Windows. Fix it by normalizing
the path in `%include` handling.

More context:
Normally, `/` and `\` can be used interchangeably on Windows. But it's not true
for UNC paths. The config parser uses `std::fs::canonicalize` to normalize
paths.  The following Python script demonstrates the difference:

  >>> import os
  >>> open('c:\\1.rc').close()
  >>> os.path.exists('\\\\?\\c:\\1.rc')
  True
  >>> os.path.exists('\\\\?\\c:/1.rc')
  False

Reviewed By: phillco

Differential Revision: D10036882

fbshipit-source-id: fd85e0bc86d1e5776701077751ac875e71d60568
2018-09-25 13:21:43 -07:00
Jun Wu
fe900beb40 profiling: move $HGPROF handling to configparser
Summary:
It's cleaner for the config parser to take care of environment variable
handling.

A side effect of this change is, `$HGPROF` only affects `profiling.type`,
not `profiling:foo.type`, which is more desirable since we don't want
`profiling:foo.type` to be overridden by `$HGPROF`.

Reviewed By: markbt

Differential Revision: D9828547

fbshipit-source-id: 27be3683beee60a4eee6040ca1b4160dc1a89f73
2018-09-21 14:37:23 -07:00
Harvey Hunt
70a0c74d3b Implement a bookmark store for managing mercurial bookmarks
Summary:
Create a storage object that can be used to load bookmarks from a
mercurial file, modify and query the bookmarks in memory and then write back
to a mercurial bookmark file.

Reviewed By: quark-zju

Differential Revision: D9768564

fbshipit-source-id: ed469d0e588ae2200d614bf62a5a0b577e7c6f74
2018-09-20 05:05:08 -07:00
Harvey Hunt
c507d4e818 Implement Display trait for revisionstore Node
Summary:
Copy functions from Mononoke to implement the Display trait
for a Node.

Reviewed By: quark-zju

Differential Revision: D9768566

fbshipit-source-id: 6961026a9e4cdaf4a0f2592dc9284abebadb0aa3
2018-09-20 05:05:08 -07:00
Jun Wu
b212efa921 configparser: preserve leading new-lines
Summary:
Preserve leading (but not tailing) new lines so the config (where `_` denotes a
space):

  x_=__
  __Foo
  __

is parsed as `"\nFoo"`.

This is useful in template configs.

Reviewed By: ryanmce

Differential Revision: D9929764

fbshipit-source-id: e30659df94937c7c2121627f42ea425191003fb1
2018-09-19 11:54:22 -07:00
Jun Wu
acc7039436 configparser: permit spaces in more cases
Summary:
Be more permissive about spaces. Namely:
- Spaces after a section name like `[foo]    ` are allowed.
- Spaces in config names are allowed.
- Spaces at trailing lines are ignored and no longer insert an `\n` to the previous config.

This makes it closer to the older config parser behavior. But it's still
different on some cases, like `[foo]]`, `[foo] # bar`, `[foo]]` still do not
parse.

Benchmark shows no obvious (within 10%) slowdown. So this is probably fine.

Reviewed By: strager

Differential Revision: D9620253

fbshipit-source-id: 8489ef8e83606d0557db56e8da0a017d55ff1514
2018-09-12 12:05:32 -07:00
Liubov Dmitrieva
32cccf30f2 commit cloud sync: fast path for pull
Summary:
Maybe useful as a backup for the regular path and also for syncing speed up.

Scm daemon know new and removed heads, so if for example 1 new and 1 removed head - it is the most probably just an amend, so scm daemon can try the fast path first depends on information in the notification, and if it fails try the slow path.

So users can have better experience before Mononoke, it is much much faster and scm daemon makes 2 attempts anyway!

Reviewed By: quark-zju

Differential Revision: D9309856

fbshipit-source-id: d59f498160a45fab11760b5c1397b48470feb7f8
2018-09-10 15:05:25 -07:00
Jun Wu
43bda98976 configparser: add a benchmark parsing large files
Summary: This would provide information about performance changes.

Reviewed By: singhsrb

Differential Revision: D9620252

fbshipit-source-id: 51d243b50b349c63e552bd1c43db17497025f73a
2018-09-07 16:56:38 -07:00
Kostia Balytskyi
59e00ccf47 hg: add some convenient panicking conversion to encoding
Summary:
Local bytes `&[u8]` or `Vec<u8>` is frequently wrapped into a `CString`,
because `CString` includes a trailing 0. Let's add a helper for that.

Reviewed By: quark-zju

Differential Revision: D9482435

fbshipit-source-id: 096ba725d83acc9c5fc1fe836dce509fe36e49e9
2018-08-30 04:42:11 -07:00
Kostia Balytskyi
8693c2d67b hg: improve encoding::path_to_local_bytes on Windows
Summary:
This improvement avoids an extra conversion to String (which can fail if
something cannot be encoded as UTF8).

Reviewed By: quark-zju

Differential Revision: D9447823

fbshipit-source-id: fa13ff9b833cc4edf9f5dc518b3f8712518c97fd
2018-08-30 02:51:13 -07:00
Jun Wu
d38749a9fd configparser: expand environment variables in HGRCPATH
Summary:
liubov-dmitrieva encountered an issue where her home hgrc is not loaded. That's because
environment variables in HGRCPATH are not expanded. Fix it by calling
`expand_path` on the paths.

Reviewed By: phillco

Differential Revision: D9499239

fbshipit-source-id: cd4b7a26fd12f1c3148a21dbb5584bbeb3885286
2018-08-28 19:51:12 -07:00
Kostia Balytskyi
9157270708 hg: fix the system config locations for Windows in Rust configparser
Summary:
Orignally both `mercurial.ini` and `hgrc.d` were looked up in the same location
as main Mercurial executable, not in the `datadir`. See from `scmwindows.py`:
```
    filename = util.executablepath()
    # Use mercurial.ini found in directory with hg.exe
    progrc = os.path.join(os.path.dirname(filename), "mercurial.ini")
    rcpath.append(progrc)
    # Use hgrc.d found in directory with hg.exe
    progrcd = os.path.join(os.path.dirname(filename), "hgrc.d")

```

Reviewed By: quark-zju

Differential Revision: D9540052

fbshipit-source-id: d5921193dd14fcb46cf428aaa77d26a58aef7868
2018-08-28 11:27:50 -07:00
Jun Wu
8356dbd506 configparser: fix windows EOL handling
Summary:
Without this patch, all hg commands will fail with our current config:

  hg: parse error: <filename>
   --> 6:5
    |
  6 |     commandexception
    |     ^---
    |
    = expected new_line

The config is:

  [blackbox]
  track = command
      commandexception
      ...

Because "\r\n" was treated as the same as double "\n"s.

Reviewed By: ryanmce

Differential Revision: D9494909

fbshipit-source-id: 64ef173c69f3cf61d4e71116c581dbca72fb2c4b
2018-08-24 00:05:34 -07:00
Kostia Balytskyi
819d195bc8 hg: add some platform-specific tests for encoding crate
Summary:
This just adds some more tests that in case of Windows try to execute the
string encoding APIs directly, while paying attention to the ANSI Code Page.

Reviewed By: quark-zju

Differential Revision: D9441406

fbshipit-source-id: c0873dca9fc8775839a62da60af46ff29e700634
2018-08-22 09:06:22 -07:00
Kostia Balytskyi
71baca5dfa hg: add osstring_to_local_bytes function to the encoding crate
Summary: Another convenience method that I plan to use in the `hgmain` later.

Reviewed By: quark-zju

Differential Revision: D9441426

fbshipit-source-id: 007e4932a344b9d1c8d4d654152bcca5c2362431
2018-08-22 09:06:22 -07:00
Kostia Balytskyi
1175b6b1c6 hg: extract platform-specific bits of encoding into separate files
Summary:
I think it's more readable to split the implementations into platform-specific
bits.

Reviewed By: quark-zju

Differential Revision: D9441424

fbshipit-source-id: 136d5a00aa4ed8cf4f0886bda0f77a40cba1f542
2018-08-22 09:06:21 -07:00
Kostia Balytskyi
fa882cf7da hg: make encoding create use ANSI code page, not OEM
Summary:
We almost never need an `OEM` code page: Windows API calls use ANSI-encoded
strings if they are `A` calls and Wide strings if they are `W` calls.

Reviewed By: quark-zju

Differential Revision: D9441425

fbshipit-source-id: 979697c349389ea4f7569be9949be3b636f6063c
2018-08-22 09:06:21 -07:00
Kostia Balytskyi
25a8ee686f hg: rename pathencoding into encoding
Summary:
In the later diffs I'll add some more functionality there, not strictly
related to encoding paths.

Reviewed By: quark-zju

Differential Revision: D9441427

fbshipit-source-id: 069ab30a24761038fa2c1a4f180bbc0699d38ef9
2018-08-22 09:06:20 -07:00
Puneet Kaushik
9b9126c79f Started Eden for Windows and integrated hg store with it.
Summary:
This diff is first in the series to make Eden work on Windows. It includes:

1. HG backing store and Object store, which provides the capability to talk to mercurial and fetch the file and folder contents on Windows.
2. Subprocess and Pipe definition for Windows.
3. The Visual studio solution and projects files to compile Eden and scm datapack.

Few Important points:

1. Most of the changes to existing code is done under a macro EDEN_WIN so that it doesn't impact on other platform.
2. Sqlite is used for caching the fetched contents. We are not using Rocksdb on Windows.
3. The main function only calls some test code and exit after printing the output.
4. The initializeMononoke code is disabled for Windows because it needs Proxygen to talk HTTP. Will enable this once I get Proxygen and other dependencies working.
5. HgImporter pass Windows handles to hg_import_helper as command line args. The code to convert these handles into fds is in a separate diff.

Reviewed By: wez

Differential Revision: D8653992

fbshipit-source-id: 52a3c3750425fb92c2a7158c2c214a9372661e13
2018-08-21 17:51:26 -07:00
Durham Goode
a0d0a75c44 revisionstore: add unit tests for ancestor logic
Summary:
This was meant to be in a prior diff but was forgotten. This also
exposes an issue where we aren't producing ancestors in topological order.

Reviewed By: quark-zju

Differential Revision: D9380009

fbshipit-source-id: 6a49f0f31c3e107353f9192ca15cda0b1b9c3693
2018-08-17 12:49:57 -07:00
Jun Wu
284c2f5ccb configparser: move some features to hg module
Summary:
The config remapping, whitelisting features are hg specific. And is done by
using `append_filter` API exposed by `config.rs`. They are more of "extended
features". So move them to `hg.rs`.

Reviewed By: DurhamG

Differential Revision: D9323789

fbshipit-source-id: 89bc4416ee7276c2d1d4db8eba6404747cbb4ec4
2018-08-17 12:21:31 -07:00
Jun Wu
36c4ce233d config: be compatible with Windows-style environment variables
Summary:
On Windows `%include` can have paths containing environment variables like
`%PROGRAMDATA%`. We already ship that kind of config files to users therefore
let's add support for that.

The change assumes `%` is not used as part of a normal path, which is probably
good enough for practical uses. If `%` does need to be legally used in a
filename, we can add escaping support later.

Reviewed By: DurhamG

Differential Revision: D9283303

fbshipit-source-id: bcc80307fe19dfc40aea88b6a0a5f69681e835fc
2018-08-17 11:50:37 -07:00
Durham Goode
6dfc0351f4 revisionstore: don't allow loading non-v1 historypacks
Summary:
v0 history packs require more complicated and slow logic for looking up
a node.  Instead of complicating our rust implementation, let's just not support
v0.

Reviewed By: quark-zju

Differential Revision: D9373395

fbshipit-source-id: 6d28a3684966b55a617619e3cae765b2944919a0
2018-08-17 09:39:36 -07:00
Durham Goode
58b15fd23c revisionstore: make get_ancestors return an error if it can't find the key
Summary:
When calling get_ancestors with 'partial' enabled, we want to return a
key error if the first key can't be found, but not if later keys can't be found.

Reviewed By: singhsrb

Differential Revision: D9367477

fbshipit-source-id: 0e9ad7ea82f83db7326392accab96bd31318f28e
2018-08-17 09:39:36 -07:00
Durham Goode
6cd8838c3c revisionstore: change HistoryIndex to accept references to filenames
Summary:
Previously HistoryIndex.write() accepted a vector and a hashmap that
contained Box<[u8]>. This diff changes it to be &Box<[u8]>, which allows us to
avoid a ton of allocations.

Reviewed By: quark-zju

Differential Revision: D9350962

fbshipit-source-id: 3f900c551584e3431202f3a30afd61aa10fbb78c
2018-08-16 12:34:52 -07:00
Durham Goode
94c6ad00ef revisionstore: remove into_boxed_slice usage
Summary:
I learned that Box::from() can be used to copy a slice into a box, so
let's replace my previous to_vec().into_boxed_slice() with this.

Reviewed By: quark-zju

Differential Revision: D9350961

fbshipit-source-id: 94053b82cd64923dfabc9acf3a9dab6daca20cf3
2018-08-16 12:34:52 -07:00
Durham Goode
37c830f836 fanouttable: make locations an Option
Summary:
Only the dataindex needs the actual locations, so let's make the
locations vector optional and only pass it from dataindex.

Based on feedback from an earlier code review.

Reviewed By: quark-zju

Differential Revision: D9350960

fbshipit-source-id: 54ec34e1bd891ae585b22d916664700ce5417353
2018-08-16 12:34:52 -07:00
Durham Goode
f71eb28587 revisionstore: fix build break on older Rust
Summary: Apparently older rust needs a & on these match statements.

Reviewed By: phillco, quark-zju

Differential Revision: D9363026

fbshipit-source-id: fa802464d01b4074546076888e6d5c92155ddf4e
2018-08-16 11:05:25 -07:00
Durham Goode
5283a0ca54 revisionstore: add SliceExt for receiving Result<> from slice reads
Summary:
Rust doesn't provide a convienent way to do `slice[range]?`, so let's
introduce an extension trait for allowing slice range reads and getting a Result
back.

Reviewed By: markbt

Differential Revision: D9276216

fbshipit-source-id: 9a8cea8ffc062c4a2dd432dd4de7fdd4ccabf8d3
2018-08-15 15:24:40 -07:00
Durham Goode
70c243ffcb pyrevisionstore: implement Repackable for HistoryPack
Summary:
Before we can finish the python bindings for HistoryPack, we need to
implement the Repackable trait.

Reviewed By: markbt

Differential Revision: D9273264

fbshipit-source-id: ed181d73c497a84fed5e0c85fad1d7d73ec52e4e
2018-08-15 15:24:40 -07:00
Durham Goode
489fc12598 historypack: implement get_ancestors
Summary: Implements the last HistoryStore api.

Reviewed By: markbt

Differential Revision: D9231388

fbshipit-source-id: 061df3f89c4abadad1e1abcf002bb38d9069ef6e
2018-08-15 15:24:39 -07:00
Durham Goode
4ac8d1cf0c historystore: add traversal options for ancestor traversals
Summary:
Previously ancestor traversals would return an error if they
encountered a node that couldn't be resolved. In some cases we want to support
partial ancestor resolutions (like iterating over part of a history in one
store, while the rest in another store). Let's add an option that decides
whether a missing node is an error or not.

Reviewed By: markbt

Differential Revision: D9231397

fbshipit-source-id: ff3063acfb8da2d453f34221f1865f3123615b0c
2018-08-15 15:24:39 -07:00
Durham Goode
faa6b7a152 historypack: implement get_missing
Summary: Implements another piece of the HistoryStore API.

Reviewed By: markbt

Differential Revision: D9231396

fbshipit-source-id: b2949396eab999c46cf1a2c24fa7a329a5971682
2018-08-15 15:24:39 -07:00
Durham Goode
e41732f1e7 historypack: implement HistoryStore::get_node_info
Summary: Implements the first of our HistoryStore APIs.

Reviewed By: markbt

Differential Revision: D9231390

fbshipit-source-id: 72e43819b4f0ad6e0aa80c6793ac28d51c1435ef
2018-08-15 15:24:39 -07:00
Durham Goode
7a459efe56 historypack: initial HistoryPack boiler plate
Summary:
Now that MutableHistoryPack and HistoryIndex are implemented, we can
put the final HistoryPack code in place. Let's start by putting the boiler plate
definition down.

Reviewed By: markbt

Differential Revision: D9231387

fbshipit-source-id: d90f20603a7e08becda604eeda90d62ef4e88cbb
2018-08-15 15:24:39 -07:00
Durham Goode
a54880cf6a historypack: make mutablehistorypack write to disk
Summary:
Now that we have serializers for all the individual parts, let's make mutablehistorypack actually serialize.

This is still missing the bit where we topologically sort the nodes before writing them, so that will come later.

Reviewed By: markbt

Differential Revision: D9231401

fbshipit-source-id: 85703a44420bd9eee80fabe1fa4ffb0ebff3ecfd
2018-08-15 15:24:39 -07:00
Durham Goode
5e01141c7b historypack: implement HistoryEntry serialization logic
Summary:
In an upcoming diff we'll begin writing the actual history data pack
file. It is primarily composed of HistoryEntry's so let's implement and unit
test the serialization logic for them.

Reviewed By: markbt

Differential Revision: D9231391

fbshipit-source-id: 1b070ee5d15e06ea0c70a678dc6eb129e0ffaa20
2018-08-15 15:24:39 -07:00
Durham Goode
6158355747 historypack: add serialization logic for FileSectionHeaders
Summary:
In an upcoming diff we'll start writing the actual history pack data
file. The file section headers are part of that file, so let's implement the
serialization logic and unit test it.

Reviewed By: markbt

Differential Revision: D9231400

fbshipit-source-id: eb1494e3b8fe3419f77edcaab25f640b48f16e4b
2018-08-15 15:24:39 -07:00
Durham Goode
1d19243ea1 datapack: change ok_or to ok_or_else
Summary:
The old ok_or would allocate a string every time. Since this is an
error condition, let's use ok_or_else to only allocate the string if there's an
error.

Reviewed By: markbt

Differential Revision: D9231394

fbshipit-source-id: e4912bfd26925077fffb7c686a7c1c2f3cb36f7c
2018-08-15 15:24:39 -07:00
Durham Goode
297cfe7625 historyindex: add node entry lookup
Summary: Add an API for reading individual nodes from an index.

Reviewed By: markbt

Differential Revision: D9231398

fbshipit-source-id: 1d7c4b34b121cba62bc28eba2323807cfedbaf3b
2018-08-15 15:24:39 -07:00
Durham Goode
176881503f historyindex: add file entry lookup
Summary:
Now that historyindex can serialize, let's add logic to perform file
entry lookups. A later diff will allow node looks.

Reviewed By: markbt

Differential Revision: D9231392

fbshipit-source-id: 9ab8e29ce85c0f372a7a432318d6d903e6c44bcc
2018-08-15 15:24:38 -07:00