sapling/eden/scm/tests/test-commitcloud-sync-workspacenames-t.py
John Reese 9fd86a4fae apply upgraded black 21.4b2 formatting to fbsource
Summary:
This applies the formatting changes from black v21.4b2 to all covered
projects in fbsource. Most changes are to single line docstrings, as black
will now remove leading and trailing whitespace to match PEP8. Any other
formatting changes are likely due to files that landed without formatting,
or files that previously triggered errors in black.

Any changes to code should be AST identical. Any test failures are likely
due to bad tests, or testing against the output of pyfmt.

Reviewed By: thatch

Differential Revision: D28204910

fbshipit-source-id: 804725bcd14f763e90c5ddff1d0418117c15809a
2021-05-04 22:16:51 -07:00

136 lines
6.0 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from testutil.dott import feature, sh, testtmp # noqa: F401
sh % "configure dummyssh"
sh % "enable amend commitcloud infinitepush rebase remotenames share"
(
sh % "cat"
<< r"""
[infinitepush]
branchpattern = re:scratch/.*
[commitcloud]
hostname = testhost
[experimental]
evolution = createmarkers, allowunstable
"""
>> "$HGRCPATH"
)
sh % "setconfig 'remotefilelog.reponame=server'"
sh % "hg init server"
sh % "cd server"
(
sh % "cat"
<< r"""
[infinitepush]
server = yes
indextype = disk
storetype = disk
reponame = testrepo
"""
>> ".hg/hgrc"
)
# Make shared part of config
(
sh % "cat"
<< r"""
[commitcloud]
servicetype = local
servicelocation = $TESTTMP
token_enforced = False
education_page = https://someurl.com/wiki/CommitCloud
"""
>> "shared.rc"
)
# Make a clone of the server
sh % "hg clone 'ssh://user@dummy/server' client1 -q"
sh % "cd client1"
sh % "cat ../shared.rc" >> ".hg/hgrc"
# Check generation of default workspace name based on user name and email
sh % "hg cloud join" == r"""
commitcloud: this repository is now connected to the 'user/test/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test/default'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/test/default' workspace"
sh % "'HGUSER=Test Longname <test.longname@example.com>' hg cloud join" == r"""
commitcloud: this repository is now connected to the 'user/test.longname@example.com/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test.longname@example.com/default'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/test.longname@example.com/default' workspace"
sh % "'HGUSER=Test Longname <test.longname@example.com>' hg cloud join --config 'commitcloud.email_domain=example.com'" == r"""
commitcloud: this repository is now connected to the 'user/test.longname/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/test.longname/default'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/test.longname/default' workspace"
sh % "'HGUSER=Another Domain <other.longname@example.org>' hg cloud join --config 'commitcloud.email_domain=example.com'" == r"""
commitcloud: this repository is now connected to the 'user/other.longname@example.org/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/other.longname@example.org/default'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/other.longname@example.org/default' workspace"
# Can join workspaces using raw workspace names
sh % "hg cloud join --raw-workspace project/unsupported" == r"""
commitcloud: this repository is now connected to the 'project/unsupported' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'project/unsupported'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'project/unsupported' workspace"
# Test deprecated joining a user workspace via full workspace name
sh % "hg cloud join -w user/other/work" == r"""
specifying full workspace names with '-w' is deprecated
(use '-u' to select another user's workspaces)
commitcloud: this repository is now connected to the 'user/other/work' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/other/work'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/other/work' workspace"
# But specifying a user and a workspace name like this just treats the workspace name as-is.
sh % "hg cloud join -u other -w user/nested/name" == r"""
commitcloud: this repository is now connected to the 'user/other/user/nested/name' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/other/user/nested/name'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/other/user/nested/name' workspace"
# Test joining other users' workspaces the right way
sh % "hg cloud join -u other -w work" == r"""
commitcloud: this repository is now connected to the 'user/other/work' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/other/work'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/other/work' workspace"
# Test joining other users' default workspace
sh % "hg cloud join -u other" == r"""
commitcloud: this repository is now connected to the 'user/other/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/other/default'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/other/default' workspace"
# Test joining other user's workspace by matching domain email
sh % "hg cloud join -u 'other@example.com' --config 'commitcloud.email_domain=example.com'" == r"""
commitcloud: this repository is now connected to the 'user/other/default' workspace for the 'server' repo
commitcloud: synchronizing 'server' with 'user/other/default'
commitcloud: commits synchronized
finished in * (glob)"""
sh % "hg cloud leave" == "commitcloud: this repository is now disconnected from the 'user/other/default' workspace"