Summary: This allows us to change configs using code.
Reviewed By: mjpieters
Differential Revision: D7392129
fbshipit-source-id: 0960d4a322d6906469a79976031ab2b619dfa183
Summary:
This allows us to have a unified way to print hint messages at the end of a
command. It would be helpful for feature discovery in general.
Reviewed By: mjpieters
Differential Revision: D7392132
fbshipit-source-id: 8b4e94cc2176266652459ecca3428bd86d95bfe2
Summary:
I did some extra xdiff changes in upstream, namely:
- Remove unused features
- Replace "long" (32-bit in MSVC) with int64_t to support large files
- Add comment on some key variables
This backports them. It also includes Matt's fixes about Windows compatibility.
Reviewed By: ryanmce
Differential Revision: D7223939
fbshipit-source-id: 9287d5be22dae4ab41b05b3a4c160d836b5714a6
Summary:
The correct gitignore matcher needs O(N^2) time to check a path which is N
directory deep. For example, to check "a/b/c/d", it needs to check:
- Whether .gitignore matches a/b/c/d
- Whether a/.gitignore matches b/c/d
- Whether a/b/.gitignore matches c/d
- Whether a/b/c/.gitignore matches d
- Whether .gitignore matches a/b/c
- Whether a/.gitignore matches b/c
- Whether a/b/.gitignore matches c
- Whether .gitignore matches a/b
- Whether a/.gitignore matches b
- Whether .gitignore matches a
It might not look that bad because N=4 for the above example. But when N is
larger (ex. node_modules/../node_modules/../node_modules/..), things get much
worse.
This patch adds "caching" about whether a directory is ignored or not. For
example, if "a/b/" is ignored, the new code would skip checking subdirectories
(ex. "a/b/c/"). The time complexity is now roughly O(N) gitignore tests instead
of O(N^2), since we only did a gitignore check for a parent directory of a path
being tested once, and then cache the parent directory result in a boolean
value.
To be clear, for the first time checking a path which is not ignored, it still
needs O(N^2) for initializing the trees. But once it's initialized, the next
time checking a file in a same directory, will be O(N).
`LruCache` is replaced by `HashMap` since it does not support `.get` and the
code needs that to work.
The perf issue was previously documented as a "PERF" comment.
This diff removes it.
Reviewed By: DurhamG
Differential Revision: D7496058
fbshipit-source-id: f10895b8f0d7dcdde6faf9daeec5cd78a1f15a2b
Summary:
Previously every time a directory was deleted in subversion it would
call delete_entry which contained a ctx.walk() that would iterate over the
entire manifest. When many directories were deleted, this was
O(directories_deleted * size_of_repo) and very slow.
The new algorithm uses bisect to avoid iterating over the entire manifest.
Reviewed By: quark-zju
Differential Revision: D7529670
fbshipit-source-id: 763c1ad5ad46929d878848d150542f255ad96dd4
Summary:
We bailifchanged() later on, but the abort does an `up -C originalwc` before that. Let's bailifchanged() immediately.
A better version: reset the transaction and clear the statefile, instead of calling `abort()`.
Reviewed By: quark-zju
Differential Revision: D7538017
fbshipit-source-id: 8c490b366e495bb269c4d8c75b6144c535c8d54f
Summary:
Minor fixes to how the `previous locations of %s` line is printed:
- Start the pager before printing this line, so it gets included in the pager
output correctly.
- Avoid printing this line when using a custom output template. Previously it
was only skipped when using the `json` template. This now matches the logic
used to skip the `no recorded locations` line that was recommended in
D7512030.
Reviewed By: ryanmce
Differential Revision: D7537661
fbshipit-source-id: eb695dd98c06149701cf96acf5ec2eb277ea9cf3
Summary:
By using low-level APIs, `environ` could contain ill-formed entries that do
not have the `NAME=VAL` form:
#define _GNU_SOURCE
#include <unistd.h>
char *envp[] = { "X", 0 };
char *argv[] = { "hg", "log", 0 };
int main() {
return execvpe("chg", argv, envp);
}
Ignore them silently so they won't break chg.
Reviewed By: DurhamG
Differential Revision: D7537406
fbshipit-source-id: 3fef3d656383723d451fbfa29ba9a9fa170311d0
Summary:
Avoid printing "no recorded locations" directly to stdout when a format
template was specified. In particular this avoids printing non-JSON data
when using `-Tjson`.
We potentially could change this to print to stderr instead. However for now
I just followed the same pattern of checking the template as was done above for
the "previous locations" message.
Reviewed By: ryanmce
Differential Revision: D7512030
fbshipit-source-id: 2c32f07962fac4ca3d6bfd8f2ca3c4840b2a8a9b
Summary:
On Windows, the `mman` and `dirent` functionality can be provided by external
libs, which we would not like to mention in the `setup.py`. This change allows
us to to call `setup.py` with the right env and link with the right libs, same
approach as with headers.
Reviewed By: quark-zju
Differential Revision: D7535358
fbshipit-source-id: d0364cb305a9114260106844f9a3575a731419e9
Summary: We don't really need this separation.
Reviewed By: quark-zju
Differential Revision: D7535364
fbshipit-source-id: a480ddb62883e2e9044e06ff7b27201151632b71
Summary:
Run single DELETE query instead of using separate single DELETE statements because it is much faster and the common way in mysql world.
One query is better because:
* Only one plan will need to be generated
* Only one transaction will be involved
* Less overhead with ODBC calls and network traffic
* Any indexes will need to be refreshed just once, not many times.
Reviewed By: StanislavGlebik
Differential Revision: D7526427
fbshipit-source-id: 39f1d4605adb26d8690a9b39e783c792dee6ad87
Summary:
Reduce number of queries for infinitepush
Use bulk INSERT instead of using separate single-row INSERT statements, that is many many times faster.
('executemany' builds a single query for us)
(out max_allowed_packet is about 134M)
One query is better than 'for loop' because:
* Only one plan will need to be generated
* Only one transaction will be involved
* Less overhead with ODBC calls and network traffic
* Any indexes will need to be refreshed just once, not many times.
Reviewed By: StanislavGlebik
Differential Revision: D7504452
fbshipit-source-id: 9b0beb1ff572bf6c7b28892878d91e0cf4897e1f
Summary: Fix long line which breaks `test-check-code.t`.
Reviewed By: farnz
Differential Revision: D7532586
fbshipit-source-id: e5add9c9407b34bb3bd4cd701ba491e0e0ce1079
Summary:
fix `hg ssl` for Commit Cloud
In Commit Cloud world, obstore can sometimes have more knowledge than the unfiltered repo.
For example, in case of many amends on one client, some stuff can not be backed up
and not fetched to another client.
But we don't need to have all obsoleted versions in both repos,
obstore helps us to provide enough information to a user of what has happened
but we need to be carefull with operator []
Reviewed By: DurhamG
Differential Revision: D7516465
fbshipit-source-id: 7e109741829b26c30f20a7528b21b5ebc9b31dde
Summary:
Using windows libs like `_kernel32 = ctypes.windll.kernel32` means that
the `GetLastError` calls are useless.
(1317 is a non-existent process)
```
In [44]: k32 = ctypes.WinDLL('kernel32', use_last_error=True)
In [52]: ctypes.windll.kernel32.OpenProcess(0x0001, False, 1317)
Out[52]: 0
In [53]: ctypes.windll.kernel32.GetLastError()
Out[53]: 0
In [54]: k32.OpenProcess(0x0001, False, 1317)
Out[54]: 0
In [55]: k32.GetLastError()
Out[55]: 5
```
This behavior can explain why we can't auto-delete the stale lock file. See the `testpid` code:
```
def testpid(pid):
'''return True if pid is still running or unable to
determine, False otherwise'''
h = _kernel32.OpenProcess(_PROCESS_QUERY_INFORMATION, False, pid)
if h:
try:
status = _DWORD()
if _kernel32.GetExitCodeProcess(h, ctypes.byref(status)):
return status.value == _STILL_ACTIVE
finally:
_kernel32.CloseHandle(h)
return _kernel32.GetLastError() != _ERROR_INVALID_PARAMETER
```
The non-existent `pid` causes `h` to be `0` and `_kernel.GetLastError()` to also be `0` (see above why). This means that we think that this process exists!
(Note: this ignores all push blocking failures!)
Reviewed By: quark-zju
Differential Revision: D7519457
fbshipit-source-id: c08f727228073962359e93db13f1fdb76f3699e6
Summary:
When a .backupfiles file is invalid, hg recover gives a not very
useful stack trace. This makes it a bit easier to debug.
Reviewed By: DurhamG
Differential Revision: D7482578
fbshipit-source-id: e8c7ad73bb14a38d2d43b636d60a3b77cd947331
Summary: When no cache has been set (`simplecache.caches=`) then there's no `name` set either. This exposed a logic error in this section of the code.
Reviewed By: ryanmce
Differential Revision: D7513976
fbshipit-source-id: ecbc7a8ac8c6eb23010d64ab8cbf9f9fb7d8f497
Summary:
Currently hg doesn't return anything from processing infinitepush parts.
However, mononoke will treat infinitepush parts just like normal hg parts.
So let's not panic if we see reply:changegroup part
Reviewed By: markbt
Differential Revision: D7513729
fbshipit-source-id: 8417a285bd49efadf2f2ef9ed80ad2f2b6d6bc94
Summary:
Currently, the `build_deb.py` writes the packages to the directory
from which the script was invoked. This leads to issues in integrating with our
continuous build setup. Therefore, this commit changes the script to write to a
known location.
Reviewed By: quark-zju
Differential Revision: D7511832
fbshipit-source-id: 85beaf37e92418cae932fd81c72065cf5d64c249
Summary:
move logic to update current rev to its new location (optional)
we are trying to update only if it is unambiguous
Reviewed By: DurhamG
Differential Revision: D7431940
fbshipit-source-id: 72e7fea7365a231c4d98ceb4cf4872a4db02d9ca
Summary:
[commitcloud] commit cloud recover state
`hg cloudrecover` command
It might be helpful to have a command like this in cases something goes wrong
with the local state
Reviewed By: DurhamG
Differential Revision: D7417147
fbshipit-source-id: 4b236f2753b1f212ff4881a649032e53e032c66c
Summary:
When pushing a backup bundle to the server, check if the response contains an
error, and fail the backup accordingly.
Differential Revision: D7498324
fbshipit-source-id: a08807ac54e9d3044ff1450e93d2a8ea9d6f767f
Summary:
Add a server-side config option `infinitepush.maxbundlesize` to control the
maximum bundle size (currently 100MB).
Add a test that shows bad behaviour when pushing backups that exceed this size.
Differential Revision: D7498323
fbshipit-source-id: 640478e7a58cb3c39408fe2a24d8d581f14d891c
Summary: Since we now have the ability to store multiple values. Add a test.
Reviewed By: DurhamG
Differential Revision: D7472880
fbshipit-source-id: 85b1c69245ac7f0c4702daf22a02f5e5072f0924
Summary:
The value type is a linked list of u64 integers. Add an API to expose that.
Using iterator framework has benefits about flexibility - the caller can
take the first value, or convert it to a vector, or count the values, etc.
easily.
Reviewed By: DurhamG
Differential Revision: D7472881
fbshipit-source-id: d31e81770e069734b54fa08729c0cd45a699aae2
Summary:
This is caught by a later test. Looking up a non-existed child (jumptable
value is 0) returns InvalidData error, while it should return Offset(0).
The added if condition does not seem to have noticeable performance impact:
index insertion 3.840 ms
index flush 3.740 ms
index lookup (memory) 1.085 ms
index lookup (disk, no verify) 1.972 ms
index lookup (disk, verified) 7.752 ms
Reviewed By: DurhamG
Differential Revision: D7472882
fbshipit-source-id: 1cc51e9afa248e123cca9c561d7bb2128fd898b1
Summary:
Previously, the code was focusing on getting the hardest (index) part right,
but less about the value part. There is no way to get all values in the
linked list, as designed, yet. This diff starts the work.
Similar to `KeyOffset::key_and_link_offset`, change the internal API of
LinkOffset to return both value and the next link offset.
Reviewed By: DurhamG
Differential Revision: D7472879
fbshipit-source-id: 4a4512d7c63abbb667146de582e0f8cd04c9c04a
Summary:
`Index::open` now takes too many parameters, which is not very convenient to
use. Inspired by `fs::OpenOptions`, use a dedicated strut for specifying
open options.
Motivation: To test checksum ability more confidently, I'd like to write
something that randomly mutates 1 byte from a sane index. To make sure the
checksum coverage is "correct", checksum chunk size is another parameter.
Reviewed By: DurhamG
Differential Revision: D7464182
fbshipit-source-id: 469ce7d1cfa5de3946028418567a9f3e2bc303fa
Summary:
Address DurhamG's review comment on D7422832.
Previously, `OffsetMap::get` expects a dirty offset. That's because it was
changed from `HashMap` and we don't control `HashMap::get`. It's cleaner to
let `OffsetMap` do the `is_dirty` check.
Reviewed By: DurhamG
Differential Revision: D7461707
fbshipit-source-id: 9f2abdf6c6f993d98d9443f16bafcc6154ee0dbb
Summary:
The new test covers the `else` branch inside `LeafOffset::set_link`
previously not covered.
Coverage was checked by the following script:
```
from __future__ import absolute_import
import glob
import os
import shutil
os.system('cargo rustc --lib --profile test -- -Ccodegen-units=1 -Clink-dead-code -Zno-landing-pads')
path = max((os.stat(path).st_mtime, path) for path in glob.glob('./target/debug/*-????????????????'))[1]
shutil.rmtree('target/kcov')
os.system('kcov --include-path $PWD/src --verify target/kcov %s' % path)
```
Reviewed By: DurhamG
Differential Revision: D7446902
fbshipit-source-id: 293da2ff53b83c8f11534f0f8e5e7fd102216a01
Summary:
Change `insert_advanced` to accept an enum that could be either a key, or an
(offset, len) that refers to the external key buffer.
Insertion becomes slower due to new flexibility overhead. For some reason,
"index lookup (no verify)" becomes faster (restores pre-D7440248 performance):
index insertion 6.434 ms
index flush 3.757 ms
index lookup (memory) 1.068 ms
index lookup (disk, no verify) 1.969 ms
index lookup (disk, verified) 7.805 ms
With 2M 20-byte keys, the non-external key version generates a 105MB index:
seconds operation
1.247 insert
0.622 flush
1.859 flush done
0.702 lookup (without checksum)
1.395 lookup (with checksum)
Using external keys,the index is 70MB, and time for each operation:
seconds operation
1.086 insert
0.702 flush
0.665 lookup (without checksums)
1.602 lookup (with checksums)
The external key will have more space wins for longer keys, ex. file path.
`Index` module was made public so `InsertKey` type is usable.
Reviewed By: DurhamG
Differential Revision: D7444907
fbshipit-source-id: b89d95246845799c2c55fb73ad203a7e6724b85e
Summary:
Previously, a leaf entry can only have a `KeyOffset`. This diff makes it
possible to be either `KeyOffset`, or `ExtKeyOffset`. The API didn't change
much since `LeafOffset::key_and_link_offset` handles the difference
transparently.
Latest benchmark result:
index insertion 4.879 ms
index flush 3.620 ms
index lookup (memory) 1.827 ms
index lookup (disk, no verify) 3.508 ms
index lookup (disk, verified) 7.861 ms
Reviewed By: DurhamG
Differential Revision: D7444909
fbshipit-source-id: 5441e1ae187d42931377d7213dcb77156b2af714
Summary:
The leaf entry has a `key_and_link_offset` method. Previously it returns a
`KeyOffset`, since we now have `ExtKeyOffset`, it's friendly to handle the
key entry type difference at the leaf entry level, instead of requiring the
caller to handle it.
Reviewed By: DurhamG
Differential Revision: D7444905
fbshipit-source-id: 56d87641a2a5a50ddca8b1e4c74c9aaa3891b542
Summary:
Previously, I thought there is only one index that will use "commit hash" as
keys, that is the nodemap, and other indexes (like childmap) would just use
shorter integer keys (ex. revision number, or offsets). So the space overhead
of storing full keys only applies to one index and seems acceptable.
But that implies strict topo order for the source of truth data (ex. to use
integers as keys in childmap, you have to know how to translate parent
revisions from hashes to integers at the time writing the revision).
Thinking about it again, it seems the topo-order requirement would make a lot
of things less flexible. It's much easier to just use hashes as keys in the
index. Then it's worthwhile to address the space efficiency problem by
introducing an "external key buffer" concept. That's actually what `radixbuf`
does.
This is the start. It adds the type to the strcut. The feature is not completed
yet.
Reviewed By: DurhamG
Differential Revision: D7444904
fbshipit-source-id: 60a83c9e6e8b0734450f0c5827928a7c5bd111d5
Summary:
A subsequent diff will need access to the node's diff and meta during iteration time. It seems like a
natural part of the API so let's add it.
Note: It's possible to call `.getdelta(name, node)` to get this data if we don't read it here.
But I ran into some weird occassional OSErrors from the mmap API when I did that. So let's just
do this.
Reviewed By: DurhamG
Differential Revision: D7369225
fbshipit-source-id: 252839a549242909153c74287db8f36d6c63bd9c
Summary:
This makes hg pull use the connectionpool. This means prefetches can
reuse the existing ssh connection when appropriate. This both speeds up
prefetches, and also means they will speak to the same server that served the
pull.
Reviewed By: ryanmce
Differential Revision: D7481107
fbshipit-source-id: f9a3670527cb7e8956029c86d50d8e030dd3cc01
Summary:
Previously the connectionpool was a remotefilelog specific concept. We
want to start sharing connections between pull and prefetches, so let's move it
to core Mercurial.
Reviewed By: ryanmce, phillco
Differential Revision: D7480670
fbshipit-source-id: 1b2eff3b0e61a815709ffaec35df802eeda0c24b
Summary:
`hg debugcolor --style` shows the component parts of each style individually,
however this doesn't work if the styles are defined as the new fallback styles
(separated by colons). This is because the fallback is only implemented for
actual style names - it doesn't work for `ui.label('brightblue:blue', 'text')`.
It's usefule to see what the fallbacks are (even if they're not necessary on
your own system), so change debugcolor to split the elements of the fallback
style and show them separately.
Reviewed By: quark-zju
Differential Revision: D7485545
fbshipit-source-id: dce7204c9f0a98bb730b3ba864db28a9ec52a339
Summary:
`len()` on a hybrid manifest wrapping a treemanifest would raise an attribute error. But if there is no treemanifest or there is *only* a treemanifest, then a TypeError is raised. Using `len()` on an object that doesn't support length should always raise `TypeError`, consistently.
Instead of looking up the `__len__` attribute, use the built-in `len()` function, which will raise `TypeError` if the wrapped manifest in a hybrid doesn't have a `__len__` method. This ensures that we get a consistent exception.
Reviewed By: farnz
Differential Revision: D7485510
fbshipit-source-id: 4132d6b383171cde8dd99dd60098716d4aedc527
Summary:
The full command line needs to come from the `dispatch.runcommand` function, as
`sys.argv` contains `serve ...` for chg invocations.
Also make sure the correlator remains the same for commands that make multiple
connections to the server.
Reviewed By: quark-zju
Differential Revision: D7443727
fbshipit-source-id: a785e372b7b67fbd0b4ab4d73e7ff914aa5db9c3
Summary:
`remotefilelog.fileserverclient.peersetup.remotefilepeer` overrides the
`_callstream` method, however it uses `command` rather than `cmd` for the first
parameter name. This doesn't match the method it's overriding, and clashes
with clienttelemetry's use of this parameter for the original command that the
user ran.
Make this method match all the others.
Reviewed By: quark-zju
Differential Revision: D7443726
fbshipit-source-id: 1170feb21056c3e044bffaf55d95f7c48ff972fb
Summary:
gitignore could have performance issues stating .gitignore files everywhere.
That happens if watchman returns O(working copy) files. Add a config to
disable it as we're finding solutions.
Reviewed By: DurhamG
Differential Revision: D7482499
fbshipit-source-id: 4c9247b0318bf034c8e9af4b74c21110cc598714
Summary:
Turns out I incorrectly assessed this situation before. We do use content from
perforce servers a lot. This change makes p4seqimport read from local disk
directly if possibel rather than resorting solely on `p4 print` to obtain file content.
```name=Checking file content src on master-importer task 0 (running for 15h+)
[15:40:23 twsvcscm@priv_global/independent_devinfra/ovrsource-master-importer/0 ~]$ egrep -o 'src: (gzip|rcs|p4)' /logs/stdout | sort | uniq -c
2567 src: gzip
24 src: p4
```
Differential Revision: D7388797
fbshipit-source-id: 5fe1a525bc211d64a75954d529edc152d22970a7
Summary:
Subsequent commits will need the new path of a mutable{data, hist}pack -- this makes
that data accessible.
Reviewed By: DurhamG
Differential Revision: D7369226
fbshipit-source-id: f6849aaed747fbd9afee7191e6a0e5e1357ca618
Summary: fastmanifest used the statvfs function to be smart about how much disk space it used. That function isn't available on windows though. This optimization is optional, and we probably won't end up using the fastmanifest cache on windows anyways, so let's just skip it if its not available.
Reviewed By: quark-zju
Differential Revision: D7478478
fbshipit-source-id: e9595f3fef397d66d76f3ecfa54f8e4328ce0921