Summary:
Instead of using KeyError to indicate that data isn't found, let's use an
Option. The Option type better encode that data is missing without having to do
a potentially error prone downcast, this may also enable us to set
RUST_BACKTRACE=1 everywhere as we won't except errors to happen often anymore,
previously, Mercurial will slow to a crawl due to the many KeyError being
thrown around.
I initially wanted to keep the change small to help reviews, but that didn't
really work out, as the dependencies on the `DataStore`/`HistoryStore` traits
are all over the place...
Reviewed By: quark-zju
Differential Revision: D17728486
fbshipit-source-id: de89c4fc441fd12ff37cc248e2230e4a1403ce44
Summary:
This pessimizes the subprocess creation (see https://bugs.python.org/issue35757) when performing
sockname discovery and isn't strictly required: watchman will
perform an equivalent operation for itself IFF it needs to spawn
the daemon.
Reviewed By: quark-zju
Differential Revision: D17728332
fbshipit-source-id: 5e00c82969aeaee38d93c44aba4959c6733cce25
Summary:
My previous change, D17083282, broke addremove on certain case
insensitive filesystems. This was caused by me naively checking for file
existence, which didn't take into account case differences. Let's normalize the
file first and compare it. This appears to be what the old dirstate.walk code
does, though it's a huge mess so it's hard to be certain.
Reviewed By: singhsrb
Differential Revision: D17731308
fbshipit-source-id: 430edc1663748bff8db491bfc8ed609e2f340c60
Summary:
This error is not particularly useful for users to see, and eventually there
will be cases where it is in fact expected that some paths will be invalid
(this is particularly useful on hosts where the same config is read by
different processes with a different environment and / or mount namespace).
Reviewed By: HarveyHunt
Differential Revision: D17710604
fbshipit-source-id: 588c3653df91a84035f044af9455c6ac83305090
Summary:
This is a short-term fix to help surface the real errors.
Instead of silently deleting or renaming data, surface the error so we
can get crash/traceback logged, and can login to investigate the broken
state.
Reviewed By: xavierd
Differential Revision: D17729511
fbshipit-source-id: b066ef12101aa742b4834bfd2e90bcb42fa15aff
Summary: Now that the `File` type is part of the crate's public API, it should be placed in the `files` module along with all the other exported file-related types (such as `FileMetadata`).
Reviewed By: xavierd
Differential Revision: D17726709
fbshipit-source-id: 4e3c0100ca765a7145f9eea49aa0b7ff11496c4b
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary: These work with just a simple auto-conversion.
Reviewed By: xavierd
Differential Revision: D17611533
fbshipit-source-id: 4be1ace941f6271d94318d88db456fb4cf91ef7f
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
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
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
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
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
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
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
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
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
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
Summary: The test test-check-code.t was complaining about it.
Reviewed By: quark-zju, singhsrb
Differential Revision: D17687037
fbshipit-source-id: b61351a239554d73fd3285dedca613e72d1d3e59
Summary: Now help text for the snapshot extension doesn't have any TODOs.
Reviewed By: markbt
Differential Revision: D17627630
fbshipit-source-id: 3e02f6540ab84010712a146a069dbb4a3968182f
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
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
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
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
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
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
Summary: This allows customization about how to expand an argument with different quotes.
Reviewed By: xavierd
Differential Revision: D17675350
fbshipit-source-id: 1dc4b2e2b7ea0296dceda0d8654c2278a602e4f8
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
Summary: The variable was used but sometimes not initialized.
Reviewed By: quark-zju
Differential Revision: D17667256
fbshipit-source-id: 9efa3b160cb23205baaa614827e5990475b956c9
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
Summary: Avoid using `rm -rf` but just create new repos aggressively.
Reviewed By: singhsrb
Differential Revision: D17669063
fbshipit-source-id: f5ea142b08f16dcbdcf99a937fba803e1d8d9958