Esempio 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
Esempio 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
def obsolete_old_patches(ui, api_server, token, bugid, bugzilla, filename, ignore_id, pre_hook=None):
    bug = None
    req = bz.get_attachments(api_server, token, bugid)
    try:
        bug = json.load(urlopen(ui, req))
    except Exception, e:
        raise util.Abort(_("Could not load info for bug %s: %s") % (bug, str(e)))