Allow user to specify git path for mirror repositories. In some case, especially the local_manifest.xml file exists for mirror repos, user may want to specify a different gitdir according to the 'path' attr. For new mirror repos, append the '--force-path' option to the 'repo init --mirror' command. For existing mirror repos, exec command 'git config --file=.repo/manifests.git/config repo.forcepath true' Change-Id: Ib0a639e9014811701fbc4eccc3b03330d9b9f4b2 Signed-off-by: Scott Fan <fancp2007@gmail.com>
diff --git a/manifest_xml.py b/manifest_xml.py index 53f3353..daadc99 100644 --- a/manifest_xml.py +++ b/manifest_xml.py
@@ -311,6 +311,10 @@ def IsMirror(self): return self.manifestProject.config.GetBoolean('repo.mirror') + @property + def ForcePath(self): + return self.manifestProject.config.GetBoolean('repo.forcepath') + def _Unload(self): self._loaded = False self._projects = {} @@ -679,6 +683,9 @@ else: relpath, worktree, gitdir = self.GetSubprojectPaths(parent, path) + if self.IsMirror and self.ForcePath: + gitdir = os.path.join(self.topdir, '%s.git' % path) + default_groups = ['all', 'name:%s' % name, 'path:%s' % relpath] groups.extend(set(default_groups).difference(groups))
diff --git a/repo b/repo index 6b374f7..a50f4ee 100755 --- a/repo +++ b/repo
@@ -156,6 +156,10 @@ dest='mirror', action='store_true', help='create a replica of the remote repositories ' 'rather than a client working directory') +group.add_option('--force-path', + dest='force_path', action='store_true', + help="force the 'path' attr's value as the local mirror directory " + "if specified for each manifest project") group.add_option('--reference', dest='reference', help='location of mirror directory', metavar='DIR')
diff --git a/subcmds/init.py b/subcmds/init.py index 1131260..40d3bc9 100644 --- a/subcmds/init.py +++ b/subcmds/init.py
@@ -84,6 +84,10 @@ dest='mirror', action='store_true', help='create a replica of the remote repositories ' 'rather than a client working directory') + g.add_option('--force-path', + dest='force_path', action='store_true', + help="force the 'path' attr's value as the local mirror directory " + "if specified for each manifest project") g.add_option('--reference', dest='reference', help='location of mirror directory', metavar='DIR') @@ -179,6 +183,8 @@ if opt.mirror: if is_new: m.config.SetString('repo.mirror', 'true') + if opt.force_path: + m.config.SetString('repo.forcepath', 'true') else: print('fatal: --mirror is only supported when initializing a new ' 'workspace.', file=sys.stderr)