1

I have one requirement where i need to copy Clearcase particular version's directory and subdirectory files to another location via python. When I used shutil.copytree function it copies the folders files but the problem is it creates the files as directory type.

ex:
source = "testfolder/@@/main/1"
destination = "/home/myid/test"
shutil.copytree(source, destination)

For the above code i am getting all the file names as directory type.

could you help me how to copy particular version's folders to another location in python or in unix (clearcase)

user2660409
  • 85
  • 1
  • 2
  • 13
  • So, if I'm understanding this correctly, what is a *file* in the `source` tree ultimately appears as a *directory* in the `destination` directory? Seems very odd. Can you confirm they're actually files and not symlinks or something of that nature? Even if that's the case, it is still odd to me... Therefore, I'm guessing the astonishment lies somewhere in the nature of how clearcase stores versioned files; something I'm not familiar with at all. – sytech Jan 17 '18 at 05:40

2 Answers2

0

If you can execute system command from python, it would be best to call clearfsimport, which is made to copy (and import) files into a ClearCase view (doing the necessary checkout/mkelem/checkin)

See a syntax example for this command here.

You can see a python wrapper here: erichschroeter/clearcase-wrapper-scripts/clearcase/import.py

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

Actually, the issue is that you are using version-extended naming in the copy. Since the source directory is testfolder@@ and not testfolder, you have CD'd into the directory ELEMENT. When you do this, all elements become directories, the branches become directories, and versions become "files."

If you have a element with 3 branches (main, br1, and br2) and 2 versions on each branch, you get something like this:

foo.c@@ (directory)

foo.c@@/main (directory)

foo.c@@/main/br1 (directory)

foo.c@@/main/br2 (directory)

foo.c@@/main/[0-2] as files

foo.c@@/main/LATEST (and any other labels on the file) as files.

This is actually how the merge tool in a dynamic view accesses the contributing versions not selected by the current view. In a snapshot view, the merge tool has to download them with the equivalent of a "cleartool get -to" command.

The best way to avoid pulling the entire element tree over? Use a view selecting the directory version you want to access.

Brian Cowan
  • 1,048
  • 6
  • 7