def create_components_from_branches(branches=None):

    if branches is None:
        branches = os.listdir('/srv/lava/branches')

    components = {}

    for branch_name in branches:
        component = Component(branch_name)
        branch = bzrlib.branch.Branch.open(
            os.path.join('/srv/lava/branches', branch_name))
        branch.lock_read()
        try:
            branch_tags = branch.tags.get_tag_dict()
            revno2release = {}
            release2revno = {}
            for tag, revid in branch_tags.iteritems():
                if tag.startswith('release-'):
                    try:
                        revno = branch.revision_id_to_dotted_revno(revid)
                    except bzrlib.errors.NoSuchRevision:
                        pass
                    else:
                        if len(revno) > 1:
                            continue
                        revno2release[revno[0]] = tag[len('release-'):]
                        release2revno[tag[len('release-'):]] = revno[0]
            if revno2release:
                component.released_revno = max(revno2release)
                component.last_release = revno2release[max(revno2release)]
            else:
                component.released_revno = None
            component.release2revno = release2revno
            component.revno2release = revno2release
            revno, revid = branch.last_revision_info()
            component.tip_revno = revno
            component.tip_revid = revid
            mainline_revs = []
            unreleased_revs = []
            while True:
                rev = branch.repository.get_revision(revid)
                if rev.message.strip() != 'post release bump':
                    if component.released_revno and revno > component.released_revno:
                        unreleased_revs.append((rev, revno))
                    mainline_revs.append((rev, revno))
                if not rev.parent_ids:
                    break
                revid = rev.parent_ids[0]
                revno -= 1
            component.unreleased_revisions = unreleased_revs
            component.mainline_revs = mainline_revs
        finally:
            branch.unlock()
        components[branch_name] = component

    return components
def create_components_from_branches(branches=None):

    if branches is None:
        branches = os.listdir('/srv/lava/branches')

    components = {}

    for branch_name in branches:
        component = Component(branch_name)
        branch = bzrlib.branch.Branch.open(
            os.path.join('/srv/lava/branches', branch_name))
        branch.lock_read()
        try:
            branch_tags = branch.tags.get_tag_dict()
            revno2release = {}
            release2revno = {}
            for tag, revid in branch_tags.iteritems():
                if tag.startswith('release-'):
                    try:
                        revno = branch.revision_id_to_dotted_revno(revid)
                    except bzrlib.errors.NoSuchRevision:
                        pass
                    else:
                        if len(revno) > 1:
                            continue
                        revno2release[revno[0]] = tag[len('release-'):]
                        release2revno[tag[len('release-'):]] = revno[0]
            if revno2release:
                component.released_revno = max(revno2release)
                component.last_release = revno2release[max(revno2release)]
            else:
                component.released_revno = None
            component.release2revno = release2revno
            component.revno2release = revno2release
            revno, revid = branch.last_revision_info()
            component.tip_revno = revno
            component.tip_revid = revid
            mainline_revs = []
            unreleased_revs = []
            while True:
                rev = branch.repository.get_revision(revid)
                if rev.message.strip() != 'post release bump':
                    if component.released_revno and revno > component.released_revno:
                        unreleased_revs.append((rev, revno))
                    mainline_revs.append((rev, revno))
                if not rev.parent_ids:
                    break
                revid = rev.parent_ids[0]
                revno -= 1
            component.unreleased_revisions = unreleased_revs
            component.mainline_revs = mainline_revs
        finally:
            branch.unlock()
        components[branch_name] = component

    return components
Exemplo n.º 3
0
def do_list(parser):
    master_branch = None

    for name in branches:
        if not master_branch:
            master_branch = name
        print "? refs/heads/%s" % name

    branch = get_remote_branch(master_branch)
    branch.lock_read()
    for tag, revid in branch.tags.get_tag_dict().items():
        try:
            branch.revision_id_to_dotted_revno(revid)
        except bzrlib.errors.NoSuchRevision:
            continue
        if not ref_is_valid(tag):
            continue
        print "? refs/tags/%s" % tag
        tags[tag] = revid
    branch.unlock()

    print "@refs/heads/%s HEAD" % master_branch
    print
Exemplo n.º 4
0
def do_list(parser):
    master_branch = None

    for name in branches:
        if not master_branch:
            master_branch = name
        print "? refs/heads/%s" % name

    branch = get_remote_branch(master_branch)
    branch.lock_read()
    for tag, revid in branch.tags.get_tag_dict().items():
        try:
            branch.revision_id_to_dotted_revno(revid)
        except bzrlib.errors.NoSuchRevision:
            continue
        if not ref_is_valid(tag):
            continue
        print "? refs/tags/%s" % tag
        tags[tag] = revid
    branch.unlock()

    print "@refs/heads/%s HEAD" % master_branch
    print