Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get the change set ID in VcsRepositoryViewer's getWebRepositoryUrlForFileDiff?

Chris Pickett April 17, 2017

I'm trying to implement VcsRepositoryViewer for Perforce Swarm. The only way Swarm can display diffs for a file revision is on the same page that shows the commit that the file revision was part of. Because of this, I need access to both the filename and change set ID in order to generate the appropriate link to view diffs. getWebRepositoryUrlForFileDiff() currently only has access to the filename and revision.

I can return null from getWebRepositoryUrlForFileDiff() to hide the "(diffs)" link for now, but it would be great if we could get the diff link working without supplying our own template to replace the built-in one.

Is there any way to get access to the change set ID in this function? I realize the design of this new plugin point was to be stateless, so I assume not, but we'd really like to get this working if possible. The problem seems to be that defaultCommitView.ftl has

[#local fileDiffUrl = linkGenerator.getWebRepositoryUrlForFileDiff(file, repositoryData)!/]
[#if fileDiffUrl?has_content]
    <a href="${fileDiffUrl}">(diffs)</a>
[/#if]


coded into it so unless we replace the template with our own, I don't see how to do this right now.

Any feedback would be appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 18, 2017
  if (file.isRevisionKnown())
        {
            String revision = file.getRevision();
}
Chris Pickett April 18, 2017

Thanks for contributing, but Perforce separates the concept of file revision from commit ID, so revision 2 of a file could be in commit 1000. In that example, the 1000 (commit.getChangeSetId()) is the part I'd need while I currently only have the 2.

Chris Pickett April 26, 2017

If this is not something that's currently possible, where can I enter a feature request to get it added?

Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 29, 2017

> revision 2 of a file could be in commit 1000.

Please help me understand, are you saying that file changed in commit 1000 can have revision number 2?

As you can imagine, usually it's not the case. Do you use Bamboo's built-in Perforce plugin to generate the changelists or something else?

Update: you probably don't, because in our Perforce plugin we deliberately ignore file revisions when creating CommitFile objects and set file revision to commit revision. If you are developer of Perforce Swarp repository plugin, then perhaps the easiest thing is to do the same.

I opened this improvement request to fix our API: https://jira.atlassian.com/browse/BAM-18354

Chris Pickett April 29, 2017

> Please help me understand, are you saying that file changed in commit 1000 can have revision number 2?

Yes, that's exactly correct.

> Do you use Bamboo's built-in Perforce plugin to generate the changelists or something else?

We have written our own Perforce plugin to fully support Perforce Streams using the new VCS plugin points in Bamboo 5.14. I hope to be able to release it once we've completed work on it.

> If you are developer of Perforce Swarp repository plugin, then perhaps the easiest thing is to do the same.

It's important to us to be able to separate file revision from commit ID because the two are distinct and each has its use in Perforce. I also use Git so I understand that other VCS's handle things differently. :)

> I opened this improvement request to fix our API: https://jira.atlassian.com/browse/BAM-18354

Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events