1

Background

In Clearcase, you can get the graphical version tree of a file by entering the following command in a linux terminal.

ct lsvtree -gra <filename>

This brings up an interface with numerous options to look at the diffs between two versions of a file.

Problem

From the graphical tree interface, I am trying to find if a string exists across any version of the file. This string was lost at some point, and I want to figure where that "somepoint" is.

Question

How can I run a text search across all versions of a file in clearcase?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
isakbob
  • 1,439
  • 2
  • 17
  • 39

2 Answers2

1

If you use dynamic views, you could take advantage of how it accesses element versions via version-extended naming. using "foo.c@@/main/branch/1" as an example, you have "foo.c@@" as the root of a directory structure, with "main" and "branch" being subdirectories, and "1" being a "file"

You can use this by doing the following:

  • cd to "foo.c@@"
  • Perform your search.

For example:

cd foo.c@@
grep -rl "target-string" *

to get the files without the string:

cd foo.c@@
grep -rlv "target-string" *

You could also use lsvtree output to power a search in a script, but the above is is the simplest trick to do this. This works on Unix and Windows, but you may want to use something other than the standard Windows "findstr" if your target string contains multiple words, as findstr handles them strangely: findstr "foo bar oof" will print lines that contain "foo", "bar", or "oof", occasionally even when /L for "literal" is used.

If you're using snapshot or web views, this is a lot trickier and will need a script to iterate on the output of lsvtree.

Brian Cowan
  • 1,048
  • 6
  • 7
  • 1
    Also, if you were looking for the reverse -- where a string "came from" in a version, you can use "cleartool annotate" to find that out. This is CC's equivalent of "git blame" and will tell you the most recent source of each text block. The third party "Visual Annotate" program IIRC iterates through multiple annotate outputs to give you the FIRST time a line/block of text appeared. I'm not affiliated with the creator of the tool, but figured I'd mention it. – Brian Cowan Apr 10 '19 at 15:34
1

As I mentioned before (2015), there is no equivalent to a git log -S or -G (pickaxe search) in ClearCase.

That pickaxe search is done (in Git) to point out past revision where a string has been added or removed.
But: you would need to script the equivalent feature for ClearCase.

Since cleartool lsvtree shows you all the version of a given file, you can, starting with the most recent version do a cleartool annotate to see when, and in which version, the line was added.
If that line include your string, then this version would be relevant.

If the most recent version does not include your string, then repeat the process with the previous version (do a cleartool annotate on that previous version, if it includes your string).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250