1

I am attempting to write a script for Base ClearCase that will find all the files on a given branch and label, and perform a trivial merge of those files to another branch, and then label the newly merged files with a different label.

For example, given files on branch \main\Proj\Proj_INT1 and labeled Ver4, I want to merge the files to the \main\Proj branch and label them with Ver4X (iff they are in need of merging).

I know that I can use -fver "\main\Proj\Proj_INT1\Ver4" to find the versions of files I want to merge, but I am not sure how to combine the merge with applying the label.

From the documentation, it does not look possible to do a cleartool findmerge ... -merge -exec "cleartool mklabel ...", so I am currently attempting to a cleartool findmerge ... -log <out_file.log> -print, and then parse the resulting log to get all the file versions. However, given that the findmerge command stops at directories, I would need to repeat this operation multiple times until all directories and files are merged (a bit of a headache to try to script and parse cleartool output).

Is there an idiomatic or simple way to perform a merge and then label the files? Perhaps I can perform the merge and have cleartool generate a log which shows what the versions for merged files (so I can then label)?

Additionally, if I perform a cleartool findmerge ... -merge operation, how does it handle non-trivial merges? I am not expecting any non-trivial merges, but I would like to skip with an error or stop the merge entirely if a non-trivial merge is encountered.

Casey Kuball
  • 7,717
  • 5
  • 38
  • 70

1 Answers1

1

As I mentioned in "ClearCase: When using clearfsimport to perform a reset merge, how can I keep it from creating evil twins?", you need to:

  • findmerge folders first (-type d), then files (-type f)
  • use findmerge -abort in order to resolve any manual merge which would cause the findmerge to fail.

Instead of using findmerge ... -merge, I was using -exec "cleartool merge $CLEARCASE_PN..." using cleartool merge syntax.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The real question is about also labeling the files. Are you suggesting that I do a `-exec "cleartool merge ... && cleartool mklabel ..."`, or can I somehow get the new version from the findmerge command to then parse and use to `cleartool mklabel` in a loop? – Casey Kuball Jan 11 '17 at 21:01
  • @Darthfett the first approach should work, as the merged version would be the LATEST and current one in the destination view. – VonC Jan 11 '17 at 21:15
  • I'm looking at the documentation now, and it looks like I need to have the file checked out before merging? Would you agree that it now looks more like `-exec "cleartool checkout ... && cleartool merge ... && cleartool checkin ... && cleartool mklabel"`? – Casey Kuball Jan 11 '17 at 21:34
  • Yes, I agree, checkout then merge, first the folders, then the files – VonC Jan 11 '17 at 21:39
  • Hmm, looks like it's not going to be possible since I can't specify the file path without the version information in order to perform the merge. I guess I'll go with my backup solution of performing the merge and hoping the version information is printed out during the `findmerge`. – Casey Kuball Jan 11 '17 at 21:57
  • @Darthfett Instead of chaincing cleartool command, call a script of your own (perl, bash, any scripting language). In it, you can extract the file path you need in order to checkout. – VonC Jan 12 '17 at 05:44