Commit Graph

11 Commits

Author SHA1 Message Date
Xavier Deguillard
c5957985a3 use pycompat.range instead of xrange
Summary: The xrange function doesn't exist in python3, use the pycompat version instead.

Reviewed By: ikostia

Differential Revision: D17607522

fbshipit-source-id: c7b992071ad7933372033892ca99e240aa11ccba
2019-09-26 15:29:48 -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
df81aa9464 simplecache: fix check-code
Summary: As the title.

Reviewed By: xavierd

Differential Revision: D16039564

fbshipit-source-id: e4388347b4e93f30cf1e21de90b4c8756fe0e6d5
2019-06-27 18:07:41 -07:00
Jun Wu
5003daafa0 simplecache: respect TESTTMP
Summary:
By default, simplecache puts its local cache in a global location that persists
across test runs. That can cause surprises. Change the location to be inside
$TESTTMP under tests.

Reviewed By: xavierd

Differential Revision: D16036296

fbshipit-source-id: c73b573b87d49798f4ad146a1c0a559f5d94caf1
2019-06-27 13:10:20 -07:00
Xavier Deguillard
f00c1f1a70 simplecache: fix infinite loop when reading from memcache socket
Summary:
In S179901, we've seen a couple of instances of `hg status` consuming as much
memory as they could until getting OOM killed. Looking at backtraces for these
processes (P67246356) the code spins trying to read data from memcache. The
connection is however closed and therefore `recv` returns an empty string,
which is then added to a list and the `recv` is retried again.

Reviewed By: kulshrax

Differential Revision: D15947154

fbshipit-source-id: f1216e26b0ce159377ff8e82bedc13a7cc3d0444
2019-06-21 14:17:27 -07:00
Durham Goode
8d31ac8424 simplecache: add checksum to simplecache values
Summary:
We're encountering an issue that I think is caused by invalid data
coming back from memcache, possibly due to our recently introduced connection
reusing. Let's add some checksums to verify that the data we put in is identical
to the data we get out for a given key.

Reviewed By: kulshrax

Differential Revision: D14141683

fbshipit-source-id: 206b51b862db7d54def02f5310b90f473d5a0d03
2019-02-20 13:56:33 -08:00
Liubov Dmitrieva
ca7f631006 lazy connection open for memcache has an issue with SIGPIPE
Summary: My earlier diff broke master, this is the fix.

Reviewed By: markbt

Differential Revision: D14005894

fbshipit-source-id: 6ce43913fb501791592512f2f12cd67ef27f0457
2019-02-08 09:44:06 -08:00
Liubov Dmitrieva
638959056d simplecache - reuse the connection to memcache
Summary:
reuse the connection for other requests
I made it global

Reviewed By: quark-zju

Differential Revision: D13964705

fbshipit-source-id: ed759e36f15b91a838dc2c20b58384ae54ad5d48
2019-02-07 04:59:48 -08:00
Mark Thomas
b44e2103d7 simplecache: don't use memcache in tests
Summary:
The simplecache test attempts to connect to a memcache instance on localhost.
This means the test fails if a memcache instance is not available.

Remove the use of memcache in the test.  We still test local files, and assume
that memcache itself works.

Also corrupt the correct key when testing corruption handling, and document the
config options.

Reviewed By: quark-zju

Differential Revision: D13818471

fbshipit-source-id: 6ca7f575aa813f95773144be5337796f029ffd90
2019-02-01 19:19:36 -08:00
Jun Wu
9dc21f8d0b codemod: import from the edenscm package
Summary:
D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`.
That has nasty problems if both `import mercurial` and
`import edenscm.mercurial` are used, because Python would think `mercurial.foo`
and `edenscm.mercurial.foo` are different modules so code like
`try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)`
would fail to handle the `edenscm.mercurial` version. There are also some
module-level states (ex. `extensions._extensions`) that would cause trouble if
they have multiple versions in a single process.

Change imports to use the `edenscm` so ideally the `mercurial` is no longer
imported at all. Add checks in extensions.py to catch unexpected extensions
importing modules from the old (wrong) locations when running tests.

Reviewed By: phillco

Differential Revision: D13868981

fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
2019-01-29 17:25:32 -08:00
Jun Wu
c12e300bb8 codemod: move Python packages to edenscm
Summary:
Move top-level Python packages `mercurial`, `hgext` and `hgdemandimport` to
a new top-level package `edenscm`. This allows the Python packages provided by
the upstream Mercurial to be installed side-by-side.

To maintain compatibility, `edenscm/` gets added to `sys.path` in
`mercurial/__init__.py`.

Reviewed By: phillco, ikostia

Differential Revision: D13853115

fbshipit-source-id: b296b0673dc54c61ef6a591ebc687057ff53b22e
2019-01-28 18:35:41 -08:00