summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Boivie <victor.boivie@sonymobile.com>2012-10-05 12:37:58 +0200
committerChirayu Desai <cdesai@cyanogenmod.org>2013-05-12 17:49:28 +0530
commit2b30e3aabafa43c224cb6d57dc232d78b28a4901 (patch)
treeba6fe5ee439091371977cd3db36b32b41c6b4e9d
parent793f90cdc0cffc3ade6acdc544e315fbd54cbb0b (diff)
downloadgit-repo-2b30e3aabafa43c224cb6d57dc232d78b28a4901.tar.gz
Use reference also for manifest git
When running 'repo init --reference=<mirror>', 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 <cdesai@cyanogenmod.org>
-rw-r--r--project.py9
-rw-r--r--subcmds/init.py23
2 files changed, 27 insertions, 5 deletions
diff --git a/project.py b/project.py
index 516d3b6c..effe75c4 100644
--- a/project.py
+++ b/project.py
@@ -1854,16 +1854,17 @@ class Project(object):
1854 if GitCommand(self, cmd).Wait() != 0: 1854 if GitCommand(self, cmd).Wait() != 0:
1855 raise GitError('%s merge %s ' % (self.name, head)) 1855 raise GitError('%s merge %s ' % (self.name, head))
1856 1856
1857 def _InitGitDir(self): 1857 def _InitGitDir(self, mirror_git=None):
1858 if not os.path.exists(self.gitdir): 1858 if not os.path.exists(self.gitdir):
1859 os.makedirs(self.gitdir) 1859 os.makedirs(self.gitdir)
1860 self.bare_git.init() 1860 self.bare_git.init()
1861 1861
1862 mp = self.manifest.manifestProject 1862 mp = self.manifest.manifestProject
1863 ref_dir = mp.config.GetString('repo.reference') 1863 ref_dir = mp.config.GetString('repo.reference') or ''
1864 1864
1865 if ref_dir: 1865 if ref_dir or mirror_git:
1866 mirror_git = os.path.join(ref_dir, self.name + '.git') 1866 if not mirror_git:
1867 mirror_git = os.path.join(ref_dir, self.name + '.git')
1867 repo_git = os.path.join(ref_dir, '.repo', 'projects', 1868 repo_git = os.path.join(ref_dir, '.repo', 'projects',
1868 self.relpath + '.git') 1869 self.relpath + '.git')
1869 1870
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
19import re 19import re
20import shutil 20import shutil
21import sys 21import sys
22try:
23 # For python3
24 import urllib.parse
25except ImportError:
26 # For python2
27 import imp
28 import urlparse
29 urllib = imp.new_module('urllib')
30 urllib.parse = urlparse.urlparse
22 31
23from color import Coloring 32from color import Coloring
24from command import InteractiveCommand, MirrorSafeCommand 33from command import InteractiveCommand, MirrorSafeCommand
@@ -135,7 +144,19 @@ to update the working directory files.
135 if not opt.quiet: 144 if not opt.quiet:
136 print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url), 145 print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url),
137 file=sys.stderr) 146 file=sys.stderr)
138 m._InitGitDir() 147
148 # The manifest project object doesn't keep track of the path on the
149 # server where this git is located, so let's save that here.
150 mirrored_manifest_git = None
151 if opt.reference:
152 manifest_git_path = urllib.parse(opt.manifest_url).path[1:]
153 mirrored_manifest_git = os.path.join(opt.reference, manifest_git_path)
154 if not mirrored_manifest_git.endswith(".git"):
155 mirrored_manifest_git += ".git"
156 if not os.path.exists(mirrored_manifest_git):
157 mirrored_manifest_git = os.path.join(opt.reference + '/.repo/manifests.git')
158
159 m._InitGitDir(mirror_git=mirrored_manifest_git)
139 160
140 if opt.manifest_branch: 161 if opt.manifest_branch:
141 m.revisionExpr = opt.manifest_branch 162 m.revisionExpr = opt.manifest_branch