SCM Gap detection using java API
I'm wondering what the best way is to do automatic gap detection in an automated build.
We've created custom plugin which will automatically detect and accept any changes which are linked to a work item that's in the correct state (fx. "Ready for deployment to DEV"). This will sometimes create Gap because not all changes will be accepted from the source stream. Therefore I'm creating a method to create warnings like: "WARNING - change set [<comment>] on work item [<id>, <summary>] is depending on work items [<id>, <id1> ...]" I'm wondering what the best method is to find and detect the parent change-set of a Versionable with a certain State. I'm seeing multiple utils to find change-sets for a Versionable, but not in the correct State. I then have to loop through all change-sets and compare the StateId. My method follows (see pastbin for properly formatted example http://pastebin.com/Hde3SNDw). (removed my code example here because it was too messy to paste here. Use pastebin link above). |
Accepted answer
You will probably not find the changeSets you need by looking at the changeSets from getHistoryFor because those changeSets are already in your workspace. If they had the state you need, then you probably wouldn't have a gap in the first place.
Starting in RTC 5.0, there is a new method IWorkspaceConnection.findChangeSetsToAcceptToFillGap. This method is basically looking through other branches of history that contain the changeSet you want to accept and seeing what changeSets they have which could be used to fill the gap. If you are on an earlier release, then you might have to use IWorkspaceManager.findChangeSets to search for all changeSets that affect your versionable (IChangeSetSearchCriteria.setItem). This will return max 512 changeSets, if you need more, take note of the modified time of the last changeSet returned from the query and requery with a new IChangeSetSearchCriteria that has the modified before time set. Morten Madsen selected this answer as the correct answer
|
One other answer
Thanks a lot Andrew. That was quite helpful information. I can certainly use that in other case.
My main concern here though is locating the Parent versionable state of a certain versionable. I didn't explain myself too well though. I'm getting version history for the target stream, not my own workspace. I'm only working with the source stream and target stream of the build, the build workspace in which the build is running is equals to the target stream at build start (i replace the components with target HEAD when build is initiated). My build is basically a build + delivery mechanism which will: a. detect incoming changes attached to work items ready for build (state). b. accept these changes and change work item state -> build in progress c. build and deploy to target environment (DEV/TEST/PROD) d. update work item state appropriately ("deployed to DEV" / "build to DEV failed") So, I guess my only way to do this is actually what I'm doing right now. There is no way of searching based in the versionable state? Only looping through all changes to that versionable and comparing State ID? My main reason for this is to provide detailed feedback why the build has failed, and maybe automatically create Depends relation on work items in certain cases: 1. The parent of the change to be delivered is not in the target stream 2. The change itself is the result of a merge and needs it's children to be in target stream 3. The change itself is a sibling of a merge and needs either no other siblings to be in target, or it would need all other siblings to be in build + the merge result change. (I know, this get's quite complicated.... but I'm so close now). thx again. /Morten. ps. I had to post an answer, it was too long to be a comment. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.