Commit Graph

42737 Commits

Author SHA1 Message Date
Kaley Huang
1e1b176911 p4fastimport: allow sync commits only when imported repository is up-to-date
Summary:
Previously we allowed a sync commit to happen at any time, but imported the
full repository to bring it into sync. This is slow for very large repositories
and might be accidentally triggered. We change this behavior to only do a sync
commit if only the imported client changed but nothing else.

Reviewed By: dsp

Differential Revision: D6838370

fbshipit-source-id: eecdfb0ea295585058784f8d1f70de5f8c733645
2018-04-13 21:51:04 -07:00
Peter Na
0911201aa9 fbsparse: add progress output for refresh
Summary: Adds output to hg sparse --refresh for long running calculations, --verbose adds more notes on progress.

Reviewed By: ryanmce

Differential Revision: D6886545

fbshipit-source-id: 9fe176724bec0cb56bc8da4939f42a6e7745cf41
2018-04-13 21:51:04 -07:00
Jun Wu
034f666e1c lfs: use sortdict to stablize tests
Summary: Previously the verbose output is not stable.

Differential Revision: D6901941

fbshipit-source-id: 2423612f3a620d92a0bd515f311ca70614bbe001
2018-04-13 21:51:04 -07:00
Jun Wu
11733bd944 lfs: remove lfutil
Summary:
lfutil contains a lot of code that works for `largefiles` extension,
which has been removed. Since we only need its `link` feature now,
write an alternative `link` function and remove `lfutil`.

Reviewed By: ryanmce

Differential Revision: D6901622

fbshipit-source-id: ec66f78a97ec443fbd29a9b93c297d15675f4694
2018-04-13 21:51:04 -07:00
Jun Wu
6da44610cf lfs: allow global cache to be disabled
Summary:
Previously there is no way to disable the global cache, since an empty
`lfs.usercache` means a default location.

This patch changes the meaning of an empty `lfs.usercache` to "disable".

This is useful for cases when the user cannot write to `~/.cache` and is
using the default configuration.

Reviewed By: ryanmce

Differential Revision: D6890047

fbshipit-source-id: 352dea5142178d5331e37a48957d9d2b8af26ab5
2018-04-13 21:51:04 -07:00
Jun Wu
144a596cc0 lfs: simplify configitems
Summary: Remove unnecessary dynamicdefault and deprecated items.

Reviewed By: ryanmce

Differential Revision: D6901621

fbshipit-source-id: 05ce7ebc0d29d9990884b27fa1864988c2f23b6c
2018-04-13 21:51:04 -07:00
Jun Wu
adaee94f27 unittestify: randomize HGPORT
Summary:
Previously a stress test that runs a single test in parallel will have race
condition on HGPORT. This patch randomizes the port so the race becomes
unlikely.

Reviewed By: DurhamG

Differential Revision: D6900641

fbshipit-source-id: 2ad741032e3aa9b0cc9fa831fa57907cc493ce37
2018-04-13 21:51:04 -07:00
Liubov Dmitrieva
789c999dd7 commit cloud: hg up improve comments
Summary: improve comments for D6899232

Reviewed By: DurhamG

Differential Revision: D6900597

fbshipit-source-id: 881fe37f2cfbf5cdfed88fe7c419894e11d07333
2018-04-13 21:51:04 -07:00
Kostia Balytskyi
8bd5930877 hg: try to make remotefilelog and gc more shared-handle-friendly
Summary:
We have seen bad `hg gc` behavior on Lego-Windows, caused evidently by the fact
that we currently use plain Python `open` and `os.unlink` instead of
Mercurial's advanced `posixfile` and `unlink`.

Reviewed By: DurhamG

Differential Revision: D6900689

fbshipit-source-id: cd7ebbbb734a6163d062622d1d4606fad43c91ac
2018-04-13 21:51:03 -07:00
Kostia Balytskyi
59946ac6cf hg: make simplecache work with Windows FS
Summary:
When simplecache is configured to use `local` cache, it tries to write files
into a cache directory on a machine. The file names are the key names and they
can contain ':' characters, which are prohibited in Windows filenames. Let's
replace them with '!' which are equivalently unlikely to be parts of actual
files in the repo, yet are allowed on Windows.

Reviewed By: ryanmce

Differential Revision: D6900184

fbshipit-source-id: d901f2ff6e0e6e8b2a0ca93db32b4a836dccd048
2018-04-13 21:51:03 -07:00
Durham Goode
d71123cbe3 hg: don't crash convert if a commit message contains a bad sha
Summary:
Convert apparently greps commit messages to replace hashes with the new
version. There can exist hash looking strings that aren't actually in the
repository though, so let's catch that and prevent convert from crashing.

Reviewed By: quark-zju

Differential Revision: D6887531

fbshipit-source-id: 26397ce11f03146b2fe9fbf45174af892cc14e66
2018-04-13 21:51:03 -07:00
Liubov Dmitrieva
f0b82a1a17 commit cloud: consider hidden revisions as well on hg up by default
Summary: commit cloud: consider hidden revisions as well on hg up by default

Reviewed By: markbt

Differential Revision: D6899232

fbshipit-source-id: 2b160e7c90c4fde2a7d757d4239a5316115d42b0
2018-04-13 21:51:03 -07:00
Durham Goode
a493c04794 hg: remove assert from treemanifest code
Summary:
This assert appears to have always been wrong, but only respected when
built by clang. The SubtreeIterator class is created with an empty string in the
path member, and the only entry to the class is the next function which
immediately asserts that path is not empty. Since the only place path is set is
later in the function, there's no way it could start off as anything other than
empty.

Reviewed By: quark-zju

Differential Revision: D6891356

fbshipit-source-id: c55e616461d4a29308ca6e22be51ea02962d9df3
2018-04-13 21:51:03 -07:00
Phil Cohen
361fcc697a rebase: fix experimental.inmemorydisallowedpaths
Summary: This was just plain broken before. I added a test.

Reviewed By: DurhamG

Differential Revision: D6882388

fbshipit-source-id: 5450b50fa81d22ce0b6e9e4ed5aab1abc6755edc
2018-04-13 21:51:03 -07:00
Jun Wu
79e07a5585 chg: prefix (re|m)allocx with chg_
Summary:
This solves issues when the binary is linked with another C library that define
those functions.

Reviewed By: DurhamG

Differential Revision: D6888242

fbshipit-source-id: d714c7eb18bc4c281912df50567e7f176d64a669
2018-04-13 21:51:03 -07:00
Jun Wu
7192afdd6b linter: disable ShellCheck for hg
Summary:
The ShellCheck linter:
- Conflict with hg check-code. ex. on "$()" vs "``".
- Over picky. ex. SC2148 should only run on scripts with `x` bit.

Therefore disable it for scm/hg.

Reviewed By: zertosh

Differential Revision: D6887739

fbshipit-source-id: 9447a4582ab5d2798a382d9dc715eb319d4255c0
2018-04-13 21:51:03 -07:00
Phil Cohen
0584f5d23f hg: fastverify: unify and fold into core
Summary: `fastverifier` was sometimes being overriden by `shallowverifier` when remotefilelog was enabled. Since the latter is a subset of the former, let's just fold both into the core verifier code backed by a config, `verify.skipmanifests`, that we can default to true.

Reviewed By: DurhamG

Differential Revision: D6882222

fbshipit-source-id: 9f337ca031a070425ccdc9ee02f6765e68436da9
2018-04-13 21:51:03 -07:00
Jun Wu
061409e444 packaging: add PKGBUILD for building on Arch Linux
Summary:
Backport the build script so it's now buildable on Linux.

Add a hard-coded fallback version `4.4.2` in `setup.py` when `hg` cannot be
found. This makes the build not depending on hg - to allow bootstrapping on
Arch Linux - you can scp the files needed to do the build, without requiring
a special hg that can read fbsource.

Note: an hg that can work with the LFS extension is still needed. But that
is just `sudo pacman -S mercurial`.

Reviewed By: DurhamG

Differential Revision: D6827349

fbshipit-source-id: 45ea75175d8890a845d987cfe2be33251cd1a806
2018-04-13 21:51:03 -07:00
Jun Wu
86f264853a ctreemanifest: fix a use-after-free
Summary: This looks obvious to fix.

Reviewed By: DurhamG

Differential Revision: D6885215

fbshipit-source-id: 35cd0dcc0d53969b1ef08d4bd7bc99b186a53457
2018-04-13 21:51:03 -07:00
Jun Wu
5678d60890 buck: add mercurial.interpreter emulating python interpreter
Summary:
A lot of tests rely on `python` interpreter being able to do
things like `import mercurial`. This becomes tricker if hg is
built as a single binary by buck.

Therefore also add a interpreter target that can be used as
a drop-in replacement of `python` in tests.

Reviewed By: DurhamG

Differential Revision: D6879868

fbshipit-source-id: 2b1d2b6306e74ceff86750d1f86387b9fa493f9a
2018-04-13 21:51:02 -07:00
Jun Wu
f623fe9d3c main: add mercurial.main as an entry point
Summary:
The old mercurial.dispatch entry point works, except it breaks
extensions wrapping `dispatch.*` (ex. `dispatch.runcommand`).

That is because things happen in this order:
- Buck's python wrapper imports `mercurial.dispatch` as mod1.
- hgdemandimport is enabled.
- An extension imports `mercurial.dispatch` and it got mod2.
- mod2 != mod1. So any changes to mod2 won't be used.

Using a separate module (`mercurial.main`) as the entry point
solves the problem.

Reviewed By: DurhamG

Differential Revision: D6879873

fbshipit-source-id: 9779edac64bbeb53dd98dfab1b21575c3a60af01
2018-04-13 21:51:02 -07:00
Jun Wu
5dabd90466 unittestify: add a script to generate python unittests
Summary:
The script is intended to be used in `python_unittest` target
in buck.

Reviewed By: DurhamG

Differential Revision: D6879870

fbshipit-source-id: 9ed27a691aa23b41dd2620be7871c0a005df60d0
2018-04-13 21:51:02 -07:00
Jun Wu
ec2892be0d hggit: disable warnings from newer dulwich
Summary:
Newer dulwich will issue warnings that break hggit tests, like:

```
 --- hg/tests/test-hggit-merge.t
+++ hg/tests/test-hggit-merge.t.err
@@ -32,6 +32,26 @@
   Initialized empty Git repository in $TESTTMP/gitrepo2/

   $ hg clone gitrepo hgrepo | grep -v '^updating'
+  hggit/git_handler.py:1250: DeprecationWarning: Use FetchPackResult.refs instead.
+    return ret if ret else {}
+  hggit/git_handler.py:278: DeprecationWarning: Use FetchPackResult.refs instead.
+    if refs:
+  hggit/git_handler.py:1285: DeprecationWarning: Use FetchPackResult.refs instead.
+    for ref, sha in refs.iteritems():
+  hggit/git_handler.py:1295: DeprecationWarning: Use FetchPackResult.refs instead.
+    return util.OrderedDict((r, refs[r]) for r in filteredrefs)
+  hggit/git_handler.py:1379: DeprecationWarning: Use FetchPackResult.refs instead.
+    keys = refs.keys()
+  hggit/git_handler.py:1415: DeprecationWarning: Use FetchPackResult.refs instead.
+    heads = dict([(ref[11:], refs[ref]) for ref in refs
+  hggit/git_handler.py:1416: DeprecationWarning: Use FetchPackResult.refs instead.
+    if ref.startswith('refs/heads/')])
+  hggit/git_handler.py:285: DeprecationWarning: Use FetchPackResult.refs instead.
+    symref = refs['HEAD']
+  hggit/git_handler.py:289: DeprecationWarning: Use FetchPackResult.refs instead.
+    rnode = refs['refs/heads/%s' % rhead]
+  hggit/git_handler.py:1451: DeprecationWarning: Use FetchPackResult.refs instead.
+    for ref_name, sha in refs.iteritems():
   importing git objects into hg
```

Since hggit code still needs to support newer and older dulwich,
Ignore the warnings to make the test pass.

Reviewed By: DurhamG

Differential Revision: D6881696

fbshipit-source-id: 576940be99bcce1ee194cff0cdc655b16c8a6e83
2018-04-13 21:51:02 -07:00
Jun Wu
d0f9b4315d hgsubversion: move its help text to mercurial/help
Summary:
So the use of `os.path.dirname(__file__)` which won't work in buck
python binary can be removed.

Reviewed By: DurhamG

Differential Revision: D6881306

fbshipit-source-id: b6504beaf07fe9853abff08b9721a17b31ac7515
2018-04-13 21:51:02 -07:00
Jun Wu
52139b2825 util: set datapath dynamically using HGDATAPATH
Summary:
This allows `HGDATAPATH` to override where to look for data files
like builtin configs, templates, help texts.

It'll be useful for running tests with a packed hg binary.

Reviewed By: DurhamG

Differential Revision: D6879865

fbshipit-source-id: 4638a9eff62a5fab088215cbeb72740bb67cac04
2018-04-13 21:51:02 -07:00
Jun Wu
beb6c1d415 traceback: do not check actual traceback content
Summary:
Both chg and a packed python binary can add extra traceback
entries. So let's grep out the important lines.

Reviewed By: DurhamG

Differential Revision: D6879869

fbshipit-source-id: e97de7d2cfe512de2340ebb25e8ac93c360d5b9e
2018-04-13 21:51:02 -07:00
Jun Wu
e92a601d9b hghave: add normal-layout feature
Summary:
With `buck build`, the single hg binary won't be guarnateed to have
access to i18n messages because directories like `mercurial/locale`
do not exist on filesystem. It could also mess up with `PYTHONPATH`
somehow because the python binary wrapper sometimes ignores
`PYTHONPATH`.

So let's add a hghave feature for it. And gate troublesome tests
with `#if normal-layout`.

Reviewed By: DurhamG, phillco

Differential Revision: D6879876

fbshipit-source-id: 3d63605b55c8f7096093b89be824add2ec491f81
2018-04-13 21:51:02 -07:00
Jun Wu
78dd086eb5 errorredirect: use absolute import
Summary: This fixes a test-check issue.

Reviewed By: DurhamG

Differential Revision: D6879862

fbshipit-source-id: c6caac6b1d3ed97bb6076d5fb9d0495a41a015c2
2018-04-13 21:51:02 -07:00
Jun Wu
b8f87be31d helpers-usechg: respect CHG environment variable
Summary: This allows CHG to override the chg program being used in tests.

Reviewed By: DurhamG

Differential Revision: D6879866

fbshipit-source-id: c6955609e2b6938d7e26d9b42aa0f6221396a4ad
2018-04-13 21:51:02 -07:00
Jun Wu
8e2207b7e6 run-tests: exit 80 if all tests are skipped
Summary:
This can be used by a wrapper script running a single test
to detect whether the test is skipped or not.

Reviewed By: DurhamG, phillco

Differential Revision: D6879864

fbshipit-source-id: 8bc535fccdbc6ad32eec870bd9e503b6f84f694b
2018-04-13 21:51:02 -07:00
Jun Wu
fbaa53a84a run-tests: create a symlink of hg
Summary:
run-tests.py creates the `python` symlink. Let's do the same for `hg`.

This means tests can just use `hg` and do not worry about it being a
wrong one (like, the system hg). And there is no need to create fragile
shell alias, or set `ui.remotecmd`.

The check to ensure `--with-hg` provides either `hg` or `hg.exe` was
removed since it's no longer necessary.

Reviewed By: DurhamG

Differential Revision: D6879879

fbshipit-source-id: 59255102ea3c4c646afc7900696403242bcfb4db
2018-04-13 21:51:01 -07:00
Jun Wu
ae4b932a4e run-tests: increase default timeout
Summary:
With the upcoming `buck test` change, the default timeout is
not enough because of the python wrapper overhead. Let's double
the limits.

Reviewed By: DurhamG

Differential Revision: D6879874

fbshipit-source-id: 19175be8c4f48dda1fc8917d75798d840d4082da
2018-04-13 21:51:01 -07:00
Jun Wu
30ca26055f run-tests: do not override --with-hg with -l
Summary:
When `--with-hg` and `-l` are both provided. `-l` will override
`--with-hg`, which is unfriendly. Let's do the reverse.

Reviewed By: DurhamG

Differential Revision: D6879863

fbshipit-source-id: 00ea9805431cc7afa6dd521cfb9059c898ed6d1f
2018-04-13 21:51:01 -07:00
Jun Wu
5ae900b05d import-checker: consider lz4 as a system module
Summary:
This fixes `test-check-module-imports.t` running under `buck test`
because `lz4` is not treated as a system module.

Reviewed By: DurhamG

Differential Revision: D6881307

fbshipit-source-id: 26a7e2d36c1ae6815064de15c6bdcb6e762c8ddf
2018-04-13 21:51:01 -07:00
Jun Wu
c03c09633f test-check: use --cwd to avoid issues
Summary:
`test-check-help.t` could run `hg help` and that command shouldn't be affected
by the current repo requirement. So let's add `--cwd /`.

`helpers-testrepo.sh` uses `-R path` and that only works if path is the repo
root. It's not guarnateed now. So let's use `--cwd` instead.

Reviewed By: DurhamG

Differential Revision: D6879867

fbshipit-source-id: 0b40ab71acf7eb215834ce323fc16156da9afcd3
2018-04-13 21:51:01 -07:00
Jun Wu
32aac9256d lazymanifest: do not read uninitialized memory
Summary:
Backported from https://phab.mercurial-scm.org/D1948.
Discovered by clang UBSAN.

Reviewed By: DurhamG, phillco

Differential Revision: D6879871

fbshipit-source-id: c068bdcf5b250c6586515960ef7ed9d0af3a2c59
2018-04-13 21:51:01 -07:00
Jun Wu
cc33c003c2 lz4: import lz4.block
Summary:
`lz4.block` needs to be imported explicitly before being able to
use `lz4.block.compress`.

We didn't notice this because we're using an old version of
`python-lz4`.

Reviewed By: DurhamG

Differential Revision: D6879877

fbshipit-source-id: 37e8fdc00386bef3733753f925ad308f42e5a740
2018-04-13 21:51:01 -07:00
Jun Wu
3a7081dc36 cleanup: remove pythonpath.py
Summary: This should be removed with D6865042.

Reviewed By: phillco

Differential Revision: D6879861

fbshipit-source-id: 960a9ab643f63d6d4a01dfb0ab7af77616cf9ea2
2018-04-13 21:51:01 -07:00
Kostia Balytskyi
84129009ee hg: log time spent waiting for the pager
Summary:
Let's collect how long we wait for a pager so that we can later subtract it
from the elapsed time.
Currently, it's impossible to compute `elapsed - pager - editor - stdio`, which
would include startup time.

Reviewed By: quark-zju

Differential Revision: D6875447

fbshipit-source-id: d055e4ba5bf1ab7ee9e567c99b6708321ab7705b
2018-04-13 21:51:01 -07:00
Durham Goode
01b34be972 hg: prefetch trees before producing changegroup
Summary:
When building a changegroup, sometimes we need to access the list of
files changed by each commit. To do so we need to inspect the manifest.
Previously this would end up downloading each tree one-by-one, producing a bunch
of pack files. With this patch we now do one bulk download at the very
beginning.

Reviewed By: quark-zju

Differential Revision: D6873076

fbshipit-source-id: b916c15efca0770129340f798d3e7b165da6aec9
2018-04-13 21:51:01 -07:00
Durham Goode
57cf49a88d hg: move prefetch onto repo object
Summary:
A future diff will add tree prefetching during changegroup creation. This
requires access to the tree prefetch function from the shallowbundle class.
let's move the prefetch functions onto the repo object in preparation for that.

Reviewed By: quark-zju

Differential Revision: D6873055

fbshipit-source-id: 18de0ee0f6ab566587509f9e23ebb2e5779ed1c8
2018-04-13 21:51:01 -07:00
Liubov Dmitrieva
ddaab68bd5 treedirstate: bugfix
Summary:
treedirstate: bugfix

Incorrect usage of write function that can cause corrupted files in some cases.

Write doen't guarantee all data will be written. Function write_all should be used instead.

https://doc.rust-lang.org/1.0.0/std/io/trait.Write.html#tymethod.write

See: It is not considered an error if the entire buffer could not be written to this writer.

Function returns number of bytes written.

Reviewed By: markbt

Differential Revision: D6883057

fbshipit-source-id: 4bc18cc9fa6e5db0ae8516d67dd6ba92c1facf21
2018-04-13 21:51:01 -07:00
Saurabh Singh
b3c9e0805e treemanifest: store ui once instead of using repo.ui every time
Summary:
setuptreestores caters to a lot of configurations through the `ui`
instance. It makes sense to store the `ui` instance once instead of referring
to it through `repo.ui` every time.

Reviewed By: DurhamG, quark-zju

Differential Revision: D6867843

fbshipit-source-id: 3ffca85332ec4ae3ec8a54bf0dacc7e7cf423b53
2018-04-13 21:51:00 -07:00
Jun Wu
1cde63d99c codemod: drop hacks changing PYTHONPATH in tests
Summary:
Now they are unnecessary since `run-tests.py` will set up `PYTONPATH`
correctly.

Differential Revision: D6865042

fbshipit-source-id: ca95314f725968e14349a9d916434aa832c596f9
2018-04-13 21:51:00 -07:00
Adam Simpkins
d61006b81f update hg rebase -i -s to bail out on unsupported src revs
Summary:
`hg rebase -i` only works if the source revision is ancestor of the working
directory parent.  This updates the code to fail with an error message in this
case instead of rebasing nothing and reporting success.

Note that attempting to change the revset calculation to use `src::` instead
of `src::.` doesn't help fix anything--the histedit code simply rejects the
histedit operation when it finds commits that are not ancestors of the working
directory.

Reviewed By: quark-zju

Differential Revision: D6853548

fbshipit-source-id: 14600f31a5f4ca43c89a81e7b522656b65a056dc
2018-04-13 21:51:00 -07:00
Kaley Huang
b787f74134 p4fastimport: fix badsymlink test
Summary: test-p4fastimport-import-badsymlink.t is failing the regex match P58977427, and this fixes it.

Differential Revision: D6836164

fbshipit-source-id: df43a9e5e30a2745a5dbb36bc6cc07ab81179525
2018-04-13 21:51:00 -07:00
Liubov Dmitrieva
b5b151319c backout: use only first line of commit message for backout default message
Summary: backout: use only first line of original commit message (title) for backout default message.

Reviewed By: phillco

Differential Revision: D6846109

fbshipit-source-id: 68efbff9db698599a12cef45de7ab4af96cf184f
2018-04-13 21:51:00 -07:00
Liubov Dmitrieva
85159c20b5 Improve UX for short hash infinitepush feature
Summary:
Improve UX for short hash infinitepush feature

I would like to provide some suggestions in case there are several with the same prefix,
so we can provide better user experience.

Reviewed By: markbt

Differential Revision: D6845233

fbshipit-source-id: 4868c1dc599f60e4ac495b71a4aed2d57c36ffa4
2018-04-13 21:51:00 -07:00
Mark Thomas
ad1f8c211c fsmonitor: add telemetry for watchman status
Summary:
Adds telemetry showing the status of watchman during an invocation of HG.

The new key, `fsmonitor_status` takes the value:
* `exception` if an exception occurred during the call to watchman.
* `unavailable` if watchman was unavailable.
* `fresh` if a fresh instance of watchman was encountered.
* `normal` if watchman was available normally.

Differential Revision: D6845070

fbshipit-source-id: 5ccf61a1009cdccbc0d1786b2533c3a7fc6ac2c9
2018-04-13 21:51:00 -07:00
Simon Farnsworth
c9914836f9 account for drawdag move in test-doctest.py
Summary:
D6827925 deletes drawdag.py from the tests directory; because the
tests in that revision were run on a repo with .pyc files left behind, the test
failure never happened. Move the test to the new location

Differential Revision: D6845181

fbshipit-source-id: 33c2836d81f66c9cc2a8e82a78b2d6835278a2ac
2018-04-13 21:51:00 -07:00