Base ClearCase FAQ 1.3.5: What was the last label type created in this vob?

Solution

$ ct lshis -all -fmt "%d %n %o\n" -since today | grep mktype | head -1

Details/discussion

One thinks at once at lshistory.
But lshis of what?
Not giving any object defaults to the local directory, and label types have nothing to do with it until one gets applied to it. So, you won't get label type creation there.

The creation event gets attached to the label type itself, so if you know the type, you can easily get the time when it was created. But if what you want is the type name itself, you are stuck in a catch-22 problem.
Destruction events get attached to the vob object, but this won't help you.


Fortunately, lshistory accepts an -all option. Its only drawback, is that the output might get quite large. So you might want to filter it.

Filtering is trickier than one might think at first. One reason is that the -short and -long options of lshis will not report identical strings (for grep).
In fact, the -long option is not very useful, and is anyway limited to one line, followed with the comment:

$ ct lshis -all -l -since today | grep -n 'create label type' | head -1
8:  create label type "APR9019999-R99ZZ01" (locked)
$ ct lshis -all -l -since today | sed -n 8,18p
  create label type "APR9019999-R99ZZ01" (locked)
... [9 lines of comments]

So, maybe more useful is to use -fmt:

$ ct lshis -all -fmt "%d %n %u %o\n" -since today | grep mktype | head -1
21-Jul-08.12:28:14 APR9019999-R99ZZ01 eeivob05 mktype

One possible drawback with this solution is that —although you didn't mention it— you care only for local label types, types that were created and applied in the local replica.
You don't? You should!
Anyway, this solution won't pay attention to this, unless you ask for it in the format (e.g. with %[master]p), and grep appropriately.

For more complex cases, and minor events which get scrubbed, consider dumpoplog.

-- MarcGirod - 21 Jul 2008



EditAttachPrint versionHistory: r2 < r1BacklinksRaw ViewRaw editMore topic actions