Commit Graph

47118 Commits

Author SHA1 Message Date
Stefan Filip
b5e80dba83 tests: update test-globalrevs to use assert
Summary:
test-check complains about the test using `raise Exception.`
For the purposes of the test, `assert` seems more appropriate.

Reviewed By: DurhamG

Differential Revision: D17724080

fbshipit-source-id: 2831a384c1e91012ee58bced47f026cd74995e86
2019-10-02 16:50:02 -07:00
Arun Kulshreshtha
7dd8231716 types: print parent hashes when content validation fails
Summary: When a downloaded manifest node fails to validate, investigating the issue generally requires the p1/p2 nodes (to manually compute the hash and compare it to the expected value). As such, let's print these out as part of the error message.

Reviewed By: xavierd

Differential Revision: D17724746

fbshipit-source-id: 0b1eb8d5344c0376a5895745dcdfb1092ad06321
2019-10-02 16:47:02 -07:00
Aleksei Kulikov
e635171709 snapshot: fix rebasestate show snapshot
Reviewed By: markbt

Differential Revision: D17666034

fbshipit-source-id: 67005c07c1c583b709310861c3ece38c4be825a3
2019-10-02 11:54:25 -07:00
Aleksei Kulikov
1a6762b57d snapshot: match files correctly during checkout, update tests
Summary: The previous matcher constructed wrong (with the extra `cwd` part) paths.

Reviewed By: markbt

Differential Revision: D17659134

fbshipit-source-id: 8556b8acda515ac68c2a72f2ede6408172d42575
2019-10-02 11:54:25 -07:00
Aleksei Kulikov
21837851bd commitcloud: sync snapshots on the client side
Summary:
Essentially, snapshots are being synced exactly like heads are.
A dedicated table in CC DB etc.

Reviewed By: markbt

Differential Revision: D17345491

fbshipit-source-id: a1e65c2a4815f437a11da68f9d46c27f046453a9
2019-10-02 11:54:24 -07:00
Durham Goode
e39abb8bf7 contrib: remove dependency on dirstate.walk
Summary:
This is the last use of dirstate.walk, aside from the actual status
function. This is necessary for an upcoming diff which deletes dirstate.walk
entirely.

Reviewed By: quark-zju

Differential Revision: D17170796

fbshipit-source-id: 9a81631d12f5f174b43a10e083bbbda2bd377854
2019-10-02 11:00:28 -07:00
Durham Goode
067db3fa78 match: fix tree.insert to mark short globs as unsure
Summary:
When inserting a glob into match._tree, it marks the tree as
'unsurerecursive' if the glob contains a complex component (i.e. a component
that contains "/"). If the glob was only one component, that check was not
executed against the component and therefore we could end up in a situation
where we didn't mark the tree as unsure. An example would be `'{*,{b,m}*/*}k'`,
which returned False for tree.visitdir("beans/black") when it should've returned
True.

Reviewed By: quark-zju

Differential Revision: D17118623

fbshipit-source-id: 50b6adbbecda13461c13c06a6e7d8523f8b29a2d
2019-10-02 11:00:27 -07:00
Durham Goode
8598048f01 match: fix patternmatcher.visitdir
Summary:
patternmatcher can be used for non-exact and non-prefix patterns, but
the current visitdir implementation will return False unless a prefix pattern or
exact patterns are provided. A future change makes dirstate.status more reliant
on correct matcher behavior, and this breaks tests.

The fix is to return True (meaning that the directory should be visited)
whenever the pattern is not an explicit list of files. Hopefully we can move
this to our rust matcher in the future which will be able to optimize this case
around globs and regular expressions.

Reviewed By: quark-zju

Differential Revision: D17116369

fbshipit-source-id: d65b08060143efc3f4bbde3198b0c505a8ff4ec7
2019-10-02 11:00:26 -07:00
Durham Goode
2975600221 addremove: remove use of dirstate.walk
Summary:
In a future diff we'll be restricting the dirstate interface. We'd like
to drop dirstate.walk, so let's remove it's use from `hg addremove`.

Reviewed By: quark-zju

Differential Revision: D17083282

fbshipit-source-id: 010483b24e1c23f8f8086bbc5f931095d94080de
2019-10-02 11:00:26 -07:00
Durham Goode
2bb8d905d4 context: remove use of dirstate.walk
Summary:
In a future diff we'll be restricting the dirstate interface. We'd like
to drop dirstate.walk, so let's remove it's use from commitablectx.walk.

Reviewed By: quark-zju

Differential Revision: D17082284

fbshipit-source-id: f6034281c10123c28c37ee93844ac7e05418973f
2019-10-02 11:00:25 -07:00
Durham Goode
7b4ce229db grep: remove use of dirstate.walk
Summary:
In a future diff we'll be restricting the dirstate interface. We'd like
to drop dirstate.walk, so let's remove it's use from `hg grep`

Reviewed By: quark-zju

Differential Revision: D17082286

fbshipit-source-id: ef7713db5288658d3fefc9ae038077570ed39bb4
2019-10-02 11:00:25 -07:00
Durham Goode
c10c1d74e4 add: remove usage of dirstate.walk
Summary:
In a future diff we'll be restricting the dirstate interface. We'd like
to drop dirstate.walk, so let's remove it's use from `hg add`.

Note, the old code was actually a bit buggy. It had `full=False` which meant the
walk might not return clean files, which meant we might not warn about the user
attempting to add clean files, depending on the dirstate implementation. The new
code avoids that bug.

Reviewed By: quark-zju

Differential Revision: D17082285

fbshipit-source-id: 946f4edc852d8c62667fb50820f4b0c1c8f229a9
2019-10-02 11:00:24 -07:00
Durham Goode
6db83db99e treedirstate: don't filter when importing to treedirstate
Summary:
In a future diff I change the implementation of status, which broke
some tests and exposed a bug in treedirstate. Basically, when importing into
treedirstate it filtered the nonnormal files to only the ones that were tracked,
which meant it didn't include removed files. The new status implementation is
more sensitive to the nonnormal set being correct, so this broke.

The fix is to just not filter stuff when importing it into treedirstate. Nothing
uses treedirstate anymore, so this is probably a no-op for users.

Reviewed By: quark-zju

Differential Revision: D17079446

fbshipit-source-id: 8a41a792933472a3d0cec7732c4f546067a9470c
2019-10-02 11:00:23 -07:00
Durham Goode
3af69afd48 match: remove explicitdir
Summary:
match.explicitdir is used for commands to know which command line
patterns were explicit directories. It's existence makes implementing different
working copies more complicated because the matcher stops becoming a simple file
and directory tester and starts to become a more complicated traversal.

To simplify the upcoming working copy refactor, let's drop this functionality.
The only two places it's used (checking if we're commiting something inside a
provided directory during commit, and purge) can be replaced with just checking
if the provided path is actually a directory on disk.

Reviewed By: quark-zju

Differential Revision: D16951181

fbshipit-source-id: c03c79724e17db25f0490ab5906ef1aacfdf1634
2019-10-02 11:00:23 -07:00
Durham Goode
0f3585ee6d dirstate: move lookup resolution into the dirstate
Summary:
Previously, dirstate.status() would produce a status result and a list
of files that it wasn't sure of. Then the workingctx class would inspect the
unsure files, update the status result, and update the dirstate. This was a
strange logic split, since the dirstate should really be responsible for all
status result computation.

In a future diff we will be moving the "what files are changed" computation
behind a new filesystem layer, so in this diff let's move this logic into the
dirstate so it can later be hidden behind the new layer.

This adds the repo object as a attribute on the dirstate, which introduces a
cyclic reference. I think this is fine because:
1. We already do this in many of our dirstate extensions
2. We use a weak reference
3. The dependency direction should probably be workingcopy -> repo anyway,
since repo should generally not have knowledge of the working copies, but the
working copies probably need knowledge of the repo (like to read tree contents
for status computation).

Reviewed By: quark-zju

Differential Revision: D16816274

fbshipit-source-id: ad4e83d489bbe94c131a844ae380a565d7018f89
2019-10-02 11:00:22 -07:00
Durham Goode
6b9cdf9f67 tests: convert test-globalrevs.t into -t.py test
Summary:
Converts the test-globalrevs.t test into the new format. Since the new
test format doesn't restart the process between invocations, we have to make the
globalrevs extension smarter about only executing its bits when the repository
in question actually has the extension enabled (instead of depending on the
process only living for the duration of a single command on a single repo).

Reviewed By: quark-zju

Differential Revision: D17693594

fbshipit-source-id: cae3c934af3c93ee2b5b83dcf82ba00b323dccac
2019-10-02 10:15:42 -07:00
Durham Goode
8b0b788ba8 hgcommands: print errors to io instead of stderr
Summary:
HgPython::run_hg was printing errors directly to stderr instead of to
the provided io.error. This caused unhandlable output in the -t.py tests. Let's
fix it to output to the provided pipe.

Reviewed By: quark-zju

Differential Revision: D17634721

fbshipit-source-id: f441e7be461193ef54db25e0939b2e67cdf06126
2019-10-02 10:12:19 -07:00
Durham Goode
00b6214529 tests: convert 5 more hgsql tests
Summary: These work with just a simple auto-conversion.

Reviewed By: xavierd

Differential Revision: D17611533

fbshipit-source-id: 4be1ace941f6271d94318d88db456fb4cf91ef7f
2019-10-02 10:12:18 -07:00
Durham Goode
413b536a21 tests: convert test-hgsql-filenames.t
Summary:
Converts test-hgsql-filenames.t to be a -t.py test and converts the
hgsql test infra to work in -t.py tests.

Reviewed By: quark-zju

Differential Revision: D17611277

fbshipit-source-id: 8c75ad01a6af743e912312bdc603529dd0f2cf4b
2019-10-02 10:12:18 -07:00
Xavier Deguillard
396ce90580 test-contrib-check-code.t: fixup after D17695858
Summary:
D17695858 removed a couple of rules from the code checker, leading to this test
failing.

Reviewed By: quark-zju

Differential Revision: D17713409

fbshipit-source-id: f37d26ebfc16541119113ce5ea22ba9f2a48c60a
2019-10-02 08:32:03 -07:00
Stefan Filip
829d5fa23e tests: fix test-hg-absorb diff settings
Summary:
It seems that on Windows the execbit feature is not enabled.
This means that git diff format is not set. I think that the
test could do without this update but I'll keep it for now.

Reviewed By: quark-zju

Differential Revision: D17703428

fbshipit-source-id: ff44c3187ec957509a07ae99ac340450d3008656
2019-10-01 18:35:04 -07:00
Jun Wu
f38e25bb56 check-code: remove rules already enforced by black
Summary:
The naive regex-based checker is unsound in some cases.

For example, "trailing whitespace" does not take multi-line docstring into
consideration:

  """
  (spaces - report as trailing whitespace - but removing it might break code)
  """

Since we use black formatter, and black will make sure space-related stuff are
done right, let's just remove space-related check-code rules.

Reviewed By: xavierd

Differential Revision: D17695858

fbshipit-source-id: 66ec8bdcfcbf3e0073a5fe0565e987e539fba6be
2019-10-01 16:24:30 -07:00
Stefan Filip
34cf9b976b tests: remove whitespace from test-absorb
Summary: Fixes test-check-code.t

Reviewed By: singhsrb

Differential Revision: D17695548

fbshipit-source-id: 6f9713bef8e3fb4842dda7bf8ba2633ada96126a
2019-10-01 14:49:59 -07:00
Xavier Deguillard
a3360b4cde remotefilelog: automatically repack when many transaction are commited
Summary:
We've seen several cases where the number of packfiles explodes and causes
Mercurial to slowly becoming unusable due to spending most of its time scanning
the filesytem for new packfiles. In the case of tree, Mercurial will blow aways
the hgcache/manifest directory entirely, causing concurrent Mercurial processes
to fail to commit packfiles to disk.

Let's just count the number of commits we've had so far, and trigger a repack
when it goes over a threshold.

Reviewed By: quark-zju

Differential Revision: D17677222

fbshipit-source-id: 99c31c6137d792be1f6de3c298ebff8a4372926e
2019-10-01 14:34:04 -07:00
Xavier Deguillard
c97df843a2 dott: manually expand TESTDIR in hgrc
Summary:
On Windows, subprocess.Popen(shell=True) will not expand environment
variables, thus, the hgcloneshallow function would fail due to
$TESTDIR/dummyssh not found. Since we know the value of TESTDIR
when the config is written, let's just expand it.

Reviewed By: quark-zju

Differential Revision: D17691487

fbshipit-source-id: 149dcf03b652960fe0e5eff34541cb533d65fa3d
2019-10-01 14:34:04 -07:00
Xavier Deguillard
a6c6909237 remotefilelog: honor --quiet for background repack
Summary:
We would always print that a background repack is started, regardless of
whether --quiet was being passed in.

Reviewed By: quark-zju

Differential Revision: D17677229

fbshipit-source-id: 4e7d2fa355f11fdeea0e4cb59f78bc8f0c56b242
2019-10-01 14:34:03 -07:00
Jun Wu
c6a432e186 testutil: remove an unused reload() function
Summary:
It does not always work cleanly because some GC/__del__ might not be able to
clean up states cleanly.

Reviewed By: kulshrax

Differential Revision: D17634974

fbshipit-source-id: 39264224ee74b05ff4f4e031729d97975ecd4d18
2019-10-01 13:05:18 -07:00
Jun Wu
edbaa1b522 test-absorb: fix the test
Summary:
- Implement a basic grep.
- Implement a naive `sedi`.
- Replace some shell for loops using Python for loops.
- Replace some shell code in Python.

Reviewed By: mitrandir77

Differential Revision: D17616051

fbshipit-source-id: 2fcc19a928989b66e5e9502e10aa07c37b8d1056
2019-10-01 10:45:44 -07:00
Jun Wu
43a605ef7b tests: auto translate "test-absorb.t"
Summary:
This is done by running:

  ./translate "test-absorb.t"

Reviewed By: xavierd

Differential Revision: D17616050

fbshipit-source-id: 7d2e9e4bce88f7702af5a512ee3b4d49c89002f5
2019-10-01 10:45:43 -07:00
Xavier Deguillard
811ea67178 tests: fix test-bisect-t.py on windows
Summary:
$TESTTMP wasn't being expanded due to being in between '', since we're
already in the right directory, there is no need to use $TESTTMP.

Reviewed By: DurhamG

Differential Revision: D17687911

fbshipit-source-id: d9f7048cc95955f59e8a492335a90d48773bc6d2
2019-10-01 09:57:16 -07:00
Xavier Deguillard
728e04deda tests: fix test-revert-t.py on Windows
Summary: The glob wasn't being expanded properly.

Reviewed By: DurhamG

Differential Revision: D17687708

fbshipit-source-id: 7a41fb94a81994a3c6119a7663b1378b51f07a79
2019-10-01 09:57:16 -07:00
Xavier Deguillard
7445aa4701 testutil: fix style in shlex
Summary: The test test-check-code.t was complaining about it.

Reviewed By: quark-zju, singhsrb

Differential Revision: D17687037

fbshipit-source-id: b61351a239554d73fd3285dedca613e72d1d3e59
2019-10-01 09:03:37 -07:00
Aleksei Kulikov
041fe70d99 snapshot: update the docs
Summary: Now help text for the snapshot extension doesn't have any TODOs.

Reviewed By: markbt

Differential Revision: D17627630

fbshipit-source-id: 3e02f6540ab84010712a146a069dbb4a3968182f
2019-10-01 06:48:43 -07:00
Aleksei Kulikov
8a79cfa7e8 snapshot: add the unionstore to handle the rebundling of snapshot bundles
Summary:
If some bundle consisted of several snapshots, and the client requests a part of that data, the server can trigger the rebundling process.
This diff teaches snapshots to the rebundling process.

The `bundlerepo` object should store data in memory, so a `unionstore` class is made up.
It allows to "pair" in-memory store with a regular local store and query them via the same API.

Reviewed By: markbt

Differential Revision: D17684945

fbshipit-source-id: 0bdb1f70b777fb2d8193b3bfa46b5915c2019663
2019-10-01 06:46:43 -07:00
Jun Wu
e1060101cb match: stablize _rootsanddirs order
Summary:
`util.dirs` does not have a defined order. This stablizes the doctest in
`_rootsanddirs`.

Reviewed By: xavierd

Differential Revision: D17679690

fbshipit-source-id: f3e92c0cde1440e6cb225881dbc0de4220c399b9
2019-09-30 21:38:15 -07:00
Arun Kulshreshtha
165a53422b treemanifest: allow configurable HTTP prefetching strategy
Summary: Allow switching between HTTP gettreepack based prefetching vs client-drive BFS HTTP prefetching via a config option. Will be used to make performance comparisons.

Reviewed By: xavierd

Differential Revision: D17381174

fbshipit-source-id: 30a029378b050dd40cb73a616f6d3ebd8e3f3e1d
2019-09-30 20:26:37 -07:00
Arun Kulshreshtha
78fe67ae86 manifest: add BFS prefetch function
Summary:
Add a client-driven tree prefetching implementation to the Rust manifest code. Unlike the existing prefetch implementation in Python, this one does all computation of which nodes to fetch on the client side using the BFS logic from BfsDiff. The trees are then bulk fetched layer-by-layer using EdenAPI.

This initial version is fairly naive, and omits some obvious optimizations (such as performing fetches of multiple trees concurrently), but is sufficient to demonstrate HTTP tree prefetching in action.

Reviewed By: xavierd

Differential Revision: D17379178

fbshipit-source-id: f17fe99834ad4fec07b4a4ab196928cc4fe91142
2019-09-30 20:26:36 -07:00
Arun Kulshreshtha
c48652ad4b manifest: walk manifest in breadth-first order
Summary:
Change the `Files` iterator in the Rust manifest code to traverse the tree in BFS order, allowing for layer-by-layer prefetching similar to `Diff`. This can substantially speed up walks over the tree when the cache is cold.

As a side-effect, this changes the order in which paths are reported during a manifest walk. (In particular, they are now reported in breadth-first order rather than depth-first order.) This may break things that rely on the existing ordering; as such, we may need to add a sort somewhere if this turns out to be a problem.

Reviewed By: xavierd

Differential Revision: D17645389

fbshipit-source-id: 624e426094a93e206bde4523ea8bd034fe5aeb90
2019-09-30 17:04:43 -07:00
Jun Wu
5e5465c313 testutil/dott: match shell's behavior on quote handling
Summary:
This diff makes the code closer to shell behavior.

For example, globs are disabled for both single and double quotes:

  ~ % echo /bin/bash*
  /bin/bash /bin/bashbug
  ~ % echo "/bin/bash*"
  /bin/bash*
  ~ % echo '/bin/bash*'
  /bin/bash*

Environment variables are not expanded for single qutoes:

  ~ % echo $PWD
  /home/quark
  ~ % echo "$PWD"
  /home/quark
  ~ % echo '$PWD'
  $PWD

Tests using single quoted environment varialbes are updated to use double
quotes, mostly by using this vim command:

  %s/\(sh % ".*\)'\([^'$]*\$[^']*\)'/\1\\"\2\\"

The translation script was updated to prefer double quotes to preserve
environment variable expansion behavior.

Reviewed By: xavierd

Differential Revision: D17675351

fbshipit-source-id: d5c8d5f23ea8e29fe093c4e6ae89ddacda97141e
2019-09-30 16:53:25 -07:00
Jun Wu
78c06706ca shlex: add an expandfunc argument
Summary: This allows customization about how to expand an argument with different quotes.

Reviewed By: xavierd

Differential Revision: D17675350

fbshipit-source-id: 1dc4b2e2b7ea0296dceda0d8654c2278a602e4f8
2019-09-30 16:53:24 -07:00
Jun Wu
b118e96ab2 testutil/dott: vendor Python 3's shlex library
Summary:
We need to get "whether an argument is single-quoted or not" information to
decide whether to run extra logic (ex. expanding globs) on it. `shlex` does not
really have public interface for that and it's hard to `wrapfunction` patch it.
Therefore vendor the script so we can customize it.

Some Python 2 compatibility work was done:
- use `cStringIO` instead of `io`
- mark the file as utf-8
- remove `quote`, which uses an incompatible `re.ASCII`

Reviewed By: xavierd

Differential Revision: D17675349

fbshipit-source-id: eb99a9b69ca15f770c410bd3845052cb0c6f1b17
2019-09-30 16:53:24 -07:00
Xavier Deguillard
f48990a312 tests: fix missing depth initialization in generateworkingcopystates
Summary: The variable was used but sometimes not initialized.

Reviewed By: quark-zju

Differential Revision: D17667256

fbshipit-source-id: 9efa3b160cb23205baaa614827e5990475b956c9
2019-09-30 11:23:55 -07:00
Jun Wu
e4e4cbb639 testutil/dott: avoid crash expanding empty argument
Summary:
`arg` can be empty in this context. Avoid crashing with IndexError.

Also fix test-sparse-issues-t.py so it quotes the pattern correctly.

Reviewed By: xavierd

Differential Revision: D17669371

fbshipit-source-id: ea9e4e7c09a88308a650442c22e133684805738e
2019-09-30 11:14:59 -07:00
Jun Wu
98795c9257 test-import: fix on Windows
Summary: Avoid using `rm -rf` but just create new repos aggressively.

Reviewed By: singhsrb

Differential Revision: D17669063

fbshipit-source-id: f5ea142b08f16dcbdcf99a937fba803e1d8d9958
2019-09-30 10:56:16 -07:00
Zeyi (Rice) Fan
784f741312 hg: make configparser buildable with cmake
Reviewed By: simpkins

Differential Revision: D17505870

fbshipit-source-id: 974ed48424b46a0828133b9fb05da86129c3e21f
2019-09-30 10:41:04 -07:00
Jun Wu
60b58132d1 phases: point out manual edits are no-ops if narrow-heads is enabled
Summary: This makes it clear that the new behavior is different.

Reviewed By: sfilipco

Differential Revision: D17584605

fbshipit-source-id: 59573dfa14b4eb7a4a9c5bce6ae7340f408035da
2019-09-27 17:24:00 -07:00
Jun Wu
640a873e9c narrow-heads: add bi-directional migration
Summary:
When migrating down from narrow-heads, we need to restore phase roots.  Use a
repo requirement to track the migration state, and perform migrations on
demand.

Reviewed By: sfilipco

Differential Revision: D17584604

fbshipit-source-id: 36c04b0385dd94481f5340a3ecd8eeef3506c765
2019-09-27 17:24:00 -07:00
Xavier Deguillard
646314794b test-bisect-t.py: fix it
Reviewed By: quark-zju

Differential Revision: D17620102

fbshipit-source-id: b73398846b38ce13c34d4df5d7c5779c1d8641ad
2019-09-27 17:24:00 -07:00
Xavier Deguillard
f0e98e6104 tests: auto translate "test-bisect.t"
Summary:
This is done by running:

  ./translate "test-bisect.t"

Reviewed By: quark-zju

Differential Revision: D17620101

fbshipit-source-id: 461299cb6b74eac7a4febc2fa495ea65e65eea8e
2019-09-27 17:24:00 -07:00
Saurabh Singh
16da1518e5 perforce: remove p4fastimport
Summary:
I think we moved the last perforce based repository into `fbsource`.
From the Scuba logs, this doesn't seem to be used any more:
https://fburl.com/scuba/lc6vgy3v. We can revive the extension if required for a
future Perforce repository import.

Reviewed By: quark-zju

Differential Revision: D17630314

fbshipit-source-id: e3ca1a97974aff5fc262b8c724b70d4548280325
2019-09-27 16:31:34 -07:00