1

The command cleartool lsvtree -s . is close but it lists more than just branches:

X:\main_dev\common>cleartool lsvtree -s .
.@@\main
.@@\main\2
.@@\main\3
.@@\main\4
.@@\main\10
.@@\main\2.1.3
.@@\main\2.1.3\1
.@@\main\13
.@@\main\3.0.2
.@@\main\3.0.2\0
.@@\main\15
.@@\main\4.1.0
.@@\main\4.1.0\0
.@@\main\17
.@@\main\4.2.0
.@@\main\4.2.0\0
.@@\main\4.5.0
.@@\main\4.5.0\0
.@@\main\20
.@@\main\lib-4.6.0
.@@\main\lib-4.6.0\0
.@@\main\27
.@@\main\4.6.0
.@@\main\4.6.0\0
.@@\main\4.6.0\4.6.01
.@@\main\4.6.0\4.6.01\0

I want it to produce just branches, like:

X:\main_dev\common>cleartool lsvtree -s .
.@@\main
.@@\main\2.1.3
.@@\main\3.0.2
.@@\main\4.1.0
.@@\main\4.2.0
.@@\main\4.5.0
.@@\main\lib-4.6.0
.@@\main\4.6.0\4.6.01

I am guessing that the solution will involve the cleartool find command. Any ideas?

Derrick
  • 323
  • 2
  • 10

1 Answers1

0

cleartool find indeed, combined with an -exec directive using cleartool describe and -fmt_ccase.

Or just lshistory with the same fmt_ccase

cleartool  lshistory -fmt "\tElement: %-13.13En Version: %Vn\n" util.c
Element: util.c Version: /main/rel2_bugfix/1
Element: util.c Version: /main/rel2_bugfix/0
Element: util.c Version: /main/rel2_bugfix 

That would still include the version though: you need to post-process the result in order to get rid of the final /x version when it exists

Something like:

cleartool  lshistory -fmt "%Vn\n" util.c|sed "s,/[0-9]\+,,g"

The OP Derrick propose in the comments the simpler option:

cleartool lsvtree aFile | grep -v '\[0-9]\+$' 

I am still looking for a deterministic (no naming assumptions) way to find all branch for a specific file/directory

Any entry in the lsvtree which has a '0' element in it is a branch.
O is the placehoster for a new branch versions.
See "Is clearcase path is a standard one — '@@' and string after that"

Example (in a dynamic view):

ls .@@\main\4.6.0
0

ls .@@\main\4.6.0\0
(nothing)

Hence \main\4.6.0 is a branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. the lsvtree seems better than lshistory since it includes only those entreis that apply to this file. Also, the sed does not eliminate the non-branch entries. Any sed that I can think of makes assumptions about non-numeric branch naming. The find solution may work but lacks details. – Derrick Oct 16 '19 at 18:40
  • @Derrick lshistory also applies only to the specified file. And sed will remove indeed non-numeric branch. Do you have numeric branches? – VonC Oct 16 '19 at 18:41
  • @Derrick Example of find + describe: https://stackoverflow.com/a/5801562/6309. But none of the fmt_ccase option would give you the branch path only. It only gives you the full extended path name, including the final version. – VonC Oct 16 '19 at 18:46
  • Yes to the numeric branching. Also, in my case lshistory gives far more results than lsvtree: ` >cleartool lshistory -fmt "%Vn\n" . | wc 568 558 7602 >cleartool lsvtree -s . | wc 54 54 991 > ` – Derrick Oct 16 '19 at 18:46
  • @Derrick 4.2.0 is not numeric, and will not be filtered out. – VonC Oct 16 '19 at 18:47
  • @Derrick Why not applying the same sed expression to lsvtree? – VonC Oct 16 '19 at 19:00
  • @Derrick What does not work? The final /xx is not removed? – VonC Oct 16 '19 at 19:58
  • Correct, the sed command does not remove the non-branch lines. However, grep -v '\\[0-9]\+$' seems to do the job. – Derrick Oct 16 '19 at 20:04
  • @Derrick Great! I have included your command in the answer, for more visibility. – VonC Oct 16 '19 at 21:53
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/201047/discussion-between-derrick-and-vonc). – Derrick Oct 17 '19 at 19:59