1

I want to apply a label to latest versions of objects that created before a specific time. For example :

MyObject.java has 4 versions.
- 1. version created on 2010-01-02
- 2. version created on 2010-06-25
- 3. version created on 2013-03-17
- 4. version created on 2014-01-13

Let's say I have 100+ objects in a specific path.

I want to find versions of objects created before 2014-01-01 and apply label to latest versions that obtain this condition of all objects (elements).

In this example;
I want to apply label on MyObject.java@@\main\3

Thanks

Update :
I am looking for a command like this :

find . -version "created_since(01-Jan-2000) && !created_since(01-Jan-2014) &&  version(/main/LATEST)" -print -exec "mklabel -replace TO_PROD"

this one is not working! I think it wants full path of objects. This find command returns paths that not include VOB path.

akdora
  • 893
  • 1
  • 9
  • 19

1 Answers1

1

Finding version before a time is tricky.

Finding version after a time is easier (created_since).

The OP akdora mentions:

find . -version "created_since(01-Jan-2000) && !created_since(01-Jan-2014) &&  version(/main/LATEST)" -print -exec "mklabel -replace TO_PROD"

That is:

find . -version "created_since(01-Jan-2000) && 
                 !created_since(01-Jan-2014) &&  
                 version(/main/LATEST)" 
       -print 
       -exec "mklabel -replace TO_PROD"

It should work if you add in the exec directive the right cleartool mklabel syntax:

-exec "cleartool mklabel -replace TO_PROD \"%CLEARCASE_PN%\""

(Windows syntax)

The CLEARCASE_PN environment variable is set automatically by the cleartool find command, and reference each element (not version) found.

find . -version "created_since(01-Jan-2000) && 
                 !created_since(01-Jan-2014)"
       -print 
       -exec "cleartool mklabel -replace TO_PROD \"%CLEARCASE_PN%\""

Alternative method

The "Additional examples of the cleartool find command" document includes:

Find and label all element versions before a certain date and time:

Get all the files in a VOB and store that data in a flat file:

cleartool find <vobtag> -all -print > <filename1>

or

cleartool find <vobtag> -version -print > <filename>

Get all the files created after the target date/time and store that data in a flat file:

cleartool find <vobtag> -element "{created_since(target-data-time)}" -print >

or

cleartool find <vobtag> -version "{created_since(target-data-time)}" -print >

Compare the two files to get the 'before version set'.

Do this by taking the first entry in filename2, then going to filename1 and taking everything that occurs before that line in filename1:

  • Save that in a new file, <filename3>
  • For every entry in <filename3> execute:
    cleartool mklabel <labelname>
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Actually i was looking for somthing like a command that i updated post – akdora Mar 14 '14 at 07:33
  • I checked it again. **"created_since(01-Jan-2000) && !created_since(01-Jan-2014) && version(/main/LATEST)"** is NOT working :( Sorry.. This finds if the latest version is created before 01-Jan-2014 then, prints the object. – akdora Mar 14 '14 at 11:18
  • @akdora right: you don't need the `&& version(/main/LATEST)` part. If it finds version from the oldest to the newest, the last `mklabel` will be applied to the right version (the most recent one before a specific date). – VonC Mar 14 '14 at 11:29