From 567d6aa43bf3e406c676ad3158a5ce3782d9fe9d Mon Sep 17 00:00:00 2001 From: Arnav Gupta Date: Sun, 24 Jan 2016 21:56:22 +0530 Subject: roomservice: check uniqueness by path, not name For repos such as hardware/qcom/media-caf we are using the same name with different branches for different paths. for eg. CyanogenMod/hardware_qcom_media-caf(branch:8994) - fetch to : /hardware/qcom/media-caf/8994 CyanogenMod/hardware_qcom_media-caf(branch:8960) - fetch to : /hardware/qcom/media-caf/8960 For such cases roomservice won't pick up a new path if one already exists. We should check for unique by target path instead. Change-Id: I89e561ca9a2d57ede8cf782f431a8e829ea47ee5 Signed-off-by: Arnav Gupta --- tools/roomservice.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/roomservice.py b/tools/roomservice.py index ee8e5d8..a1b69cd 100755 --- a/tools/roomservice.py +++ b/tools/roomservice.py @@ -87,9 +87,9 @@ if not depsonly: local_manifests = r'.repo/local_manifests' if not os.path.exists(local_manifests): os.makedirs(local_manifests) -def exists_in_tree(lm, repository): +def exists_in_tree(lm, path): for child in lm.getchildren(): - if child.attrib['name'].endswith(repository): + if child.attrib['path'] == path: return True return False @@ -139,7 +139,7 @@ def get_from_manifest(devicename): return None -def is_in_manifest(projectname): +def is_in_manifest(projectpath): try: lm = ElementTree.parse(".repo/local_manifests/roomservice.xml") lm = lm.getroot() @@ -147,8 +147,8 @@ def is_in_manifest(projectname): lm = ElementTree.Element("manifest") for localpath in lm.findall("project"): - if localpath.get("name") == projectname: - return 1 + if localpath.get("path") == projectpath: + return True ## Search in main manifest, too try: @@ -158,10 +158,10 @@ def is_in_manifest(projectname): lm = ElementTree.Element("manifest") for localpath in lm.findall("project"): - if localpath.get("name") == projectname: - return 1 + if localpath.get("path") == projectpath: + return True - return None + return False def add_to_manifest(repositories, fallback_branch = None): try: @@ -173,8 +173,9 @@ def add_to_manifest(repositories, fallback_branch = None): for repository in repositories: repo_name = repository['repository'] repo_target = repository['target_path'] - if exists_in_tree(lm, repo_name): - print('CyanogenMod/%s already exists' % (repo_name)) + print('Checking if %s is fetched from %s' % (repo_target, repo_name)) + if is_in_manifest(repo_target): + print('CyanogenMod/%s already fetched to %s' % (repo_name, repo_target)) continue print('Adding dependency: CyanogenMod/%s -> %s' % (repo_name, repo_target)) @@ -210,7 +211,7 @@ def fetch_dependencies(repo_path, fallback_branch = None): fetch_list = [] for dependency in dependencies: - if not is_in_manifest("CyanogenMod/%s" % dependency['repository']): + if not is_in_manifest(dependency['target_path']): fetch_list.append(dependency) syncable_repos.append(dependency['target_path']) -- cgit v1.1