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 void
addCollectChangesProgress(String progressMessage)
boolean
compareAndSetStatus(VcsRootStatus prevStatus, VcsRootStatus.Type newStatus)
Sets new status only if current status is the same as prevStatus.String
describe(boolean verbose)
boolean
equals(Object o)
SVcsModification
findModificationById(long modId)
Returns VCS modification object associated with this VCS root instance and having the specified id.SVcsModification
findModificationByVersion(String version)
Searches for a VCS modification object associated with this VCS root and having the specified version (aka revision)Long
findModificationIdByVersion(String version)
Same asVcsRootInstance.findModificationByVersion(String)
but retuns id of the VCS modification.List<String>
getCollectChangesProgress()
RepositoryVersion
getCurrentRevision()
DAG<Long>
getDag()
Returns DAG of VCS commits, for non DAG based VCS root instances the method will return a linear DAG.String
getDefaultBranchName()
For DAG based VCS roots returns default branch name if it is known.VcsRootInstanceEx
getDelegate()
String
getDescription()
int
getEffectiveModificationCheckInterval()
String
getExternalId()
long
getId()
returns root internal idDate
getLastFinishChangesCollectingTime()
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 startOperationRequestor
getLastRequestor()
Return the last requestor for checking for changes operationRepositoryVersion
getLastUsedRevision()
RepositoryState
getLastUsedState()
VcsDurationMetrics
getMetrics()
TC collects timing for the last checking for changes operations to show it on Vcs Status tabString
getName()
returns descriptive name of the vcs rootSVcsRoot
getParent()
long
getParentId()
VcsRootStatus
getPreviousStatus()
Map<String,String>
getProperties()
Returns mapping from a property name to its valueString
getProperty(String propertyName)
Provides specified property valueString
getProperty(String propertyName, String defaultValue)
Provides specified property value or default value if property is not definedVcsRootStatus
getStatus()
Map<SBuildType,CheckoutRules>
getUsages()
Set<String>
getVcsBranchesContainingModId(long modId)
String
getVcsDisplayName()
Returns VCS plugin display nameString
getVcsName()
Returns name of the corresponding version control.protected VcsRootInstanceEx
getVcsRootInstance()
VcsSupportCore
getVcsSupportCore()
int
hashCode()
boolean
isChangesCollectingLockObtained()
boolean
isConnectedDAGsTraversingEnabled()
boolean
isCurrentVersionExpensive()
boolean
isDagBased()
boolean
isPollingMode()
The polling mode is enabled by default.boolean
isSubrepo()
String
mapPath(String fileName, CheckoutRules checkoutRules)
void
resetPollingStateCache()
Resets internal polling state cache so that next access to it's fields fetched them from the databaseboolean
sameParameters(Map<String,String> paramsForComparison)
boolean
setExplicitModificationCheckInterval(Integer secondsInterval)
void
setPollingMode(boolean pollingMode)
void
setStatus(VcsRootStatus.Type status)
boolean
shouldStoreParentRevisions()
void
startChangesCollectingInLock(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.boolean
tryLockChangesCollecting()
boolean
tryLockChangesCollecting(int timeoutMillis)
Try lock changes collecting lock for specified number of secondsvoid
unlockChangesCollecting()
Releases changes collection lock and marks VCS Root FINISHED<R> R
withConnectedDAG(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:
isSubrepo
in interfaceVcsRootInstanceEx
- Returns:
- true if this root is a subrepository of some other root
-
getPreviousStatus
@NotNull public VcsRootStatus getPreviousStatus()
- Specified by:
getPreviousStatus
in interfaceVcsRootInstanceEx
-
findModificationByVersion
@Nullable public SVcsModification findModificationByVersion(@NotNull String version)
Description copied from interface:VcsRootInstance
Searches for a VCS modification object associated with this VCS root and having the specified version (aka revision)- Specified by:
findModificationByVersion
in 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:VcsRootInstance
Same asVcsRootInstance.findModificationByVersion(String)
but retuns id of the VCS modification.- Specified by:
findModificationIdByVersion
in 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:VcsRootInstance
Returns DAG of VCS commits, for non DAG based VCS root instances the method will return a linear DAG.- Specified by:
getDag
in interfaceVcsRootInstance
- Returns:
- see above
-
getVcsBranchesContainingModId
@NotNull public Set<String> getVcsBranchesContainingModId(long modId)
- Specified by:
getVcsBranchesContainingModId
in interfaceVcsRootInstanceEx
-
findModificationById
@Nullable public SVcsModification findModificationById(long modId)
Description copied from interface:VcsRootInstance
Returns VCS modification object associated with this VCS root instance and having the specified id.- Specified by:
findModificationById
in interfaceVcsRootInstance
- Parameters:
modId
- id of a VCS modification- Returns:
- found VCS modification or null
-
addCollectChangesProgress
public void addCollectChangesProgress(@NotNull String progressMessage)
- Specified by:
addCollectChangesProgress
in interfaceVcsRootInstanceEx
-
getCollectChangesProgress
@NotNull public List<String> getCollectChangesProgress()
- Specified by:
getCollectChangesProgress
in interfaceVcsRootInstanceEx
-
getLastUsedState
@NotNull public RepositoryState getLastUsedState()
- Specified by:
getLastUsedState
in interfaceLVcsRootInstanceEx
- Specified by:
getLastUsedState
in interfaceVcsRootInstanceEx
-
getDefaultBranchName
@Nullable public String getDefaultBranchName()
Description copied from interface:VcsRootInstanceEx
For 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:
getDefaultBranchName
in interfaceVcsRootInstanceEx
- Returns:
- see above
-
mapPath
@Nullable public String mapPath(@NotNull String fileName, @NotNull CheckoutRules checkoutRules)
- Specified by:
mapPath
in 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:
setPollingMode
in interfaceVcsRootInstanceEx
-
sameParameters
public boolean sameParameters(@NotNull Map<String,String> paramsForComparison)
- Specified by:
sameParameters
in 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:VcsRootInstanceEx
TC collects timing for the last checking for changes operations to show it on Vcs Status tab- Specified by:
getMetrics
in interfaceVcsRootInstanceEx
-
resetPollingStateCache
public void resetPollingStateCache()
Description copied from interface:VcsRootInstanceEx
Resets internal polling state cache so that next access to it's fields fetched them from the database- Specified by:
resetPollingStateCache
in interfaceVcsRootInstanceEx
-
shouldStoreParentRevisions
public boolean shouldStoreParentRevisions()
- Specified by:
shouldStoreParentRevisions
in 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:VcsRootInstanceEx
Calls 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:
withConnectedDAG
in interfaceVcsRootInstanceEx
- Returns:
-
isConnectedDAGsTraversingEnabled
public boolean isConnectedDAGsTraversingEnabled()
- Specified by:
isConnectedDAGsTraversingEnabled
in interfaceVcsRootInstanceEx
-
getDescription
@NotNull public String getDescription()
- Specified by:
getDescription
in interfaceLVcsRoot
- Returns:
- short human readable description of the root. Composed by underlying VCS support.
-
getVcsDisplayName
@NotNull public String getVcsDisplayName()
Description copied from interface:LVcsRoot
Returns VCS plugin display name- Specified by:
getVcsDisplayName
in interfaceLVcsRoot
- Returns:
- see above, returns null if VCS plugin corresponding to VCS root does not exist
-
isCurrentVersionExpensive
public boolean isCurrentVersionExpensive()
- Specified by:
isCurrentVersionExpensive
in interfaceLVcsRootInstance
-
getParentId
public long getParentId()
- Specified by:
getParentId
in 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:
getStatus
in interfaceLVcsRootInstance
- Returns:
- VcsRootInstance status
-
isDagBased
public boolean isDagBased()
- Specified by:
isDagBased
in 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:
getCurrentRevision
in interfaceVcsRootInstance
- Overrides:
getCurrentRevision
in classVcsSettingsOperations
- Returns:
- current revision in VCS for this VCS root (same as
CollectSingleStatePolicy.getCurrentVersion(VcsRoot)
). - Throws:
VcsException
-
getLastUsedRevision
@Nullable public RepositoryVersion getLastUsedRevision()
- Specified by:
getLastUsedRevision
in interfaceVcsRootInstance
- Returns:
- previous revision used to collect changes by this VCS root
-
getParent
@NotNull public SVcsRoot getParent()
- Specified by:
getParent
in interfaceVcsRootInstance
- Returns:
- parent VCS root object which unresolved parameters were used to construct this instance.
-
getUsages
@NotNull public Map<SBuildType,CheckoutRules> getUsages()
- Specified by:
getUsages
in 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:
getEffectiveModificationCheckInterval
in 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:VcsRootInstance
The 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:
isPollingMode
in interfaceLVcsRootInstanceEx
- Specified by:
isPollingMode
in interfaceVcsRootInstance
- Returns:
- see above
- See Also:
OperationRequestor
-
setStatus
public void setStatus(@NotNull VcsRootStatus.Type status)
- Specified by:
setStatus
in interfaceLVcsRootInstanceEx
-
compareAndSetStatus
public boolean compareAndSetStatus(@NotNull VcsRootStatus prevStatus, @NotNull VcsRootStatus.Type newStatus)
Description copied from interface:LVcsRootInstanceEx
Sets new status only if current status is the same as prevStatus.- Specified by:
compareAndSetStatus
in 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:LVcsRootInstanceEx
Set 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:
startChangesCollectingInLock
in interfaceLVcsRootInstanceEx
-
getLastRequestor
@NotNull public OperationRequestor getLastRequestor()
Description copied from interface:LVcsRootInstanceEx
Return the last requestor for checking for changes operation- Specified by:
getLastRequestor
in interfaceLVcsRootInstanceEx
- Returns:
-
setExplicitModificationCheckInterval
public boolean setExplicitModificationCheckInterval(@Nullable Integer secondsInterval)
- Specified by:
setExplicitModificationCheckInterval
in 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:LVcsRootInstanceEx
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 start- Specified by:
getLastFinishChangesCollectingTime
in interfaceLVcsRootInstanceEx
- Returns:
-
getVcsSupportCore
@NotNull public VcsSupportCore getVcsSupportCore()
- Specified by:
getVcsSupportCore
in interfaceLVcsRootInstanceEx
-
tryLockChangesCollecting
public boolean tryLockChangesCollecting() throws InterruptedException
- Specified by:
tryLockChangesCollecting
in interfaceLVcsRootInstanceEx
- Returns:
- true if changes collection was locked
- Throws:
InterruptedException
-
tryLockChangesCollecting
public boolean tryLockChangesCollecting(int timeoutMillis) throws InterruptedException
Description copied from interface:LVcsRootInstanceEx
Try lock changes collecting lock for specified number of seconds- Specified by:
tryLockChangesCollecting
in 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:LVcsRootInstanceEx
Releases changes collection lock and marks VCS Root FINISHED- Specified by:
unlockChangesCollecting
in interfaceLVcsRootInstanceEx
-
isChangesCollectingLockObtained
public boolean isChangesCollectingLockObtained()
- Specified by:
isChangesCollectingLockObtained
in interfaceLVcsRootInstanceEx
-
describe
@NotNull public String describe(boolean verbose)
-
getId
public long getId()
Description copied from interface:VcsRoot
returns root internal id
-
getName
@NotNull public String getName()
Description copied from interface:VcsRoot
returns descriptive name of the vcs root
-
getVcsName
@NotNull public String getVcsName()
Description copied from interface:VcsRoot
Returns name of the corresponding version control.- Specified by:
getVcsName
in interfaceVcsRoot
- Returns:
- name of the corresponding version control
-
getProperties
@NotNull public Map<String,String> getProperties()
Description copied from interface:VcsRoot
Returns mapping from a property name to its value- Specified by:
getProperties
in interfaceVcsRoot
- Returns:
- map of all defined properties
-
getProperty
@Nullable public String getProperty(@NotNull String propertyName)
Description copied from interface:VcsRoot
Provides specified property value- Specified by:
getProperty
in 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:VcsRoot
Provides specified property value or default value if property is not defined- Specified by:
getProperty
in 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:
getExternalId
in 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:
getVcsRootInstance
in classVcsSettingsOperations
-
getDelegate
@NotNull public VcsRootInstanceEx getDelegate()
-
-