How to find list of changes delivered since yesterday from delivered activities? - clearcase-ucm

I am using cleartool find command to find the list of files delivered to integration stream since previous day. Following is the command [ I am storing the result in powershell variable]
$ListOfFilesChanges = cleartool find "$folderPath" -version "{brtype($streamName) && created_since($fromDate)}" -print
But it is taking much time as we are verifying many folder. If we are able to find list of activities delivered since yesterday and find the list of files delivered as part of delivery it may be faster.
I need to find the list of deliveries done previous day. Then need to check what are all the files delivered as part of it.
Is there any cleartool command available to do this?

Deliver in UCM generates a deliver activity, named "deliver.dev_stream.xxxx" (see an example in "Describe baseline and expand deliver and rebase activities").
You can use fmt_ccase filters to display the date:
cleartool lsact -in yourIntStream#\yourPVob -fmt "%Nd\t%n\n" | sort -r
This is similar to a previous question "how to find the list activities delivered to integration stream on a particular day?".
It would be easier to list all activities created since yesterday, and, for each delivery activity, list their versions in the change set of said activities.
You can describe each version found in those activities with the -fmt "%En" parameter to get the element name (that is the name of the file instead of the extended pathname of the version), and sort that list to get rid of similar elements (|uniq)

Related

git: detect file creator

I run a book digitizing project and pay people certain rate per 10K characters for the text files they upload to a git repo. Till now I was using following command to detect files authored by CertainEditor:
git log --use-mailmap --no-merges --author="CertainEditor" --name-only --pretty=format:""
Then I would pipe this output in wc -m and get amount of characters authored by CertainEditor and pay him accordingly. Usually editors do not touch each other's files and everything worked well. However recently one editor spotted a typo in somebody else's file and corrected it. This behavior is actually good and I would like to encourage it. However, now the command above lists the corrected file also as his, and so he gets paid for all the characters in the file while he changed only one of them. This, obviously, is not good.
Do you have an idea how can I list all the files created (not authored / committed) by a user, so I can implement a fair characters counting?
Maybe some commit hooks can be used that will check whether the Author of a new commit is different from the previous one and if true - override it to the previous Author?
Those small changes by a non-creator may be left not paid for (as this action is not so intensive and may be reciprocal), but if you have a good idea how I can pay for the "diff" the non-creator provides - it would be nice!
Overall not a nice approach as mentioned in the comments, still you can get an author of the file via git:
git log --diff-filter=A --pretty=format:"%an" <file>
So you can find all files created by the author and then filter out the rest. Or find an author for each file you selected with your command and then filter out.

How to get pvob name by a given clearcase stream (windows)?

Let's say user raise a request:
I'm unable to deliver form stream "spider_dev"
And that user didn't mention view name as well.
How do I get the PVOB name?
Our ClearCase environment is too big (around 300 vobs). It's very difficult to go each and every vob and check.
Assume you have been provided only the stream name "spider_dev"and nothing else. After shaming the developer for not helping me help him, consider the following commands to cycle thru the vobs and locate the stream (I have not worked in multi-site, so YMMV, also tagged as Windows, so conversion to PowerShell/DOSShell req'd):
MY_STREAM=spider_dev # the stream you're looking for
Get a list of all the vobs:
VOB_LIST=$(cleartool lsvob| grep ucmvob| cut -c3-| awk '{print $1}')
# list all vobs, match ucmvob, chop the active indicator (*), print the value
Cycle through the vobs to find matching dev streams:
MY_STREAM=spider_dev # the stream you're looking for
for vob in ${VOB_LIST}; do
for stream in $(cleartool lsproject -obs -fmt "%[dstreams]p\n" -inv ${vob}); do
if [[ ${stream} == ${MY_STREAM} ]]; then
echo "!!! ${stream}#${vob}"
break
fi
done
done
Now that you know where the stream is, find the deliver status:
cleartool deliver -status -stream ${stream}#${vob}
The result will be of the form:
Deliver operation in progress on stream "stream:spider_dev#/vobs/my_pvob"
Started by "username" on "2016-03-15T12:34:56Z"
Using integration activity "deliver.activity".
Using view "user_view".
Activities will be delivered to the default target stream stream:spider_int#/vobs/my_pvob"
in project "project:spider#/vobs/my_pvob".
Baselines to be delivered:
You can of course wrap this up into a shell command, functions, batch script, etc. as appropriate. We have some 250 vobs w/4000 branches and had scripted many little utilities to help us manage many similar problems, so feel your pain.
Finally, remind the user next time help will be more forthcoming with more details and take inordinately longer when fewer details provided.
One possibility is to look for any view named after the stream
cleartool lsview|grep -i spider_dev
(grep is available for Windows, or part of gow: Gnu On Windows)
If those views are also named after the user login, you can refine the search further.
Once you have the view, you have its stream with cleartool lsstream:
cleartool lsstream -l -view view_tag -anc
That should include the extended name of its UCM project (with its pvob).
This is not quite possible if you have only the information provided in your example. Ideally, the user should provide the name of the stream in the following format
stream:<stream-name>#<pvob>
This is mandatory as there could be another stream named 'spider_dev' in another PVOB.
If the user does not know his PVOB (that can happen), you should try to get the name of the source VOB, i.e. the VOB containing the source code. If you manage to get the name of the source VOB, you can simply use the "cleartool desc" command. Typically, the command
cleartool desc -l vob:<source-vob-tag>
will list a lot of information, including the hyperlink of the VOB with its PVOB. That's how you would then obtain the name of the PVOB.

Terminal find using download time

I was wondering if there is a way to find files using the find tool in Terminal based on file's download time. I know there are options for access (-amin), creation (-cmin), and modified (-mmin), but can't figure out a way to filter files based on time they were downloaded.
I checked and the creation time was not same as it's download time. If find can't do it, what's my other best option.
There's no creation time in Unix; ctime is the inode change time.
Your best bet is to use the time of last modification, aka mtime, which gives you the time the download ended. If you must know when the download started, you need to record the date prior to the download. If you need the download duration, you subtract the end time from the start time. There are tons of questions how to compute the length between two time stamps. Don't ask another :-)
EDIT: It appears your downloader (which one? Why didn't you specify it?) changes the time stamps to match the original. You can read its documentation if it has an option to suppress this. You could also find out if it can write the file to stdout and redirect it (e.g. wget -O - http://file > file) This will always force the mtime to be current.

How to programmatically find the difference between two directories

First off; I am not necessarily looking for Delphi code, spit it out any way you want.
I've been searching around (especially here) and found a bit about people looking for ways to compare to directories (inclusive subdirs) though they were using byte-by-byte methods. Second off, I am not looking for a difftool, I am "just" looking for a way to find files which do not match and, just as important, files which are in one directory but not the other and vice versa.
To be more specific: I have one directory (the backup folder) which I constantly update using FindFirstChangeNotification. Though the first time I need to copy all files and I also need to check the backup directory against the original when the applications starts (in case something happened when the application wasn't running or FindFirstChangeNotification didn't catch a file change). To solve this I am thinking of creating a CRC list for the backed up files and then run through the original directory computing the CRC for every file and finally compare the two CRCs. Then somehow look for files which are in one directory and not the other (again; vice versa).
Here's the question: Is this the fastest way? If so, how would one (roughly) get the job done?
You don't necessarily need CRCs for each file, you can just compare the "last modified" date for every file for most normal purposes. It's WAY faster. If you need additional safety, you can also compare the lengths. You get both of these metrics for free with the find functions.
And in your change notification, you should probably add the files to a queue and use a timer object to copy the new queued files every ~30sec or something, so you don't bog down the system with frequent updates/checks.
For additional speed, use the Win32 functions wherever possible, avoid any Delphi find/copy/getfileinfo functions. I'm not familiar with the Delphi framework but for example the C# stuff is WAY WAY WAY slower than the Win32 functions.
Regardless of you "not looking for a difftool", are you opposed to using Cygwin with it's "diff" command for the shell? If you are open to this its quite easy, particularly using diff with the -r "recursive" option.
The following generates the differences between 2 Rails installs on my machine, and greps out not only information about differences between files but also, specifically by grepping for 'Only', finds files in one directory, but not the other:
$ diff -r pgnindex pgnonrails | egrep '^Only|diff'
Only in pgnindex/app/controllers: openings_controller.rb
Only in pgnindex/app/helpers: openings_helper.rb
Only in pgnindex/app/views: openings
diff -r pgnindex/config/environment.rb pgnonrails/config/environment.rb
diff -r pgnindex/config/initializers/session_store.rb pgnonrails/config/initializers/session_store.rb
diff -r pgnindex/log/development.log pgnonrails/log/development.log
Only in pgnindex/test/functional: openings_controller_test.rb
Only in pgnindex/test/unit: helpers
The fastest way to compare one directory on the local machine to a directory on another machine thousands of miles away is exactly as you propose:
generate a CRC/checksum for every file
send the name, path, and CRC/checksum for each file over the internet to the other machine
compare
Perhaps the easiest way to do that is to use rsync with the "--dryrun" or "--list-only" option.
(Or use one of the many applications that use the rsync algorithm,
or compile the rsync algorithm into your application).
cd some_backup_directory
rsync --dryrun myname#remote_host:latest_version_directory .
For speed, the default rsync assumes, as Blindy suggested, that two files with the same name and the same path and the same length and the same modification time are the same.
For extra safety, you can give rsync the "--checksum" option to ignore the length and modification time and force it to compare (the checksum of) the actual contents of the file.

Does anyone know the CVS command line options to get the details of the last check in?

I'm using CVS on Windows (with the WinCVS front end), and would like to add details of the last check in to the email from our automated build process, whenever a build fails, in order to make it easier to fix.
I need to know the files that have changed, the user that changed them, and the comment.
I've been trying to work out the command line options, but never seem to get accurate results (either get too many result rather than just from one checkin, or details of some random check in from two weeks ago)
CVS doesn't group change sets like other version control systems do; each file has its own, independent version number and history. This is one of the deficiencies in CVS that prompts people to move to a newer VC.
That said, there are ways you could accomplish your goal. The easiest might be to add a post-commit hook to send email or log to a file. Then, at least, you can group a set of commits together by looking at the time the emails are sent and who made the change.
Wow.
I'd forgotten how hard this is to do. What I'd done before was a two stage process.
Firstly, running
cvs history -c -a -D "7 days ago" |
gawk '{ print "$1 == \"" $6 "\" && $2 == \"" $8 "/" $7 "\" { print \"" $2 " " $3 " " $6 " " $5 " " $8 "/" $7 "\"; next }" }' > /tmp/$$.awk
to gather information about all checkins in the previous 7 days and to generate a script that would be used to create a part of the email that was sent.
I then trawled the CVS/Entries file in the directory that contained the broken file(s) to get more info.
Mungeing the two together allowed me to finger the culprit and send an email to them notifying them that they'de broken the build.
Sorry that this answer isn't as complete as I'd hoped.
CVS does not provide this capability. You can, however, get it by buying a license for FishEye or possibly by using CVSTrac (note: I have not tried CVS Trac).
Or you could migrate to SVN, which does provide this capability via atomic commits. You can check in a group of files and have it count as a single commit. In CVS, each file is a separate commit no matter what you do.
We did this via a perl script that dumps the changelog and you can get a free version of perl for Windows at the second link.
Cvs2Cl script
Active Perl
I use loginfo in CVSROOT and write that information to a file
http://ximbiot.com/cvs/manual/cvs-1.11.23/cvs_18.html#SEC186
Will "cvs history -a -l" get you close? Shows for all users last event per project...
CVSNT supports commit IDs which you can use in place of tags in log, checkout or update commands. Each set of files committed (commits are atomic in CVSNT) receives its own unique ID. You just have to determine the commitid of the last checked in file via cvs log first (you can restrict the output via -d"1 hour ago" or similar) and then query which other files have that ID.
Eclipse has ChangeSets built in. You can browse the last changes (at least incoming changes aka updates) by commit. It does this by grouping the commits by author, commit message and similar timestamps.
This also works for "Compare with/Another Branch or Version" where you can choose Branches, Tags and Dates. Look through the Synchronization View Icons for a popup menu with "Change Sets" and see for yourself.
Edit: This would require to change to Eclipse at least as a viewer, but depending on the frequency you need to compare and group it might not be too bad. If you don't want to use more - use Eclipse just for CVS. It should be possible to even get a decent sized graphical cvs client through the rcp with all the plugins, but this'd definitely be out of scope...
Isn't this a solved problem? I would think any of the several tools on the CI Matrix that supports both CVS and email notifications could do this for you.

Resources