VCS plugin - feature branches

Answered

Hi,

I'm currently adding support for feature branches in the Plastic SCM VCS Plugin. I think I have everything ready (clearly I'm wrong) but TeamCity detects all new changesets to belong to all branches. This renders the plugin unusable, since a new commit in the default branch would trigger a build in all active branches.

I have a PlasticVcsSupport class extending ServerVcsSupport. This is the PlasticVcsSupport.getCollectChangesPolicy() method:

@NotNull
public CollectChangesPolicy getCollectChangesPolicy() {
return new PlasticCollectChangesPolicy(this, currentSettings, settingsLock);
}

This is an overview of the PlasticCollectChangesPolicy:

public class PlasticCollectChangesPolicy implements CollectChangesBetweenRepositories {

@NotNull
public RepositoryStateData getCurrentState(VcsRoot root) throws VcsException {
/* ... */
BranchInfo[] branches = QueryCommands.GetBranches(wi);

return RepositoryStateData.createVersionState(
mSettings.getSelectorBranch(), getBranchHeads(branches));
/* ... */
}

@NotNull
public List<ModificationData> collectChanges(
@NotNull VcsRoot fromRoot,
@NotNull RepositoryStateData fromState,
@NotNull VcsRoot toRoot,
@NotNull RepositoryStateData toState,
@NotNull CheckoutRules checkoutRules) throws VcsException {
return collectChanges(fromRoot, fromState, toState, checkoutRules);
}

public List<ModificationData> collectChanges(
@NotNull VcsRoot vcsRoot,
@NotNull RepositoryStateData fromState,
@NotNull RepositoryStateData toState,
@NotNull CheckoutRules checkoutRules) throws VcsException {
/* ... */

for (String branch : fromState.getBranchRevisions().keySet()){
result.addAll(getDifferencesBetweenVersions(
vcsRoot,
wkInfo,
branch,
fromState.getBranchRevisions().get(branch),
toState.getBranchRevisions().get(branch)));
}
/* ... */

return result;
}
}

The getCurrentStatus() method seems to be working fine since new changes are being properly detected and the from/to states passed to the collectChanges() methods make sense. However, it seems I'm missing something to be set to the returned ModificationData, since TeamCity is unable to find out the branch for each ModificationData. I'm setting the proper parent changeset using the addParentRevision(String) method, but that achieved nothing. I've checked the git plugin code too, but I can't see what I'm missing :-(

This is how ModificationData are built:

List<VcsChange> files = /* fill changeset data */;
ModificationData md = new ModificationData(
changeset.getDate(),
files,
changeset.getComments(),
changeset.getOwner(),
vcsRoot, // Unmodified
changeset.getSpec(),
changeset.getId());
md.addParentRevision(changeset.getParentSpec());

Any kind of help will be really appreciated :-)

Thanks!

Miguel

 

1 comment

 

 

To report commits graph to TeamCity correctly you need to report revisions in repository state and use them as versions and parent versions in modification data. So shouldn't it be:

ModificationData md = new ModificationData(
changeset.getDate(),
files,
changeset.getComments(),
changeset.getOwner(),
vcsRoot, // Unmodified
changeset.getId(),
changeset.getId());
md.addParentRevision(changeset.getParentIds());

?

0

Please sign in to leave a comment.