예제 #1
0
def command(args):
    import sys

    from sr.tools.trac import Ticket, TracProxy, WrongServer

    try:
        server = TracProxy()
    except WrongServer:
        print("Error: The specified server is not a Trac instance",
              file=sys.stderr)
        sys.exit(1)

    t = Ticket(args.ticket, server)

    for n in args.deps:
        t.deps.remove(n)

    if args.m is not None:
        msg = args.m
        msg += "\n\n"
    else:
        msg = ""

    msg += "Removing dependencies:"
    for n in args.deps:
        msg += "\n * #{0}".format(n)

    updated = t.cleanup(dry_run=args.dry_run, msg=msg)

    if updated:
        if args.dry_run:
            print("Ticket would have been updated if not for --dry-run.")
        else:
            print("Ticket updated.")
예제 #2
0
def command(args):
    import sys

    from sr.tools.trac import Ticket, TracProxy, WrongServer

    try:
        server = TracProxy()
    except WrongServer:
        print("Error: The specified server is not a Trac instance",
              file=sys.stderr)
        sys.exit(1)

    t = Ticket(args.ticket, server)

    for n in args.deps:
        t.deps.remove(n)

    if args.m is not None:
        msg = args.m
        msg += "\n\n"
    else:
        msg = ""

    msg += "Removing dependencies:"
    for n in args.deps:
        msg += "\n * #{0}".format(n)

    updated = t.cleanup(dry_run=args.dry_run, msg=msg)

    if updated:
        if args.dry_run:
            print("Ticket would have been updated if not for --dry-run.")
        else:
            print("Ticket updated.")
예제 #3
0
def command(args):
    import sys

    from sr.tools.trac import Ticket, TracProxy, WrongServer

    try:
        server = TracProxy()
    except WrongServer:
        print("Error: The specified server is not a Trac instance",
              file=sys.stderr)
        sys.exit(1)

    t = Ticket(args.ticket, server)

    current = set(t.deps)
    new = set(args.deps)

    to_add = new - current
    already = new - to_add

    if len(already):
        for n in already:
            print('#{0} is already a dep of #{1}'.format(n, args.ticket),
                  file=sys.stderr)

    if len(to_add) == 0:
        sys.exit("No new dependencies to add to #{0}".format(args.ticket))

    t.deps += to_add

    if args.m is not None:
        msg = args.m
        msg += "\n\n"
    else:
        msg = ""

    msg += "Adding dependencies:"
    for n in to_add:
        msg += "\n * #{0}".format(n)

    updated = t.cleanup(dry_run=args.dry_run, msg=msg)

    if updated:
        if args.dry_run:
            print("Ticket would have been updated if not for --dry-run.")
        else:
            print("Ticket updated.")
예제 #4
0
def command(args):
    import sys

    from sr.tools.trac import Ticket, TracProxy, WrongServer

    try:
        server = TracProxy()
    except WrongServer:
        print("Error: The specified server is not a Trac instance",
              file=sys.stderr)
        sys.exit(1)

    t = Ticket(args.ticket, server)

    current = set(t.deps)
    new = set(args.deps)

    to_add = new - current
    already = new - to_add

    if len(already):
        for n in already:
            print('#{0} is already a dep of #{1}'.format(n, args.ticket),
                  file=sys.stderr)

    if len(to_add) == 0:
        sys.exit("No new dependencies to add to #{0}".format(args.ticket))

    t.deps += to_add

    if args.m is not None:
        msg = args.m
        msg += "\n\n"
    else:
        msg = ""

    msg += "Adding dependencies:"
    for n in to_add:
        msg += "\n * #{0}".format(n)

    updated = t.cleanup(dry_run=args.dry_run, msg=msg)

    if updated:
        if args.dry_run:
            print("Ticket would have been updated if not for --dry-run.")
        else:
            print("Ticket updated.")
예제 #5
0
def command(args):
    import sys

    from sr.tools.trac import Ticket, TracProxy, WrongServer

    try:
        server = TracProxy()
    except WrongServer:
        print("Error: The specified server is not a Trac instance",
              file=sys.stderr)
        sys.exit(1)

    tickets = {}

    done = set()
    todo = set([args.ticket])

    print("digraph G {")
    print("rankdir=LR;")

    while len(todo):
        for num in list(todo):
            t = Ticket(num, server)
            tickets[num] = t

            for dep in t.deps:
                if dep not in done:
                    todo.add(dep)

                print("{0} -> {1};".format(dep, num))

            done.add(num)
            todo.remove(num)

    for num, ticket in tickets.items():
        if args.summaries:
            label = "#{}: {}".format(num, ticket.summary)
        else:
            label = "#{}".format(num)
        props = {"label": label, "URL": ticket.url}

        if ticket.status == "closed":
            props["style"] = "filled"
            props["color"] = "grey"

        propstr = ""
        for name, val in props.items():
            propstr += """{0}="{1}" """.format(name, val)

        print("{0} [{1}]".format(num, propstr))

    print("}")
예제 #6
0
def command(args):
    import sys

    from sr.tools.trac import Ticket, TracProxy, WrongServer

    try:
        server = TracProxy()
    except WrongServer:
        print("Error: The specified server is not a Trac instance",
              file=sys.stderr)
        sys.exit(1)

    search_ticket = args.ticket

    query = "description=~{}".format(search_ticket)
    matches = server.ticket.query(query)

    deps = []
    refs = []
    for num in matches:
        t = Ticket(num, server)
        if search_ticket in t.deps:
            deps.append(t)
        else:
            refs.append(t)

    if len(deps):
        print("The following tickets depend on {}:".format(search_ticket))
        for t in deps:
            print("\t{} [{}]".format(t, t.url))
    else:
        print("Nothing depends on {}".format(search_ticket))

    if len(refs):
        print("The following tickets appear to reference {}:".format(
            search_ticket))
        for t in refs:
            print("\t{} [{}]".format(t, t.url))