From 2b30e3aabafa43c224cb6d57dc232d78b28a4901 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Fri, 5 Oct 2012 12:37:58 +0200 Subject: Use reference also for manifest git When running 'repo init --reference=', the mirror will be used for all projects except the manifest project. This is because the _InitGitDir function uses the 'repo.reference' git config value specified in the manifest git, which has no effect when creating the manifest git as that value will be set after the git has been successfully cloned. Information about where the manifest git is located on the server is only known when performing the 'repo init', so that information has to be provided when cloning the git in order for it to set up a proper mapping. Change-Id: I47a2c8b3267a4065965058718ce1def4ecb34d5a Signed-off-by: Chirayu Desai --- subcmds/init.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'subcmds/init.py') diff --git a/subcmds/init.py b/subcmds/init.py index 29730cc4..1f915268 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -19,6 +19,15 @@ import platform import re import shutil import sys +try: + # For python3 + import urllib.parse +except ImportError: + # For python2 + import imp + import urlparse + urllib = imp.new_module('urllib') + urllib.parse = urlparse.urlparse from color import Coloring from command import InteractiveCommand, MirrorSafeCommand @@ -135,7 +144,19 @@ to update the working directory files. if not opt.quiet: print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url), file=sys.stderr) - m._InitGitDir() + + # The manifest project object doesn't keep track of the path on the + # server where this git is located, so let's save that here. + mirrored_manifest_git = None + if opt.reference: + manifest_git_path = urllib.parse(opt.manifest_url).path[1:] + mirrored_manifest_git = os.path.join(opt.reference, manifest_git_path) + if not mirrored_manifest_git.endswith(".git"): + mirrored_manifest_git += ".git" + if not os.path.exists(mirrored_manifest_git): + mirrored_manifest_git = os.path.join(opt.reference + '/.repo/manifests.git') + + m._InitGitDir(mirror_git=mirrored_manifest_git) if opt.manifest_branch: m.revisionExpr = opt.manifest_branch -- cgit v1.2.3-54-g00ecf