It's all about the answers!

Ask a question

Using "scm diff" with UUIDs as beforetype


Stefan Bellon (612) | asked Aug 05 '14, 10:43 a.m.
edited Aug 05 '14, 10:44 a.m.
I have a question regarding how to interface to the RTC command line tool "scm" in a very specific automated nightly build scenario:

Let's assume we have a sandbox with the local copy of a repository workspace already set up.

After the automated build updates the local content using "scm accept" to bring in the latest changes from the stream, we want to find out "file revisions" of all files now loaded into the sandbox.

It looks like "scm --show-uuid y list remotefiles" is doing exactly that: showing each file (and directory) in the local sandbox together with the object selector and version selector of the file in its current state.

Then it looks like you can make use of the object selector and version selector in the command "scm get file" to fetch the contents of a single file in the future in a very specific version (like it was recorded earlier with "scm list remotefiles" above).

What I am missing now is the possibility to use the version selector together with the "scm diff" command's "beforetype" in order to diff the version of the file currently in the sandbox against an older version using a previously recorded version selector.

Alternatively - if there is no way to diff using a version selector UUID - is there a way to get the numbers of the latest changesets the files in the sandbox were modified in? So that we can record the most current changeset for each file (instead of the version selector) and then use "scm changeset extract" instead of "scm get file" to fetch the file and "scm diff" with "changeset" as "beforetype"?

Thanks for your help in advance!

One answer



permanent link
Lily Wang (4.9k714) | answered Aug 05 '14, 10:41 p.m.
 Hi Stefan,
The "beforetype" for file is not supported by "scm diff" command line.
This question was answered in https://jazz.net/forum/questions/48283/scm-diff-with-beforetype-quotfilequot.

You can use "scm show history <filename>" command to find the change set history in the sandbox. If you use parameter "--maximum 2", the last listed change set is the changeset you are looking for.

Hope that's helpful.

Comments
Stefan Bellon commented Aug 06 '14, 2:21 a.m.

First of all, thanks for your quick answer.

Regarding "file" not supported as "beforetype" in "scm diff" ... yes, that's clear. That wasn't what I was looking for. I'm rather looking for something like "versionselector" or "uuid" as "beforetype". But obviously that does not exist either.

Regarding "scm show history <filename>" ... but that means that I'd have to call that command for thousands of files in the current sandbox? Is there no efficient way to get at the most recent changeset number for all files in the sandbox in one (or a few) calls without the need to query each file on its own?

Back to my scenario: At point of time "A" I want to record for each file in the sandbox its most recent changeset number, so that I can later (at point in time "B") do a diff of individual files between point in time "A" and point in time "B" and fetch the contents of the file as it was at point in time "A".


Lily Wang commented Aug 06 '14, 8:34 p.m.

I can not think a way to list the latest change set for all files as each file has different history.


Actually if you are using RTC build, a snapshot is created for each build if you have "Jazz Source Control" pre-build in the build definition. The snapshot is created in the build workspace so you can use "scm list snapshot" to get the snapshot name and uuid. Then you can use the snapshot as the "beforetype" of the "scm diff" command to get the difference of a file between current build and last build.


Stefan Bellon commented Aug 15 '14, 5:45 a.m.

I think I'll try the following:

- call "scm list components --json WORKSPACE"
- then for each component in the workspace, do "scm show history --json COMPONENT"

It looks like you can extract the internals UUIDs of the changesets, all the files that have been changed in the changeset as well as the file's UUID and the version UUID of the file from that output.

The UUID of the changeset can be used with "scm diff file FILE changeset CHANGESET_UUID" and the file UUID and version UUID combination can be used with "scm get file FILE_UUID VERSION_UUID".

So it looks like parsing the JSON from "show history" and reconstructing the changeset/filename/version mapping over the history may be the way to go.

Your answer


Register or to post 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.