Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 567d6aa4 authored by Arnav Gupta's avatar Arnav Gupta Committed by Gerrit Code Review
Browse files

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: default avatarArnav Gupta <championswimmer@gmail.com>
parent e129b5e7
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -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'])