Exemple #1
0
def getuserconfigpath(ui, overrideconfig):
    """returns the path for per-user configuration

    These paths can be overridden using the given config option.

    Unix:
        returns the home dir, based on 'HOME' environment variable
        if it is set and not equal to the empty string
    Windows:
        returns the value of the 'APPDATA' environment variable
        if it is set and not equal to the empty string
    """
    path = ui.config("commitcloud", overrideconfig)
    if path and not os.path.isdir(path):
        raise ccerror.ConfigurationError(
            ui, _("invalid commitcloud.%s '%s'") % (overrideconfig, path)
        )
    if path:
        return util.expandpath(path)

    if pycompat.iswindows:
        envvar = "APPDATA"
    else:
        envvar = "HOME"
    configpath = encoding.environ.get(envvar)
    if not configpath:
        raise ccerror.ConfigurationError(
            ui, _("$%s environment variable not found") % envvar
        )

    if not os.path.isdir(configpath):
        raise ccerror.ConfigurationError(ui, _("invalid config path '%s'") % configpath)

    return configpath
Exemple #2
0
def getcachepath(ui, allowempty=False):
    cachepath = ui.config("remotefilelog", "cachepath")
    if not cachepath:
        if allowempty:
            return None
        else:
            raise error.Abort(
                _("could not find config option "
                  "remotefilelog.cachepath"))
    return util.expandpath(cachepath)
Exemple #3
0
    def __init__(self, repo):
        ui = repo.ui
        self.repo = repo
        self.ui = ui

        self.cacheprocess = ui.config("remotefilelog", "cacheprocess")
        if not self.cacheprocess:
            self.cacheprocess = ui.config("remotefilelog", "cacheprocess2")
            if self.cacheprocess:
                key = ui.config("remotefilelog", "cachekey",
                                "") + repo.name + ":"
                self.cacheprocess += " " + key

        if self.cacheprocess:
            self.cacheprocess = util.expandpath(self.cacheprocess)

        # This option causes remotefilelog to pass the full file path to the
        # cacheprocess instead of a hashed key.
        self.cacheprocesspasspath = ui.configbool("remotefilelog",
                                                  "cacheprocess.includepath")

        self.debugoutput = ui.configbool("remotefilelog", "debug")

        if self.cacheprocess:
            options = ""
            cachepath = shallowutil.getcachepackpath(
                self.repo, constants.FILEPACK_CATEGORY)

            if self.ui.configbool("remotefilelog", "indexedlogdatastore"):
                path = shallowutil.getindexedlogdatastorepath(self.repo)
                options += "--indexedlog_dir %s" % path

            if self.ui.configbool("remotefilelog", "indexedloghistorystore"):
                path = shallowutil.getindexedloghistorystorepath(self.repo)
                options += " --indexedloghistorystore_dir %s" % path

            cmd = " ".join([self.cacheprocess, cachepath, options])
            self.remotecache = cacheconnection(repo, cmd)
        else:
            self.remotecache = simplecache()

        self.getpackclient = getpackclient(repo)
Exemple #4
0
    def __init__(self, repo):
        ui = repo.ui
        self.repo = repo
        self.ui = ui
        self.cacheprocess = ui.config("remotefilelog", "cacheprocess")
        if not self.cacheprocess:
            self.cacheprocess = ui.config("remotefilelog", "cacheprocess2")

        if self.cacheprocess:
            self.cacheprocess = util.expandpath(self.cacheprocess)

        self.key = ui.config("remotefilelog", "cachekey", "")

        # This option causes remotefilelog to pass the full file path to the
        # cacheprocess instead of a hashed key.
        self.cacheprocesspasspath = ui.configbool("remotefilelog",
                                                  "cacheprocess.includepath")

        self.debugoutput = ui.configbool("remotefilelog", "debug")

        self.remotecache = cacheconnection(repo)
        self.getpackclient = getpackclient(repo)
Exemple #5
0
def uisetup(ui):
    for cmd, path in ui.configitems("extdiff"):
        path = util.expandpath(path)
        if cmd.startswith("cmd."):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config("extdiff", "opts." + cmd)
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += " " + diffopts
        elif cmd.startswith("opts."):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(pycompat.shlexsplit(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config("diff-tools", cmd + ".diffargs") or ui.config(
                "merge-tools", cmd + ".diffargs"
            )
            if args:
                cmdline += " " + args
        command(
            cmd, extdiffopts[:], _("hg %s [OPTION]... [FILE]...") % cmd, inferrepo=True
        )(savedcmd(path, cmdline))
Exemple #6
0
def expandpath(path):
    # Replace `pwd`, it is commonly used in tests.
    pwd = os.getcwd()
    path = path.replace("`pwd`", pwd).replace("$PWD", pwd)
    return util.expandpath(path)