Ejemplo n.º 1
0
def obsolete_old_patches(ui, auth, bugid, bugzilla, filename, ignore_id, pre_hook=None):
    try:
        bug_attachments = bz.get_attachments(auth, bugid)
        attachments = bug_attachments['bugs'][bugid]
    except Exception as e:
        raise util.Abort(e.message)

    patches = [p for p in attachments
               if (p["is_patch"]
                   and not p["is_obsolete"]
                   and p["file_name"] == filename
                   and int(p["id"]) != int(ignore_id))]
    if not patches:
        return True

    for p in patches:
        #TODO: "?last_change_time=" + p["last_change_time"] to avoid conflicts?
        attachment_url = urlparse.urljoin(bugzilla, "attachment.cgi?id=%s" % (p['id']))
        if pre_hook and not pre_hook(url=attachment_url, filename=p['file_name'], description=p["description"]):
            continue

        try:
            bz.obsolete_attachment(auth, p)
        except Exception as e:
            raise util.Abort(e.message)

    return True
Ejemplo n.º 2
0
def obsolete_old_patches(ui, auth, bugid, bugzilla, filename, ignore_id, pre_hook=None):
    try:
        bug_attachments = bz.get_attachments(auth, bugid)
        attachments = bug_attachments['bugs'][bugid]
    except Exception as e:
        raise util.Abort(e.message)

    patches = [p for p in attachments
               if (p["is_patch"]
                   and not p["is_obsolete"]
                   and p["file_name"] == filename
                   and int(p["id"]) != int(ignore_id))]
    if not patches:
        return True

    for p in patches:
        #TODO: "?last_change_time=" + p["last_change_time"] to avoid conflicts?
        attachment_url = urlparse.urljoin(bugzilla, "attachment.cgi?id=%s" % (p['id']))
        if pre_hook and not pre_hook(url=attachment_url, filename=p['file_name'], description=p["description"]):
            continue

        try:
            bz.obsolete_attachment(auth, p)
        except Exception as e:
            raise util.Abort(e.message)

    return True
    patches = [p
               for p in bug["attachments"]
               if (p["is_patch"]
                   and not p["is_obsolete"]
                   and p["file_name"] == filename
                   and int(p["id"]) != int(ignore_id))]
    if not len(patches):
        return True

    for p in patches:
        #TODO: "?last_change_time=" + p["last_change_time"] to avoid conflicts?
        attachment_url = urlparse.urljoin(bugzilla, "attachment.cgi?id=%s" % (p['id']))
        if pre_hook and not pre_hook(url=attachment_url, filename=p['file_name'], description=p["description"]):
            continue

        req = bz.obsolete_attachment(api_server, token, p)
        try:
            json.load(urlopen(ui, req))
        except Exception, e:
            raise util.Abort(_("Could not update attachment %s: %s") % (p["id"], str(e)))

    return True


def find_reviewers(ui, api_server, user_cache_filename, token, search_strings):
    cache = bzauth.load_user_cache(ui, api_server, user_cache_filename)
    section = api_server

    search_results = []
    for search_string in search_strings:
        name = cache.get(section, search_string)