clearcase snapshot hijacked files : how to checkou

2020-03-30 15:56发布

问题:

Clearcase sucks a lot. It seems I cannot just save modifications to my project quickly. By quickly I mean in less than 1 second.

The solution I have found is to use the combo clearcase + git. I'm using snapshots views because I can easily hijack my files without having to checkout all the files in my project every time I want to do refactoring.

The problem is, when I play with git and navigate between new and old versions, clearcase think all the files are hijacked. Then I need to do the following.

  1. cleartool update
  2. cleartool ls -recurse | grep "hijacked" | xargs cleartool diff -prev [...] > changed
  3. cat changed | xargs cleartool co -nc
  4. cat changed | xargs cleartool ci -c 'some words...'
  5. rm **/*.keep
  6. git checkout .

The operation consisting of "clearcase push" which takes about 2 seconds with git will last for at least 10 minutes. I see only two explanation regarding this issue:

  1. I really do not know how to use clearcase
  2. Clearcase really sucks!

Does somebody knows how to quickly checkout then checkin modified hijacked files with Clearcase not UCM version ?

Edit:

Following the advices of Vonc I made a script that uses clearfsimport:

#!/bin/bash/
OUT="$(mktemp -d)"
DST=/vob/project_root/
echo -e "\nCreating temporary folder..."
echo $OUT

echo -e "\nCopying relevant elements..."
find . | grep -E '.*?\.(c|h|inc|asm|mac|def|ldf|rst)$' | xargs -I % cp --parents % $OUT
DOUT=$(cygpath -d $OUT/*)
DDST=$(cygpath -d $DST)
echo -e "\nImporting new elements to cleacase..."
clearfsimport -rec -unco -nset $DOUT $DDST

echo -e "\nRemoving temporary files..."
rm -rf $OUT   

The reason why I need to make a copy of my repository is that clearfsimport cannot directly exclude files or directories and wildcard options does not work with this tool. It takes a directory tree as is. Also I do not want to remove all my unversionned files such as object files or even the .git from my working directory.

I think I can make this script much better by identifying with git all the files that changed since the last execution of my script. Might be a bit tricky to do...

Also I can set my matching files pattern using .gitignore

Perhaps others already made such scripts...

回答1:

Your sequence for updating ClearCase file from a git working tree is pretty much the "optimal" one, meaning it won't get much faster.

One alternative I have been playing with when using ClearCase and Git is clearfsimport, with 2 ClearCase views.

  • one snapshot view is for updating a set of files which are then make hijacked (for a git working tree to use)
  • one snapshot (or dynamic actually) view to be the recipient, the destination of the changes done in the first working tree.

clearfsimport allows you to take any working tree (managed or not by ClearCase, it doesn't care), and import it in a ClearCase view (it can be a dynamic view, by the way), and:

  • checkout only the modified files
  • leave the identical files alone
  • remove / add the files in the ClearCase view, which were deleted/created in the working tree

It is a process more efficient than diff'ing everything, and it should be much faster.
That doesn't mean it is fast.
It is still, after all, ClearCase.