It's all about the answers!

Ask a question

How can I programmatically obtain a list of files modified since a certain date?


Peter Verdon (61132) | asked Jan 17 '13, 8:43 a.m.
For bureaucratic purposes, I need to produce a list of files that have been modified (in our main development stream) since a given date. This needs to happen as part of a build (using Ant in JBE, but I don't mind shelling out to bash, writing Java, or hitting Web APIs if required). I realise the definition of "modified since" might have some tricky edge cases, but I'm willing to ignore a few false positives or negatives as they won't have any technical impact. Delivery of the last changeset that touched it is ideally what I'd regard as modification time, but any events likely to happen around the same time will do.

So far the closest I have been able to come is a list of the most recent changeset that modified each file, using scm history, but I don't seem to be able to get dates out of this.

The number of files may potentially be large, so I don't want to end up making an individual request for each one if I can avoid it.

I am using RTC 3.0.1

I'm not really familiar with the RTC Java or ReST APIs, so if a response involves using them then a bit of hand-holding would not go amiss!

I'm doing this inside IBM, so can use any code that other IBMers may have.

Thanks,

Pete

Comments
Tim Mok commented Jan 17 '13, 4:14 p.m.
JAZZ DEVELOPER

Can you create baselines or snapshots where you can use them in a comparison later? This would help simplify what you need to do. Or are the dates arbitrary?


Peter Verdon commented Jan 18 '13, 4:45 a.m.

Well, it's happening in a build, so I guess I have the "now" snapshot automatically. The "then" snapshot doesn't currently exist, and it wouldn't be tied to a particular development activity but to an arbitrary date. These aren't happening all that frequently, so I guess we could manually create them when required, but I'd prefer not to do that if possible.

Thanks.


Tim Mok commented Jan 18 '13, 2:46 p.m.
JAZZ DEVELOPER

Because you don't have snapshots of the "then" state, it'll be more work to get the information that you need. It might be best to use the Java APIs and go through each file to see when it was last modified in a stream. I think you'll have to go the route of checking the date on the last change set in the stream that includes the file.


I don't have confidence that this would run very quickly but it sounds like you won't be doing it very often. If you want to go this route, the forums will be here to help any questions about your implementation.


Peter Verdon commented Jan 21 '13, 6:58 a.m.

This does sound like the approach I'll need to take. You're right that it doesn't need to happen often, so provided it completes in less than a few hours it will be acceptable.


I've never used the Java API before - I'm not asking you to do my work for me, but can you point me to a decent primer to get started and any thoughts you already have on which bits I'd need to use?

Thanks.


Tim Mok commented Jan 21 '13, 10:42 a.m.
JAZZ DEVELOPER

https://jazz.net/wiki/bin/view/Main/RTCSDK20_SourceControl


There's the wiki page describing the API for source control. I don't believe anything has changed significantly for what you want to do so that information should still apply despite it was originally written for RTC 2.0.

You'll want to look at IConfiguration to get your files of interest. The files are of type IVersionable as a generic type for files, folders, and anything else stored in source control. IVersionable is an IItem and it does have a modified(), which is the date the item state was created. This may be enough for you but this date won't necessarily be the same or near the date of change set delivery. So you may want to retrieve the file history to get the last change set and it's date for a closer approximation of delivery.

This is all a lot of information to take in so please feel free to ask questions on the forum.


Peter Verdon commented Jan 21 '13, 11:01 a.m.

Thanks - I'll take a look at that and see how I get on.


modified() may well be what I need - the specific business requirement is based on "the date the file was changed", which as we know is not as simple a definition as the lawyer who wrote it probably thinks :-). I was taking delivery as my timestamp, being the date it changed in our main dev stream, but it sounds like this represents the date someone checked it into a changeset, which seems equally valid to me.

showing 5 of 6 show 1 more comments

2 answers



permanent link
Li Zhu (11) | answered Jan 18 '13, 12:47 p.m.
JAZZ DEVELOPER
I did some similar work in CLM to publish the child builds work items in the RTC build result by running 'scm compare' in Ant.  Please see the wiki https://jazz.net/wiki/bin/view/Main/CLMBuildsComparer#Work_item_changes_included_in_th.
Unfortunately it does not give the list of files changes.

I'm wondering if you could run build snapshot comparison, then go to the Change Explorer view. There is a "Save Change log" option. Select 'Filesystem changes' in the Elements to include section, you will get the list of files changes in Clipboard or a specified file.

Comments
Peter Verdon commented Jan 21 '13, 6:53 a.m.

Sorry, this all appears to be GUI stuff rather than something I can incorporate into a build. 


permanent link
Eddie Breeveld (6112530) | answered Jan 15 '14, 5:02 a.m.
edited Jan 15 '14, 5:03 a.m.
I don't know if your question has been answered, but I asked a similar question recently and got a couple of ideas: List of files changed since 1st january

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.