Package jetbrains.buildServer.vcs.impl
Class VcsRootInstanceWithParent
- java.lang.Object
-
- jetbrains.buildServer.vcs.impl.VcsSettingsOperations
-
- jetbrains.buildServer.vcs.impl.VcsRootInstanceWithParent
-
- All Implemented Interfaces:
Loggable,LVcsRoot,LVcsRootInstance,LVcsRootInstanceEx,VcsRoot,VcsRootInstance,VcsRootInstanceEx
public class VcsRootInstanceWithParent extends VcsSettingsOperations implements VcsRootInstanceEx
-
-
Field Summary
-
Fields inherited from interface jetbrains.buildServer.vcs.VcsRoot
SECURE_PROPERTY_PREFIX
-
-
Constructor Summary
Constructors Constructor Description VcsRootInstanceWithParent(VcsRootInstanceEx originalRoot, SVcsRoot parentRoot)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCollectChangesProgress(String progressMessage)booleancompareAndSetStatus(VcsRootStatus prevStatus, VcsRootStatus.Type newStatus)Sets new status only if current status is the same as prevStatus.Stringdescribe(boolean verbose)booleanequals(Object o)SVcsModificationfindModificationById(long modId)Returns VCS modification object associated with this VCS root instance and having the specified id.SVcsModificationfindModificationByVersion(String version)Searches for a VCS modification object associated with this VCS root and having the specified version (aka revision)LongfindModificationIdByVersion(String version)Same asVcsRootInstance.findModificationByVersion(String)but retuns id of the VCS modification.List<String>getCollectChangesProgress()RepositoryVersiongetCurrentRevision()DAG<Long>getDag()Returns DAG of VCS commits, for non DAG based VCS root instances the method will return a linear DAG.StringgetDefaultBranchName()For DAG based VCS roots returns default branch name if it is known.VcsRootInstanceExgetDelegate()StringgetDescription()intgetEffectiveModificationCheckInterval()StringgetExternalId()longgetId()returns root internal idDategetLastFinishChangesCollectingTime()Return the time when the last changes collecting was finished (the root status status changed toVcsRootStatus.Type.FINISHED) or null if no changes collecting is finished since server startOperationRequestorgetLastRequestor()Return the last requestor for checking for changes operationRepositoryVersiongetLastUsedRevision()RepositoryStategetLastUsedState()VcsDurationMetricsgetMetrics()TC collects timing for the last checking for changes operations to show it on Vcs Status tabStringgetName()returns descriptive name of the vcs rootSVcsRootgetParent()longgetParentId()VcsRootStatusgetPreviousStatus()Map<String,String>getProperties()Returns mapping from a property name to its valueStringgetProperty(String propertyName)Provides specified property valueStringgetProperty(String propertyName, String defaultValue)Provides specified property value or default value if property is not definedVcsRootStatusgetStatus()Map<SBuildType,CheckoutRules>getUsages()Set<String>getVcsBranchesContainingModId(long modId)StringgetVcsDisplayName()Returns VCS plugin display nameStringgetVcsName()Returns name of the corresponding version control.protected VcsRootInstanceExgetVcsRootInstance()VcsSupportCoregetVcsSupportCore()inthashCode()booleanisChangesCollectingLockObtained()booleanisConnectedDAGsTraversingEnabled()booleanisCurrentVersionExpensive()booleanisDagBased()booleanisPollingMode()The polling mode is enabled by default.booleanisSubrepo()StringmapPath(String fileName, CheckoutRules checkoutRules)voidresetPollingStateCache()Resets internal polling state cache so that next access to it's fields fetched them from the databasebooleansameParameters(Map<String,String> paramsForComparison)booleansetExplicitModificationCheckInterval(Integer secondsInterval)voidsetPollingMode(boolean pollingMode)voidsetStatus(VcsRootStatus.Type status)booleanshouldStoreParentRevisions()voidstartChangesCollectingInLock(OperationRequestor requestor)Set a requestor for the checking for changes procedure, also sets current VcsRootStatus status to STARTED Requires that VcsRootInstance is locked for changes collecting.booleantryLockChangesCollecting()booleantryLockChangesCollecting(int timeoutMillis)Try lock changes collecting lock for specified number of secondsvoidunlockChangesCollecting()Releases changes collection lock and marks VCS Root FINISHED<R> RwithConnectedDAG(Predicate<VcsRootInstance> vcsRootPredicate, Function<DAG<Long>,R> function)Calls provided function with a DAG which potentially can have VCS modifications belonging to different VCS root instances.-
Methods inherited from class jetbrains.buildServer.vcs.impl.VcsSettingsOperations
findService, getCheckoutPropertiesHash, getCurrentState, getService, getService, getVcsRootInstanceContext, getVersionDisplayName
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.vcs.LVcsRootInstance
findService, getCheckoutPropertiesHash, getService, getService, getVersionDisplayName
-
Methods inherited from interface jetbrains.buildServer.vcs.LVcsRootInstanceEx
getCurrentState
-
Methods inherited from interface jetbrains.buildServer.vcs.VcsRootInstanceEx
getVcsRootInstanceContext
-
-
-
-
Constructor Detail
-
VcsRootInstanceWithParent
public VcsRootInstanceWithParent(@NotNull VcsRootInstanceEx originalRoot, @NotNull SVcsRoot parentRoot)
-
-
Method Detail
-
isSubrepo
public boolean isSubrepo()
- Specified by:
isSubrepoin interfaceVcsRootInstanceEx- Returns:
- true if this root is a subrepository of some other root
-
getPreviousStatus
@NotNull public VcsRootStatus getPreviousStatus()
- Specified by:
getPreviousStatusin interfaceVcsRootInstanceEx
-
findModificationByVersion
@Nullable public SVcsModification findModificationByVersion(@NotNull String version)
Description copied from interface:VcsRootInstanceSearches for a VCS modification object associated with this VCS root and having the specified version (aka revision)- Specified by:
findModificationByVersionin interfaceVcsRootInstance- Parameters:
version- a version of a VCS modification object- Returns:
- a found object or null
-
findModificationIdByVersion
@Nullable public Long findModificationIdByVersion(@NotNull String version)
Description copied from interface:VcsRootInstanceSame asVcsRootInstance.findModificationByVersion(String)but retuns id of the VCS modification.- Specified by:
findModificationIdByVersionin interfaceVcsRootInstance- Parameters:
version- a version of a VCS modification object- Returns:
- an id of a found object or null
-
getDag
@NotNull public DAG<Long> getDag()
Description copied from interface:VcsRootInstanceReturns DAG of VCS commits, for non DAG based VCS root instances the method will return a linear DAG.- Specified by:
getDagin interfaceVcsRootInstance- Returns:
- see above
-
getVcsBranchesContainingModId
@NotNull public Set<String> getVcsBranchesContainingModId(long modId)
- Specified by:
getVcsBranchesContainingModIdin interfaceVcsRootInstanceEx
-
findModificationById
@Nullable public SVcsModification findModificationById(long modId)
Description copied from interface:VcsRootInstanceReturns VCS modification object associated with this VCS root instance and having the specified id.- Specified by:
findModificationByIdin interfaceVcsRootInstance- Parameters:
modId- id of a VCS modification- Returns:
- found VCS modification or null
-
addCollectChangesProgress
public void addCollectChangesProgress(@NotNull String progressMessage)- Specified by:
addCollectChangesProgressin interfaceVcsRootInstanceEx
-
getCollectChangesProgress
@NotNull public List<String> getCollectChangesProgress()
- Specified by:
getCollectChangesProgressin interfaceVcsRootInstanceEx
-
getLastUsedState
@NotNull public RepositoryState getLastUsedState()
- Specified by:
getLastUsedStatein interfaceLVcsRootInstanceEx- Specified by:
getLastUsedStatein interfaceVcsRootInstanceEx
-
getDefaultBranchName
@Nullable public String getDefaultBranchName()
Description copied from interface:VcsRootInstanceExFor DAG based VCS roots returns default branch name if it is known. The default branch name is known if the last used repository state is not empty.- Specified by:
getDefaultBranchNamein interfaceVcsRootInstanceEx- Returns:
- see above
-
mapPath
@Nullable public String mapPath(@NotNull String fileName, @NotNull CheckoutRules checkoutRules)
- Specified by:
mapPathin interfaceVcsRootInstanceEx- Parameters:
fileName- name of file from personal build which includes repository identity and relative path within repository, seePersonalSupportBatchService.mapPath(Collection, String, boolean)- Returns:
- first matched mapped path within given VcsRootInstance with given checkoutRules
-
setPollingMode
public void setPollingMode(boolean pollingMode)
- Specified by:
setPollingModein interfaceVcsRootInstanceEx
-
sameParameters
public boolean sameParameters(@NotNull Map<String,String> paramsForComparison)- Specified by:
sameParametersin interfaceVcsRootInstanceEx- Returns:
- true if this VCS root instance has the same set of parameters as the passed map
-
getMetrics
public VcsDurationMetrics getMetrics()
Description copied from interface:VcsRootInstanceExTC collects timing for the last checking for changes operations to show it on Vcs Status tab- Specified by:
getMetricsin interfaceVcsRootInstanceEx
-
resetPollingStateCache
public void resetPollingStateCache()
Description copied from interface:VcsRootInstanceExResets internal polling state cache so that next access to it's fields fetched them from the database- Specified by:
resetPollingStateCachein interfaceVcsRootInstanceEx
-
shouldStoreParentRevisions
public boolean shouldStoreParentRevisions()
- Specified by:
shouldStoreParentRevisionsin interfaceVcsRootInstanceEx- Returns:
- true if parent revisions should be stored into the database when a newly detected VCS commit is persisted
-
withConnectedDAG
public <R> R withConnectedDAG(@NotNull Predicate<VcsRootInstance> vcsRootPredicate, @NotNull Function<DAG<Long>,R> function)Description copied from interface:VcsRootInstanceExCalls provided function with a DAG which potentially can have VCS modifications belonging to different VCS root instances. The VCS root instances which can be used to connect DAGs should be accepted by the specified filter. The value returned by the function is also the result of this method.- Specified by:
withConnectedDAGin interfaceVcsRootInstanceEx- Returns:
-
isConnectedDAGsTraversingEnabled
public boolean isConnectedDAGsTraversingEnabled()
- Specified by:
isConnectedDAGsTraversingEnabledin interfaceVcsRootInstanceEx
-
getDescription
@NotNull public String getDescription()
- Specified by:
getDescriptionin interfaceLVcsRoot- Returns:
- short human readable description of the root. Composed by underlying VCS support.
-
getVcsDisplayName
@NotNull public String getVcsDisplayName()
Description copied from interface:LVcsRootReturns VCS plugin display name- Specified by:
getVcsDisplayNamein interfaceLVcsRoot- Returns:
- see above, returns null if VCS plugin corresponding to VCS root does not exist
-
isCurrentVersionExpensive
public boolean isCurrentVersionExpensive()
- Specified by:
isCurrentVersionExpensivein interfaceLVcsRootInstance
-
getParentId
public long getParentId()
- Specified by:
getParentIdin interfaceLVcsRootInstance- Returns:
- id of the parent VCS root object which unresolved parameters were used to construct this instance.
-
getStatus
@NotNull public VcsRootStatus getStatus()
- Specified by:
getStatusin interfaceLVcsRootInstance- Returns:
- VcsRootInstance status
-
isDagBased
public boolean isDagBased()
- Specified by:
isDagBasedin interfaceVcsRootInstance- Returns:
- true if root is from dag-based VCS and feature branches support is enabled for it, false otherwise or if VCS for the root cannot be found
-
getCurrentRevision
@NotNull public RepositoryVersion getCurrentRevision() throws VcsException
- Specified by:
getCurrentRevisionin interfaceVcsRootInstance- Overrides:
getCurrentRevisionin classVcsSettingsOperations- Returns:
- current revision in VCS for this VCS root (same as
CollectSingleStatePolicy.getCurrentVersion(VcsRoot)). - Throws:
VcsException
-
getLastUsedRevision
@Nullable public RepositoryVersion getLastUsedRevision()
- Specified by:
getLastUsedRevisionin interfaceVcsRootInstance- Returns:
- previous revision used to collect changes by this VCS root
-
getParent
@NotNull public SVcsRoot getParent()
- Specified by:
getParentin interfaceVcsRootInstance- Returns:
- parent VCS root object which unresolved parameters were used to construct this instance.
-
getUsages
@NotNull public Map<SBuildType,CheckoutRules> getUsages()
- Specified by:
getUsagesin interfaceVcsRootInstance- Returns:
- all usages of this VCS root _instance_ in various build configurations. Usages in versioned settings are not returned.
-
getEffectiveModificationCheckInterval
public int getEffectiveModificationCheckInterval()
- Specified by:
getEffectiveModificationCheckIntervalin interfaceVcsRootInstance- Returns:
- Effective modification check interval in seconds for this VcsRootInstance, either default, or an explicitly set
-
isPollingMode
public boolean isPollingMode()
Description copied from interface:VcsRootInstanceThe polling mode is enabled by default. If recently detected changes came via a commit hook from the VCS server, this mode is disabled.- Specified by:
isPollingModein interfaceLVcsRootInstanceEx- Specified by:
isPollingModein interfaceVcsRootInstance- Returns:
- see above
- See Also:
OperationRequestor
-
setStatus
public void setStatus(@NotNull VcsRootStatus.Type status)- Specified by:
setStatusin interfaceLVcsRootInstanceEx
-
compareAndSetStatus
public boolean compareAndSetStatus(@NotNull VcsRootStatus prevStatus, @NotNull VcsRootStatus.Type newStatus)Description copied from interface:LVcsRootInstanceExSets new status only if current status is the same as prevStatus.- Specified by:
compareAndSetStatusin interfaceLVcsRootInstanceEx- Parameters:
prevStatus- previous statusnewStatus- new status- Returns:
- true if status has been changed to new and false otherwise
-
startChangesCollectingInLock
public void startChangesCollectingInLock(@NotNull OperationRequestor requestor)Description copied from interface:LVcsRootInstanceExSet a requestor for the checking for changes procedure, also sets current VcsRootStatus status to STARTED Requires that VcsRootInstance is locked for changes collecting.- Specified by:
startChangesCollectingInLockin interfaceLVcsRootInstanceEx
-
getLastRequestor
@NotNull public OperationRequestor getLastRequestor()
Description copied from interface:LVcsRootInstanceExReturn the last requestor for checking for changes operation- Specified by:
getLastRequestorin interfaceLVcsRootInstanceEx- Returns:
-
setExplicitModificationCheckInterval
public boolean setExplicitModificationCheckInterval(@Nullable Integer secondsInterval)- Specified by:
setExplicitModificationCheckIntervalin interfaceLVcsRootInstanceEx- Parameters:
secondsInterval- new effective modification check interval in seconds, null to fallback to a user-defined value- Returns:
- true if the value for the interval has actually been changed
-
getLastFinishChangesCollectingTime
@Nullable public Date getLastFinishChangesCollectingTime()
Description copied from interface:LVcsRootInstanceExReturn the time when the last changes collecting was finished (the root status status changed toVcsRootStatus.Type.FINISHED) or null if no changes collecting is finished since server start- Specified by:
getLastFinishChangesCollectingTimein interfaceLVcsRootInstanceEx- Returns:
-
getVcsSupportCore
@NotNull public VcsSupportCore getVcsSupportCore()
- Specified by:
getVcsSupportCorein interfaceLVcsRootInstanceEx
-
tryLockChangesCollecting
public boolean tryLockChangesCollecting() throws InterruptedException- Specified by:
tryLockChangesCollectingin interfaceLVcsRootInstanceEx- Returns:
- true if changes collection was locked
- Throws:
InterruptedException
-
tryLockChangesCollecting
public boolean tryLockChangesCollecting(int timeoutMillis) throws InterruptedExceptionDescription copied from interface:LVcsRootInstanceExTry lock changes collecting lock for specified number of seconds- Specified by:
tryLockChangesCollectingin interfaceLVcsRootInstanceEx- Parameters:
timeoutMillis- timeout in milliseconds- Returns:
- true if lock was acquired
- Throws:
InterruptedException- when thread was interrupted while trying to acquire the lock
-
unlockChangesCollecting
public void unlockChangesCollecting()
Description copied from interface:LVcsRootInstanceExReleases changes collection lock and marks VCS Root FINISHED- Specified by:
unlockChangesCollectingin interfaceLVcsRootInstanceEx
-
isChangesCollectingLockObtained
public boolean isChangesCollectingLockObtained()
- Specified by:
isChangesCollectingLockObtainedin interfaceLVcsRootInstanceEx
-
describe
@NotNull public String describe(boolean verbose)
-
getId
public long getId()
Description copied from interface:VcsRootreturns root internal id
-
getName
@NotNull public String getName()
Description copied from interface:VcsRootreturns descriptive name of the vcs root
-
getVcsName
@NotNull public String getVcsName()
Description copied from interface:VcsRootReturns name of the corresponding version control.- Specified by:
getVcsNamein interfaceVcsRoot- Returns:
- name of the corresponding version control
-
getProperties
@NotNull public Map<String,String> getProperties()
Description copied from interface:VcsRootReturns mapping from a property name to its value- Specified by:
getPropertiesin interfaceVcsRoot- Returns:
- map of all defined properties
-
getProperty
@Nullable public String getProperty(@NotNull String propertyName)
Description copied from interface:VcsRootProvides specified property value- Specified by:
getPropertyin interfaceVcsRoot- Parameters:
propertyName- name of the property whose value is requested- Returns:
- value of a specified property
-
getProperty
@Contract("_,null->null;_,!null->!null") @Nullable public String getProperty(@NotNull String propertyName, @Nullable String defaultValue)Description copied from interface:VcsRootProvides specified property value or default value if property is not defined- Specified by:
getPropertyin interfaceVcsRoot- Parameters:
propertyName- name of the property whose value is requesteddefaultValue- default value which is returned if property value was not specified explicitly- Returns:
- - value of a specified property or 'defaultValue' if it is not defined
-
getExternalId
@NotNull public String getExternalId()
- Specified by:
getExternalIdin interfaceVcsRoot- Returns:
- External VCS Root ID in VCS services and on build agent. If unset (in tests, for instance), empty string is returned.
-
getVcsRootInstance
@NotNull protected VcsRootInstanceEx getVcsRootInstance()
- Specified by:
getVcsRootInstancein classVcsSettingsOperations
-
getDelegate
@NotNull public VcsRootInstanceEx getDelegate()
-
-