Exemplo n.º 1
0
def branch(repos, cfg, newLabel, troveSpecs, makeShadow=False,
           sourceOnly=False, binaryOnly=False, allowEmptyShadow=False,
           info=False, forceBinary=False, ignoreConflicts=False,
           targetFile=None):
    branchType = _getBranchType(binaryOnly, sourceOnly)

    client = conaryclient.ConaryClient(cfg)

    troveSpecs = [ updatecmd.parseTroveSpec(x) for x in troveSpecs ]

    componentSpecs = [ x[0] for x in troveSpecs
                        if (':' in x[0] and x[0].split(':')[1] != 'source')]
    if componentSpecs:
        raise errors.ParseError('Cannot branch or shadow individual components: %s' % ', '.join(componentSpecs))

    result = repos.findTroves(cfg.buildLabel, troveSpecs, cfg.buildFlavor)
    troveList = [ x for x in itertools.chain(*result.itervalues())]

    sigKey = selectSignatureKey(cfg, newLabel)

    if makeShadow:
        dups, cs = client.createShadowChangeSet(newLabel, troveList,
                                                allowEmptyShadow=\
                                                    allowEmptyShadow,
                                                branchType=branchType,
                                                sigKeyId=sigKey)
    else:
        dups, cs = client.createBranchChangeSet(newLabel, troveList,
                                                branchType=branchType,
                                                sigKeyId = sigKey)

    for (name, branch) in dups:
        log.warning("%s already has branch %s", name, branch.asString())

    if not cs:
        return

    if makeShadow:
        branchOps = 'shadows'
    else:
        branchOps = 'branches'

    hasBinary = False
    for trvCs in cs.iterNewTroveList():
        if not trvCs.getName().endswith(':source'):
            hasBinary = True
            break

    if cfg.interactive or info:
        print 'The following %s will be created:' % branchOps
        displayBranchJob(cs, shadow=makeShadow)

    if cfg.interactive:
        print
        if hasBinary and branchType & client.BRANCH_BINARY:
            print 'WARNING: You have chosen to create binary %s. ' \
                  'This is not recommended\nwith this version of cvc.' \
                    % branchOps
            print
        okay = cmdline.askYn('Continue with %s? [y/N]' % branchOps.lower(),
                             default=False)
        if not okay:
            return
    elif (not forceBinary) and hasBinary and branchType & client.BRANCH_BINARY:
        print 'Creating binary %s is only allowed in interactive mode. ' \
              'Rerun cvc\nwith --interactive.' % branchOps
        return 1

    if not info:
        if targetFile:
            cs.writeToFile(targetFile)
        else:
            client.repos.commitChangeSet(cs)
Exemplo n.º 2
0
def branch(repos,
           cfg,
           newLabel,
           troveSpecs,
           makeShadow=False,
           sourceOnly=False,
           binaryOnly=False,
           allowEmptyShadow=False,
           info=False,
           forceBinary=False,
           ignoreConflicts=False,
           targetFile=None):
    branchType = _getBranchType(binaryOnly, sourceOnly)

    client = conaryclient.ConaryClient(cfg)

    troveSpecs = [updatecmd.parseTroveSpec(x) for x in troveSpecs]

    componentSpecs = [
        x[0] for x in troveSpecs
        if (':' in x[0] and x[0].split(':')[1] != 'source')
    ]
    if componentSpecs:
        raise errors.ParseError(
            'Cannot branch or shadow individual components: %s' %
            ', '.join(componentSpecs))

    result = repos.findTroves(cfg.buildLabel, troveSpecs, cfg.buildFlavor)
    troveList = [x for x in itertools.chain(*result.itervalues())]

    sigKey = selectSignatureKey(cfg, newLabel)

    if makeShadow:
        dups, cs = client.createShadowChangeSet(newLabel, troveList,
                                                allowEmptyShadow=\
                                                    allowEmptyShadow,
                                                branchType=branchType,
                                                sigKeyId=sigKey)
    else:
        dups, cs = client.createBranchChangeSet(newLabel,
                                                troveList,
                                                branchType=branchType,
                                                sigKeyId=sigKey)

    for (name, branch) in dups:
        log.warning("%s already has branch %s", name, branch.asString())

    if not cs:
        return

    if makeShadow:
        branchOps = 'shadows'
    else:
        branchOps = 'branches'

    hasBinary = False
    for trvCs in cs.iterNewTroveList():
        if not trvCs.getName().endswith(':source'):
            hasBinary = True
            break

    if cfg.interactive or info:
        print 'The following %s will be created:' % branchOps
        displayBranchJob(cs, shadow=makeShadow)

    if cfg.interactive:
        print
        if hasBinary and branchType & client.BRANCH_BINARY:
            print 'WARNING: You have chosen to create binary %s. ' \
                  'This is not recommended\nwith this version of cvc.' \
                    % branchOps
            print
        okay = cmdline.askYn('Continue with %s? [y/N]' % branchOps.lower(),
                             default=False)
        if not okay:
            return
    elif (not forceBinary) and hasBinary and branchType & client.BRANCH_BINARY:
        print 'Creating binary %s is only allowed in interactive mode. ' \
              'Rerun cvc\nwith --interactive.' % branchOps
        return 1

    if not info:
        if targetFile:
            cs.writeToFile(targetFile)
        else:
            client.repos.commitChangeSet(cs)
Exemplo n.º 3
0
            return

    # We use a changeset here instead of getTroves because changeset knows
    # how to do efficient recursion.
    cs = repos.createChangeSet(jobList, withFiles = True,
                               withFileContents = False, recurse = recurse)

    totalNum = len([ x for x in cs.iterNewTroveList() ])
    misfires = []

    for i, trvCs in enumerate(cs.iterNewTroveList()):
        trv = trove.Trove(trvCs)
        callback.signTrove(i + 1, totalNum)

        label = trv.getVersion().branch().label()
        signatureKey = selectSignatureKey(cfg, label.asString())

        if not signatureKey:
            if not cfg.quiet:
                print "\nNo key is defined for label %s" % label
                return

            continue

        # Look for a public key for this key; don't catch the exception
        keyCache = trove.openpgpkey.getKeyCache()
        key = keyCache.getPublicKey(signatureKey)
        signatureKey = key.getFingerprint()

        try:
            trv.getDigitalSignature(signatureKey)
Exemplo n.º 4
0
    # We use a changeset here instead of getTroves because changeset knows
    # how to do efficient recursion.
    cs = repos.createChangeSet(jobList,
                               withFiles=True,
                               withFileContents=False,
                               recurse=recurse)

    totalNum = len([x for x in cs.iterNewTroveList()])
    misfires = []

    for i, trvCs in enumerate(cs.iterNewTroveList()):
        trv = trove.Trove(trvCs)
        callback.signTrove(i + 1, totalNum)

        label = trv.getVersion().branch().label()
        signatureKey = selectSignatureKey(cfg, label.asString())

        if not signatureKey:
            if not cfg.quiet:
                print "\nNo key is defined for label %s" % label
                return

            continue

        # Look for a public key for this key; don't catch the exception
        keyCache = trove.openpgpkey.getKeyCache()
        key = keyCache.getPublicKey(signatureKey)
        signatureKey = key.getFingerprint()

        try:
            trv.getDigitalSignature(signatureKey)