예제 #1
0
def mqcommit_info(ui, repo, opts):
    mqcommit = opts.pop('mqcommit', None)

    try:
        auto = ui.configbool('mqext', 'qcommit', None)
        if auto is None:
            raise error.ConfigError()
    except error.ConfigError:
        auto = ui.config('mqext', 'qcommit', 'auto').lower()

    if mqcommit is None and auto:
        if auto == 'auto':
            if repo.mq and repo.mq.qrepo():
                mqcommit = True
        else:
            mqcommit = True

    if mqcommit is None:
        return (None, None, None)

    q = repo.mq
    if q is None:
        raise error.Abort("-Q option given but mq extension not installed")
    r = q.qrepo()
    if r is None:
        raise error.Abort("-Q option given but patch directory is not "
                          "versioned")

    return mqcommit, q, r
예제 #2
0
def buildinfo_for_job(jenkins_server, job_name):
    # We retrieve all builds matching a hg-node.
    build_for_hgnode = defaultdict(list)
    try:
        jobinfo = jenkins_server.get_job_info(job_name)
    except NotFoundException:
        raise error.ConfigError(
            "job '%s' not found" % job_name,
            hint='see if jenkins.job config entry is correct',
        )
    for build in jobinfo['builds']:
        build_number = build['number']
        build_info = jenkins_server.get_build_info(job_name, build_number)
        for action in build_info['actions']:
            hgnode = action.get('mercurialNodeName')
            if hgnode:
                build_for_hgnode[hgnode].append({
                    'number':
                    build_number,
                    'status':
                    build_info['result'],
                    'building':
                    build_info['building'],
                    'url':
                    build_info['url'],
                })
                break
    # Ultimately, we only keep the latest build (i.e. the one with largest
    # build number) for each hg-node.
    for hgnode, values in build_for_hgnode.items():
        values.sort(key=lambda d: d['number'])
        build_for_hgnode[hgnode] = values[-1]
    return build_for_hgnode
예제 #3
0
def getint(ui, section, name, default):
    # for "historical portability":
    # ui.configint has been available since 1.9 (or fa2b596db182)
    v = ui.config(section, name, None)
    if v is None:
        return default
    try:
        return int(v)
    except ValueError:
        raise error.ConfigError(("%s.%s is not an integer ('%s')")
                                % (section, name, v))
예제 #4
0
def clonenarrowcmd(orig, ui, repo, *args, **opts):
    """Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
    opts = pycompat.byteskwargs(opts)
    wrappedextraprepare = util.nullcontextmanager()
    narrowspecfile = opts[b'narrowspec']

    if narrowspecfile:
        filepath = os.path.join(encoding.getcwd(), narrowspecfile)
        ui.status(_(b"reading narrowspec from '%s'\n") % filepath)
        try:
            fdata = util.readfile(filepath)
        except IOError as inst:
            raise error.Abort(
                _(b"cannot read narrowspecs from '%s': %s") %
                (filepath, encoding.strtolocal(inst.strerror)))

        includes, excludes, profiles = sparse.parseconfig(ui, fdata, b'narrow')
        if profiles:
            raise error.ConfigError(
                _(b"cannot specify other files using '%include' in"
                  b" narrowspec"))

        narrowspec.validatepatterns(includes)
        narrowspec.validatepatterns(excludes)

        # narrowspec is passed so we should assume that user wants narrow clone
        opts[b'narrow'] = True
        opts[b'include'].extend(includes)
        opts[b'exclude'].extend(excludes)

    if opts[b'narrow']:

        def pullbundle2extraprepare_widen(orig, pullop, kwargs):
            orig(pullop, kwargs)

            if opts.get(b'depth'):
                kwargs[b'depth'] = opts[b'depth']

        wrappedextraprepare = extensions.wrappedfunction(
            exchange, b'_pullbundle2extraprepare',
            pullbundle2extraprepare_widen)

    with wrappedextraprepare:
        return orig(ui, repo, *args, **pycompat.strkwargs(opts))