Commit Graph

46328 Commits

Author SHA1 Message Date
Xavier Deguillard
f0a2127ace tests: remove newly added flaky test in test-hgsubversion-push-command.py
Summary: This newly added test keeps failing. Let's remove it from now.

Reviewed By: DurhamG

Differential Revision: D16381346

fbshipit-source-id: 11146d44fbbcd1e1c960fe4a0b6e3c28854f456d
2019-07-19 13:09:23 -07:00
Matt Glazar
9b88f1e59b Fix slow rebase for commits which move files
Summary:
When rebasing or showing a diff for a commit which moved files, remotefilectx.ancestors (called by _tracefile) calculates the linkrev for each ancestor. Sometimes [1], this is a disaster:

* remotefilectx._linkrev executes its slow path and scans the change log.
* For each entry in the change log, remotefilectx._linkrev downloads trees if needed.
* Hg downloads trees one-by-one (as of D15964145).

remotefilectx.ancestors is only calculating linkrevs so it can sort the ancestors topologically. _tracefile only needs the ancestors to be ordered topologically, not by linkrev. remotefilectx.ancestors's calls to remotefilectx._linkrev are redundant.

Optimize _tracefile's use of remotefilectx.ancestors: order remotefilectx objects topologically (breadth-first) without sorting by linkrev. Create a new function for this purpose (topological_ancestors) to avoid possibly breaking other callers of remotefilectx.ancestors. As a side effect, make this new function return remotefilectx objects lazily, similar to the filectx.ancestors function.

On my machine, with warm caches, this speeds up 'hg diff -c' and 'hg rebase' for a modestly-sized commit. 'hg diff -c' takes 0.64 seconds, down from 65.6 seconds.

[1] Hypothesis: After 'hg amend', 'hg bundle' packages linkrevs which refer to the pre-amend commit (which is not serialized into the bundle) rather than the post-amend commit. 'hg unbundle' thus creates linkrevs referring to a missing commit.

Reviewed By: DurhamG

Differential Revision: D16297426

fbshipit-source-id: 407597d5e36fc06b33719c28f5ea5052e01dc7a3
2019-07-19 12:35:22 -07:00
Xavier Deguillard
ec9ec06360 run-tests: add testpilot test runner
Summary:
Testpilot can give us a lot of things for free, including the automatic
detection of flaky tests, disabling of them, re-enabling too, easy retries on
failure, timeouts, better tracking, and the list goes on.

At a first step, I'd like to make the testpilot runner the default in hgbuild
to get all the benefits listed above.

Reviewed By: quark-zju

Differential Revision: D16294182

fbshipit-source-id: aadfbac9eb05e9d64336daba7a50a6263e38c162
2019-07-19 11:47:04 -07:00
Xavier Deguillard
9151a3cc24 tests: fix test-run-tests.t
Summary: When all tests are skipped, run-tests.py no longer return a 80 error code.

Reviewed By: singhsrb

Differential Revision: D16380129

fbshipit-source-id: e84a3558df8c2c4ebef9a382a1172d859a47e220
2019-07-19 11:39:56 -07:00
Aida Getoeva
1fb44ce297 remotenames: disable selectivepull on clone
Summary:
Streaming clone works only if we fetch all data from the server, however with selective pull feature hg specifies the particular heads it needs to pull. It causes downgrade in clone performance.
I decided to disable selective pull just before the clone operation, so the feature will be working everywhere else. Also I still store, even after clone, only "subscribed" remote bookmarks.

There are, however, artifacts of such behaviour, they are shown by changes in `test-commitcloud-sync-remote-bookmarks.t`: the whole tree of commits now is available locally, except of the remote bookmarks.

Reviewed By: simpkins

Differential Revision: D16223458

fbshipit-source-id: 0564ac23a16fe54d245e0a6ce9db5be4b6e3532f
2019-07-19 10:04:26 -07:00
Aida Getoeva
3c81066860 commitcloud: fix sync when remotebooks sync disabled on one of the copies
Summary:
If one of the repo checkouts doesn't have remote bookmarks synchronization enabled, it must not affect the Cloud's remote bookmarks state.

I also changed `localserver` (is used for our tests) because Commit Cloud server deletes the "old" bookmark names from the db and inserts "new". However, the `localserver` just set the "new" books dictionary as a new state, which is not quite correct.

Reviewed By: simpkins

Differential Revision: D16338257

fbshipit-source-id: d77d9218b1c35ea1a097bbe7393d0910ce7b4d38
2019-07-19 10:04:25 -07:00
Aida Getoeva
6ab4fcf8f8 commitcloud: fix remote bookmarks' merge on sync
Summary: While checking if one public commit is an ancestor of another public commit, I used string hashes instead of binary nodes. Fixing.

Reviewed By: farnz

Differential Revision: D16338256

fbshipit-source-id: e27ed8d79ec9ed3a188cdee93366ab2f96526152
2019-07-19 10:04:25 -07:00
Zeyi (Rice) Fan
e2655fac28 RFC: hg: make zsh completion to return list of draft commits
Summary:
By default the zsh completion will give me a list of bookmark names which personally I don't think it is useful at all.

I think making it giving me the list of draft commits is much better.

Reviewed By: quark-zju

Differential Revision: D16094724

fbshipit-source-id: 3493895a12ae02df011560b53dd5e55c8d183c79
2019-07-18 22:26:01 -07:00
Xavier Deguillard
3ce0ed8fa2 tests: fix test-hgsubversion-externals.py
Summary:
This was failing in our contbuild on centos. For some reason the memoization of
repo and ui was what made it fail.

Reviewed By: DurhamG

Differential Revision: D16368137

fbshipit-source-id: c3bec702bfa311f4be438f5aaf4939e6e725c63b
2019-07-18 22:20:35 -07:00
Xavier Deguillard
f9b4c4917a run-tests: return a success error code when tests are skipped
Summary:
As run-tests.py will be used with testpilot and at diff time, we do not
want to fail a run when all the tests were simply skipped. Let's make
that a success instead.

Reviewed By: quark-zju

Differential Revision: D16364297

fbshipit-source-id: ef8e912ddde91bd5be52784fceaf012857841eea
2019-07-18 15:54:21 -07:00
Jun Wu
0720c26f71 dispatch: do not override 'msg' in case of interruption
Summary:
The `msg` variable was unintentionally changed in the "killed" case. Use a
different variable name to solve it.

This diff changes:

  [legacy][command_finish] killed!
   exited -1 after 1.60 seconds

to:

  [legacy][command_finish] <command> exited -1 after 1.60 seconds

Reviewed By: singhsrb

Differential Revision: D16360967

fbshipit-source-id: fb52025cd743a49c18116275c2eeac7b5c436e3b
2019-07-18 15:11:57 -07:00
Jun Wu
56cf4cef7d blackbox: buffer logs before initialization
Summary:
This allows us to preserve logs before the blackbox initialization.

In the edenscm usecase, we might want to log a "process start" event before
knowing the location of the blackbox.

Reviewed By: xavierd

Differential Revision: D16044038

fbshipit-source-id: 7f41994989bb3a83e9ded3014e5afeae00f3350c
2019-07-18 15:11:57 -07:00
Jun Wu
17ee0df47c blackbox: remove Option for the blackbox singleton
Summary:
Use the new in-memory features from indexedlog and always create a blackbox
instance. This will allows us to buffer blackbox logs before `init` gets
called.

Reviewed By: xavierd

Differential Revision: D16044034

fbshipit-source-id: d137fdc3af8876c0c3dc3149c7478eb46025f457
2019-07-18 15:11:57 -07:00
Jun Wu
6b52d9c55c indexedlog: support in-memory-only RotateLog
Summary: This makes it possible to create RotateLog without writing to filesystem.

Reviewed By: xavierd

Differential Revision: D16044037

fbshipit-source-id: 451adaf8c2f97f0bd46bb2e5f42a33047d2ddfb0
2019-07-18 15:11:56 -07:00
Jun Wu
322d6990fd indexedlog: support in-memory-only Log
Summary: This allows using the Log without side effects on the filesystem.

Reviewed By: xavierd

Differential Revision: D16044036

fbshipit-source-id: 20182a58a51e61deea87c98b87f5598b98dadbb2
2019-07-18 15:11:56 -07:00
Jun Wu
21100e9dc5 indexedlog: make dir in some Log methods optional
Summary:
Change some functions to support emtpy dir, and create in-memory-only indexes.
This would allow creating in-memory-only Log.

Reviewed By: xavierd

Differential Revision: D16044039

fbshipit-source-id: 278662d3ab0093e4072e9321f3e8d4336b80ddfe
2019-07-18 15:11:56 -07:00
Jun Wu
9768b58340 indexedlog: make Log.dir optional
Summary: This allows Log to be constructed without a "dir".

Reviewed By: xavierd

Differential Revision: D16044040

fbshipit-source-id: 035416603f37af09be1ec75d1865e552ced89229
2019-07-18 15:11:55 -07:00
Jun Wu
880f04de84 indexedlog: support in-memory-only Index
Summary: This allows using the Index without side effects on disk.

Reviewed By: xavierd

Differential Revision: D16044041

fbshipit-source-id: dba6edd76e7e7a09628d836d3aa50b2defcd2555
2019-07-18 15:11:55 -07:00
Jun Wu
ec4ff4a2d2 indexedlog: make Index.file optional
Summary:
This makes it possible to create an Index instance without providing a
file. It's used in later changes.

Reviewed By: xavierd

Differential Revision: D16044035

fbshipit-source-id: e7b52b9cb342cc82567c6583902eecd003ac0949
2019-07-18 15:11:55 -07:00
Jun Wu
82b6c96907 indexedlog: extract empty mmap logic to a function
Summary:
This starts a series of changes to make indexedlog work in "in-memory-only"
mode. It is useful in 2 cases:

- buffering blackbox writes (short term)
- reused in Mononoke which does not want side-effect on disk (longer term)

Reviewed By: sfilipco

Differential Revision: D16044042

fbshipit-source-id: bdf35a9565e39e65c9ba4ddb949aa86412b4d496
2019-07-18 15:11:55 -07:00
Jun Wu
2ec82860a2 test-dirstate: fix testcase handling in new tests
Summary:
`#testcases` was translated to `for testcase in ...`, which is subtly
different since the for loop does not clean up states. Insert `cd $TESTTMP`
to make sure `setconfig` sets the global config, instead of the repo one.

Reviewed By: singhsrb

Differential Revision: D16363261

fbshipit-source-id: ea20c758e9131268f9329b98759e7423d9f1aa87
2019-07-18 15:06:45 -07:00
Saurabh Singh
c137206645 globalrevs: return globalrevs while resolving svnrev template keyword
Reviewed By: quark-zju

Differential Revision: D16361887

fbshipit-source-id: 547b03af9c17aa7ab033f9d1bd733f4a63830d07
2019-07-18 12:23:00 -07:00
Saurabh Singh
0766f36b29 hgsubversion: refactor method for svnrev template keyword to easy wrapping
Summary:
This commit is just a simple refactor of the method for the resolving
the `svnrev` template keyword. In particular, we split the method so that it
can be easily wrapped by other extensions like globalrevs in D16361887.

Reviewed By: quark-zju

Differential Revision: D16361888

fbshipit-source-id: 9f20fb33afd2b286c4f30571fa257b8284f2bb54
2019-07-18 12:23:00 -07:00
Jun Wu
53cc0f0766 test-contrib-check-code: update the test
Summary:
D16344714 made some rules only apply to edenscm/. Update the test to reflect
the changes.

Some formatting rules (ex. "string join across lines") are less important since
all files are formatted by black.

Reviewed By: xavierd

Differential Revision: D16360508

fbshipit-source-id: 9d38d710501eaf71c033ca49328774b8688fb5e0
2019-07-18 11:38:02 -07:00
Shu-Ting Tseng
fd5abc16e3 rewrite svn commit message with hg hash
Summary:
When we are migrating www to hg as source of truth, we would like to maintain the
reverse sync for some time in case we need to rollback.

In order to achieve that, we need to know the latest svn and hg commit to operate on. We
would like to record this information in the svn commit itself so it doesn't require
extra syncing and transaction.

In ordre to get this info, we can run `svn log -l 1` and parse the commit message from
there.

Reviewed By: quark-zju

Differential Revision: D16337012

fbshipit-source-id: acf66babdb48c07f95e9eb49daac0d3d3e6a96a0
2019-07-18 10:06:05 -07:00
Jun Wu
0c36fd8b5e tests: translate some .t tests to Python
Summary:
Those tests were converted using:

  echo *.t | xargs -P20 -n1 python -m testutil.dott.translate --black --verify

They run 5x faster (via run-tests.py), and 10x faster (via python directly).

run-tests.py on old .t files, 652 CPU seconds:

  % time ./run-tests.py `cat list-t.txt`  --noprogress
  .................................................................................................................................
  # Ran 129 tests, 0 skipped, 0 failed.
  ./run-tests.py `cat list-t.txt` --noprogress  505.30s user 146.37s system 1451% cpu 44.899 total

run-tests.py on new py tests, 135 CPU seconds:

  % time ./run-tests.py `cat list-py.txt` --noprogress
  .............................................................................................................................
  # Ran 125 tests, 0 skipped, 0 failed.
  ./run-tests.py `cat list-py.txt` --noprogress  55.73s user 78.80s system 744% cpu 18.061 total

vanilla python on new tests, 59 CPU seconds:

  % time (for i in `cat list-py.txt`; do python $i; done;)
  ( for i in `cat list-py.txt`; do; python $i; done; )  41.61s user 17.47s system 90% cpu 1:05.31 total

The new tests also have auto fix ability. `python test-foo-t.py --fix` will
autofix the code.

Reviewed By: xavierd

Differential Revision: D16172902

fbshipit-source-id: dda53990a7dfff5ac214c1237e4206a4d67e8e48
2019-07-17 21:11:32 -07:00
Jun Wu
59c9cee23a testutil/dott: append '(trailing spaces)' to lines with trailing spaces
Summary:
Some linters or editers are unhappy with trailing spaces in heredoc.
Workaround it.

Reviewed By: xavierd

Differential Revision: D16344717

fbshipit-source-id: 63be8b992e2e4718faea1a55655c592f0e87b206
2019-07-17 21:11:32 -07:00
Jun Wu
77dbcbbf24 testutil/dott: add a script to translate .t files
Summary:
Add a script to automatically translate .t tests to .py tests using
testutil.dott.

Reviewed By: xavierd

Differential Revision: D16172903

fbshipit-source-id: a1d736ae3e8035ac254af59c6dff5eb9f204f1fb
2019-07-17 21:11:31 -07:00
Jun Wu
4853d63b69 testutil/dott: implement per-command environment variables
Summary: This allows FOO=bar to work in some tests.

Reviewed By: xavierd

Differential Revision: D16344718

fbshipit-source-id: b600d928a42e9e8e36a2ab9f5db97fd489878d02
2019-07-17 21:11:31 -07:00
Jun Wu
b8f57dbe27 testutil/dott: implement feature test
Summary:
`.t` tests use `hghave` to test features, and can have `#testcases` for
multiple test cases. Implement them.

Reviewed By: xavierd

Differential Revision: D16209201

fbshipit-source-id: 1e8ea32d966f922efcf94e555cc9ab946cc85b27
2019-07-17 21:11:31 -07:00
Jun Wu
4a0d11f14f testutil/dott: implement "source library.sh"
Summary:
Tests use "source" to enable new features. One the main sources is
"library.sh", which includes remotefilelog utilties. Implement it.

Reviewed By: xavierd

Differential Revision: D16209209

fbshipit-source-id: 3bce4296861947e753e37bccf83c05129960dece
2019-07-17 21:11:30 -07:00
Jun Wu
57483c41b1 testutil/dott: implement some tinit.sh functions
Summary: tinit.sh provides some handy functions. Implement them.

Reviewed By: xavierd

Differential Revision: D16209205

fbshipit-source-id: 084669833086fef61e215865e792260dc2e35794
2019-07-17 21:11:30 -07:00
Jun Wu
c5a7b31dbf testutil/dott: implement "hg"
Summary:
Implement hg commands. This uses the dispatch code path to run hg commands
without startup overhead. It's possible that some side effects in the Python
world can cause unwanted behavior. Therefore a "reload" function was provided.

Once we have Rust as the entry point, we might still want to have some Python
binding to the Rust logic so the test code can use them.

Reviewed By: xavierd

Differential Revision: D16209204

fbshipit-source-id: e510f59629b46afd6b140c7bec9de07698b523b9
2019-07-17 21:11:30 -07:00
Jun Wu
1364b3a3ae testutil/dott: implement a subset of coreutils
Summary: Implement a subset of coreutils so functions used by .t can run.

Reviewed By: xavierd

Differential Revision: D16209202

fbshipit-source-id: 953bebbfdc09cf191e8aa04c5ee1468c764b4360
2019-07-17 21:11:30 -07:00
Jun Wu
6977426d45 testutil/dott: remove indentation from heredoc
Summary:
To make the code look better, indentation gets added to heredoc content.
Remove them. This replaces `inspect.cleandoc`. The difference is
`inspect.cleandoc` special handles the first line, which is undesirable.

Reviewed By: xavierd

Differential Revision: D16344716

fbshipit-source-id: c69c20607ddc5292bc6bcdd840587258276016ed
2019-07-17 21:11:29 -07:00
Jun Wu
cb0126cb4a util: add istest() method
Summary:
There are multiple places that want to know whether the code is running inside
tests or not. Add `util.istest` for that and migrate those callsites to use it.

Reviewed By: xavierd

Differential Revision: D16344715

fbshipit-source-id: faa4261c83e4d889d59d63968b440954c4cac2ce
2019-07-17 21:11:29 -07:00
Jun Wu
744a504d00 testutil/dott: implement TESTTMP support
Summary:
TESTTMP was handled by run-tests.py. This diff extracts a subset of TESTTMP
logic so tests using testutil/dott can run via Python directly without using
run-tests.py

Reviewed By: xavierd

Differential Revision: D16209203

fbshipit-source-id: 7605505a725c30c9d07d83b7d3bfe92ec215cefc
2019-07-17 21:11:29 -07:00
Jun Wu
b87a92215f testutil/dott: implement advanced output matching
Summary:
`run-tests.py` supports `(glob)`, `(re)`, `(esc)` for output matching.
Implement them.

Note: `(?)` is harder to implement. It is not implemented in this diff.

Reviewed By: xavierd

Differential Revision: D16209212

fbshipit-source-id: 52172158c41286a0673e6ae25bde2c774ac24c52
2019-07-17 21:11:28 -07:00
Jun Wu
08c15a105a testutil/dott: normalize error messages
Summary:
run-tests.py uses common-pattern.py to normalize error messages to things
like `$ENOENT$`. Implement that behavior.

Reviewed By: xavierd

Differential Revision: D16209208

fbshipit-source-id: 3e609cc16442f80b844264f93dce9ea46517458d
2019-07-17 21:11:28 -07:00
Jun Wu
27908b883c testutil/dott: initial framework
Summary:
The testutil/dott module is to be "somehow" compatible with ".t" tests.
At its core, it emulates "bash" syntax using Python functions.

This diff adds the core "sh" syntax to call into Python functions.
The test code can be written as:

  from testutil.dott import sh

  sh % "echo foo" == "foo\n"
  sh % "echo remotefilelog" > ".hg/requires"
  sh % "cat" << "[extensions]\nrebase=" > ".hg/hgrc"

This is similar to ".t" test:

  $ echo foo
  foo
  $ echo remotefilelog > .hg/requires
  $ cat << EOF > .hg/hgrc
  > [extensions]
  > rebase=
  > EOF

And is compat even after black formatting.

Reviewed By: xavierd

Differential Revision: D16172901

fbshipit-source-id: 7bb666e7e1621536ffdd6516542a468ac419d80a
2019-07-17 21:11:28 -07:00
Jun Wu
2232a26c42 testutil: add "eq" assertion with autofix ability
Summary: The "eq" API is similar to `assert_eq!` in Rust, with the autofix ability.

Reviewed By: xavierd

Differential Revision: D16168821

fbshipit-source-id: bf7dcfd24c42dee30c54aeeaa71eccab78a8f0f6
2019-07-17 21:11:27 -07:00
Jun Wu
cffb710c1f hintutil: clear state after printing them out
Summary: Clear hintutil state after each command invocation so the code path can be reused.

Reviewed By: xavierd

Differential Revision: D16209207

fbshipit-source-id: 7c0ac4352aafa4c2b1fcd1c75e7f2a69daea0b47
2019-07-17 21:11:27 -07:00
Jun Wu
3ed818ac63 ui: add fast paths for edit
Summary: For cases where the editor is "cat" or "cat>", avoid shelling out.

Reviewed By: xavierd

Differential Revision: D16209206

fbshipit-source-id: 1ee28e56a5e40a9b7c17dc1f9fbd7599e4b1b0d9
2019-07-17 21:11:27 -07:00
Jun Wu
dd1b0586c0 testutil: add a utility to calculate argument positions
Summary:
The utility is used by a later change which provides the "autofix" feature for
Python code.

Reviewed By: xavierd

Differential Revision: D16168823

fbshipit-source-id: feb55a9e6ba5e78ad0f490cadeeafbcc1306e8ca
2019-07-17 21:11:27 -07:00
Jun Wu
71f0a58960 check-code: scope a subset of rules to edenscm
Summary:
Some of the check-code rules assume `mercurial.util` or `ui` is available,
which is not true for all Python scripts. Move those rules to a separate
set of patterns that only applies to `edenscm`.

Reviewed By: xavierd

Differential Revision: D16344714

fbshipit-source-id: 9cb5751887b8b2e1277cef617b47d520525a3cc2
2019-07-17 21:11:26 -07:00
Jun Wu
ea5d939ece indexedlog: fix an unsound unsafe use
Summary:
The difference between `&'static T` and `*const T` is, the former implies the
LLVM "noalias" intrinsic, which is not correct in this use. Replace it with
`*const T`.

Reviewed By: xavierd

Differential Revision: D16297631

fbshipit-source-id: 3052cb084968e504de1d2629540bf8fb9e58e17e
2019-07-17 19:33:55 -07:00
Jun Wu
750bd29a06 setup: rename IPython.zip to edenscmdeps.zip
Summary: IPython.zip contains not only just IPyhton dependencies. Rename it to clarify.

Reviewed By: xavierd

Differential Revision: D16167579

fbshipit-source-id: c7bbd24c8efd58ed322bfb4520b9b2454b919978
2019-07-17 17:35:52 -07:00
Xavier Deguillard
7a3c5da48f revisionstore: ensure no loops are added to the historypack
Summary:
We've had issues in the perforce and svn converter where a node's parent was
itself, causing mayhem. Durham fixed this (D16189602) in the python code, but
since the python code is going away very soon, let's have this check in the
Rust code too.

Reviewed By: quark-zju

Differential Revision: D16346625

fbshipit-source-id: 54cec11a7822510ede91824eaf8663a9c1b7a0aa
2019-07-17 17:03:01 -07:00
Jun Wu
02185ba1ec bindings: expose vlq encoding APIs
Summary: This enables VLQ encoding in Python.

Reviewed By: sfilipco

Differential Revision: D16294466

fbshipit-source-id: 7a5f3b521f19842a09724eaef757d7019bf548a2
2019-07-17 16:37:29 -07:00
Jun Wu
15dd9c54fd bindings: add basic bindings around dag
Summary:
This exposes a subset of "dag" features to the Python world so we can actually
use it to build segments, and calculate common ancestors.

It does not expose the "SpanSet" concept yet, although that's planned.

Reviewed By: sfilipco

Differential Revision: D15404620

fbshipit-source-id: d05143f7b88bb398e96b5723a38d246ff02c1050
2019-07-17 16:37:29 -07:00