使用RTC源代码控制获取已更改文件的文件名,位置和作者 [英] Getting filename, location and author of changed files using RTC source control
问题描述
我正在尝试访问给定流的已更改文件的文件名,位置和作者。下面的代码是我到目前为止。看看api文档这似乎不可能吗?可以使用java api或其他方法实现吗?
I'm trying to access the filename, location and author of changed files for a given stream. Below code is what I have so far. Looking at the api documentation this does not seem possible? Can this be achieved using the java api or some other method ?
IChangeSetSearchCriteria c = IChangeSetSearchCriteria.FACTORY.newInstance();
WorkspaceManager mgr = (WorkspaceManager) SCMPlatform.getWorkspaceManager(repo);
IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
criteria.setKind(IWorkspaceSearchCriteria.STREAMS);
criteria.setExactName("mystream");
推荐答案
注意:尽量不要直接使用Stream名称,因为Stream可以重命名,或者另一个Stream可以具有相同的名称。
参见此主题获取更多信息。
Note: try to not use the Stream name directly, as a Stream can be renamed or another Stream can have the same name.
See this thread for more.
如果他们在命令行上运行,那么您可以获取流的UUID,从中创建句柄并在搜索条件中设置值(尽管您可能希望首先获取流,因为用户可能已经输入了错字)。
If they're running on the command line, then you can take the UUID of the stream, create a handle from it and set the value in the search criteria (although you may want to fetch the stream first, since the user may have made a typo).
从UUID转到ItemHandle
For going from a UUID to an ItemHandle
workspaceHandle = (IWorkspaceHandle)IWorkspace.ITEM_TYPE.createItemHandle(workspaceID, null);
关于列出变更集的内容,这个主题提供了一些线索:
Regarding listing the content of a changeset, this thread provides some clues:
如果versionable代表一个文件,它将是
IFileItem
的一个实例,它有一个与之关联的内容对象。$
您可以从内容对象获取内容流。
If the versionable represents a file, it will be an instance of an
IFileItem
which has a content object associated with it.
You can get a stream to the contents from the content object.
再次,获取变更集(如此主题)可以是确保所有数据的关键。
Again, fetching the changeset (as in this thread) can be key to be sure to get all the data.
注意:使用REST API路线可能更容易:
您的查询是POST
Note: taking the REST API route might be easier:
Your query is a POST
Request URL:https://jazzServer/jazz/oslc-scm/changeSet?jazz_scm:workspaceId=_OQt98EyrEeGAvYGjhK23_g&jazz_scm:maxResults=25&jazz_scm:changeKind=31
Request Method:POST
Cookie:SaveStateCookie=undefined%2Ccom.ibm.team.workitem.category%2Ccom.ibm.teamz.dsdef.category%2Ccom.ibm.team.dashboard.category%2Ccom.ibm.team.dashboard.category~%23_~%23com.ibm.team.dashboard.server.saveTeamDashboard; JSESSIONID=BF3DA3D5E0FCA16193876307E91A5471; JazzFormAuth=Form; net-jazz-ajax-cookie-rememberUserId=VonC; JSESSIONIDSSO=05626E20EC4F6DB231759EFC4DB69785
Host:jazzServer
Origin:https://jazzServer
Referer:https://jazzServer/jazz/web/projects/My%2°RTC%20Project
Form Dataview URL encoded
{"propertyRequest":{"jazz_scm:lastModified":null,"jazz_scm:creator":{"dcterms:name,rdf:resource":null},"jazz_scm:reasons":{"dcterms:title,rdf:resource":null},"jazz_scm:relatedArtifacts":{"dcterms:title,dcterms:description,rdf:resource,jazz_scm:linkTypeId,oslc_scm:mimeType":null}}}:
这将返回:
{jazz_scm:firstTimestamp:1350975540822, jazz_scm:lastTimestamp:1350285276229,…}
jazz_scm:firstTimestamp: 1350975540822
jazz_scm:lastTimestamp: 1350285276229
jazz_scm:results: [{rdf:resource:https://jazzServer/jazz/oslc-scm/changeSetId/__KSygRzVEeK_Q6KSNVybvA,…},…]
0: {rdf:resource:https://jazzServer/jazz/oslc-scm/changeSetId/__KSygRzVDeK_Q6KSNVybvA,…}
dcterms:description: "Check-in of xslts into RTC taken from UAT server."
dcterms:identifier: "itemOid/com.ibm.team.scm.ChangeSet/__KSygRzVDeK_Q6KSNVybvA"
dcterms:modified: 1350975540822
dcterms:name: null
dcterms:type: "com.ibm.team.scm.changeSet"
jazz_scm:creator: {,…}
dcterms:description: null
dcterms:identifier: "itemOid/com.ibm.team.repository.Contributor/_YakgYGUUEeCXgMjSYYyTpw"
dcterms:modified: 1321511726283
dcterms:name: "a User"
dcterms:type: "com.ibm.team.scm.contributor"
jazz_scm:itemId: "_YakgYGUUEeCXgMjSYYyTpw"
jazz_scm:itemType: "com.ibm.team.repository.Contributor"
prefixes: {dcterms:http://purl.org/dc/elements/1.1/, rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#,…}
qname: "jazz_scm:Contributor"
rdf:resource: "https://jazzServer/jazz/oslc-scm/itemOid/com.ibm.team.repository.Contributor/_YakgYGUUEeCXgMgSYYyTpw"
jazz_scm:itemId: "__KSygRzVDeK_Q6KSNVybvA"
jazz_scm:itemType: "com.ibm.team.scm.ChangeSet"
jazz_scm:lastModified: null
jazz_scm:reasons: [{rdf:resource:itemName/com.ibm.team.workitem.WorkItem/258061,…}]
jazz_scm:relatedArtifacts: []
prefixes: {dcterms:http://purl.org/dc/elements/1.1/, rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#,…}
qname: "oslc_scm:ChangeSet"
rdf:resource: "https://jazzServer/jazz/oslc-scm/changeSetId/__KSygRzVEeK_Q6KSNVybvA"
1: {rdf:resource:https://jazzServer/jazz/oslc-scm/changeSetId/_Pg_RMRwzEeK_Q6KSNVybvA,…}
2: {rdf:resource:https://jazzServer/jazz/oslc-scm/changeSetId/_3L3gcRwyEeK_Q6KSNVybvA,…}
....
_OQt98EyrEeGAvYGjhK23_g
流的 workspaceItemId
(Stream是一个工作区,元素为 stream
设置为true!
With _OQt98EyrEeGAvYGjhK23_g
the workspaceItemId
of the Stream (a Stream is a Workspace with the element "stream
" set to true!)
您可以使用以下查询获取Stream的WorkspaceItemId:
You can get the WorkspaceItemId of a Stream with the following query:
Request URL:https://jazzServer/jazz/service/com.ibm.team.scm.common.internal.rest.IScmRestService2/searchWorkspaces?workspaceName=A%20STREAM%20NAME&workspaceNameKind=partial%20ignorecase&maxResultSize=50&workspaceKind=both
Request Method:GET
Cookie:SaveStateCookie=undefined%2Ccom.ibm.team.workitem.category%2Ccom.ibm.teamz.dsdef.category%2Ccom.ibm.team.dashboard.category%2Ccom.ibm.team.dashboard.category~%23_~%23com.ibm.team.dashboard.server.saveTeamDashboard; JSESSIONID=BF3DA3D5E0FCA16193876307E91A5471; JazzFormAuth=Form; net-jazz-ajax-cookie-rememberUserId=VonC; JSESSIONIDSSO=05626E20EC4F6DB231759EFC4DB69785
Host:jazzServer
Referer:https://jazzServer/jazz/web/projects/A%20STREAM%20NAME
X-Requested-With:XMLHttpRequest
Query String Parametersview URL encoded
workspaceName:A STREAM NAME
workspaceNameKind:partial ignorecase
maxResultSize:50
workspaceKind:both
这将返回结果,包括:
<workspaces>
<workspace itemId="_OQt98EyrEeGAvYGjhK23_g" properties="">
<stateId>_-flUwBwpEeK_Q6KSNVybvA</stateId>
<immutable>true</immutable>
<contextId>_Dp6kMdwTEd2jUupDpEV1Rw</contextId>
<modified>2012-10-32T10:22:18.766Z</modified>
<name>A Stream Name</name>
<stream>true</stream>
<description>a stream</description>
<time>109</time>
<customContext xsi:nil="true"/>
<normalizedName>a stream name</normalizedName>
<readPermissionMode>0</readPermissionMode>
<modifiedBy itemId="_Y70gkCYmEeGAvYGjhJ23_g"/>
<owner itemId="_ICt_wDL6EeGeLde_4UGHCg" xsi:type="process:ProjectAreaHandle"/>
<flows>
...
这篇关于使用RTC源代码控制获取已更改文件的文件名,位置和作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!