Allow mirror to be created in directories specified by 'path' attribute

In some cases, especially when local manifest files exist, users may want
to force the mirrored repositories to be created in folders according to
their 'path' attribute in the manifest, rather than according to the name
of the repositories.

To enable this functionality for specified mirror, add a new attribute
'force-path' for that project in the manifest, set its value to 'true'.

Change-Id: I61df8c987a23d84309b113e7d886ec90c838a6cc
Signed-off-by: Scott Fan <fancp2007@gmail.com>
This commit is contained in:
Scott Fan 2013-02-28 09:34:14 +08:00
parent ede7f12d4a
commit db83b1b5ab
2 changed files with 11 additions and 0 deletions

View File

@ -57,6 +57,7 @@ following DTD:
<!ATTLIST project sync-s CDATA #IMPLIED> <!ATTLIST project sync-s CDATA #IMPLIED>
<!ATTLIST project upstream CDATA #IMPLIED> <!ATTLIST project upstream CDATA #IMPLIED>
<!ATTLIST project clone-depth CDATA #IMPLIED> <!ATTLIST project clone-depth CDATA #IMPLIED>
<!ATTLIST project force-path CDATA #IMPLIED>
<!ELEMENT annotation (EMPTY)> <!ELEMENT annotation (EMPTY)>
<!ATTLIST annotation name CDATA #REQUIRED> <!ATTLIST annotation name CDATA #REQUIRED>
@ -227,6 +228,12 @@ Attribute `clone-depth`: Set the depth to use when fetching this
project. If specified, this value will override any value given project. If specified, this value will override any value given
to repo init with the --depth option on the command line. to repo init with the --depth option on the command line.
Attribute `force-path`: Set to true to force this project to create the
local mirror repository according to its `path` attribute (if supplied)
rather than the `name` attribute. This attribute only applies to the
local mirrors syncing, it will be ignored when syncing the projects in a
client working directory.
Element annotation Element annotation
------------------ ------------------

View File

@ -690,6 +690,10 @@ class XmlManifest(object):
default_groups = ['all', 'name:%s' % name, 'path:%s' % relpath] default_groups = ['all', 'name:%s' % name, 'path:%s' % relpath]
groups.extend(set(default_groups).difference(groups)) groups.extend(set(default_groups).difference(groups))
if self.IsMirror and node.hasAttribute('force-path'):
if node.getAttribute('force-path').lower() in ("yes", "true", "1"):
gitdir = os.path.join(self.topdir, '%s.git' % path)
project = Project(manifest = self, project = Project(manifest = self,
name = name, name = name,
remote = remote.ToRemoteSpec(name), remote = remote.ToRemoteSpec(name),