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 voidaddChange(VcsRoot root, ModificationDataBuilder modification)voidaddChange(VcsRoot vcsRoot, MockVcsModification modification)voidaddChange(VcsRoot root, ModificationData modification)voidaddChangeSetCurrentVersion(VcsRootInstance vcsRoot, MockVcsModification mockVcsModification)<T extends VcsExtension>
voidaddCustomVcsExtension(Class<T> extensionClass, T extension)booleanallowSourceCaching()voidbuildPatch(VcsRoot root, String fromVersion, String toVersion, PatchBuilder builder, CheckoutRules checkoutRules)Called to retrieve detailed info on modification between two given revisions.voidclearRequestedChangesVersions()voidclearRequestedPathVersions()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.StringdescribeVcsRoot(VcsRoot vcsRoot)Returns presentable text describing specified vcs root, for example: svn: http://www.somehost.com/project/BuildPatchPolicygetBuildPatchPolicy()CollectChangesPolicygetCollectChangesPolicy()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.VcsFileContentProvidergetContentProvider()StringgetCurrentVersion(VcsRoot root)Repository state is now implemented via jetbrains.buildServer.vcs.CollectChangesPolicy, this method is left here for compatibilityStringgetDefaultBranchName(VcsRoot vcsRoot)Map<String,String>getDefaultVcsProperties()Returns default VCS property values.StringgetDisplayName()Returns name to be shown in the UI.LabelingSupportgetLabelingSupport()StringgetName()Unique VCS identifier among other installed plugins.List<String>getRequestedChangesVersions()List<String>getRequestedPatchVersions()protected longgetRootId(VcsRoot root)TestConnectionSupportgetTestConnectionSupport()Map<String,Map<String,String>>getUrl2PropsMap()UrlSupportgetUrlSupport()protected <T extends VcsExtension>
TgetVcsCustomExtension(Class<T> extensionClass)PropertiesProcessorgetVcsPropertiesProcessor()Validator for the version control settings as displayed on configuration page for the VCS root.StringgetVcsRootIdentity(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 repositoriesStringgetVcsSettingsJspFilePath()Version control settings editor page.Comparator<String>getVersionComparator()Returns comparator which allows to sort modifications by their version.StringgetVersionDisplayName(String version, VcsRoot root)Returns readable presentation of version (this format should be the same as DisplayVersion of VcsModification)booleanisAgentSideCheckoutAvailable()booleanisCurrentVersionExpensive()If the obtaining current version is an expensive operation (see CollectSingleStatePolicy#getCurrentVersion(VcsRoot)}) the implementation may optimize performance by returningtrue.booleanisDAGBasedVcs()booleanisTestConnectionSupported()voidresetChanges(VcsRoot root)voidsetAgentSideCheckoutAvailable(boolean agentSideCheckoutAvailable)voidsetCollectChangesPolicy(CollectChangesPolicy policy)voidsetContent(VcsRoot root, String revision, String path, Object content)Sets result of next getContent call.voidsetCurrentVersion(VcsRootInstance vcsRoot, String version)voidsetDAGBased(boolean dagBased)voidsetDisplayName(String rev, String revDisplayName)voidsetIgnoreServerCaches(boolean b)voidsetSourcesUpdatePossibleIfChangesNotFound(boolean sourcesCanBeUpdatedWithoutChanges)booleansourcesUpdatePossibleIfChangesNotFound(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.StringtestConnection(VcsRoot vcsRoot)Called to test connection to the given VCS root.StringtoString()-
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:VcsSupportConfigValidator for the version control settings as displayed on configuration page for the VCS root.- Specified by:
getVcsPropertiesProcessorin interfaceVcsSupportConfig- Returns:
- - properties validator
- See Also:
AbstractVcsPropertiesProcessor
-
getVcsSettingsJspFilePath
@NotNull public String getVcsSettingsJspFilePath()
Description copied from interface:VcsSupportConfigVersion control settings editor page.- Specified by:
getVcsSettingsJspFilePathin 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, VcsExceptionDescription copied from interface:BuildPatchByCheckoutRulesCalled to retrieve detailed info on modification between two given revisions. Results are to be fed to the builder passed.- Specified by:
buildPatchin 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 VcsExceptionDescription copied from interface:VcsFileContentProviderGet binary content of the single file in modification set.- Specified by:
getContentin 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:VcsSupportConfigUnique VCS identifier among other installed plugins.- Specified by:
getNamein interfaceVcsSupportConfig- Returns:
- - unique version control name
-
getDisplayName
@NotNull public String getDisplayName()
Description copied from interface:VcsSupportConfigReturns name to be shown in the UI.- Specified by:
getDisplayNamein interfaceVcsSupportConfig- Returns:
- name to be shown to user
-
getCurrentVersion
@NotNull public String getCurrentVersion(@NotNull VcsRoot root) throws VcsException
Description copied from class:ServerVcsSupportRepository state is now implemented via jetbrains.buildServer.vcs.CollectChangesPolicy, this method is left here for compatibility- Specified by:
getCurrentVersionin interfaceCollectSingleStatePolicy- Overrides:
getCurrentVersionin 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:VcsSupportConfigReturns presentable text describing specified vcs root, for example: svn: http://www.somehost.com/project/- Specified by:
describeVcsRootin 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 VcsExceptionDescription copied from interface:VcsFileContentProviderGet binary content of the single file in modification set.- Specified by:
getContentin 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:TestConnectionSupportCalled to test connection to the given VCS root.- Specified by:
testConnectionin interfaceTestConnectionSupport- Parameters:
vcsRoot- root to be tested- Returns:
- current connection description or
nullif 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:VcsSupportConfigReturns default VCS property values.- Specified by:
getDefaultVcsPropertiesin interfaceVcsSupportConfig- Returns:
- default configuration values
-
getVersionDisplayName
@NotNull public String getVersionDisplayName(@NotNull String version, @NotNull VcsRoot root) throws VcsException
Description copied from interface:VcsSupportConfigReturns readable presentation of version (this format should be the same as DisplayVersion of VcsModification)- Specified by:
getVersionDisplayNamein 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:
isAgentSideCheckoutAvailablein 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:VcsSupportConfigReturns 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:
getVersionComparatorin 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:
allowSourceCachingin 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:VcsSupportCoreMust 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:
sourcesUpdatePossibleIfChangesNotFoundin interfaceVcsSupportCore- Parameters:
root- VCS root- Returns:
- see above
-
setSourcesUpdatePossibleIfChangesNotFound
public void setSourcesUpdatePossibleIfChangesNotFound(boolean sourcesCanBeUpdatedWithoutChanges)
-
getContentProvider
@NotNull public VcsFileContentProvider getContentProvider()
- Specified by:
getContentProviderin interfaceVcsSupportContext- Returns:
- implementation for file content operations
-
getCollectChangesPolicy
@NotNull public CollectChangesPolicy getCollectChangesPolicy()
- Specified by:
getCollectChangesPolicyin interfaceVcsSupportContext- Returns:
- change collecting policy implementation
-
setCollectChangesPolicy
public void setCollectChangesPolicy(@Nullable CollectChangesPolicy policy)
-
getBuildPatchPolicy
@NotNull public BuildPatchPolicy getBuildPatchPolicy()
- Specified by:
getBuildPatchPolicyin interfaceVcsSupportContext- Returns:
- patch building policy implementation
-
getTestConnectionSupport
public TestConnectionSupport getTestConnectionSupport()
- Specified by:
getTestConnectionSupportin 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:CollectSingleStateChangesByCheckoutRulesReturns list of the changes between two revisions given. CheckVcsSupportCore.isCurrentVersionExpensive()if you like to have null for currentVersion- Specified by:
collectChangesin 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:
getUrlSupportin interfaceVcsSupportContext
-
convertToVcsRootProperties
@Nullable public Map<String,String> convertToVcsRootProperties(@NotNull VcsUrl url)
Description copied from interface:UrlSupportConverts the given url to a set of VCS root properties valid enough for creating a VCS root.- Specified by:
convertToVcsRootPropertiesin 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:
getLabelingSupportin interfaceVcsSupportContext- Returns:
- if the implementation supports labeling this method returns VcsPersonalSupport implementation. Otherwise null.
-
isCurrentVersionExpensive
public boolean isCurrentVersionExpensive()
Description copied from interface:VcsSupportCoreIf 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:
isCurrentVersionExpensivein interfaceVcsSupportCore- Returns:
- true if the obtaining current version is an expensive operation.
- See Also:
CollectChangesPolicy
-
isDAGBasedVcs
public boolean isDAGBasedVcs()
- Specified by:
isDAGBasedVcsin interfaceVcsSupportConfig- Returns:
- true if VCS is DAG-based
-
getVcsCustomExtension
@Nullable protected <T extends VcsExtension> T getVcsCustomExtension(@NotNull Class<T> extensionClass)
- Overrides:
getVcsCustomExtensionin 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:VcsRootIdentityProviderFor 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:
getVcsRootIdentityin 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:
getDefaultBranchNamein 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
-
-