Class MockVcsSupport
- java.lang.Object
-
- jetbrains.buildServer.vcs.ServerVcsSupport
-
- jetbrains.buildServer.serverSide.impl.MockVcsSupport
-
- All Implemented Interfaces:
BuildPatchByCheckoutRules
,BuildPatchPolicy
,CollectChangesPolicy
,CollectSingleStateChangesByCheckoutRules
,CollectSingleStatePolicy
,TestConnectionSupport
,UrlSupport
,VcsExtension
,VcsFileContentProvider
,VcsRootIdentityProvider
,VcsSupportConfig
,VcsSupportContext
,VcsSupportCore
,VcsGenericService
,VcsService
- Direct Known Subclasses:
MockBranchSupport
public class MockVcsSupport extends ServerVcsSupport implements CollectSingleStateChangesByCheckoutRules, BuildPatchByCheckoutRules, VcsFileContentProvider, TestConnectionSupport, UrlSupport, VcsRootIdentityProvider
-
-
Constructor Summary
Constructors Constructor Description MockVcsSupport(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChange(VcsRoot root, ModificationDataBuilder modification)
void
addChange(VcsRoot vcsRoot, MockVcsModification modification)
void
addChange(VcsRoot root, ModificationData modification)
void
addChangeSetCurrentVersion(VcsRootInstance vcsRoot, MockVcsModification mockVcsModification)
<T extends VcsExtension>
voidaddCustomVcsExtension(Class<T> extensionClass, T extension)
boolean
allowSourceCaching()
void
buildPatch(VcsRoot root, String fromVersion, String toVersion, PatchBuilder builder, CheckoutRules checkoutRules)
Called to retrieve detailed info on modification between two given revisions.void
clearRequestedChangesVersions()
void
clearRequestedPathVersions()
List<ModificationData>
collectChanges(VcsRoot root, String fromVersion, String currentVersion, CheckoutRules checkoutRules)
Returns list of the changes between two revisions given.Map<String,String>
convertToVcsRootProperties(VcsUrl url)
Converts the given url to a set of VCS root properties valid enough for creating a VCS root.String
describeVcsRoot(VcsRoot vcsRoot)
Returns presentable text describing specified vcs root, for example: svn: http://www.somehost.com/project/BuildPatchPolicy
getBuildPatchPolicy()
CollectChangesPolicy
getCollectChangesPolicy()
byte[]
getContent(String filePath, VcsRoot versionedRoot, String version)
Get binary content of the single file in modification set.byte[]
getContent(VcsModification parentModification, VcsChangeInfo change, VcsChangeInfo.ContentType contentType, VcsRoot vcsRoot)
Get binary content of the single file in modification set.VcsFileContentProvider
getContentProvider()
String
getCurrentVersion(VcsRoot root)
Repository state is now implemented via jetbrains.buildServer.vcs.CollectChangesPolicy, this method is left here for compatibilityString
getDefaultBranchName(VcsRoot vcsRoot)
Map<String,String>
getDefaultVcsProperties()
Returns default VCS property values.String
getDisplayName()
Returns name to be shown in the UI.LabelingSupport
getLabelingSupport()
String
getName()
Unique VCS identifier among other installed plugins.List<String>
getRequestedChangesVersions()
List<String>
getRequestedPatchVersions()
protected long
getRootId(VcsRoot root)
TestConnectionSupport
getTestConnectionSupport()
Map<String,Map<String,String>>
getUrl2PropsMap()
UrlSupport
getUrlSupport()
protected <T extends VcsExtension>
TgetVcsCustomExtension(Class<T> extensionClass)
PropertiesProcessor
getVcsPropertiesProcessor()
Validator for the version control settings as displayed on configuration page for the VCS root.String
getVcsRootIdentity(VcsRoot vcsRoot)
For the provided VCS root calculate identity, which can be used by TeamCity core to decide if two VCS root represent the same or different repositoriesString
getVcsSettingsJspFilePath()
Version control settings editor page.Comparator<String>
getVersionComparator()
Returns comparator which allows to sort modifications by their version.String
getVersionDisplayName(String version, VcsRoot root)
Returns readable presentation of version (this format should be the same as DisplayVersion of VcsModification)boolean
isAgentSideCheckoutAvailable()
boolean
isCurrentVersionExpensive()
If the obtaining current version is an expensive operation (see CollectSingleStatePolicy#getCurrentVersion(VcsRoot)}) the implementation may optimize performance by returningtrue
.boolean
isDAGBasedVcs()
boolean
isTestConnectionSupported()
void
resetChanges(VcsRoot root)
void
setAgentSideCheckoutAvailable(boolean agentSideCheckoutAvailable)
void
setCollectChangesPolicy(CollectChangesPolicy policy)
void
setContent(VcsRoot root, String revision, String path, Object content)
Sets result of next getContent call.void
setCurrentVersion(VcsRootInstance vcsRoot, String version)
void
setDAGBased(boolean dagBased)
void
setDisplayName(String rev, String revDisplayName)
void
setIgnoreServerCaches(boolean b)
void
setSourcesUpdatePossibleIfChangesNotFound(boolean sourcesCanBeUpdatedWithoutChanges)
boolean
sourcesUpdatePossibleIfChangesNotFound(VcsRoot root)
Must return true if source files in the build checkout directory can be updated even if no changes were detected between some versions.String
testConnection(VcsRoot vcsRoot)
Called to test connection to the given VCS root.String
toString()
-
Methods inherited from class jetbrains.buildServer.vcs.ServerVcsSupport
getCore, getVcsExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.vcs.VcsSupportConfig
getCheckoutProperties, getServerCheckoutProperties, isDAGBased
-
Methods inherited from interface jetbrains.buildServer.vcs.VcsSupportContext
getListFilesPolicy, getPersonalSupport
-
-
-
-
Constructor Detail
-
MockVcsSupport
public MockVcsSupport(String name)
-
-
Method Detail
-
setDAGBased
public void setDAGBased(boolean dagBased)
-
getVcsPropertiesProcessor
public PropertiesProcessor getVcsPropertiesProcessor()
Description copied from interface:VcsSupportConfig
Validator for the version control settings as displayed on configuration page for the VCS root.- Specified by:
getVcsPropertiesProcessor
in interfaceVcsSupportConfig
- Returns:
- - properties validator
- See Also:
AbstractVcsPropertiesProcessor
-
getVcsSettingsJspFilePath
@NotNull public String getVcsSettingsJspFilePath()
Description copied from interface:VcsSupportConfig
Version control settings editor page.- Specified by:
getVcsSettingsJspFilePath
in interfaceVcsSupportConfig
- Returns:
- path to configuration jsp page
-
buildPatch
public void buildPatch(@NotNull VcsRoot root, String fromVersion, @NotNull String toVersion, @NotNull PatchBuilder builder, @NotNull CheckoutRules checkoutRules) throws IOException, VcsException
Description copied from interface:BuildPatchByCheckoutRules
Called to retrieve detailed info on modification between two given revisions. Results are to be fed to the builder passed.- Specified by:
buildPatch
in interfaceBuildPatchByCheckoutRules
- Parameters:
root
- current settingsfromVersion
- collect files, changed since this version. If it is null, collect all project files for 'toVersion' parameter (full checkout patch).toVersion
- collect files, changed between 'fromVersion' and this versionbuilder
- call methods of this interface in order to build patch.checkoutRules
- checkout rules for sources to get.- Throws:
IOException
- rethrow this exception, if it will be thrown from some PatchBuilder methodVcsException
- throw this exception if some problem occurred while collecting changes or changes cannot be collected because of invalid configuration. Localized message will be shown on the web page for the corresponding project.IncrementalPatchImpossibleException
- if this exception is thrown during building an incremental patch (fromVersion is not null) this method will be called again with fromVersion set to null, i.e. full checkout patch will be requested. This is useful for the situation when the underlying VCS repository has forgotten the fromVersion for some reason and therefore VCS support is unable to extract the differences.- See Also:
service class prevents you from manual mapping of file pathes.
-
getContent
@NotNull public byte[] getContent(@NotNull VcsModification parentModification, @NotNull VcsChangeInfo change, @NotNull VcsChangeInfo.ContentType contentType, @NotNull VcsRoot vcsRoot) throws VcsException
Description copied from interface:VcsFileContentProvider
Get binary content of the single file in modification set.- Specified by:
getContent
in interfaceVcsFileContentProvider
- Parameters:
parentModification
- modification set.change
- specified change of file.contentType
- specified what content should be return - before modification or after it.vcsRoot
- current settings.- Returns:
- content of the file specified by VcsChange, by version, specified in 'contentType' parameter.
- Throws:
VcsException
- if some problem occurred.VcsFileNotFoundException
- when no such file found. If "file not found" condition cannot be detected easily the implementation may throw jetbrains.buildServer.vcs.VcsException. In this case some TeamCity functions may work inefficiently, for example the file content cache.
-
setContent
public void setContent(@NotNull VcsRoot root, @NotNull String revision, @NotNull String path, @Nullable Object content)
Sets result of next getContent call. Content can be a byte array of a file content, a VcsException or RuntimeException. If content is an exception - it is thrown during getContent operation.
-
getName
@NotNull public String getName()
Description copied from interface:VcsSupportConfig
Unique VCS identifier among other installed plugins.- Specified by:
getName
in interfaceVcsSupportConfig
- Returns:
- - unique version control name
-
getDisplayName
@NotNull public String getDisplayName()
Description copied from interface:VcsSupportConfig
Returns name to be shown in the UI.- Specified by:
getDisplayName
in interfaceVcsSupportConfig
- Returns:
- name to be shown to user
-
getCurrentVersion
@NotNull public String getCurrentVersion(@NotNull VcsRoot root) throws VcsException
Description copied from class:ServerVcsSupport
Repository state is now implemented via jetbrains.buildServer.vcs.CollectChangesPolicy, this method is left here for compatibility- Specified by:
getCurrentVersion
in interfaceCollectSingleStatePolicy
- Overrides:
getCurrentVersion
in classServerVcsSupport
- Parameters:
root
- - current configuration- Returns:
- - current version of repository. This version has to have the same meaning as a VcsModification version
- Throws:
VcsException
- throw this exception if some problem occurred while collecting changes or changes cannot be collected because of invalid configuration. Localized message will be shown on the web page for the corresponding project.
-
getRootId
protected long getRootId(VcsRoot root)
-
describeVcsRoot
@NotNull public String describeVcsRoot(@NotNull VcsRoot vcsRoot)
Description copied from interface:VcsSupportConfig
Returns presentable text describing specified vcs root, for example: svn: http://www.somehost.com/project/- Specified by:
describeVcsRoot
in interfaceVcsSupportConfig
- Parameters:
vcsRoot
- vcs root to describe- Returns:
- vcs root description
-
isTestConnectionSupported
public boolean isTestConnectionSupported()
-
clearRequestedPathVersions
public void clearRequestedPathVersions()
-
setCurrentVersion
public void setCurrentVersion(VcsRootInstance vcsRoot, String version)
-
addChange
public void addChange(@NotNull VcsRoot root, @NotNull ModificationDataBuilder modification)
-
addChange
public void addChange(@NotNull VcsRoot root, @NotNull ModificationData modification)
-
addChange
public void addChange(VcsRoot vcsRoot, MockVcsModification modification)
-
getContent
@NotNull public byte[] getContent(@NotNull String filePath, @NotNull VcsRoot versionedRoot, @NotNull String version) throws VcsException
Description copied from interface:VcsFileContentProvider
Get binary content of the single file in modification set.- Specified by:
getContent
in interfaceVcsFileContentProvider
- Parameters:
filePath
- file path relative to the project root, "checkout root" from vcs root should not be includedversionedRoot
- current settings.version
- version returned byVcsModification.getVersion()
or check jetbrains.buildServer.vcs.CollectChangesPolicy.- Returns:
- specified file content, corresponding to the repository version specified in 'version' parameter.
- Throws:
VcsException
- if some problem occurred.VcsFileNotFoundException
- when no such file found. If "file not found" condition cannot be detected easily the implementation may throw jetbrains.buildServer.vcs.VcsException. In this case some TeamCity functions may work inefficiently, for example the file content cache.
-
testConnection
public String testConnection(@NotNull VcsRoot vcsRoot) throws VcsException
Description copied from interface:TestConnectionSupport
Called to test connection to the given VCS root.- Specified by:
testConnection
in interfaceTestConnectionSupport
- Parameters:
vcsRoot
- root to be tested- Returns:
- current connection description or
null
if no additional information shall be displayed to the user in case of successful connection. - Throws:
VcsException
- - throw this exception if connection failed
-
getDefaultVcsProperties
@Nullable public Map<String,String> getDefaultVcsProperties()
Description copied from interface:VcsSupportConfig
Returns default VCS property values.- Specified by:
getDefaultVcsProperties
in interfaceVcsSupportConfig
- Returns:
- default configuration values
-
getVersionDisplayName
@NotNull public String getVersionDisplayName(@NotNull String version, @NotNull VcsRoot root) throws VcsException
Description copied from interface:VcsSupportConfig
Returns readable presentation of version (this format should be the same as DisplayVersion of VcsModification)- Specified by:
getVersionDisplayName
in interfaceVcsSupportConfig
- Parameters:
version
- version in internal formatroot
- root to get version display name for.- Returns:
- display format of repository version
- Throws:
VcsException
- some problem with version control server occurred.
-
isAgentSideCheckoutAvailable
public boolean isAgentSideCheckoutAvailable()
- Specified by:
isAgentSideCheckoutAvailable
in interfaceVcsSupportConfig
- Returns:
- boolean value indicating agent side checkout ability support
-
setAgentSideCheckoutAvailable
public void setAgentSideCheckoutAvailable(boolean agentSideCheckoutAvailable)
-
getVersionComparator
@NotNull public Comparator<String> getVersionComparator()
Description copied from interface:VcsSupportConfig
Returns comparator which allows to sort modifications by their version. Latest modification in the sorted collection should be latest modification made in the repository.- Specified by:
getVersionComparator
in interfaceVcsSupportConfig
- Returns:
- comparator of two repository versions, both versions were got from VcsModification.getVersion, specific for this support.
- See Also:
Service comparator for dates
,service comparator for integer versions
,service comparator for string versions
-
addChangeSetCurrentVersion
public void addChangeSetCurrentVersion(VcsRootInstance vcsRoot, MockVcsModification mockVcsModification)
-
setIgnoreServerCaches
public void setIgnoreServerCaches(boolean b)
-
allowSourceCaching
public boolean allowSourceCaching()
- Specified by:
allowSourceCaching
in interfaceVcsSupportCore
- Returns:
- true if you want TeamCity to use its internal source cache to reuse patches retrieved earlier and minimize patch building. Returning false may have sense if the underlying version control system has its own effective local caching system (e.g. Mercurial).
-
sourcesUpdatePossibleIfChangesNotFound
public boolean sourcesUpdatePossibleIfChangesNotFound(@NotNull VcsRoot root)
Description copied from interface:VcsSupportCore
Must return true if source files in the build checkout directory can be updated even if no changes were detected between some versions. This is possible for example if VCS support plugin can't detect changes when a tag/label is moved. Note that if true is returned for some VCS root, plugin should be able to correctly build patch for this VCS root.
For example, if plugin performs changes collecting in the buildPatch method and then creates patch by detected changes, it should create clean patch for VCS root for which it returned true in this method.- Specified by:
sourcesUpdatePossibleIfChangesNotFound
in interfaceVcsSupportCore
- Parameters:
root
- VCS root- Returns:
- see above
-
setSourcesUpdatePossibleIfChangesNotFound
public void setSourcesUpdatePossibleIfChangesNotFound(boolean sourcesCanBeUpdatedWithoutChanges)
-
getContentProvider
@NotNull public VcsFileContentProvider getContentProvider()
- Specified by:
getContentProvider
in interfaceVcsSupportContext
- Returns:
- implementation for file content operations
-
getCollectChangesPolicy
@NotNull public CollectChangesPolicy getCollectChangesPolicy()
- Specified by:
getCollectChangesPolicy
in interfaceVcsSupportContext
- Returns:
- change collecting policy implementation
-
setCollectChangesPolicy
public void setCollectChangesPolicy(@Nullable CollectChangesPolicy policy)
-
getBuildPatchPolicy
@NotNull public BuildPatchPolicy getBuildPatchPolicy()
- Specified by:
getBuildPatchPolicy
in interfaceVcsSupportContext
- Returns:
- patch building policy implementation
-
getTestConnectionSupport
public TestConnectionSupport getTestConnectionSupport()
- Specified by:
getTestConnectionSupport
in interfaceVcsSupportContext
- Returns:
- test connection provider. Null if the implementation doesn't support test connections.
-
collectChanges
public List<ModificationData> collectChanges(@NotNull VcsRoot root, @NotNull String fromVersion, @Nullable String currentVersion, @NotNull CheckoutRules checkoutRules) throws VcsException
Description copied from interface:CollectSingleStateChangesByCheckoutRules
Returns list of the changes between two revisions given. CheckVcsSupportCore.isCurrentVersionExpensive()
if you like to have null for currentVersion- Specified by:
collectChanges
in interfaceCollectSingleStateChangesByCheckoutRules
- Parameters:
root
- current settings.fromVersion
- collect changes from this version.currentVersion
- collect changes up to this version.checkoutRules
- checkout rules built on union of all checkout rules of all configurations connected to the root. Include rules have 'from' part the same as 'to' one so you can don't map file paths according to include rules. see jetbrains.buildServer.vcs.VcsSupportUtil#collectBuildChanges(jetbrains.buildServer.vcs.VcsRoot, String, String, jetbrains.buildServer.vcs.CheckoutRules, jetbrains.buildServer.CollectChangesByIncludeRules) service method, which allows you to collect changes for each root include rule.- Returns:
- list of changes between specified versions.
- Throws:
VcsException
- throw this exception if some problem occurred while collecting changes or changes cannot be collected because of invalid configuration. Localized message will be shown on the web page for the corresponding project
-
clearRequestedChangesVersions
public void clearRequestedChangesVersions()
-
getUrlSupport
public UrlSupport getUrlSupport()
- Specified by:
getUrlSupport
in interfaceVcsSupportContext
-
convertToVcsRootProperties
@Nullable public Map<String,String> convertToVcsRootProperties(@NotNull VcsUrl url)
Description copied from interface:UrlSupport
Converts the given url to a set of VCS root properties valid enough for creating a VCS root.- Specified by:
convertToVcsRootProperties
in interfaceUrlSupport
- Parameters:
url
- url to repository with optional credentials- Returns:
- the VCS root properties if url belongs to this VCS plugin or null if it does not belong
-
getLabelingSupport
public LabelingSupport getLabelingSupport()
- Specified by:
getLabelingSupport
in interfaceVcsSupportContext
- Returns:
- if the implementation supports labeling this method returns VcsPersonalSupport implementation. Otherwise null.
-
isCurrentVersionExpensive
public boolean isCurrentVersionExpensive()
Description copied from interface:VcsSupportCore
If the obtaining current version is an expensive operation (see CollectSingleStatePolicy#getCurrentVersion(VcsRoot)}) the implementation may optimize performance by returningtrue
. In this case collecting changes for the current version will be done without specifying upper version. OtherwiseCollectSingleStatePolicy.getCurrentVersion(VcsRoot)
will be called first and then the result will be passed to the change collector as the upper version.- Specified by:
isCurrentVersionExpensive
in interfaceVcsSupportCore
- Returns:
- true if the obtaining current version is an expensive operation.
- See Also:
CollectChangesPolicy
-
isDAGBasedVcs
public boolean isDAGBasedVcs()
- Specified by:
isDAGBasedVcs
in interfaceVcsSupportConfig
- Returns:
- true if VCS is DAG-based
-
getVcsCustomExtension
@Nullable protected <T extends VcsExtension> T getVcsCustomExtension(@NotNull Class<T> extensionClass)
- Overrides:
getVcsCustomExtension
in classServerVcsSupport
-
addCustomVcsExtension
public <T extends VcsExtension> void addCustomVcsExtension(@NotNull Class<T> extensionClass, T extension)
-
resetChanges
public void resetChanges(@NotNull VcsRoot root)
-
getVcsRootIdentity
@NotNull public String getVcsRootIdentity(@NotNull VcsRoot vcsRoot) throws VcsException
Description copied from interface:VcsRootIdentityProvider
For the provided VCS root calculate identity, which can be used by TeamCity core to decide if two VCS root represent the same or different repositories- Specified by:
getVcsRootIdentity
in interfaceVcsRootIdentityProvider
- Parameters:
vcsRoot
- VCS Root to get identity for- Returns:
- see above
- Throws:
VcsException
- in case of VCS problem
-
getDefaultBranchName
@Nullable public String getDefaultBranchName(@NotNull VcsRoot vcsRoot)
- Specified by:
getDefaultBranchName
in interfaceVcsRootIdentityProvider
- Returns:
- which branch should be treated as default to be used by TeamCity core e.g. to compare current states or null if not applicable
-
-