Commit Graph

43765 Commits

Author SHA1 Message Date
Jun Wu
abf764ebce check-code: complain about Python underscore variable names
Summary:
Previously only function names are checked. Let's extend the check to
variable names.

Existing names breaking the rule are whitelisted.

Reviewed By: DurhamG

Differential Revision: D8744130

fbshipit-source-id: ca52d938305ccc3b2e1ea59e4e8f9c0dadff5970
2018-07-06 09:36:36 -07:00
Stanislau Hlebik
4f70dea422 prefer 'infinitepush' path instead of 'default'
Reviewed By: markbt

Differential Revision: D8734958

fbshipit-source-id: 7ed7910befdbd7081af645c0bd89927a9f0c0ce4
2018-07-06 08:12:28 -07:00
Liubov Dmitrieva
b159ed37b8 commitcloud: advertise Cloud Sync when user uses short hashes and also updates to own commit
Summary:
Currently many users use hg up to move own commits between the repos because unaware about cloud sync.
The hint will be shown on ambiguous prefix only, so it will not distract anyone.

Reviewed By: markbt

Differential Revision: D8732276

fbshipit-source-id: ae8fa10b28873134da013bc56ff9ebc33e9ed303
2018-07-06 07:05:47 -07:00
Durham Goode
28e570113e lib: remove cbincode from cargo workspace
Summary: This doesn't exist.

Reviewed By: quark-zju

Differential Revision: D8743699

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

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

Reviewed By: phillco

Differential Revision: D8696912

fbshipit-source-id: 95f07aa0c5eb1b63947b0f77f534957f4ab65364
2018-07-05 17:52:43 -07:00
Jun Wu
d0c1b6d014 cargo: add a workspace
Summary:
Make `lib` a cargo workspace so building in subprojects would share a
`target` directory and `cargo doc` will build documentation for all
subprojects.

Reviewed By: DurhamG

Differential Revision: D8741175

fbshipit-source-id: 512325bcb23d51e866e764bdc76dddb22c59ef05
2018-07-05 16:06:35 -07:00
Jun Wu
a745c5a8ae dirstate: use treestate fast path for selecting files
Summary:
This speeds up the matcher against several prefixes, helps commands
like `hg files subdir`.

Reviewed By: phillco

Differential Revision: D8721759

fbshipit-source-id: 8b1b35abc5bde7d3265c0874796808a39eb8810f
2018-07-05 15:36:10 -07:00
Jun Wu
d66878ce6f treestate: add a fast path getting files under a prefix
Summary:
This adds `repo.dirstate._map.keys(prefix=prefix)` API that returns tracked
files for a subdirectory quickly. If `prefix` ends up with `/`, it selects
the subdirectory and all files in it recursively. Otherwise it's an exact
match of a single file.

Reviewed By: phillco

Differential Revision: D8721758

fbshipit-source-id: 200def986e08fd3b9842b6c8012cb7f8350f0822
2018-07-05 15:36:10 -07:00
Durham Goode
a1b6fa3007 mutabledatapack: implement get_meta
Summary:
Implements the get_meta function of the DataStore trait. This caught a
bug in how we record lengths as well.

Reviewed By: quark-zju

Differential Revision: D8598661

fbshipit-source-id: 566dca1770d6666e4215fa1fd8f33babdede2f90
2018-07-05 14:53:19 -07:00
Durham Goode
b728154963 mutabledatapack: change error to contain String
Summary:
We want to be able to format error strings, so we can't return a static
str anymore.

Reviewed By: quark-zju

Differential Revision: D8598659

fbshipit-source-id: 44d7a73c06416efca51ca4d0f24a0c8911af8582
2018-07-05 14:53:19 -07:00
Durham Goode
587fc95964 mutabledatapack: begin implementing DataStore trait
Summary:
A mutabledatapack also needs to be readable as a normal store. Let's
start implementing the DataStore trait, starting with get_missing

Reviewed By: quark-zju

Differential Revision: D8598657

fbshipit-source-id: 1f8bc89fae2be73fe789bc0ef1cdd922222019a2
2018-07-05 14:53:18 -07:00
Durham Goode
875758fdbe datapack: implement getdeltachain
Summary: Implements the last of the DataStore api, getdeltachain.

Reviewed By: quark-zju

Differential Revision: D8557950

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

Reviewed By: quark-zju

Differential Revision: D8557949

fbshipit-source-id: 276005360bfa48e9154143dedce579a21129e976
2018-07-05 14:53:18 -07:00
Durham Goode
c6af00dbc9 datapack: implement getmetadata
Summary:
Introduces the DataEntry structure which is able to parse data entries
from pack files. Uses it to implement getmetadata

Reviewed By: quark-zju

Differential Revision: D8556610

fbshipit-source-id: c25427c3c247970a879ad7d409b821f3695b97d9
2018-07-05 14:53:17 -07:00
Durham Goode
79a9dd976f datapack: implement getmissing
Summary: Adds the DataStore trait and implements the getmissing function.

Reviewed By: quark-zju

Differential Revision: D8554391

fbshipit-source-id: 41c107c07de7d6945ca7370e264c6bc0bf154754
2018-07-05 14:53:17 -07:00
Durham Goode
ebc31e8daf datapack: add initial datapack structure
Summary:
This adds the initial struct and opener for a datapack. Future diffs
will add actual functionality and tests.

Reviewed By: quark-zju

Differential Revision: D8553436

fbshipit-source-id: 3b17f995632e859019205f242a4cce389ac77407
2018-07-05 14:53:17 -07:00
Durham Goode
029666cf27 mutabledatapack: write index to disk during serialization
Summary:
Actually write the index to disk when the mutabledatapack is
serializing.

Reviewed By: quark-zju

Differential Revision: D8552276

fbshipit-source-id: 354c7fdc3fe84b91d582f0e8cde8c6ae2494c559
2018-07-05 14:53:17 -07:00
Durham Goode
e68c0ec7e0 mutabledatapack: add logic for reading DataIndex
Summary: This adds the logic for reading a DataIndex from disk.

Reviewed By: quark-zju

Differential Revision: D8552278

fbshipit-source-id: 611ff09c27716b8d8ff7424c1a27287b9fc42b78
2018-07-05 14:53:16 -07:00
Durham Goode
d22f6ce58d mutabledatapack: add logic for writing DataIndex
Summary:
Soon we will be writing the index during pack file serialization, so
let's add the logic for serializing the index.

Reviewed By: quark-zju

Differential Revision: D8552277

fbshipit-source-id: 60829631eb060f62d266c16f6016f34080311f8e
2018-07-05 14:53:16 -07:00
Durham Goode
69a59f53d9 revisionstore: add Node::from_slice
Summary: A simple helper method for producing Node's from slices in a safe way.

Reviewed By: quark-zju

Differential Revision: D8547679

fbshipit-source-id: 85ae8fcd7749c662b1459af1d84ccf9695dd5f0b
2018-07-05 14:53:16 -07:00
Durham Goode
1c3767bc11 mutabledatapack: implement data index header serialization
Summary:
We're beginning to implement the DataPack index file logic. Let's start
with header serialization/deserialization.

Reviewed By: quark-zju

Differential Revision: D8319727

fbshipit-source-id: 079aab06ececb1c5159aec2da3243268eea0cb61
2018-07-05 14:53:15 -07:00
Durham Goode
12e0e5bf16 mutabledatapack: build inmemory index as revisions are added
Summary:
Let's build an inmemory hash table of the revisions that were added. A
future diff will serialize this index into a dataidx file.

Reviewed By: quark-zju

Differential Revision: D8309730

fbshipit-source-id: 9efc7f0f34129a63c52309b4d70179f2c10840b3
2018-07-05 14:53:15 -07:00
Durham Goode
763d1e4bef datapack: implement a fanout table
Summary:
Implements a fanout table trait that history pack and data pack will
use. It basically consists of logic to build and read a quick lookup table that
uses the first few bytes of a key to determine the bounding range of a binary
search.

Reviewed By: quark-zju

Differential Revision: D8309729

fbshipit-source-id: 71e398277dc8ae041447035f044e5d47ca41cf7e
2018-07-05 14:53:15 -07:00
Durham Goode
4588cc18c8 mutabledatapack: write version number header
Summary:
The mutabledatapack format has a one byte header containing the version
number.

Reviewed By: quark-zju

Differential Revision: D8305653

fbshipit-source-id: c4a96dc48e64acd2c5849034e5d90b87363fbc8d
2018-07-05 14:53:15 -07:00
Durham Goode
99a11bbb24 mutabledatapack: use hash of contents as name
Summary:
Implements the logic that builds a hash of the contents of the pack
file and uses it as the name.

Reviewed By: quark-zju

Differential Revision: D8305654

fbshipit-source-id: d1270e7519a7718aa5427f3be5cdc0cd0dee2fe2
2018-07-05 14:53:14 -07:00
Durham Goode
3f467bd21f mutabledatapack: implement add()
Summary:
This is the start of a rust mutable datapack implementation. The first
diff adds a simple add function. Later diffs will add the logic that builds the
index, serializes the index, and computes the final hash name.

Reviewed By: quark-zju

Differential Revision: D8304036

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

Reviewed By: quark-zju

Differential Revision: D8303603

fbshipit-source-id: 7e7a7aa218c05179b205abf8b151b1488be674b3
2018-07-05 14:53:14 -07:00
Matt Glazar
9b7a4d32a1 templater: allow non-ASCII fillchar in pad()
Summary:
Hg's `pad()` template function can only fill with a single character. To assert this, Hg checks the length of the fill string. Because the fill string is a Python 2 `str`, Hg rejects UTF-8 `'☃'` (`'\xe2\x98\x83'`) because its length is 3.

Instead of checking the length of the fill string, check the width of the fill string while taking encoding into account. This lets us use ☃ as a pad fill character.

For ASCII fill strings in `pad()`, this diff should not change behaviour.

Reviewed By: phillco

Differential Revision: D8730727

fbshipit-source-id: ad015aa4cae274160bc2726e0cb5e570e6edcc1e
2018-07-05 14:20:44 -07:00
Liubov Dmitrieva
8eba8372c3 commitcloud: cloud sync always wait for the background process to complete
Summary: before the waiting provide all the information to the user

Reviewed By: markbt

Differential Revision: D8734860

fbshipit-source-id: 9c0203b0879091d1d367c2ded9eccd8db4ee1bb9
2018-07-05 11:35:16 -07:00
Jun Wu
e4f29da588 hardlink: whitelist apfs
Summary: `hg debugfs` can report `apfs` correctly on latest mac. So let's add it to whitelist.

Reviewed By: ikostia

Differential Revision: D8725764

fbshipit-source-id: a9eb0db9d1f75cdd64c28b5c2f41451955758e18
2018-07-05 10:06:41 -07:00
Mark Thomas
e96dc290b9 tests: relax output for rename commit in treeonly-copyamend test
Summary:
The output of the rename commit can vary depending on how many files hg needs
to download as part of the rename.  This makes this test flaky when run with
watchman in the stress runs.

We don't actually care about the commit output here, so just match anything.

Reviewed By: mitrandir77

Differential Revision: D8731713

fbshipit-source-id: c2eded9115d2348c11fcb79eb425b923d073eddb
2018-07-05 09:50:59 -07:00
Phil Cohen
b32405f449 rebase: replace opts['noconflict;'] with opts.get('noconflict')
Summary: simpkins found a user getting a KeyError with the former.

Reviewed By: simpkins

Differential Revision: D8730525

fbshipit-source-id: 40d80f17e0ab8b2905fc53377e501546c21feaae
2018-07-03 17:49:44 -07:00
Mark Thomas
2ca405cbe0 remotefilelog: add config option to disable descendantrev fastpath
Summary:
The fastpath for adjusting linknodes using the fact that a filenode ctx was
created from a descendant rev can sometimes cause lots of treefetches.  Add an
option to disable it.

Reviewed By: mitrandir77

Differential Revision: D8691202

fbshipit-source-id: f196565929a2cf9b850c1c7c35f3ba6fa90f9031
2018-07-03 12:55:46 -07:00
Mark Thomas
af37374ca6 remotefilelog, treemanifest: add test demonstrating excessive gettreepacks on amend
Summary:
When amending a commit containing a file rename for a file with a long history
where the original content was usually on a separate branch, we end up in
`remotefilelogctx._adjustlinknode` for every commit the file was modified in.
Each of these looks up the manifest for the file, which causes a tree fetch.

Reviewed By: quark-zju

Differential Revision: D8691179

fbshipit-source-id: 088a6b402a79d37790ce7ac4481a39c657f690ee
2018-07-03 12:55:44 -07:00
Phil Cohen
0cc316cdc4 tests: run check-code.py in parallel via xargs (2x-4x speedup)
Summary:
This cuts the total time for this test from:

Laptop: 24s -> 12.4s
Devserver: 23s -> 5.8s

Reviewed By: quark-zju

Differential Revision: D8721177

fbshipit-source-id: f2922093a72c29f05d08967a77d83fbc65c0ed14
2018-07-03 11:36:17 -07:00
Jun Wu
c7e304d4e1 dirstate: fix symlink handling about unknown files
Summary:
Fix an issue where pathaudit failed (see [1] for what pathaudit does) files
showing up in "hg status" with fsmonitor enabled.

This is a problem with all dirstate implementation. Treestate makes it
easier exposed, as it merges "notefiles" with "nonnormalset", instead of
replacing an exisiting "notefiles" set.

[1]: https://www.mercurial-scm.org/repo/hg/rev/2cbd27f4f3c4

Reviewed By: DurhamG

Differential Revision: D8721020

fbshipit-source-id: 7c6c8c2f202c0da4c3eeee3c9b1ce10bf7970dd8
2018-07-03 05:50:52 -07:00
Jun Wu
a397871bd0 dirstate: add a test showing a symlink problem
Summary:
Files with one of its directory being a symlink should be considered as
outside the repo. The test demonstrates that with fsmonitor, all dirstate
implementations have problems showing auditfail [1] files.

[1]: https://www.mercurial-scm.org/repo/hg/rev/2cbd27f4f3c4

Reviewed By: DurhamG

Differential Revision: D8721021

fbshipit-source-id: fcb9808b637993c4d0c173d771fd7220afb52d83
2018-07-03 05:50:52 -07:00
Phil Cohen
cd0765f073 tests: make check-code.py output in a sortable way, and sort it
Summary:
Print the output from check-code.py in a way amenable to sorting (mostly, print each offense on one line instead of several)

The next diff will explain why.

Reviewed By: quark-zju

Differential Revision: D8721178

fbshipit-source-id: d814f94c151c6251f827ed6fe099e170e0b5353a
2018-07-02 23:50:57 -07:00
Phil Cohen
b879f0f5b3 tests: fix legitimate test-check-code.t failures
Summary: Mostly os.getcwd() or os.environ issues.

Reviewed By: DurhamG, quark-zju

Differential Revision: D8721169

fbshipit-source-id: 6615382775ce29dff814d830841f0c7eb4cad901
2018-07-02 23:50:56 -07:00
Phil Cohen
1064b3d79c tests: remove check-code complaint about grep's context flags
Summary:
It blames to here: https://www.mercurial-scm.org/repo/hg-committed/rev/0c09afdf5704

I'm pretty sure we don't care about Solaris :)

Reviewed By: DurhamG

Differential Revision: D8721170

fbshipit-source-id: 0c500ccb28828862136f6fcc44181477f5a21eee
2018-07-02 19:21:01 -07:00
Phil Cohen
b5f65c2cff tests: move "no new files in root" check to its own file
Summary:
This takes about 4.5s on my laptop. By moving it to its own file, we can run it in parallel and save from the total check-code time.

Laptop: 31.74s -> 25.53s
Devserver: 24.5s -> 22.21s

Reviewed By: quark-zju

Differential Revision: D8721156

fbshipit-source-id: 6d4d2c86517239f1762a413bc5d3dfefe184eaca
2018-07-02 19:21:01 -07:00
Phil Cohen
b59890687a overlayworkingcontext: properly handle copy-on-clean context
Summary:
This is a more minimal fix compared to D8676355, to handle extra calls to `markcopied` from `copies.duplicatecopies`.

Let's just make overlayworkingcontext properly support receiving copy information on (non-deleted) files, which it should do anyway.

This leaves the incorrect non-IMM behavior, but since it just involves incorrectly creating an empty commit, that's probably fine.

Reviewed By: quark-zju

Differential Revision: D8697039

fbshipit-source-id: 0c204c47e6b5031eb20928c1844be3aebcb96edb
2018-07-02 15:50:18 -07:00
Jun Wu
f526d1a4ed treestate: update clock when watchman returns is_fresh_instance=True
Summary:
When watchman returns is_fresh_instance=True, it means the old clock value
cannot help watchman to do less work. Therefore the clock value needs to be
updated to make the next status call faster.

Reviewed By: phillco

Differential Revision: D8714863

fbshipit-source-id: 1eb2bf876b21bd0f17134a3b93b06b759746fd4c
2018-07-02 13:35:42 -07:00
Phil Cohen
47c81d5606 tests: fix the build (v2)
Summary: eyes

Reviewed By: kulshrax

Differential Revision: D8716471

fbshipit-source-id: 7b2b29cc845cc03af2387190482ce356337ff451
2018-07-02 13:05:35 -07:00
Phil Cohen
df568f4e22 tests: fix the build
Summary: eyes

Reviewed By: singhsrb

Differential Revision: D8716279

fbshipit-source-id: aa214a554455513d5f121560b0c69278e5f8e982
2018-07-02 12:35:48 -07:00
Phil Cohen
05ac4a77f5 tests: modernize test-fb-hgext-fbamend-restack.t
Summary:
This test is 990+ lines and takes 1+ minutes to run on my laptop.

- Use `newrepo` instead of a custom reset function
- Use `enable` and `setconfig`
- Split out the auto-restack part into its own function

Reviewed By: quark-zju

Differential Revision: D8706316

fbshipit-source-id: fb48208e3225b376a0e4d06021ef82e8c4255d08
2018-07-02 11:36:46 -07:00
Phil Cohen
0be0108bed rebase: replace --tool :abort with rebase --noconflict
Summary:
I was thinking about what we need to enable automatic restacking on non-conflicting amends (see the next diff), but I realized the --tool :abort tool I implemented in D8493065 doesn't really work well for this for three reasons:

- It can't handle the case of mergedriver having to run, which is the other reason we'd have to break out of IMM.
- It hard-codes the merge tool. The user might want to specify another tool that doesn't recreate conflicts or solves them differently.
- It'd force callers to detect if IMM will be used (to prevent an on-disk merge hapening by mistake). A flag can implement this much more easily.
- As I learned when writing D8493065, it would require hardcoded logic in every command anyway to support the non-IMM case. (Just raising an abort will leave most commands with an interrupted state.)

So, I think we should replace it with this flag to make auto-restacking work very reliably (we could add it to graft, too). If there was some big demand for --tool :abort we could always add it back in the future.

Reviewed By: quark-zju

Differential Revision: D8701897

fbshipit-source-id: ea3b92d0a224a8ce43edb120b53bec241d92a61d
2018-07-02 11:36:46 -07:00
Phil Cohen
46358b47c2 merge: add the type of conflict (file or driver) and path(s) to InMemoryMergeConflictsError
Summary: This will let us print more helpful/precise error messages.

Reviewed By: singhsrb

Differential Revision: D8699551

fbshipit-source-id: 060058eff925d94ffa8e6b4432c4e51bd93b2945
2018-07-02 11:36:46 -07:00
Phil Cohen
200ae35c45 rebase: remove experimental.inmemorydisallowedpaths
Summary: This config was needed when IMM restarts were long and painful, but now that they're not, this clunky and inaccurate hueristic can be removed, which simplifies the control flow a bit.

Reviewed By: singhsrb

Differential Revision: D8700868

fbshipit-source-id: 0aeac26e5c41f7f0260ee826f05a8f9047dbad5a
2018-07-02 11:36:44 -07:00
Phil Cohen
7350e2a60c rebase: remove rebase.experimental.nomergedriver
Summary: This configuration is set everywhere, and the spectre of stateful preprocess() functions was a Facebook-only abomination that hopefully won't reoccur. Delete this config.

Reviewed By: quark-zju

Differential Revision: D8700125

fbshipit-source-id: b5ef163f988b7bb79310275d54afea3eab2c23a2
2018-07-02 10:35:25 -07:00