Mercurial > hg
changeset 29506:2550604f5ec7
share: don't recreate the source repo each time
Previously, every time you asked for the source repo of a shared working copy it
would recreate the repo object, which required calling reposetup. With certain
extension enabled, this can be quite expensive, and it can happen many times
(for instance, share attaches a post transaction hook to update bookmarks that
triggers this).
The fix is to just cache the repo object instead of constantly recreating it.
author | Durham Goode <durham@fb.com> |
---|---|
date | Mon, 11 Jul 2016 13:40:02 -0700 |
parents | 2dce3f96ad7b |
children | 97dcdcf75f4f |
files | hgext/share.py |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/share.py Mon Jul 11 10:44:18 2016 +0200 +++ b/hgext/share.py Mon Jul 11 13:40:02 2016 -0700 @@ -157,10 +157,15 @@ if repo.sharedpath == repo.path: return None + if util.safehasattr(repo, 'srcrepo') and repo.srcrepo: + return repo.srcrepo + # the sharedpath always ends in the .hg; we want the path to the repo source = repo.vfs.split(repo.sharedpath)[0] srcurl, branches = parseurl(source) - return repository(repo.ui, srcurl) + srcrepo = repository(repo.ui, srcurl) + repo.srcrepo = srcrepo + return srcrepo def getbkfile(orig, repo): if _hassharedbookmarks(repo):