Esempio n. 1
0
def hostnameworkspace(ui, user=None):
    """Returns the host workspace for the given or current user for the current host"""
    if user is None:
        domain = ui.config("commitcloud", "email_domain")
        user = util.emaildomainuser(ui.username(), domain)
    return "user/%s/%s" % (
        user,
        ui.config("commitcloud", "hostname", socket.gethostname()),
    )
Esempio n. 2
0
def parseworkspace(ui, opts):
    """Parse command line options to get a workspace name.

    Returns None if the user specifies no workspace command line arguments.

    Workspace naming convention:
    section/section_name/workspace_name
        where section is one of ('user', 'group', 'team', 'project')
    Examples:
        team/source_control/shared
        user/<username>/default
        project/commit_cloud/default
    """
    rawworkspace = opts.get("raw_workspace")
    if rawworkspace:
        for opt in "user", "workspace":
            if opts.get(opt):
                raise error.Abort(_("--raw-workspace and --%s are incompatible") % opt)
        return rawworkspace

    user = opts.get("user")
    workspace = opts.get("workspace")
    if not any([user, workspace]):
        # User has not specified any workspace options.
        return None

    # Currently only "user" workspaces are implemented
    if not user:
        user = ui.username()
    domain = ui.config("commitcloud", "email_domain")
    user = util.emaildomainuser(user, domain)
    prefix = "user/%s/" % user

    if not workspace:
        workspace = "default"

    # Workaround for users specifying the full workspace name with "-w"
    if workspace.startswith("user/") and not opts.get("user"):
        msg = (
            "specifying full workspace names with '-w' is deprecated\n"
            "(use '-u' to select another user's workspaces)\n"
        )
        ui.warn(msg)
        return workspace

    return prefix + workspace
Esempio n. 3
0
def defaultworkspace(ui, user=None):
    """Returns the default workspace for the given or current user"""
    if user is None:
        domain = ui.config("commitcloud", "email_domain")
        user = util.emaildomainuser(ui.username(), domain)
    return "user/%s/default" % user
Esempio n. 4
0
def userworkspaceprefix(ui, user=None):
    """Returns the workspace prefix for the given user or current user"""
    if user is None:
        domain = ui.config("commitcloud", "email_domain")
        user = util.emaildomainuser(ui.username(), domain)
    return "user/%s/" % user