1

I am looking to find a way to generate a report that can show the creation date of each element in a ClearCase project. Basically, I am trying to get a sense of the old legacy elements in our project. I am not able to achieve it using find, lshistory or reportbuilder, so looking for some help from the community to see if someone has done anything similar before or has any pointers to share.

Thanks in advance. NP

1 Answers1

0

cleartool find should be a valid option though.
Combined with fmt_ccase

cleartool find -nvis -all -exec "cleartool descr -fmt \"%Xn %d\n\" \"%CLEARCASE_PN%\"" | grep "\\0"

On Unix:

cleartool find -nvis -all -exec 'cleartool descr -fmt "%Xn %d\n" "$CLEARCASE_PN"' | grep /0

What you are looking at version 0, the placeholder version marking the creation:

  • either of a new branch for a file
  • the file element itself

For a given file, the sorted extended path would be the one where the element itself was created.

The OP proposes in the comments:

cleartool find -all \
  -exec "cleartool descr -fmt \"%Nd %Xn : %d\n\" \"%CLEARCASE_PN%\"" | \
grep \\0 | sort 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thanks for taking my question. I do not see -fmt as an option for CT find and it errors. I tried to run just: cleartool find -nvis -all -print but that does not seem to show the date. I am actually trying to display creation date of the element. Any suggestion? Thanks. – user6341332 Sep 17 '20 at 17:46
  • @user6341332 I have updated the commands. Are you on Windows or Linux? – VonC Sep 17 '20 at 18:17
  • I see that you used the -exec. I can see the command rendering the dates, however I am on windows and grep is not available. Any way to filter the output on Windows? Thanks. – user6341332 Sep 17 '20 at 20:09
  • @user6341332 grep is available in Windows, for years: http://gnuwin32.sourceforge.net/packages/grep.htm – VonC Sep 17 '20 at 20:12
  • that vaguely remembered using it in the past. Thanks for pointing it out. I will install it and update you on the outcome. – user6341332 Sep 17 '20 at 20:14
  • That worked. I am not seem to have luck with picking up elements with \0, however I am getting much better result when I chase \\1. Any idea? Here is my command: cleartool find -all -exec "cleartool descr -fmt \"%Xn : %d\n\" \"%CLEARCASE_PN%\"" | grep \\0 – user6341332 Sep 21 '20 at 22:03
  • sorry, it seems to be working even for \\0, however very slow. Is there a way to get the output redirected to a text file? I tried to append > path\filename.txt and it doesn't work. – user6341332 Sep 21 '20 at 22:14
  • @user6341332 Following https://www.rushis.com/windows-command-prompt-redirecting-stdoutstderr/#:~:text=The%20regular%20output%20is%20sent,%3E%E2%80%9D%20for%20the%20redirection%20symbol., try to append ` > path\filename.txt 2>&1`: that will redirect both stdout and stderr. – VonC Sep 22 '20 at 06:22
  • Thanks for the tip. Yes, I am now able to get the output redirected to a text file now. It seems to me that the command is not bringing all the elements but only a subset of them. How to run it such that it brings every versioned element in a particular project. Also is there a way to sort the result for eg based of the creation date? TIA. – user6341332 Sep 22 '20 at 18:49
  • @user6341332 Not sure about the subset part. But you can use as a format "`%Nd %Xn`" and use the command sort to sort by date (since each line will start with `yyyymmdd.time`) – VonC Sep 22 '20 at 21:43
  • thanks again for the pointer for | sort. I am able to get the sort order correct. I am currently running it on the stream (branch) level. Is there a better place to run it from to get all the elements listed. As I mentioned before, I am getting a handful of elements only. cleartool find -all is bringing everything but as soon as -exec... comes in picture, the output shrinks considerably. – user6341332 Sep 23 '20 at 21:54
  • @user6341332 The `-exec` should not diminish the number of items returned by `cleartool find`. The `grep` might. Try without any `grep` just to confirm you still see *all* the results. – VonC Sep 24 '20 at 05:47
  • you are correct, seems like grep is eating up more than I expect it to. Shouldn't there be a \0 for every element in a stream/branch? – user6341332 Sep 24 '20 at 18:58
  • @user6341332 what is the exact grep command you are using? – VonC Sep 24 '20 at 19:00
  • @user6341332 for example, on windows, you might need a grep "\\0", because the extended path could use \ instead of /. – VonC Sep 24 '20 at 20:02
  • Correct, I figured that I need \\0 when I could not get the result. Here is the command I have that I still need to remove the trailing date/time stamp eventually: cleartool find -all -exec "cleartool descr -fmt \"%Nd %Xn : %d\n\" \"%CLEARCASE_PN%\"" | grep \\0 | sort – user6341332 Sep 24 '20 at 21:36
  • @user6341332 Looks good. I have included your command in the answer for more visibility. – VonC Sep 25 '20 at 05:39