Commit Graph

13 Commits

Author SHA1 Message Date
Saurabh Singh
e79d8cb772 globalrevs: fail quickly for invalid searches during globalrev fast lookup
Summary:
Currently, if you lookup a globalrev which does not exist in the
repository, it leads to a linear scan of the entire changelog even while using
the globalrev based fast commit lookup. This commit speeds up the same by
relying on the indexing information.

Differential Revision: D14726937

fbshipit-source-id: 076ad8608aa656075dcb2c1287502ffe93bed851
2019-04-02 11:23:19 -07:00
Saurabh Singh
e855940cb8 globalrevs: refactor globalrevmap to include repo object as a class member
Summary:
This is just pending feedback from D14694620 which makes the class
interface more cleaner.

Reviewed By: quark-zju

Differential Revision: D14718748

fbshipit-source-id: 032fc25d7e5922aac5f4195eb007bd009822cb86
2019-04-02 08:33:09 -07:00
Saurabh Singh
d7361b3c2b globalrevs: fix failure in globalrev lookup due to incorrect type
Summary:
The type for globalrev during lookup should be an integer instead of a
string after D14694623.

Reviewed By: quark-zju

Differential Revision: D14718749

fbshipit-source-id: eddc49ea0faa61df6ad435db2192fba4f61b0075
2019-04-01 17:42:02 -07:00
Jun Wu
3a121d0fb2 globalrevs: do not have side effect at import time
Summary:
Importing an extension should be side-effect free. Move the patching to uisetup
so they only get executed when the extension is enabled.

Reviewed By: kulshrax

Differential Revision: D14694622

fbshipit-source-id: c2802e0f4d852445dd7900f11d4ede6e58883d94
2019-04-01 14:08:00 -07:00
Jun Wu
9431288ad2 globalrevs: change index format to be more efficient
Summary:
Change the index key from decimal to binary to make the index more compact and
efficient.  Move the binary to the beginning to avoid common prefixes and speed
up lookups.

Reviewed By: singhsrb

Differential Revision: D14694623

fbshipit-source-id: e908d287c1d3559639dbafa39a465f89b8f6f14e
2019-04-01 14:08:00 -07:00
Jun Wu
0014b20bf3 globalrevs: add progress bar for updateglobalrevmeta
Summary: This makes the progress visible.

Reviewed By: singhsrb

Differential Revision: D14694621

fbshipit-source-id: bb80546cb513c423471ba004bf00db7431046bcf
2019-04-01 14:08:00 -07:00
Jun Wu
ba7f94d545 globalrevs: change index logic to cover all commits
Summary:
Use revision numbers to make sure the index contains all commits.
Also include svnrev in the same index. This has multiple benefits:

- Handles svnrev mapping, too. Easier to drop hgsubversion.
- Handles the special commit without globalrev or svnrev gracefully.

It takes about 3 minutes to build the index for www.

I removed code about phases, or heads. The code runs on hg servers
and hg servers (hgsql) have hard dependency on rev numbers.

If we get a chance to migrate away from client-side local changelog,
we'll have Mononoke equivalent commit mapping by that time (or, push
commit mapping work to other teams).

Reviewed By: singhsrb

Differential Revision: D14694620

fbshipit-source-id: 9b74782f4c37b6620ab7168f7c7199d0cc5bc396
2019-04-01 14:08:00 -07:00
Saurabh Singh
5f5c2d2eae globalrev: enable fast commit lookup using globalrev
Summary:
This is a requirement to enable Phabricator migration to a globalrev
based repository. The release engineering team has also expressed interest in a
faster way to lookup the commits using globalrev.

I am just using indexed log for now to enable faster lookup. We might not need
to backfill the indexed log since we mostly care for the newer commits. But if
we do need to, we can do it later.

Reviewed By: quark-zju

Differential Revision: D14687707

fbshipit-source-id: fe02e9a72b9edb57cfd49a294642014c7204c058
2019-04-01 12:43:00 -07:00
Saurabh Singh
50d1fa694c globalrev: introduce command to backfill the globalrev-hg map
Summary:
This is required for the fast commit lookup based on globalrev in
D14687707. This code is heavily inspired from DurhamG's implementation for the
git-hg mapping in the `hggit` extension.

quark-zju has good suggestions for improving this to include the svnrev as well
which can eliminate the requirement for a svnrev-hg mapping in the future. We
can certainly do those in a later iteration.

Reviewed By: quark-zju

Differential Revision: D14674111

fbshipit-source-id: d09d9e65ac0abcafd478c873086898f787398867
2019-04-01 12:43:00 -07:00
Saurabh Singh
a12254fa3f globalrev: use a constant to refer to the globalrev key in the extras
Summary: This is just for convenience and making the code cleaner.

Reviewed By: quark-zju

Differential Revision: D14689470

fbshipit-source-id: 911f49e24a3bb504098537169e9096b080a86535
2019-04-01 11:45:15 -07:00
Saurabh Singh
c305090b83 globalrevs: fix formatting for 'hg help globalrevs'
Summary: See title

Differential Revision: D14332372

fbshipit-source-id: f4a25ae034d66e7c9f8ab6bb44c8919c717e35c2
2019-03-05 16:48:14 -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