I was trying to migrate a file from directory A to directory B in a branch, call it file.txt. What I did was:
cd A
cp file.txt ../B/
ct rm A
cd ../B
ct mkelem -ci -nc file.txt
Thereby losing all the history. I am trying to recover from this to do what I should have done which is simply ct mv file.txt ../B
I read that for this I should do something like this:
cd A
ct ln .##/main/?/file.txt ./file.txt
where luckily, from another view, I've figured out ? should be 27. Unfortunately when I try to do the above I get:
cleartool: Error: Entry named "file.txt" already exists.
cleartool: Error: Unable to create link: "./file.txt".
and I try to do:
ct rmelem file.txt
but got:
cleartool: Error: Element "file.txt" has branches not created by user
though presumably that's not what I should be doing anyway. How do I get back that file? It was simply a ct rm. I even get the entry already exists error if I do ct rm on the new copy file I added to directory B..
You are on the right track, but I would recommend a simple rmname, instead of a rmelem (which deletes the element with all its versions, branches and such).
That would remove file.txt from the latest version of the parent directory, and allows you to proceed with the symlink.
Next time, a cleartool mv might be easier, and keep the history of the file being moved.
Related
I'm working with clearcase in Unix.
I accidently execute a shell, which make some file in the directory: /vobs/somePath/myDir.
I execute the command below in the directory:
cleartool ls -l
And I do get some view private object files.
What I need is to recover this directory with my baseline, which has been set before. Besides, I have some uncheckin files in other paths and I don't want to check them in right now. In other words, I just want to recover the directory myDir and don't touch any other files.
How to achieve this?
For a dynamic view (/vobs/avob/myview/...), only private files are writable, so you can delete everything and it will only delete the private ones.
But, if you have checked out files (which should not be deleted), or if you don't want to risk anything, you can clean just the private files with, using cleartool lsprivate:
cd /vobs/somePath/myDir
ct lspriv . | grep -v checkedout | xargs rm -rf
I have a new branch in which I would like to remove some files. I was able to remove some files with this commands:
cleartool co -nc .
cleartool rmname <filename>
cleartool ci -nc .
But for some other files I get this error:
$ ct rmname file
cleartool: Error: Element "file" has checkouts.
In my branch, in my view, these files are not checked out. However I can find some checkout with ct lsco file in other branches.
Why do I get an error. Removing a file from my branch shouldn't affect the other branches, right?
Can I force the command with -f ?
You could try the -force option for the cleartool rmname command, to get past the fact there are other versions checked out. But that -force option might not be available (depending on the cleartool version)
I have seen that option in "Cleartool removing a checkedout file from a folder with rmname" for rmname.
If rmname -f works, then it is the way to proceed.
That error message is more about warning the users that, while the file won't be visible anymore, it is still being modified elsewhere.
When I do "ct lsco -a" I can see that I have three checkouts. But they don't show up in xclearcase, and the directories aren't visible from the command line.
ct lsco -a | grep hendrixjl
--07-29T15:32 hendrixjl checkout directory version "/vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/3/icondetails_decoupled" from /main/rel_core_0.5.0.0__int/fea__cr_47__0.5.0.0_ui_decouple/0 (unreserved)
--07-29T15:32 hendrixjl checkout directory version "/vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/4/overlays" from /main/rel_core_0.5.0.0__int/fea__cr_47__0.5.0.0_ui_decouple/0 (unreserved)
--07-29T15:32 hendrixjl checkout directory version "/vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/4/overlays/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/1/images" from /main/rel_core_0.5.0.0__int/fea__cr_47__0.5.0.0_ui_decouple/0 (unreserved)
[hendrixjl#BA-JBCP-HENDRIX CORE]$ cd /vobs/CORE/CORE_APPS/src/mapmgr_decoupled
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$ ls
Makefile ascope_translator common_decoupled displaySA_decoupled filters mgr_decoupled unit_test
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$ ct unco .
cleartool: Error: No branch of element is checked out to view "cc-svr:/data/cc_store/viewstore/hendrixjl/fea__cr_47__0.5.0.0_ui_decouple__hendrixjl_view.vws".
cleartool: Error: Unable to find checked out version for ".".
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$ ct unco icondetails_decoupled
cleartool: Error: Element name not found: "icondetails_decoupled".
[hendrixjl#BA-JBCP-HENDRIX mapmgr_decoupled]$
Those directories are checked-out in parent directories which are not visible/selected by your current view, probably because they have been removed (rmnamed).
That means the checked-out versions are not accessible from this view.
However, a potential workaround is to search for those same checked-out directories from the GUI "find checkouts" window: there you can select the checked-out element (file or directory) and select "undo checkout".
Another workaround is to go to the full extended path of that directory in a dynamic view: you will then be able to "cleartool unco" the directory.
cd /vobs/CORE/CORE_APPS/src/mapmgr_decoupled##/main/rel_core_0.5.0.0__int/fea__cr_54__0.5.0.0_decouple_map_manager/3
cleartool unco icondetails_decoupled
In any case, whenever you don't see an element, the first think to do is a version tree of the parent directory of that element, in order to check if the missing element has been rmname'd in one of the version of said parent directory.
Lets say I have a directory at \testfolder, and the latest is currently at /main/10. I know that the operation resulting in testfolder##/main/6 is to remove a file named test.txt.
What's a sequence of cleartool operations that can be done in a script that will take "testfolder##/main/6" and "test.txt" as input, and will cat out the contents of test.txt as of that time?
One way I can think of is to get the time of /main/6 operation, create a view with config spec -time set to that time, and then cat the test.txt at the directory. But I'm wondering if I can do this in a easier way that doesn't involve manipulating config specs, perhaps through "cleartool find" and extended path names
If you are using a dynamic view, you should be explore directly the extended pathnames of testfolder in order to access the content of test.txt.
cd m:\myview\myVob\path\to\testfolder
# In version 5 of testfolder, test.txt was still there
cd ##/main/5
# Note: test.txt is a directory! only LATEST is a file
type test.txt#/main/LATEST
The OP adds:
how about if test.txt was moved from testFolder to testFolder2, and then a new version of test.txt is checked in? In this when I go into testfolder##/main/5, test.txt##/main/LATEST is incorrect...
Technically, this is a case of evil twins: 2 objects of the same names exists (one in testfolder##/main/5, one in testfolder##/main/10) with different history.
You need, to get back the former test.txt (a like rollbacking a file), remove your current test.txt and get back the old one currently moved to Folder2. (cleartool move)
cd testFolder2
cleartool checkout -c "move test.txt back to testFolder"
cd ../testFolder
cleartool checkout -c "get back test.txt from testFolder2"
cleartool rmname test.txt
cleartool move ../testFolder2/test.txt
cleartool ci -nc .
cleartool ci -nc ../testFolder2
I want to check in a directory and all the sub-directories into the clear case.
Is there a specific command to achieve it?
Currently I am going into each directory and manually checking in each file.
I would recommend this question:
Now the problem is to checkin everything that has changed.
It is problematic since often not everything has changed, and ClearCase will trigger an error message when trying to check in an identical file. Meaning you will need 2 commands:
ct lsco -r -cvi -fmt "ci -nc \"%n\"\n" | ct
ct lsco -r -cvi -fmt "unco -rm %n\n" | ct
(with 'ct being 'cleartool' : type 'doskey ct=cleartool $*' on Windows to set that alias)
But if by "checkin" you mean:
"enter into source control for the first time"
"updating a large number of files which may have changed on an existing versionned directory"
I would recommend creating a dynamic view and clearfsimport your snapshot tree (with the new files) in the dynamic view.
See this question or this question.
the clearfsimport script is better equipped to import multiple times the same set of files, and automatically:
add new files,
make new version of existing files previously imported (but modified in the source set of files re-imported)
remove files already imported but no longer present in the source set of files.
make a clear log of all operations made during the import process.
:
clearfsimport -preview -rec -nset c:\sourceDir\* m:\MyView\MyVob\MyDestinationDirectory
did you used -recurse option in the clearfsimport command.
Example: clearfsimport -recurse source_dir .
This should help.
If you're using the Windows client, right-click on the parent folder, select Search, leave the file name field empty, click Search, select all the files in the result window (ctrl-A), right-click on them and select ClearCase -> Add to Source Control
If you are in windows you may try,
for /f "usebackq" %i in (`cleartool lsco -cview -me -r -s`) do cleartool ci -nc %i