mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
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
This commit is contained in:
parent
50d1fa694c
commit
5f5c2d2eae
@ -54,6 +54,10 @@ template.
|
||||
# revision number.
|
||||
svnrevinteroperation = False
|
||||
|
||||
# If this configuration is true, we use a cached mapping from `globalrev ->
|
||||
# hash` to enable fast lookup of commits based on the globalrev. This
|
||||
# mapping can be built using the `updateglobalrevmeta` command.
|
||||
fastlookup = False
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
@ -79,6 +83,7 @@ from .pushrebase import isnonpushrebaseblocked
|
||||
configtable = {}
|
||||
configitem = registrar.configitem(configtable)
|
||||
configitem("format", "useglobalrevs", default=False)
|
||||
configitem("globalrevs", "fastlookup", default=False)
|
||||
configitem("globalrevs", "onlypushrebase", default=True)
|
||||
configitem("globalrevs", "readonly", default=False)
|
||||
configitem("globalrevs", "reponame", default=None)
|
||||
@ -336,6 +341,12 @@ def _lookupglobalrev(repo, grev):
|
||||
commitglobalrev = changelogrevision(rev).extra.get(EXTRASGLOBALREVKEY)
|
||||
return commitglobalrev is not None and int(commitglobalrev) == grev
|
||||
|
||||
if repo.ui.configbool("globalrevs", "fastlookup"):
|
||||
globalrevmap = _globalrevmap(repo)
|
||||
hgnode = globalrevmap.gethgnode(str(grev))
|
||||
if hgnode:
|
||||
return [hgnode]
|
||||
|
||||
matchedrevs = []
|
||||
for rev in repo.revs("reverse(all())"):
|
||||
if matchglobalrev(rev):
|
||||
|
@ -674,3 +674,28 @@ repository.
|
||||
$ getglobalrev 'm5004'
|
||||
abort: unknown revision 'm5004'!
|
||||
|
||||
|
||||
|
||||
- Test that the lookup works as expected when the configuration
|
||||
`globalrevs.fastlookup` is true.
|
||||
|
||||
$ cd ../client
|
||||
$ setconfig globalrevs.fastlookup=True
|
||||
|
||||
$ testlookup
|
||||
|
||||
$ getglobalrev 'globalrev(4999)'
|
||||
|
||||
|
||||
$ getglobalrev 'globalrev(-1)'
|
||||
|
||||
|
||||
$ hg updateglobalrevmeta
|
||||
|
||||
$ testlookup
|
||||
|
||||
$ getglobalrev 'globalrev(4999)'
|
||||
|
||||
|
||||
$ getglobalrev 'globalrev(-1)'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user