diff options
-rw-r--r-- | project.py | 9 | ||||
-rw-r--r-- | subcmds/init.py | 23 |
2 files changed, 27 insertions, 5 deletions
@@ -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 | |||
19 | import re | 19 | import re |
20 | import shutil | 20 | import shutil |
21 | import sys | 21 | import sys |
22 | try: | ||
23 | # For python3 | ||
24 | import urllib.parse | ||
25 | except ImportError: | ||
26 | # For python2 | ||
27 | import imp | ||
28 | import urlparse | ||
29 | urllib = imp.new_module('urllib') | ||
30 | urllib.parse = urlparse.urlparse | ||
22 | 31 | ||
23 | from color import Coloring | 32 | from color import Coloring |
24 | from command import InteractiveCommand, MirrorSafeCommand | 33 | from 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 |